mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-03 13:47:04 +03:00
tree-wide: port more code over to PATH_STARTSWITH_SET()
This commit is contained in:
parent
d898ed65ab
commit
da9fc98ded
@ -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;
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user