chiark / gitweb /
core: don't fail to run services in --user instances if $HOME is missing
[elogind.git] / src / core / execute.c
index 12a96a76399561af1a32f0f10eac03dfeb69f914..1f6072c6aba368f886ec24b604e90c5f3de6e4d5 100644 (file)
@@ -40,8 +40,6 @@
 #include <sys/poll.h>
 #include <glob.h>
 #include <sys/personality.h>
-#include <libgen.h>
-#undef basename
 
 #ifdef HAVE_PAM
 #include <security/pam_appl.h>
@@ -1417,7 +1415,7 @@ static int exec_child(
 
                 sprintf(t, "%i", context->oom_score_adjust);
                 r = write_string_file("/proc/self/oom_score_adj", t);
-                if (r == -EPERM || r == EACCES) {
+                if (r == -EPERM || r == -EACCES) {
                         log_open();
                         log_unit_debug_errno(params->unit_id, r, "Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
                         log_close();
@@ -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;
                 }
@@ -2588,7 +2587,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,