From 488e43525391e1279fefc17c381e664788680706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 11 Dec 2018 17:45:34 +0100 Subject: [PATCH 1/4] man: reword tmpfiles.d descriptions to refer less to previous descriptions I think it is OK if some option is described as "similar to ..., but in addition ...", as long as the "in addition" part is strictly additive this is unambiguous. Otherwise, we'd have to repeat a lot of text, and then we'd probably forget to adjust some of the descriptions when doing changes. But when the "in addition" part is about replacing or removing parts of functionality, it is better to avoid this pattern and describe the later option from scratch. Some paragraph breaks are added and minor changes made. UID/GID is changed to user/group, since we generally expect user/group names to be used, not numeric ids. Fixes #11115. --- man/tmpfiles.d.xml | 116 ++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml index 7641b790af..3cca3d27b7 100644 --- a/man/tmpfiles.d.xml +++ b/man/tmpfiles.d.xml @@ -95,9 +95,9 @@ The configuration format is one line per path containing type, path, mode, ownership, age, and argument fields: - #Type Path Mode UID GID Age Argument -d /run/user 0755 root root 10d - -L /tmp/foobar - - - - /dev/null + #Type Path Mode User Group Age Argument +d /run/user 0755 root root 10d - +L /tmp/foobar - - - - /dev/null Fields may be enclosed within quotes and contain C-style escapes. @@ -135,49 +135,49 @@ L /tmp/foobar - - - - /dev/null d - Create a directory. The mode and ownership will be adjusted if - specified and the directory already exists. Contents of this directory are subject - to time based cleanup if the age argument is specified. - - - - D - Similar to d, but in addition the contents - of the directory will be removed when is used. + Create a directory. The mode and ownership will be adjusted if specified. Contents + of this directory are subject to time based cleanup if the age argument is specified. + + D + Similar to d, but in addition the contents of the directory will + be removed when is used. + + e - Similar to d, but the directory will not be created if - it does not exist. Lines of this type accept shell-style globs in place of normal path - names. For this entry to be useful, at least one of the mode, uid, gid, or age arguments - must be specified, since otherwise this entry has no effect. If the age argument is - 0, contents of the directory will be unconditionally deleted every time - systemd-tmpfiles --clean is run. This can be useful when combined with - !, see the examples. + Adjust the mode and ownership of existing directories and remove their contents + based on age. + Lines of this type accept shell-style globs in place of normal path names. Contents of the + directories are subject to time based cleanup if the age argument is specified. If the age argument + is 0, contents will be unconditionally deleted every time + systemd-tmpfiles --clean is run. + + For this entry to be useful, at least one of the mode, user, group, or age arguments must be + specified, since otherwise this entry has no effect. As an exception, an entry with no effect may + be useful when combined with !, see the examples. v - Create a subvolume if the path does not - exist yet, the file system supports subvolumes (btrfs), and - the system itself is installed into a subvolume - (specifically: the root directory / is - itself a subvolume). Otherwise, create a normal directory, in - the same way as d. A subvolume created - with this line type is not assigned to any higher-level - quota group. For that, use q or - Q, which allow creating simple quota - group hierarchies, see below. + Create a subvolume if the path does not exist yet, the file system supports + subvolumes (btrfs), and the system itself is installed into a subvolume (specifically: the root + directory / is itself a subvolume). Otherwise, create a normal directory, in + the same way as d. + + A subvolume created with this line type is not assigned to any higher-level quota group. For + that, use q or Q, which allow creating simple quota group + hierarchies, see below. q - Similar to v. However, makes sure that the subvolume will be assigned to - the same higher-level quota groups as the subvolume it has been created in. This ensures that higher-level - limits and accounting applied to the parent subvolume also include the specified subvolume. On non-btrfs file - systems, this line type is identical to d. + Create a subvolume or directory the same as v, but assign the + subvolume to the same higher-level quota groups as the parent. This ensures that higher-level + limits and accounting applied to the parent subvolume also include the specified subvolume. On + non-btrfs file systems, this line type is identical to d. If the subvolume already exists, no change to the quota hierarchy is made, regardless of whether the subvolume is already attached to a quota group or not. Also see Q below. See Q - Similar to q. However, instead of copying the higher-level quota group - assignments from the parent as-is, the lowest quota group of the parent subvolume is determined that is not - the leaf quota group. Then, an "intermediary" quota group is inserted that is one level below this level, and - shares the same ID part as the specified subvolume. If no higher-level quota group exists for the parent - subvolume, a new quota group at level 255 sharing the same ID as the specified subvolume is inserted - instead. This new intermediary quota group is then assigned to the parent subvolume's higher-level quota - groups, and the specified subvolume's leaf quota group is assigned to it. + Create the subvolume or directory the same as v, but assign the + new subvolume to a new leaf quota group. Instead of copying the higher-level quota group + assignments from the parent as is done with q, the lowest quota group of the + parent subvolume is determined that is not the leaf quota group. Then, an "intermediary" quota + group is inserted that is one level below this level, and shares the same ID part as the specified + subvolume. If no higher-level quota group exists for the parent subvolume, a new quota group at + level 255 sharing the same ID as the specified subvolume is inserted instead. This new intermediary + quota group is then assigned to the parent subvolume's higher-level quota groups, and the specified + subvolume's leaf quota group is assigned to it. Effectively, this has a similar effect as q, however introduces a new higher-level quota group for the specified subvolume that may be used to enforce limits and accounting to the specified @@ -213,8 +215,8 @@ L /tmp/foobar - - - - /dev/null /var/tmp. As with q, Q has no effect on the quota group hierarchy if the - subvolume already exists, regardless of whether the subvolume already belong to a quota group or - not. + subvolume already exists, regardless of whether the subvolume already belong to a quota group or not. + @@ -320,20 +322,17 @@ L /tmp/foobar - - - - /dev/null z - Adjust the access mode, group and user, and - restore the SELinux security context of a file or directory, - if it exists. Lines of this type accept shell-style globs in - place of normal path names. Does not follow symlinks. + Adjust the access mode, user and group ownership, and restore the SELinux security + context of a file or directory, if it exists. Lines of this type accept shell-style globs in place + of normal path names. Does not follow symlinks. Z - Recursively set the access mode, group and - user, and restore the SELinux security context of a file or - directory if it exists, as well as of its subdirectories and - the files contained therein (if applicable). Lines of this - type accept shell-style globs in place of normal path - names. Does not follow symlinks. + Recursively set the access mode, user and group ownership, and restore the SELinux + security context of a file or directory if it exists, as well as of its subdirectories and the + files contained therein (if applicable). Lines of this type accept shell-style globs in place of + normal path names. Does not follow symlinks. @@ -480,13 +479,14 @@ w- /proc/sys/vm/swappiness - - - - 10 - UID, GID + User, Group - The user and group to use for this file or directory. This may either be a numeric user/group ID or a user or group - name. If omitted or when set to -, the user/group ID of the user who invokes systemd-tmpfiles is used. - For z and Z lines, when omitted or when set to -, the file ownership will not be - modified. These parameters are ignored for x, r, R, L, - t, and a lines. + The user and group to use for this file or directory. This may either be a numeric ID or a + user/group name. If omitted or when set to -, the user and group of the user who + invokes systemd-tmpfiles is used. For z and Z + lines, when omitted or when set to -, the file ownership will not be modified. These + parameters are ignored for x, r, R, + L, t, and a lines. From abcb67ceed56a722b9cf352fa27b4ba0076280c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 11 Dec 2018 19:09:48 +0100 Subject: [PATCH 2/4] man: rewrite the general description of tmpfiles We would describe tmpfiles.d through what systemd-tmpfiles does with them, but I think it's better to start with a geneneral statement what they are. Also, let's make the description of volatile file systems less prominent. Also, strenghten the advice to use RuntimeDirectory and mention {Cache,Logs,Configuration,State}Directory=. --- man/tmpfiles.d.xml | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml index 3cca3d27b7..5be96b8e9a 100644 --- a/man/tmpfiles.d.xml +++ b/man/tmpfiles.d.xml @@ -40,22 +40,33 @@ Description - systemd-tmpfiles uses the configuration - files from the above directories to describe the creation, - cleaning and removal of volatile and temporary files and - directories which usually reside in directories such as - /run or /tmp. + tmpfiles.d configuration files provide a generic mechanism to define the + creation of regular files, directories, pipes, and device nodes, adjustments to + their access mode, ownership, attributes, quota assignments, and contents, and + finally their time-based removal. It is mostly commonly used for volatile and + temporary files and directories (such as those located under /run, + /tmp, /var/tmp, the API file systems such as + /sys or /proc, as well as some other directories below + /var). - Volatile and temporary files and directories are those located in /run, - /tmp, /var/tmp, the API file systems such as /sys or - /proc, as well as some other directories below /var. + systemd-tmpfiles uses this configuration to create volatile files and + directories during boot and to do periodic cleanup afterwards. See + systemd-tmpfiles5 for + the description of systemd-tmpfiles-setup.service, + systemd-tmpfiles-cleanup.service, and associated units. - System daemons frequently require private runtime - directories below /run to place communication - sockets and similar in. For these, consider declaring them in - their unit files using RuntimeDirectory= (see - systemd.exec5 - for details), if this is feasible. + System daemons frequently require private runtime directories below /run to + store communication sockets and similar. For these, is is better to use + RuntimeDirectory= in their unit files (see + systemd.exec5 for + details), if the flexibility provided by tmpfiles.d is not required. The advantages + are that the configuration required by the unit is centralized in one place, and that the lifetime of the + directory is tied to the lifetime of the service itself. Similarly, StateDirectory=, + CacheDirectory=, LogsDirectory=, and + ConfigurationDirectory= should be used to create directories under + /var/lib/, /var/cache/, /var/log/, and + /etc/. tmpfiles.d should be used for files whose lifetime is + independent of any service or requires more complicated configuration. From d7ef12572671545e8871e7aaa4d372f620a6c9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 11 Dec 2018 19:12:38 +0100 Subject: [PATCH 3/4] core: fix typo in comment --- src/core/dynamic-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c index c47d1740c8..889492aeec 100644 --- a/src/core/dynamic-user.c +++ b/src/core/dynamic-user.c @@ -178,7 +178,7 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) { * * 1. Initially, we try to read the UID of a number of specified paths. If any of these UIDs works, we use * them. We use in order to increase the chance of UID reuse, if StateDirectory=, CacheDirectory= or - * LogDirectory= are used, as reusing the UID these directories are owned by saves us from having to + * LogsDirectory= are used, as reusing the UID these directories are owned by saves us from having to * recursively chown() them to new users. * * 2. If that didn't yield a currently unused UID, we hash the user name, and try to use that. This should be From 6a89d671dfdd92c0b1b703d7fcb5b0551cafb570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 11 Dec 2018 22:11:46 +0100 Subject: [PATCH 4/4] man: add a note that /var/run should not be used in tmpfiles --- man/tmpfiles.d.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml index 5be96b8e9a..5d393f3984 100644 --- a/man/tmpfiles.d.xml +++ b/man/tmpfiles.d.xml @@ -741,6 +741,13 @@ e! /var/cache/krb5rcache - - - 0 + + <filename>/run/</filename> and <filename>/var/run/</filename> + /var/run/ is a deprecated symlink to /run/, and + applications should use the latter. systemd-tmpfiles will warn if + /var/run/ is used. + + See Also