1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-12 09:17:44 +03:00

sysctl: drop /proc/sys/ in prefix

This commit is contained in:
Yu Watanabe 2022-08-17 03:11:00 +09:00
parent 350ffa9749
commit c01404fdf1

View File

@ -56,18 +56,7 @@ static bool test_prefix(const char *p) {
if (strv_isempty(arg_prefixes)) if (strv_isempty(arg_prefixes))
return true; return true;
STRV_FOREACH(i, arg_prefixes) { return path_startswith_strv(p, arg_prefixes);
const char *t;
t = path_startswith(*i, "/proc/sys/");
if (!t)
t = *i;
if (path_startswith(p, t))
return true;
}
return false;
} }
static Option *option_new( static Option *option_new(
@ -360,6 +349,7 @@ static int parse_argv(int argc, char *argv[]) {
break; break;
case ARG_PREFIX: { case ARG_PREFIX: {
const char *s;
char *p; char *p;
/* We used to require people to specify absolute paths /* We used to require people to specify absolute paths
@ -368,10 +358,8 @@ static int parse_argv(int argc, char *argv[]) {
* sysctl name available. */ * sysctl name available. */
sysctl_normalize(optarg); sysctl_normalize(optarg);
if (path_startswith(optarg, "/proc/sys")) s = path_startswith(optarg, "/proc/sys");
p = strdup(optarg); p = strdup(s ?: optarg);
else
p = path_join("/proc/sys", optarg);
if (!p) if (!p)
return log_oom(); return log_oom();