From 4468addca6d01a0d2d154371dd72f54307a9c786 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 22 Mar 2013 17:44:15 +0100 Subject: 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. --- src/shared/strv.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/shared/strv.c') 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; -- cgit v1.2.3-54-g00ecf