|
|
17aa40 |
From 520ff5394187a0d6cb0cb40251f6e8e997ccdd0e Mon Sep 17 00:00:00 2001
|
|
|
17aa40 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
17aa40 |
Date: Wed, 7 Apr 2021 17:54:49 +0200
|
|
|
17aa40 |
Subject: [PATCH] tmpfiles: rework condition check
|
|
|
17aa40 |
|
|
|
17aa40 |
(!a && b) || (a && c) is replaced by (a ? c : b).
|
|
|
17aa40 |
|
|
|
17aa40 |
path_startswith() != NULL is need to avoid type warning.
|
|
|
17aa40 |
|
|
|
17aa40 |
(cherry picked from commit 875e7b25d84a111755dab79241c9e64e44836910)
|
|
|
17aa40 |
|
|
|
17aa40 |
Related: #1944468
|
|
|
17aa40 |
---
|
|
|
17aa40 |
src/tmpfiles/tmpfiles.c | 11 ++++++++---
|
|
|
17aa40 |
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
17aa40 |
|
|
|
17aa40 |
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
|
|
|
17aa40 |
index 1aeeed0d2e..50fada99dd 100644
|
|
|
17aa40 |
--- a/src/tmpfiles/tmpfiles.c
|
|
|
17aa40 |
+++ b/src/tmpfiles/tmpfiles.c
|
|
|
17aa40 |
@@ -2705,7 +2705,11 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
|
|
|
17aa40 |
for (size_t nj = 0; nj < ja->count; nj++) {
|
|
|
17aa40 |
Item *j = ja->items + nj;
|
|
|
17aa40 |
|
|
|
17aa40 |
- if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA))
|
|
|
17aa40 |
+ if (!IN_SET(j->type, CREATE_DIRECTORY,
|
|
|
17aa40 |
+ TRUNCATE_DIRECTORY,
|
|
|
17aa40 |
+ CREATE_SUBVOLUME,
|
|
|
17aa40 |
+ CREATE_SUBVOLUME_INHERIT_QUOTA,
|
|
|
17aa40 |
+ CREATE_SUBVOLUME_NEW_QUOTA))
|
|
|
17aa40 |
continue;
|
|
|
17aa40 |
|
|
|
17aa40 |
if (path_equal(j->path, i->path)) {
|
|
|
17aa40 |
@@ -2713,8 +2717,9 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
|
|
|
17aa40 |
break;
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
- if ((!candidate_item && path_startswith(i->path, j->path)) ||
|
|
|
17aa40 |
- (candidate_item && path_startswith(j->path, candidate_item->path) && (fnmatch(i->path, j->path, FNM_PATHNAME | FNM_PERIOD) == 0)))
|
|
|
17aa40 |
+ if (candidate_item
|
|
|
17aa40 |
+ ? (path_startswith(j->path, candidate_item->path) && fnmatch(i->path, j->path, FNM_PATHNAME | FNM_PERIOD) == 0)
|
|
|
17aa40 |
+ : path_startswith(i->path, j->path) != NULL)
|
|
|
17aa40 |
candidate_item = j;
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|