mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
load-fragment: add user credential specifiers to user.conf
This enables the ManagerEnvironment= settings in the user's user.conf to reference some user data like $HOME for the purpose of setting environment variables derived from these values.
This commit is contained in:
committed by
Luca Boccassi
parent
28f3cbbded
commit
0b40688d18
@@ -604,6 +604,36 @@
|
||||
<xi:include href="standard-specifiers.xml" xpointer="W"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="T"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="V"/>
|
||||
<row>
|
||||
<entry><literal>%h</literal></entry>
|
||||
<entry>User home directory</entry>
|
||||
<entry>This is the home directory of the <emphasis>user running the service manager instance</emphasis>.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>%u</literal></entry>
|
||||
<entry>Username</entry>
|
||||
<entry>This is the username of the <emphasis>user running the service manager instance</emphasis>.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>%U</literal></entry>
|
||||
<entry>User id</entry>
|
||||
<entry>This is the user id of the <emphasis>user running the service manager instance</emphasis>.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>%g</literal></entry>
|
||||
<entry>Primary group</entry>
|
||||
<entry>This is the primary group of the <emphasis>user running the service manager instance</emphasis>.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>%G</literal></entry>
|
||||
<entry>Primary group id</entry>
|
||||
<entry>This is the primary group id of the <emphasis>user running the service manager instance</emphasis>.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>%s</literal></entry>
|
||||
<entry>User shell</entry>
|
||||
<entry>This is the shell of the <emphasis>user running the service manager instance</emphasis>.</entry>
|
||||
</row>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="percent"/>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
|
||||
@@ -2744,6 +2744,16 @@ int config_parse_environ(
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_system = ltype;
|
||||
|
||||
const Specifier table[] = {
|
||||
COMMON_SYSTEM_SPECIFIERS,
|
||||
COMMON_TMP_SPECIFIERS,
|
||||
COMMON_CREDS_SPECIFIERS(is_system ? LOOKUP_SCOPE_SYSTEM : LOOKUP_SCOPE_USER),
|
||||
{ 'h', specifier_user_home, NULL },
|
||||
{ 's', specifier_user_shell, NULL },
|
||||
};
|
||||
|
||||
for (const char *p = rvalue;; ) {
|
||||
_cleanup_free_ char *word = NULL, *resolved = NULL;
|
||||
|
||||
@@ -2761,7 +2771,7 @@ int config_parse_environ(
|
||||
if (u)
|
||||
r = unit_env_printf(u, word, &resolved);
|
||||
else
|
||||
r = specifier_printf(word, sc_arg_max(), system_and_tmp_specifier_table, NULL, NULL, &resolved);
|
||||
r = specifier_printf(word, sc_arg_max(), table, NULL, NULL, &resolved);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to resolve specifiers in %s, ignoring: %m", word);
|
||||
|
||||
@@ -664,8 +664,8 @@ static int parse_config_file(void) {
|
||||
{ "Manager", "DefaultStartLimitInterval", config_parse_sec, 0, &arg_default_start_limit_interval }, /* obsolete alias */
|
||||
{ "Manager", "DefaultStartLimitIntervalSec", config_parse_sec, 0, &arg_default_start_limit_interval },
|
||||
{ "Manager", "DefaultStartLimitBurst", config_parse_unsigned, 0, &arg_default_start_limit_burst },
|
||||
{ "Manager", "DefaultEnvironment", config_parse_environ, 0, &arg_default_environment },
|
||||
{ "Manager", "ManagerEnvironment", config_parse_environ, 0, &arg_manager_environment },
|
||||
{ "Manager", "DefaultEnvironment", config_parse_environ, arg_system, &arg_default_environment },
|
||||
{ "Manager", "ManagerEnvironment", config_parse_environ, arg_system, &arg_manager_environment },
|
||||
{ "Manager", "DefaultLimitCPU", config_parse_rlimit, RLIMIT_CPU, arg_default_rlimit },
|
||||
{ "Manager", "DefaultLimitFSIZE", config_parse_rlimit, RLIMIT_FSIZE, arg_default_rlimit },
|
||||
{ "Manager", "DefaultLimitDATA", config_parse_rlimit, RLIMIT_DATA, arg_default_rlimit },
|
||||
|
||||
Reference in New Issue
Block a user