tree-wide: port more code over to PATH_STARTSWITH_SET()

This commit is contained in:
Lennart Poettering 2018-11-23 16:51:53 +01:00
parent d898ed65ab
commit da9fc98ded
4 changed files with 8 additions and 19 deletions

View 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;

View 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"

View 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;

View 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) {