diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-11-25 13:22:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 13:22:56 +0100 |
commit | 9642983a51c6c866d11092c1e1e2ab9bc3c0df5a (patch) | |
tree | 27c0cb438756fa75976b900b8f4a28e148be72cb | |
parent | 8bc6ade721ef0b356df0d3f21829d6055aba5ed3 (diff) | |
parent | e93387f38b7782afb41b6b6256e6a0f635662e75 (diff) | |
download | systemd-9642983a51c6c866d11092c1e1e2ab9bc3c0df5a.tar.gz |
Merge pull request #17715 from yuwata/specifier-follow-ups
Sort specifiers
-rw-r--r-- | man/systemd.unit.xml | 39 | ||||
-rw-r--r-- | man/tmpfiles.d.xml | 20 | ||||
-rw-r--r-- | src/core/unit-printf.c | 59 | ||||
-rw-r--r-- | src/resolve/resolved-conf.c | 8 | ||||
-rw-r--r-- | src/resolve/resolved-dnssd.c | 8 | ||||
-rw-r--r-- | src/shared/install-printf.c | 24 | ||||
-rw-r--r-- | src/shared/specifier.h | 38 | ||||
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 16 |
8 files changed, 105 insertions, 107 deletions
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 52db36be71..5364c4c975 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1734,10 +1734,9 @@ </varlistentry> </variablelist> - <para>The following specifiers are interpreted in the Install - section: %n, %N, %p, %i, %j, %g, %G, %U, %u, %m, %H, %b, %v. For their - meaning see the next section. - </para> + <para>The following specifiers are interpreted in the Install section: + %a, %b, %B, %g, %G, %H, %i, %j, %l, %m, %n, %N, %o, %p, %u, %U, %v, %w, %W, %%. + For their meaning see the next section.</para> </refsect1> <refsect1> @@ -1788,6 +1787,16 @@ <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the unescaped prefix name prepended with <filename>/</filename>. This implements unescaping according to the rules for escaping absolute file system paths discussed above.</entry> </row> <row> + <entry><literal>%g</literal></entry> + <entry>User group</entry> + <entry>This is the name of the group running the service manager instance. In case of the system manager this resolves to <literal>root</literal>.</entry> + </row> + <row> + <entry><literal>%G</literal></entry> + <entry>User GID</entry> + <entry>This is the numeric GID of the user running the service manager instance. In case of the system manager this resolves to <literal>0</literal>.</entry> + </row> + <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>. In case of the system manager this resolves to <literal>/root</literal>. @@ -1802,11 +1811,6 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry> </row> <row> - <entry><literal>%l</literal></entry> - <entry>Short host name</entry> - <entry>The hostname of the running system at the point in time the unit configuration is loaded, truncated at the first dot to remove any domain component.</entry> - </row> - <row> <entry><literal>%i</literal></entry> <entry>Instance name</entry> <entry>For instantiated units this is the string between the first <literal>@</literal> character and the type suffix. Empty for non-instantiated units.</entry> @@ -1827,12 +1831,16 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us <entry>Same as <literal>%j</literal>, but with escaping undone.</entry> </row> <row> + <entry><literal>%l</literal></entry> + <entry>Short host name</entry> + <entry>The hostname of the running system at the point in time the unit configuration is loaded, truncated at the first dot to remove any domain component.</entry> + </row> + <row> <entry><literal>%L</literal></entry> <entry>Log directory root</entry> <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename index="false">/log</filename> appended (for user managers).</entry> </row> <xi:include href="standard-specifiers.xml" xpointer="m"/> - <xi:include href="standard-specifiers.xml" xpointer="o"/> <row> <entry><literal>%n</literal></entry> <entry>Full unit name</entry> @@ -1843,6 +1851,7 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us <entry>Full unit name</entry> <entry>Same as <literal>%n</literal>, but with the type suffix removed.</entry> </row> + <xi:include href="standard-specifiers.xml" xpointer="o"/> <row> <entry><literal>%p</literal></entry> <entry>Prefix name</entry> @@ -1870,16 +1879,6 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us </row> <xi:include href="standard-specifiers.xml" xpointer="T"/> <row> - <entry><literal>%g</literal></entry> - <entry>User group</entry> - <entry>This is the name of the group running the service manager instance. In case of the system manager this resolves to <literal>root</literal>.</entry> - </row> - <row> - <entry><literal>%G</literal></entry> - <entry>User GID</entry> - <entry>This is the numeric GID of the user running the service manager instance. In case of the system manager this resolves to <literal>0</literal>.</entry> - </row> - <row> <entry><literal>%u</literal></entry> <entry>User name</entry> <entry>This is the name of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>root</literal>. diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml index 5f69054847..49ce8375a4 100644 --- a/man/tmpfiles.d.xml +++ b/man/tmpfiles.d.xml @@ -640,6 +640,16 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para> <entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CACHE_HOME</varname>, and <filename>/var/cache</filename> otherwise.</entry> </row> <row> + <entry><literal>%g</literal></entry> + <entry>User group</entry> + <entry>This is the name of the group running the command. In case of the system instance this resolves to <literal>root</literal>.</entry> + </row> + <row> + <entry><literal>%G</literal></entry> + <entry>User GID</entry> + <entry>This is the numeric GID of the group running the command. In case of the system instance this resolves to <constant>0</constant>.</entry> + </row> + <row> <entry><literal>%h</literal></entry> <entry>User home directory</entry> <entry>This is the home directory of the user running the command. In case of the system instance this resolves to <literal>/root</literal>.</entry> @@ -665,16 +675,6 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para> </row> <xi:include href="standard-specifiers.xml" xpointer="T"/> <row> - <entry><literal>%g</literal></entry> - <entry>User group</entry> - <entry>This is the name of the group running the command. In case of the system instance this resolves to <literal>root</literal>.</entry> - </row> - <row> - <entry><literal>%G</literal></entry> - <entry>User GID</entry> - <entry>This is the numeric GID of the group running the command. In case of the system instance this resolves to <constant>0</constant>.</entry> - </row> - <row> <entry><literal>%u</literal></entry> <entry>User name</entry> <entry>This is the name of the user running the command. In case of the system instance this resolves to <literal>root</literal>.</entry> diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index ba3e6456b7..0c1e20d9ce 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -177,35 +177,23 @@ int unit_name_printf(const Unit *u, const char* format, char **ret) { * This will use the passed string as format string and replace the following specifiers (which should all be * safe for inclusion in unit names): * - * %n: the full id of the unit (foo@bar.waldo) - * %N: the id of the unit without the suffix (foo@bar) - * %p: the prefix (foo) + * %n: the full id of the unit (foo-aaa@bar.waldo) + * %N: the id of the unit without the suffix (foo-aaa@bar) + * %p: the prefix (foo-aaa) * %i: the instance (bar) - * - * %U: the UID of the running user - * %u: the username of the running user - * - * %m: the machine ID of the running system - * %b: the boot ID of the running system - * %H: the hostname of the running system - * %v: the kernel version - * %a: the native userspace architecture - * %o: the OS ID according to /etc/os-release - * %w: the OS version ID, according to /etc/os-release - * %B: the OS build ID, according to /etc/os-release - * %W: the OS variant ID, according to /etc/os-release + * %j: the last componet of the prefix (aaa) */ const Specifier table[] = { + { 'i', specifier_string, u->instance }, + { 'j', specifier_last_component, NULL }, { 'n', specifier_string, u->id }, { 'N', specifier_prefix_and_instance, NULL }, { 'p', specifier_prefix, NULL }, - { 'i', specifier_string, u->instance }, - { 'j', specifier_last_component, NULL }, - - COMMON_CREDS_SPECIFIERS, COMMON_SYSTEM_SPECIFIERS, + + COMMON_CREDS_SPECIFIERS, {} }; @@ -226,19 +214,15 @@ int unit_full_printf(const Unit *u, const char *format, char **ret) { * %r: where units in this slice are placed in the cgroup tree (deprecated) * %R: the root of this systemd's instance tree (deprecated) * - * %t: the runtime directory root (e.g. /run or $XDG_RUNTIME_DIR) - * %S: the state directory root (e.g. /var/lib or $XDG_CONFIG_HOME) * %C: the cache directory root (e.g. /var/cache or $XDG_CACHE_HOME) - * %L: the log directory root (e.g. /var/log or $XDG_CONFIG_HOME/log) * %E: the configuration directory root (e.g. /etc or $XDG_CONFIG_HOME) - * %T: the temporary directory (e.g. /tmp, or $TMPDIR, $TEMP, $TMP) - * %V: the temporary directory for large, persistent stuff (e.g. /var/tmp, or $TMPDIR, $TEMP, $TMP) + * %L: the log directory root (e.g. /var/log or $XDG_CONFIG_HOME/log) + * %S: the state directory root (e.g. /var/lib or $XDG_CONFIG_HOME) + * %t: the runtime directory root (e.g. /run or $XDG_RUNTIME_DIR) * * %h: the homedir of the running user * %s: the shell of the running user * - * %v: `uname -r` of the running system - * * NOTICE: When you add new entries here, please be careful: specifiers which depend on settings of the unit * file itself are broken by design, as they would resolve differently depending on whether they are used * before or after the relevant configuration setting. Hence: don't add them. @@ -249,32 +233,35 @@ int unit_full_printf(const Unit *u, const char *format, char **ret) { assert(ret); const Specifier table[] = { - { 'n', specifier_string, u->id }, - { 'N', specifier_prefix_and_instance, NULL }, - { 'p', specifier_prefix, NULL }, - { 'P', specifier_prefix_unescaped, NULL }, { 'i', specifier_string, u->instance }, { 'I', specifier_instance_unescaped, NULL }, { 'j', specifier_last_component, NULL }, { 'J', specifier_last_component_unescaped, NULL }, + { 'n', specifier_string, u->id }, + { 'N', specifier_prefix_and_instance, NULL }, + { 'p', specifier_prefix, NULL }, + { 'P', specifier_prefix_unescaped, NULL }, { 'f', specifier_filename, NULL }, + { 'c', specifier_cgroup, NULL }, { 'r', specifier_cgroup_slice, NULL }, { 'R', specifier_cgroup_root, NULL }, - { 't', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_RUNTIME) }, - { 'S', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_STATE) }, { 'C', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_CACHE) }, - { 'L', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_LOGS) }, { 'E', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_CONFIGURATION) }, - COMMON_TMP_SPECIFIERS, + { 'L', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_LOGS) }, + { 'S', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_STATE) }, + { 't', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_RUNTIME) }, - COMMON_CREDS_SPECIFIERS, { 'h', specifier_user_home, NULL }, { 's', specifier_user_shell, NULL }, COMMON_SYSTEM_SPECIFIERS, + + COMMON_CREDS_SPECIFIERS, + + COMMON_TMP_SPECIFIERS, {} }; diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 92a7b168c2..f2a3316251 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -230,14 +230,14 @@ int config_parse_dnssd_service_name( void *userdata) { static const Specifier specifier_table[] = { - { 'm', specifier_machine_id, NULL }, + { 'a', specifier_architecture, NULL }, { 'b', specifier_boot_id, NULL }, + { 'B', specifier_os_build_id, NULL }, { 'H', specifier_host_name, NULL }, /* We will use specifier_dnssd_host_name(). */ - { 'v', specifier_kernel_release, NULL }, - { 'a', specifier_architecture, NULL }, + { 'm', specifier_machine_id, NULL }, { 'o', specifier_os_id, NULL }, + { 'v', specifier_kernel_release, NULL }, { 'w', specifier_os_version_id, NULL }, - { 'B', specifier_os_build_id, NULL }, { 'W', specifier_os_variant_id, NULL }, {} }; diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c index 9ea9ec07db..8b40639728 100644 --- a/src/resolve/resolved-dnssd.c +++ b/src/resolve/resolved-dnssd.c @@ -157,14 +157,14 @@ static int specifier_dnssd_host_name(char specifier, const void *data, const voi int dnssd_render_instance_name(DnssdService *s, char **ret_name) { static const Specifier specifier_table[] = { - { 'm', specifier_machine_id, NULL }, + { 'a', specifier_architecture, NULL }, { 'b', specifier_boot_id, NULL }, + { 'B', specifier_os_build_id, NULL }, { 'H', specifier_dnssd_host_name, NULL }, - { 'v', specifier_kernel_release, NULL }, - { 'a', specifier_architecture, NULL }, + { 'm', specifier_machine_id, NULL }, { 'o', specifier_os_id, NULL }, + { 'v', specifier_kernel_release, NULL }, { 'w', specifier_os_version_id, NULL }, - { 'B', specifier_os_build_id, NULL }, { 'W', specifier_os_variant_id, NULL }, {} }; diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c index 7f60359c78..6bc3f15def 100644 --- a/src/shared/install-printf.c +++ b/src/shared/install-printf.c @@ -104,32 +104,18 @@ static int specifier_last_component(char specifier, const void *data, const void } int install_full_printf(const UnitFileInstallInfo *i, const char *format, char **ret) { - /* This is similar to unit_full_printf() but does not support - * anything path-related. - * - * %n: the full id of the unit (foo@bar.waldo) - * %N: the id of the unit without the suffix (foo@bar) - * %p: the prefix (foo) - * %i: the instance (bar) - - * %U the UID of the running user - * %u the username of running user - * %m the machine ID of the running system - * %H the hostname of the running system - * %b the boot ID of the running system - * %v `uname -r` of the running system - */ + /* This is similar to unit_name_printf() */ const Specifier table[] = { + { 'i', specifier_instance, NULL }, + { 'j', specifier_last_component, NULL }, { 'n', specifier_name, NULL }, { 'N', specifier_prefix_and_instance, NULL }, { 'p', specifier_prefix, NULL }, - { 'i', specifier_instance, NULL }, - { 'j', specifier_last_component, NULL }, - - COMMON_CREDS_SPECIFIERS, COMMON_SYSTEM_SPECIFIERS, + + COMMON_CREDS_SPECIFIERS, {} }; diff --git a/src/shared/specifier.h b/src/shared/specifier.h index e01ee67db3..1323b41d98 100644 --- a/src/shared/specifier.h +++ b/src/shared/specifier.h @@ -37,24 +37,48 @@ int specifier_tmp_dir(char specifier, const void *data, const void *userdata, ch int specifier_var_tmp_dir(char specifier, const void *data, const void *userdata, char **ret); /* Typically, in places where one of the above specifier is to be resolved the other similar ones are to be - * resolved, too. Hence let's define common macros for the relevant array entries. */ + * resolved, too. Hence let's define common macros for the relevant array entries. + * + * COMMON_SYSTEM_SPECIFIERS: + * %a: the native userspace architecture + * %b: the boot ID of the running system + * %B: the OS build ID, according to /etc/os-release + * %H: the hostname of the running system + * %l: the short hostname of the running system + * %m: the machine ID of the running system + * %o: the OS ID according to /etc/os-release + * %v: the kernel version + * %w: the OS version ID, according to /etc/os-release + * %W: the OS variant ID, according to /etc/os-release + * + * COMMON_CREDS_SPECIFIERS: + * %g: the groupname of the running user + * %G: the GID of the running user + * %u: the username of the running user + * %U: the UID of the running user + * + * COMMON_TMP_SPECIFIERS: + * %T: the temporary directory (e.g. /tmp, or $TMPDIR, $TEMP, $TMP) + * %V: the temporary directory for large, persistent stuff (e.g. /var/tmp, or $TMPDIR, $TEMP, $TMP) + */ + #define COMMON_SYSTEM_SPECIFIERS \ - { 'm', specifier_machine_id, NULL }, \ + { 'a', specifier_architecture, NULL }, \ { 'b', specifier_boot_id, NULL }, \ + { 'B', specifier_os_build_id, NULL }, \ { 'H', specifier_host_name, NULL }, \ { 'l', specifier_short_host_name, NULL }, \ - { 'v', specifier_kernel_release, NULL }, \ - { 'a', specifier_architecture, NULL }, \ + { 'm', specifier_machine_id, NULL }, \ { 'o', specifier_os_id, NULL }, \ + { 'v', specifier_kernel_release, NULL }, \ { 'w', specifier_os_version_id, NULL }, \ - { 'B', specifier_os_build_id, NULL }, \ { 'W', specifier_os_variant_id, NULL } #define COMMON_CREDS_SPECIFIERS \ { 'g', specifier_group_name, NULL }, \ { 'G', specifier_group_id, NULL }, \ - { 'U', specifier_user_id, NULL }, \ - { 'u', specifier_user_name, NULL } + { 'u', specifier_user_name, NULL }, \ + { 'U', specifier_user_id, NULL } #define COMMON_TMP_SPECIFIERS \ { 'T', specifier_tmp_dir, NULL }, \ diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 684762c842..9906c70eef 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -188,24 +188,26 @@ static int specifier_machine_id_safe(char specifier, const void *data, const voi static int specifier_directory(char specifier, const void *data, const void *userdata, char **ret); static const Specifier specifier_table[] = { - { 'm', specifier_machine_id_safe, NULL }, + { 'a', specifier_architecture, NULL }, { 'b', specifier_boot_id, NULL }, + { 'B', specifier_os_build_id, NULL }, { 'H', specifier_host_name, NULL }, { 'l', specifier_short_host_name, NULL }, - { 'v', specifier_kernel_release, NULL }, - { 'a', specifier_architecture, NULL }, + { 'm', specifier_machine_id_safe, NULL }, { 'o', specifier_os_id, NULL }, + { 'v', specifier_kernel_release, NULL }, { 'w', specifier_os_version_id, NULL }, - { 'B', specifier_os_build_id, NULL }, { 'W', specifier_os_variant_id, NULL }, - COMMON_CREDS_SPECIFIERS, { 'h', specifier_user_home, NULL }, - { 't', specifier_directory, UINT_TO_PTR(DIRECTORY_RUNTIME) }, - { 'S', specifier_directory, UINT_TO_PTR(DIRECTORY_STATE) }, { 'C', specifier_directory, UINT_TO_PTR(DIRECTORY_CACHE) }, { 'L', specifier_directory, UINT_TO_PTR(DIRECTORY_LOGS) }, + { 'S', specifier_directory, UINT_TO_PTR(DIRECTORY_STATE) }, + { 't', specifier_directory, UINT_TO_PTR(DIRECTORY_RUNTIME) }, + + COMMON_CREDS_SPECIFIERS, + COMMON_TMP_SPECIFIERS, {} }; |