2015-02-13 10:43:21 +01:00
|
|
|
---
|
2015-02-16 12:36:25 +01:00
|
|
|
man/tmpfiles.d.xml | 3 +++
|
2015-12-02 16:45:15 +01:00
|
|
|
src/tmpfiles/tmpfiles.c | 46 ++++++++++++++++++++++++++++++++++++++++------
|
|
|
|
2 files changed, 43 insertions(+), 6 deletions(-)
|
2015-02-13 10:43:21 +01:00
|
|
|
|
2015-12-02 16:45:15 +01:00
|
|
|
Index: systemd-228/man/tmpfiles.d.xml
|
2015-02-13 10:43:21 +01:00
|
|
|
===================================================================
|
2015-12-02 16:45:15 +01:00
|
|
|
--- systemd-228.orig/man/tmpfiles.d.xml
|
|
|
|
+++ systemd-228/man/tmpfiles.d.xml
|
|
|
|
@@ -599,6 +599,9 @@
|
2015-02-16 12:36:25 +01:00
|
|
|
<varname>f</varname>, <varname>F</varname>, and
|
2015-12-02 16:45:15 +01:00
|
|
|
<varname>w</varname>, the argument may be used to specify a short string that
|
2015-02-16 12:36:25 +01:00
|
|
|
is written to the 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 excluded
|
|
|
|
+ during directory cleanup. Ignored for all other lines. For
|
|
|
|
<varname>C</varname>, specifies the source file or
|
2015-12-02 16:45:15 +01:00
|
|
|
directory. For <varname>t</varname> and <varname>T</varname>,
|
2015-06-23 14:56:50 +02:00
|
|
|
determines extended attributes to be set. For
|
2015-12-02 16:45:15 +01:00
|
|
|
Index: systemd-228/src/tmpfiles/tmpfiles.c
|
2015-02-13 10:43:21 +01:00
|
|
|
===================================================================
|
2015-12-02 16:45:15 +01:00
|
|
|
--- systemd-228.orig/src/tmpfiles/tmpfiles.c
|
|
|
|
+++ systemd-228/src/tmpfiles/tmpfiles.c
|
2015-06-23 14:56:50 +02:00
|
|
|
@@ -37,6 +37,7 @@
|
|
|
|
#include <sys/xattr.h>
|
2015-12-02 16:45:15 +01:00
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
2015-06-23 14:56:50 +02:00
|
|
|
+#include <pwd.h>
|
|
|
|
|
2015-12-02 16:45:15 +01:00
|
|
|
#include "acl-util.h"
|
|
|
|
#include "alloc-util.h"
|
|
|
|
@@ -378,6 +379,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-12-02 16:45:15 +01:00
|
|
|
@@ -428,14 +430,46 @@ static int dir_cleanup(
|
2014-12-18 12:26:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Is there an item configured for this path? */
|
2015-06-23 14:56:50 +02:00
|
|
|
- if (ordered_hashmap_get(items, sub_path)) {
|
2015-02-16 12:36:25 +01:00
|
|
|
- log_debug("Ignoring \"%s\": a separate entry exists.", sub_path);
|
2014-12-18 12:26:58 +01:00
|
|
|
- continue;
|
2015-02-16 12:36:25 +01:00
|
|
|
+ bool found_glob = false;
|
2015-06-23 14:56:50 +02:00
|
|
|
+ found = ordered_hashmap_get(items, sub_path);
|
2015-02-16 12:36:25 +01:00
|
|
|
+ if (!found) {
|
|
|
|
+ found_glob = true;
|
|
|
|
+ found = find_glob(globs, sub_path);
|
2015-06-23 14:56:50 +02:00
|
|
|
}
|
2015-12-02 16:45:15 +01:00
|
|
|
|
2015-06-23 14:56:50 +02:00
|
|
|
- if (find_glob(globs, sub_path)) {
|
|
|
|
- log_debug("Ignoring \"%s\": a separate glob exists.", sub_path);
|
|
|
|
- continue;
|
2014-12-18 12:26:58 +01:00
|
|
|
+ if (found) {
|
2015-02-16 12:36:25 +01:00
|
|
|
+ struct passwd *pw;
|
|
|
|
+ char *userfound = NULL, *args;
|
|
|
|
+ bool match = false;
|
|
|
|
+ uid_t uid = -1;
|
|
|
|
+
|
2014-12-18 12:26:58 +01:00
|
|
|
+ /* evaluate username arguments in ignore statements */
|
2015-02-16 12:36:25 +01:00
|
|
|
+ if ((found->type != IGNORE_PATH && found->type != IGNORE_DIRECTORY_PATH) ||
|
|
|
|
+ !found->argument) {
|
|
|
|
+ if (found_glob)
|
|
|
|
+ log_debug("Ignoring \"%s\": a separate glob exists.", sub_path);
|
|
|
|
+ else
|
|
|
|
+ log_debug("Ignoring \"%s\": a separate entry exists.", sub_path);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ args = strdup(found->argument);
|
|
|
|
+ assert_se(args != NULL);
|
|
|
|
+ while ((userfound = strsep(&args, ",")) != NULL) {
|
|
|
|
+ pw = getpwnam(userfound);
|
|
|
|
+ if (pw == NULL) {
|
|
|
|
+ log_error("Unknown user '%s' in ignore statement.", userfound);
|
2015-02-13 10:43:21 +01:00
|
|
|
+ continue;
|
2014-12-18 12:26:58 +01:00
|
|
|
+ }
|
2015-02-16 12:36:25 +01:00
|
|
|
+ uid = pw->pw_uid;
|
|
|
|
+ if (s.st_uid == uid) {
|
|
|
|
+ match = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (match) {
|
|
|
|
+ found = NULL;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
}
|
2014-12-18 12:26:58 +01:00
|
|
|
|
|
|
|
if (S_ISDIR(s.st_mode)) {
|