From cfeaa44a09756a93a881f786678973d9b1e382db Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 29 Apr 2015 21:40:54 +0200 Subject: sd-bus: properly handle creds that are known but undefined for a process A number of fields do not apply to all processes, including: there a processes without a controlling tty, without parent process, without service, user services or session. To distuingish these cases from the case where we simply don't have the data, always return ENXIO for them, while returning ENODATA for the case where we really lack the information. Also update the credentials dumping code to show this properly. Fields that are known but do not apply are now shown as "n/a". Note that this also changes some of the calls in process-util.c and cgroup-util.c to return ENXIO for these cases. --- src/test/test-process-util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/test/test-process-util.c') diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 1de100cdae..e4e2efecd5 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -44,9 +44,8 @@ static void test_get_process_comm(void) { if (stat("/proc/1/comm", &st) == 0) { assert_se(get_process_comm(1, &a) >= 0); log_info("pid1 comm: '%s'", a); - } else { + } else log_warning("/proc/1/comm does not exist."); - } assert_se(get_process_cmdline(1, 0, true, &c) >= 0); log_info("pid1 cmdline: '%s'", c); @@ -87,7 +86,7 @@ static void test_get_process_comm(void) { log_info("self strlen(environ): '%zu'", strlen(env)); if (!detect_container(NULL)) - assert_se(get_ctty_devnr(1, &h) == -ENOENT); + assert_se(get_ctty_devnr(1, &h) == -ENXIO); getenv_for_pid(1, "PATH", &i); log_info("pid1 $PATH: '%s'", strna(i)); -- cgit v1.2.3-54-g00ecf