diff options
author | Shawn Landden <shawnlandden@gmail.com> | 2013-07-15 18:10:56 -0700 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-07-16 04:27:04 +0200 |
commit | 3a83211689bdf4ab617a4fb79e11980c50918123 (patch) | |
tree | e01b35ef57b7fb48ee3acd7ced3cdb9dc9498848 /src/shared/util.c | |
parent | fa7deadb074dfbe473cf3bd942768dbd94cbf7c3 (diff) |
journal: add logging of effective capabilities _CAP_EFFECTIVE
I think this is the most important of the capabilities bitmasks to log.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 5c7204a567..19ca8ad135 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -726,6 +726,40 @@ int is_kernel_thread(pid_t pid) { return 0; } +int get_process_capeff(pid_t pid, char **capeff) { + const char *p; + _cleanup_free_ char *status = NULL; + char *t = NULL; + int r; + + assert(capeff); + assert(pid >= 0); + + if (pid == 0) + p = "/proc/self/status"; + else + p = procfs_file_alloca(pid, "status"); + + r = read_full_file(p, &status, NULL); + if (r < 0) + return r; + + t = strstr(status, "\nCapEff:\t"); + if (!t) + return -ENOENT; + + for (t += strlen("\nCapEff:\t"); t[0] == '0'; t++) + continue; + + if (t[0] == '\n') + t--; + + *capeff = strndup(t, strchr(t, '\n') - t); + if (!*capeff) + return -ENOMEM; + + return 0; +} int get_process_exe(pid_t pid, char **name) { const char *p; |