#include <sys/mount.h>
#include <linux/fs.h>
#include <linux/oom.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <glob.h>
#include <sys/personality.h>
-#include <libgen.h>
-#undef basename
#ifdef HAVE_PAM
#include <security/pam_appl.h>
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();
return -ENOMEM;
}
- r = mkdir_safe(p, context->runtime_directory_mode, uid, gid);
+ r = mkdir_safe_label(p, context->runtime_directory_mode, uid, gid);
if (r < 0) {
*exit_status = EXIT_RUNTIME_DIRECTORY;
return r;
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(
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;
}
_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;
}
assert(f);
prefix = strempty(prefix);
- prefix2 = strappenda(prefix, "\t");
+ prefix2 = strjoina(prefix, "\t");
cmd = exec_command_line(c->argv);
fprintf(f,