2015-02-13 10:43:21 +01:00
|
|
|
---
|
|
|
|
man/tmpfiles.d.xml | 5 +++++
|
|
|
|
src/tmpfiles/tmpfiles.c | 42 ++++++++++++++++++++++++++++++++++++++----
|
|
|
|
2 files changed, 43 insertions(+), 4 deletions(-)
|
|
|
|
|
|
|
|
Index: systemd-218/man/tmpfiles.d.xml
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/man/tmpfiles.d.xml
|
|
|
|
+++ systemd-218/man/tmpfiles.d.xml
|
|
|
|
@@ -545,6 +545,11 @@ r! /tmp/.X[0-9]*-lock</programlisting>
|
2014-12-18 12:26:58 +01:00
|
|
|
and <varname>w</varname> may be used to
|
|
|
|
specify a short string that is written to the
|
2015-02-13 10:43:21 +01:00
|
|
|
file, suffixed by a newline. For
|
|
|
|
+ <varname>x</varname>, <varname>X</varname>,
|
|
|
|
+ a comma separated list of usernames. If given,
|
|
|
|
+ only paths belonging to these users will be
|
2014-12-18 12:26:58 +01:00
|
|
|
+ excluded during directory cleanup.
|
2015-02-13 10:43:21 +01:00
|
|
|
+ Ignored for all other lines. For
|
|
|
|
<varname>C</varname>, specifies the source file
|
|
|
|
or directory. For <varname>t</varname> determines
|
|
|
|
extended attributes to be set. Ignored for all other lines.</para>
|
|
|
|
Index: systemd-218/src/tmpfiles/tmpfiles.c
|
|
|
|
===================================================================
|
|
|
|
--- systemd-218.orig/src/tmpfiles/tmpfiles.c
|
|
|
|
+++ systemd-218/src/tmpfiles/tmpfiles.c
|
|
|
|
@@ -278,6 +278,7 @@ static int dir_cleanup(
|
2014-12-18 12:26:58 +01:00
|
|
|
struct timespec times[2];
|
|
|
|
bool deleted = false;
|
|
|
|
int r = 0;
|
|
|
|
+ Item *found = NULL;
|
|
|
|
|
|
|
|
while ((dent = readdir(d))) {
|
|
|
|
struct stat s;
|
2015-02-13 10:43:21 +01:00
|
|
|
@@ -322,11 +323,44 @@ static int dir_cleanup(
|
2014-12-18 12:26:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Is there an item configured for this path? */
|
|
|
|
- if (hashmap_get(items, sub_path))
|
|
|
|
- continue;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ found = hashmap_get(items, sub_path);
|
|
|
|
|
2014-12-18 12:26:58 +01:00
|
|
|
- if (find_glob(globs, sub_path))
|
|
|
|
- continue;
|
|
|
|
+ if (!found)
|
|
|
|
+ found = find_glob(globs, sub_path);
|
|
|
|
+
|
|
|
|
+ if (found) {
|
|
|
|
+ /* evaluate username arguments in ignore statements */
|
|
|
|
+ if (found->type == IGNORE_PATH || found->type == IGNORE_DIRECTORY_PATH) {
|
2015-02-13 10:43:21 +01:00
|
|
|
+ if (!found->argument) {
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
2014-12-18 12:26:58 +01:00
|
|
|
+ struct passwd *pw;
|
|
|
|
+ char *userfound = NULL, *args = strdup(found->argument);
|
|
|
|
+ bool match = false;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ uid_t uid = -1;
|
2014-12-18 12:26:58 +01:00
|
|
|
+
|
|
|
|
+ while ((userfound = strsep(&args, ","))) {
|
|
|
|
+ pw = getpwnam(userfound);
|
|
|
|
+
|
|
|
|
+ if (!pw)
|
|
|
|
+ log_error("Unknown user '%s' in ignore statement.", userfound);
|
|
|
|
+ else {
|
|
|
|
+ uid = pw->pw_uid;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ if (s.st_uid == uid) {
|
2014-12-18 12:26:58 +01:00
|
|
|
+ match = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (match) {
|
|
|
|
+ found = NULL;
|
2015-02-13 10:43:21 +01:00
|
|
|
+ continue;
|
2014-12-18 12:26:58 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2015-02-13 10:43:21 +01:00
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
2014-12-18 12:26:58 +01:00
|
|
|
+ }
|
|
|
|
|
|
|
|
if (S_ISDIR(s.st_mode)) {
|
|
|
|
|