mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
namespace: ignore prefix chars when comparing paths
Other callers of path_strv_contains() or PATH_IN_SET() don't seem to handle paths prefixed with -+.
This commit is contained in:
parent
3b5b6826aa
commit
de46b2be07
@ -1125,3 +1125,19 @@ bool path_strv_contains(char **l, const char *path) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool prefixed_path_strv_contains(char **l, const char *path) {
|
||||||
|
char **i, *j;
|
||||||
|
|
||||||
|
STRV_FOREACH(i, l) {
|
||||||
|
j = *i;
|
||||||
|
if (*j == '-')
|
||||||
|
j++;
|
||||||
|
if (*j == '+')
|
||||||
|
j++;
|
||||||
|
if (path_equal(j, path))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -173,3 +173,4 @@ static inline const char *empty_to_root(const char *path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool path_strv_contains(char **l, const char *path);
|
bool path_strv_contains(char **l, const char *path);
|
||||||
|
bool prefixed_path_strv_contains(char **l, const char *path);
|
||||||
|
@ -1192,7 +1192,7 @@ static bool root_read_only(
|
|||||||
if (protect_system == PROTECT_SYSTEM_STRICT)
|
if (protect_system == PROTECT_SYSTEM_STRICT)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (path_strv_contains(read_only_paths, "/"))
|
if (prefixed_path_strv_contains(read_only_paths, "/"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1217,9 +1217,9 @@ static bool home_read_only(
|
|||||||
if (protect_home != PROTECT_HOME_NO)
|
if (protect_home != PROTECT_HOME_NO)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (path_strv_contains(read_only_paths, "/home") ||
|
if (prefixed_path_strv_contains(read_only_paths, "/home") ||
|
||||||
path_strv_contains(inaccessible_paths, "/home") ||
|
prefixed_path_strv_contains(inaccessible_paths, "/home") ||
|
||||||
path_strv_contains(empty_directories, "/home"))
|
prefixed_path_strv_contains(empty_directories, "/home"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (i = 0; i < n_temporary_filesystems; i++)
|
for (i = 0; i < n_temporary_filesystems; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user