SHA256
1
0
forked from pool/systemd

Accepting request 265723 from home:tsaupe

update systemd-tmpfiles ignore statements code

OBS-URL: https://build.opensuse.org/request/show/265723
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=837
This commit is contained in:
Dr. Werner Fink 2014-12-18 11:26:58 +00:00 committed by Git OBS Bridge
parent dfc6901177
commit c3bbe59bf0
6 changed files with 104 additions and 22 deletions

View File

@ -1,10 +0,0 @@
diff -Naur systemd-208/units/systemd-tmpfiles-clean.service.in systemd-208-mod/units/systemd-tmpfiles-clean.service.in
--- systemd-208/units/systemd-tmpfiles-clean.service.in 2013-08-13 20:02:52.826756410 +0000
+++ systemd-208-mod/units/systemd-tmpfiles-clean.service.in 2014-02-21 13:34:56.456511025 +0000
@@ -19,5 +19,6 @@
[Service]
Type=oneshot
+ExecStart=-@rootbindir@/systemd-tmpfiles-keep
ExecStart=@rootbindir@/systemd-tmpfiles --clean
IOSchedulingClass=idle

View File

@ -0,0 +1,78 @@
diff -Naur systemd-210/man/tmpfiles.d.xml systemd-210.mod/man/tmpfiles.d.xml
--- systemd-210/man/tmpfiles.d.xml 2014-12-18 09:40:29.403629407 +0100
+++ systemd-210.mod/man/tmpfiles.d.xml 2014-12-18 10:34:06.274130934 +0100
@@ -435,8 +435,12 @@
<varname>f</varname>, <varname>F</varname>,
and <varname>w</varname> may be used to
specify a short string that is written to the
- file, suffixed by a newline. Ignored for all
- other lines.</para>
+ 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.</para>
</refsect2>
</refsect1>
diff -Naur systemd-210/src/tmpfiles/tmpfiles.c systemd-210.mod/src/tmpfiles/tmpfiles.c
--- systemd-210/src/tmpfiles/tmpfiles.c 2014-12-18 09:40:29.342629177 +0100
+++ systemd-210.mod/src/tmpfiles/tmpfiles.c 2014-12-18 11:58:16.686576974 +0100
@@ -263,6 +263,7 @@
struct timespec times[2];
bool deleted = false;
int r = 0;
+ Item *found = NULL;
while ((dent = readdir(d))) {
struct stat s;
@@ -306,11 +307,43 @@
}
/* Is there an item configured for this path? */
- if (hashmap_get(items, sub_path))
- continue;
-
- if (find_glob(globs, sub_path))
- continue;
+ found = hashmap_get(items, sub_path);
+
+ 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) {
+ if (!found->argument)
+ continue;
+ else {
+ struct passwd *pw;
+ char *userfound = NULL, *args = strdup(found->argument);
+ bool match = false;
+ int uid = -1;
+
+ while ((userfound = strsep(&args, ","))) {
+ pw = getpwnam(userfound);
+
+ if (!pw)
+ log_error("Unknown user '%s' in ignore statement.", userfound);
+ else {
+ uid = pw->pw_uid;
+ if (s.st_uid == uid) {
+ match = true;
+ break;
+ }
+ }
+ }
+ if (match) {
+ found = NULL;
+ continue;
+ }
+ }
+ } else
+ continue;
+ }
if (S_ISDIR(s.st_mode)) {

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Dec 17 14:57:42 UTC 2014 - thomas.blume@suse.com
- remove 0022-systemd-tmpfiles-ownerkeep.patch since this is now
implemented into the systemd-tmpfiles binary
- add user based ignore statements in tmpfiles removal directives
(bnc#903009)
add systemd-add-user-keep.patch
-------------------------------------------------------------------
Tue Dec 16 09:45:38 UTC 2014 - thomas.blume@suse.com

View File

@ -42,7 +42,6 @@
%bcond_with udevsettle
%endif
%bcond_with systemgrps
%{expand: %%global has_tmpkeep %(type -p systemd-tmpfiles-keep &>/dev/null && echo 1 || echo 0)}
Name: systemd-mini
Url: http://www.freedesktop.org/wiki/Software/systemd
@ -396,8 +395,6 @@ Patch181: 0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
Patch182: 0019-make-completion-smart-to-be-able-to-redirect.patch
# PATCH-FIX-SUSE 0001-add-network-device-after-NFS-mount-units.patch werner@suse.com
Patch183: 0001-add-network-device-after-NFS-mount-units.patch
# PATCH-FIX-SUSE 0022-systemd-tmpfiles-ownerkeep.patch
Patch184: 0022-systemd-tmpfiles-ownerkeep.patch
# PATCH-FIX-SUSE systemd-powerd-initctl-support.patch
Patch185: systemd-powerd-initctl-support.patch
# PATCH-FIX-SUSE systemctl-set-default-target.patch
@ -1062,6 +1059,9 @@ Patch517: 0004-core-fix-transaction-destructiveness-check-once-more.patch
Patch518: 0001-units-tmpfiles-setup-dev-allow-unsafe-file-creation-.patch
# PATCH-FIX-UPSTREAM added at 2014/12/16
Patch519: 0002-man-tmpfiles.d-recommend-using-b-and-c.patch
# PATCH-FIX-SUSE systemd-add-user-keep.patch (bnc#903009)
Patch520: systemd-add-user-keep.patch
#
# UDEV PATCHES
# ============
@ -1605,9 +1605,6 @@ cp %{SOURCE7} m4/
%patch181 -p1
%patch182 -p1
%patch183 -p1
%if 0%{?has_tmpkeep}
%patch184 -p1
%endif
%patch185 -p1
%patch186 -p1
%patch187 -p1
@ -1943,6 +1940,7 @@ cp %{SOURCE7} m4/
%patch517 -p0
%patch518 -p1
%patch519 -p1
%patch520 -p1
# udev patches
%patch1001 -p1

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Dec 17 14:57:42 UTC 2014 - thomas.blume@suse.com
- remove 0022-systemd-tmpfiles-ownerkeep.patch since this is now
implemented into the systemd-tmpfiles binary
- add user based ignore statements in tmpfiles removal directives
(bnc#903009)
add systemd-add-user-keep.patch
-------------------------------------------------------------------
Tue Dec 16 09:45:38 UTC 2014 - thomas.blume@suse.com

View File

@ -40,7 +40,6 @@
%bcond_with udevsettle
%endif
%bcond_with systemgrps
%{expand: %%global has_tmpkeep %(type -p systemd-tmpfiles-keep &>/dev/null && echo 1 || echo 0)}
Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
@ -391,8 +390,6 @@ Patch181: 0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
Patch182: 0019-make-completion-smart-to-be-able-to-redirect.patch
# PATCH-FIX-SUSE 0001-add-network-device-after-NFS-mount-units.patch werner@suse.com
Patch183: 0001-add-network-device-after-NFS-mount-units.patch
# PATCH-FIX-SUSE 0022-systemd-tmpfiles-ownerkeep.patch
Patch184: 0022-systemd-tmpfiles-ownerkeep.patch
# PATCH-FIX-SUSE systemd-powerd-initctl-support.patch
Patch185: systemd-powerd-initctl-support.patch
# PATCH-FIX-SUSE systemctl-set-default-target.patch
@ -1057,6 +1054,9 @@ Patch517: 0004-core-fix-transaction-destructiveness-check-once-more.patch
Patch518: 0001-units-tmpfiles-setup-dev-allow-unsafe-file-creation-.patch
# PATCH-FIX-UPSTREAM added at 2014/12/16
Patch519: 0002-man-tmpfiles.d-recommend-using-b-and-c.patch
# PATCH-FIX-SUSE systemd-add-user-keep.patch (bnc#903009)
Patch520: systemd-add-user-keep.patch
#
# UDEV PATCHES
# ============
@ -1600,9 +1600,6 @@ cp %{SOURCE7} m4/
%patch181 -p1
%patch182 -p1
%patch183 -p1
%if 0%{?has_tmpkeep}
%patch184 -p1
%endif
%patch185 -p1
%patch186 -p1
%patch187 -p1
@ -1938,6 +1935,7 @@ cp %{SOURCE7} m4/
%patch517 -p0
%patch518 -p1
%patch519 -p1
%patch520 -p1
# udev patches
%patch1001 -p1