]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: port more code over to PATH_STARTSWITH_SET()
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 15:51:53 +0000 (16:51 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 26 Nov 2018 13:08:46 +0000 (14:08 +0100)
src/basic/time-util.c
src/core/umount.c
src/journal/journald-native.c
src/nspawn/nspawn.c

index 30ad83d0a76b6e293ddf84e21fe9f525404463b9..f1f52f1beb057016d631cf05cf7ce10cb09f3029 100644 (file)
@@ -1384,9 +1384,7 @@ int get_timezone(char **tz) {
         if (r < 0)
                 return r; /* returns EINVAL if not a symlink */
 
-        e = path_startswith(t, "/usr/share/zoneinfo/");
-        if (!e)
-                e = path_startswith(t, "../usr/share/zoneinfo/");
+        e = PATH_STARTSWITH_SET(t, "/usr/share/zoneinfo/", "../usr/share/zoneinfo/");
         if (!e)
                 return -EINVAL;
 
index 9e6c404ab960e0e4016476975f27e41413714135..bd4e4e7257dfd5a657220a820285dde05cf8dde1 100644 (file)
@@ -29,6 +29,7 @@
 #include "process-util.h"
 #include "signal-util.h"
 #include "string-util.h"
+#include "strv.h"
 #include "umount.h"
 #include "util.h"
 #include "virt.h"
index 7dd9ca62d51af5de08727b45800583bcf8a1c807..5ea4601ba35fdf29f78283608435630bae9e7b98 100644 (file)
@@ -25,6 +25,7 @@
 #include "selinux-util.h"
 #include "socket-util.h"
 #include "string-util.h"
+#include "strv.h"
 #include "unaligned.h"
 
 static bool allow_object_pid(const struct ucred *ucred) {
@@ -337,11 +338,7 @@ void server_process_native_file(
                         return;
                 }
 
-                e = path_startswith(k, "/dev/shm/");
-                if (!e)
-                        e = path_startswith(k, "/tmp/");
-                if (!e)
-                        e = path_startswith(k, "/var/tmp/");
+                e = PATH_STARTSWITH_SET(k, "/dev/shm/", "/tmp/", "/var/tmp/");
                 if (!e) {
                         log_error("Received file outside of allowed directories. Refusing.");
                         return;
index 47fe7d4865db87299956aa1ed71fbd310aff22f6..c581514b297ddbb108b182393e587eab74e73819 100644 (file)
@@ -1427,17 +1427,10 @@ static int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t u
 }
 
 static const char *timezone_from_path(const char *path) {
-        const char *z;
-
-        z = path_startswith(path, "../usr/share/zoneinfo/");
-        if (z)
-                return z;
-
-        z = path_startswith(path, "/usr/share/zoneinfo/");
-        if (z)
-                return z;
-
-        return NULL;
+        return PATH_STARTSWITH_SET(
+                        path,
+                        "../usr/share/zoneinfo/",
+                        "/usr/share/zoneinfo/");
 }
 
 static int setup_timezone(const char *dest) {