diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-03-22 17:44:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-03-22 17:44:19 +0100 |
commit | 4468addca6d01a0d2d154371dd72f54307a9c786 (patch) | |
tree | 01d5a809da50ccdf1621a5e5cb7813b262519ae4 /src/shared/strv.c | |
parent | 8e70580bb07ae46dc0b0bf377de6333540668acc (diff) |
journalctl: give a nice hint about group membership based on ACLs of /var/log/journal
If we notice that we unprivileged and not in any of the groups which
have access to /var/log/journal, print a nice message about which groups
do.
This checks and prints all groups that are in the default ACL for
/var/log/journal, which is not necessarily correct for all journal
files, but pretty close.
Diffstat (limited to 'src/shared/strv.c')
-rw-r--r-- | src/shared/strv.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c index 7bcfabbf1a..e57e0ee7bf 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -387,32 +387,43 @@ fail: return NULL; } -int strv_extend(char ***l, const char *value) { +int strv_push(char ***l, char *value) { char **c; - char *v; unsigned n; if (!value) return 0; - v = strdup(value); - if (!v) - return -ENOMEM; - n = strv_length(*l); c = realloc(*l, sizeof(char*) * (n + 2)); - if (!c) { - free(v); + if (!c) return -ENOMEM; - } - c[n] = v; + c[n] = value; c[n+1] = NULL; *l = c; return 0; } +int strv_extend(char ***l, const char *value) { + char *v; + int r; + + if (!value) + return 0; + + v = strdup(value); + if (!v) + return -ENOMEM; + + r = strv_push(l, v); + if (r < 0) + free(v); + + return r; +} + char **strv_uniq(char **l) { char **i; |