From ed689f7894e56024a11bd02327b2bdfce5636dfd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 25 Sep 2018 12:02:26 +0200 Subject: [PATCH 1/2] exec-util: handle putenv() errors Just paranoia, as putenv() can fail and we should catch it, like we catch all other errors. Follow-up for #10073 --- src/basic/exec-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index e8af191104..169bef11fa 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -102,7 +102,8 @@ static int do_execute( alarm(DIV_ROUND_UP(timeout, USEC_PER_SEC)); STRV_FOREACH(e, envp) - putenv(*e); + if (putenv(*e) < 0) + return log_error_errno(errno, "Failed to set environment variable: %m"); STRV_FOREACH(path, paths) { _cleanup_free_ char *t = NULL; From 653d469519f78d3931c0bc9fe5597d18454bef3d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 25 Sep 2018 12:03:06 +0200 Subject: [PATCH 2/2] exec-util: add missing logging call This function logs about all errors, but one case was forgotten. Fix that. --- src/basic/exec-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index 169bef11fa..aa26902a20 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -87,7 +87,7 @@ static int do_execute( r = conf_files_list_strv(&paths, NULL, NULL, CONF_FILES_EXECUTABLE|CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED, (const char* const*) directories); if (r < 0) - return r; + return log_error_errno(r, "Failed to enumerate executables: %m"); if (!callbacks) { pids = hashmap_new(NULL);