X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsysctl%2Fsysctl.c;h=809e59b71fdb6acd8a184e2f52a5fca7d2c092ce;hb=74a550c5d8228e58b936dd70e183f633bf373632;hp=8ce9870432c1e54772f3a7a0f43ecb4a62286f3b;hpb=601185b43da638b1c74153deae01dbd518680889;p=elogind.git diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 8ce987043..809e59b71 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -219,7 +219,7 @@ static void help(void) { "Applies kernel sysctl settings.\n\n" " -h --help Show this help\n" " --version Show package version\n" - " --prefix=PATH Only apply rules that apply to paths with the specified prefix\n" + " --prefix=PATH Only apply rules with the specified prefix\n" , program_invocation_short_name); } @@ -258,11 +258,19 @@ static int parse_argv(int argc, char *argv[]) { case ARG_PREFIX: { char *p; - for (p = optarg; *p; p++) - if (*p == '.') - *p = '/'; - - if (strv_extend(&arg_prefixes, optarg) < 0) + /* We used to require people to specify absolute paths + * in /proc/sys in the past. This is kinda useless, but + * we need to keep compatibility. We now support any + * sysctl name available. */ + normalize_sysctl(optarg); + if (startswith(optarg, "/proc/sys")) + p = strdup(optarg); + else + p = strappend("/proc/sys/", optarg); + + if (!p) + return log_oom(); + if (strv_consume(&arg_prefixes, p) < 0) return log_oom(); break; @@ -292,7 +300,7 @@ int main(int argc, char *argv[]) { umask(0022); - sysctl_options = hashmap_new(string_hash_func, string_compare_func); + sysctl_options = hashmap_new(&string_hash_ops); if (!sysctl_options) { r = log_oom(); goto finish;