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)
|
if (r < 0)
|
||||||
return r; /* returns EINVAL if not a symlink */
|
return r; /* returns EINVAL if not a symlink */
|
||||||
|
|
||||||
e = path_startswith(t, "/usr/share/zoneinfo/");
|
e = PATH_STARTSWITH_SET(t, "/usr/share/zoneinfo/", "../usr/share/zoneinfo/");
|
||||||
if (!e)
|
|
||||||
e = path_startswith(t, "../usr/share/zoneinfo/");
|
|
||||||
if (!e)
|
if (!e)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "signal-util.h"
|
#include "signal-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
#include "strv.h"
|
||||||
#include "umount.h"
|
#include "umount.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "virt.h"
|
#include "virt.h"
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "selinux-util.h"
|
#include "selinux-util.h"
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
#include "strv.h"
|
||||||
#include "unaligned.h"
|
#include "unaligned.h"
|
||||||
|
|
||||||
static bool allow_object_pid(const struct ucred *ucred) {
|
static bool allow_object_pid(const struct ucred *ucred) {
|
||||||
|
@ -337,11 +338,7 @@ void server_process_native_file(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = path_startswith(k, "/dev/shm/");
|
e = PATH_STARTSWITH_SET(k, "/dev/shm/", "/tmp/", "/var/tmp/");
|
||||||
if (!e)
|
|
||||||
e = path_startswith(k, "/tmp/");
|
|
||||||
if (!e)
|
|
||||||
e = path_startswith(k, "/var/tmp/");
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
log_error("Received file outside of allowed directories. Refusing.");
|
log_error("Received file outside of allowed directories. Refusing.");
|
||||||
return;
|
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) {
|
static const char *timezone_from_path(const char *path) {
|
||||||
const char *z;
|
return PATH_STARTSWITH_SET(
|
||||||
|
path,
|
||||||
z = path_startswith(path, "../usr/share/zoneinfo/");
|
"../usr/share/zoneinfo/",
|
||||||
if (z)
|
"/usr/share/zoneinfo/");
|
||||||
return z;
|
|
||||||
|
|
||||||
z = path_startswith(path, "/usr/share/zoneinfo/");
|
|
||||||
if (z)
|
|
||||||
return z;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_timezone(const char *dest) {
|
static int setup_timezone(const char *dest) {
|
||||||
|
|
Loading…
Reference in New Issue