X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fexecute.c;h=340b8000d4f224667a96863f5f9bfc2891955e0b;hb=cf1d0302aeaf4e44a6a643fb41e5525fdd04b1d5;hp=19d3ec0da91e84ec474c0fd79a0752b5709f23a7;hpb=6cb7fa17b3d89741a5fd3ac807775a3022c7d891;p=elogind.git diff --git a/src/core/execute.c b/src/core/execute.c index 19d3ec0da..340b8000d 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -40,8 +40,6 @@ #include #include #include -#include -#undef basename #ifdef HAVE_PAM #include @@ -1582,9 +1580,9 @@ static int exec_child( if (context->private_tmp && runtime) { if (runtime->tmp_dir) - tmp = strappenda(runtime->tmp_dir, "/tmp"); + tmp = strjoina(runtime->tmp_dir, "/tmp"); if (runtime->var_tmp_dir) - var = strappenda(runtime->var_tmp_dir, "/tmp"); + var = strjoina(runtime->var_tmp_dir, "/tmp"); } r = setup_namespace( @@ -1619,7 +1617,8 @@ static int exec_child( return -errno; } - if (chdir(context->working_directory ? context->working_directory : "/") < 0) { + if (chdir(context->working_directory ?: "/") < 0 && + !context->working_directory_missing_ok) { *exit_status = EXIT_CHDIR; return -errno; } @@ -1627,13 +1626,14 @@ static int exec_child( _cleanup_free_ char *d = NULL; if (asprintf(&d, "%s/%s", - context->root_directory ? context->root_directory : "", - context->working_directory ? context->working_directory : "") < 0) { + context->root_directory ?: "", + context->working_directory ?: "") < 0) { *exit_status = EXIT_MEMORY; return -ENOMEM; } - if (chdir(d) < 0) { + if (chdir(d) < 0 && + !context->working_directory_missing_ok) { *exit_status = EXIT_CHDIR; return -errno; } @@ -2588,7 +2588,7 @@ void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) { assert(f); prefix = strempty(prefix); - prefix2 = strappenda(prefix, "\t"); + prefix2 = strjoina(prefix, "\t"); cmd = exec_command_line(c->argv); fprintf(f,