X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fexecute.c;h=5767037acde73250f8437d0bf98e24143fc2cb3e;hp=5083af9aedec5b4011b55a3f6fbe7900d69b21cd;hb=7fd1b19bc9e9f5574f2877936b8ac267c7706947;hpb=2d76d14ea3682c1c144001449654eb0c6bbda08d diff --git a/src/core/execute.c b/src/core/execute.c index 5083af9ae..5767037ac 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -997,7 +997,7 @@ int exec_spawn(ExecCommand *command, int r; char *line; int socket_fd; - char _cleanup_strv_free_ **files_env = NULL; + _cleanup_strv_free_ char **files_env = NULL; assert(command); assert(context); @@ -1036,9 +1036,10 @@ int exec_spawn(ExecCommand *command, return log_oom(); log_struct_unit(LOG_DEBUG, - unit_id, - "MESSAGE=About to execute %s", line, - NULL); + unit_id, + "EXECUTABLE=%s", command->path, + "MESSAGE=About to execute: %s", line, + NULL); free(line); r = cgroup_bonding_realize_list(cgroup_bondings); @@ -1068,7 +1069,7 @@ int exec_spawn(ExecCommand *command, const char *username = NULL, *home = NULL; uid_t uid = (uid_t) -1; gid_t gid = (gid_t) -1; - char _cleanup_strv_free_ **our_env = NULL, **pam_env = NULL, + _cleanup_strv_free_ char **our_env = NULL, **pam_env = NULL, **final_env = NULL, **final_argv = NULL; unsigned n_env = 0; bool set_access = false; @@ -1361,7 +1362,7 @@ int exec_spawn(ExecCommand *command, goto fail_child; } } else { - char _cleanup_free_ *d = NULL; + _cleanup_free_ char *d = NULL; if (asprintf(&d, "%s/%s", context->root_directory ? context->root_directory : "", @@ -1516,6 +1517,20 @@ int exec_spawn(ExecCommand *command, final_env = strv_env_clean(final_env); + if (_unlikely_(log_get_max_level() >= LOG_PRI(LOG_DEBUG))) { + line = exec_command_line(final_argv); + if (line) { + log_open(); + log_struct_unit(LOG_DEBUG, + unit_id, + "EXECUTABLE=%s", command->path, + "MESSAGE=Executing: %s", line, + NULL); + log_close(); + free(line); + line = NULL; + } + } execve(command->path, final_argv, final_env); err = -errno; r = EXIT_EXEC; @@ -1712,7 +1727,7 @@ int exec_context_load_environment(const ExecContext *c, char ***l) { int k; bool ignore = false; char **p; - glob_t _cleanup_globfree_ pglob = {}; + _cleanup_globfree_ glob_t pglob = {}; int count, n; fn = *i; @@ -1756,6 +1771,9 @@ int exec_context_load_environment(const ExecContext *c, char ***l) { strv_free(r); return k; } + /* Log invalid environment variables with filename */ + if (p) + p = strv_env_clean_log(p, pglob.gl_pathv[n]); if (r == NULL) r = p;