summaryrefslogtreecommitdiff
path: root/src/sysctl
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-08-17 03:11:00 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-17 14:30:20 +0900
commitc01404fdf100b03dafa8a366d07f74f3c30d5330 (patch)
tree37f77c178eddc6cdfec9aa3e9538a2550383c8e1 /src/sysctl
parent350ffa9749f2ce5d62e4b66cc7418e25e6829963 (diff)
downloadsystemd-c01404fdf100b03dafa8a366d07f74f3c30d5330.tar.gz
sysctl: drop /proc/sys/ in prefix
Diffstat (limited to 'src/sysctl')
-rw-r--r--src/sysctl/sysctl.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index dda112f45a..ae079b7a71 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -56,18 +56,7 @@ static bool test_prefix(const char *p) {
if (strv_isempty(arg_prefixes))
return true;
- STRV_FOREACH(i, arg_prefixes) {
- const char *t;
-
- t = path_startswith(*i, "/proc/sys/");
- if (!t)
- t = *i;
-
- if (path_startswith(p, t))
- return true;
- }
-
- return false;
+ return path_startswith_strv(p, arg_prefixes);
}
static Option *option_new(
@@ -360,6 +349,7 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_PREFIX: {
+ const char *s;
char *p;
/* 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_normalize(optarg);
- if (path_startswith(optarg, "/proc/sys"))
- p = strdup(optarg);
- else
- p = path_join("/proc/sys", optarg);
+ s = path_startswith(optarg, "/proc/sys");
+ p = strdup(s ?: optarg);
if (!p)
return log_oom();