chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core: rewind message before forwarding it
[elogind.git]
/
src
/
core
/
execute.c
diff --git
a/src/core/execute.c
b/src/core/execute.c
index 12a96a76399561af1a32f0f10eac03dfeb69f914..39ec5adbbe44f2783691945a7816c0dd0f393424 100644
(file)
--- a/
src/core/execute.c
+++ b/
src/core/execute.c
@@
-19,8
+19,6
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <assert.h>
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
@@
-29,19
+27,11
@@
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/prctl.h>
-#include <linux/sched.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <grp.h>
#include <sys/stat.h>
#include <grp.h>
-#include <pwd.h>
-#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 <glob.h>
#include <sys/personality.h>
-#include <libgen.h>
-#undef basename
#ifdef HAVE_PAM
#include <security/pam_appl.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
@@
-82,12
+72,14
@@
#include "errno-list.h"
#include "af-list.h"
#include "mkdir.h"
#include "errno-list.h"
#include "af-list.h"
#include "mkdir.h"
-#include "apparmor-util.h"
#include "smack-util.h"
#include "bus-endpoint.h"
#include "smack-util.h"
#include "bus-endpoint.h"
-#include "label.h"
#include "cap-list.h"
#include "cap-list.h"
+#ifdef HAVE_APPARMOR
+#include "apparmor-util.h"
+#endif
+
#ifdef HAVE_SECCOMP
#include "seccomp-util.h"
#endif
#ifdef HAVE_SECCOMP
#include "seccomp-util.h"
#endif
@@
-1417,7
+1409,7
@@
static int exec_child(
sprintf(t, "%i", context->oom_score_adjust);
r = write_string_file("/proc/self/oom_score_adj", t);
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();
log_open();
log_unit_debug_errno(params->unit_id, r, "Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
log_close();
@@
-1526,7
+1518,7
@@
static int exec_child(
return -ENOMEM;
}
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 (r < 0) {
*exit_status = EXIT_RUNTIME_DIRECTORY;
return r;
@@
-1582,9
+1574,9
@@
static int exec_child(
if (context->private_tmp && runtime) {
if (runtime->tmp_dir)
if (context->private_tmp && runtime) {
if (runtime->tmp_dir)
- tmp = str
append
a(runtime->tmp_dir, "/tmp");
+ tmp = str
join
a(runtime->tmp_dir, "/tmp");
if (runtime->var_tmp_dir)
if (runtime->var_tmp_dir)
- var = str
append
a(runtime->var_tmp_dir, "/tmp");
+ var = str
join
a(runtime->var_tmp_dir, "/tmp");
}
r = setup_namespace(
}
r = setup_namespace(
@@
-1619,7
+1611,8
@@
static int exec_child(
return -errno;
}
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;
}
*exit_status = EXIT_CHDIR;
return -errno;
}
@@
-1627,13
+1620,14
@@
static int exec_child(
_cleanup_free_ char *d = NULL;
if (asprintf(&d, "%s/%s",
_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;
}
*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;
}
*exit_status = EXIT_CHDIR;
return -errno;
}
@@
-2588,7
+2582,7
@@
void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
assert(f);
prefix = strempty(prefix);
assert(f);
prefix = strempty(prefix);
- prefix2 = str
append
a(prefix, "\t");
+ prefix2 = str
join
a(prefix, "\t");
cmd = exec_command_line(c->argv);
fprintf(f,
cmd = exec_command_line(c->argv);
fprintf(f,