diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-07-14 13:41:37 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-07-14 18:02:58 +0200 |
commit | 39f0d1d2e733381180ece8477bb0b91e72061dc1 (patch) | |
tree | 8e4f669ca8f369566bd6236718e9d7a1c847a6fb /src | |
parent | bbe29ca29b60ca264309d2c7f879afe49518e279 (diff) | |
download | systemd-39f0d1d2e733381180ece8477bb0b91e72061dc1.tar.gz |
sysctl: also process sysctl requests via the "sysctl.extra" credential
Diffstat (limited to 'src')
-rw-r--r-- | src/sysctl/sysctl.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 2b854a7370..e92640d948 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -10,6 +10,7 @@ #include <sys/types.h> #include "conf-files.h" +#include "creds-util.h" #include "def.h" #include "errno-util.h" #include "fd-util.h" @@ -277,6 +278,25 @@ static int parse_file(OrderedHashmap **sysctl_options, const char *path, bool ig return r; } +static int read_credential_lines(OrderedHashmap **sysctl_options) { + _cleanup_free_ char *j = NULL; + const char *d; + int r; + + r = get_credentials_dir(&d); + if (r == -ENXIO) + return 0; + if (r < 0) + return log_error_errno(r, "Failed to get credentials directory: %m"); + + j = path_join(d, "sysctl.extra"); + if (!j) + return log_oom(); + + (void) parse_file(sysctl_options, j, /* ignore_enoent= */ true); + return 0; +} + static int help(void) { _cleanup_free_ char *link = NULL; int r; @@ -416,6 +436,10 @@ static int run(int argc, char *argv[]) { if (k < 0 && r == 0) r = k; } + + k = read_credential_lines(&sysctl_options); + if (k < 0 && r == 0) + r = k; } k = apply_all(sysctl_options); |