diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-28 17:50:02 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-28 18:42:18 +0100 |
commit | 5b12334d35eadf1f45cc3d631fd1a2e72ffaea0a (patch) | |
tree | 55682fbecfeb705adfaf0f78fd76f5c8dc219b1b /src/shared/util.c | |
parent | 70f75a523b16ad495a7791d595ee3eececf75953 (diff) |
bus: add new sd_bus_creds object to encapsulate process credentials
This way we can unify handling of credentials that are attached to
messages, or can be queried for bus name owners or connection peers.
This also adds the ability to extend incomplete credential information
with data from /proc,
Also, provide a convenience call that will automatically determine the
most appropriate credential object for an incoming message, by using the
the attached information if possible, the sending name information if
available and otherwise the peer's credentials.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 0fce2537da..38134ae521 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -430,7 +430,7 @@ char *split_quoted(const char *c, size_t *l, char **state) { *state = (char*) e; } - return current; + return (char*) current; } int get_parent_of_pid(pid_t pid, pid_t *_ppid) { @@ -497,7 +497,7 @@ int get_starttime_of_pid(pid_t pid, unsigned long long *st) { f = fopen(p, "re"); if (!f) - return -errno; + return errno == ENOENT ? -ESRCH : -errno; if (!fgets(line, sizeof(line), f)) { if (ferror(f)) @@ -563,6 +563,7 @@ char *truncate_nl(char *s) { int get_process_comm(pid_t pid, char **name) { const char *p; + int r; assert(name); assert(pid >= 0); @@ -572,7 +573,11 @@ int get_process_comm(pid_t pid, char **name) { else p = procfs_file_alloca(pid, "comm"); - return read_one_line_file(p, name); + r = read_one_line_file(p, name); + if (r == -ENOENT) + return -ESRCH; + + return r; } int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line) { @@ -729,7 +734,7 @@ int get_process_exe(pid_t pid, char **name) { r = readlink_malloc(p, name); if (r < 0) - return r; + return r == -ENOENT ? -ESRCH : r; d = endswith(*name, " (deleted)"); if (d) |