X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fexecute.c;h=f8b7521ff9ceb20b4a8f81b96036d40cb37c2e68;hp=be15fb95eea99dc7870ce35a10d3789320278311;hb=d9d93745cd2efcdfca8f82d798e61e0ee70cef5c;hpb=5f8640fb628cb034981e02d741fd9ddf26fdf38d diff --git a/src/core/execute.c b/src/core/execute.c index be15fb95e..f8b7521ff 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #undef basename @@ -957,10 +958,20 @@ static int apply_seccomp(ExecContext *c) { if (!seccomp) return -ENOMEM; - SET_FOREACH(id, c->syscall_archs, i) { - r = seccomp_arch_add(seccomp, PTR_TO_UINT32(id) - 1); - if (r == -EEXIST) - continue; + if (c->syscall_archs) { + + SET_FOREACH(id, c->syscall_archs, i) { + r = seccomp_arch_add(seccomp, PTR_TO_UINT32(id) - 1); + if (r == -EEXIST) + continue; + if (r < 0) { + seccomp_release(seccomp); + return r; + } + } + } else { + + r = seccomp_add_secondary_archs(seccomp); if (r < 0) { seccomp_release(seccomp); return r; @@ -1362,6 +1373,13 @@ int exec_spawn(ExecCommand *command, goto fail_child; } + if (context->personality != 0xffffffffUL) + if (personality(context->personality) < 0) { + err = -errno; + r = EXIT_PERSONALITY; + goto fail_child; + } + if (context->utmp_id) utmp_put_init_process(context->utmp_id, getpid(), getsid(0), context->tty_path); @@ -1673,6 +1691,7 @@ void exec_context_init(ExecContext *c) { c->syslog_level_prefix = true; c->ignore_sigpipe = true; c->timer_slack_nsec = (nsec_t) -1; + c->personality = 0xffffffffUL; } void exec_context_done(ExecContext *c) { @@ -1958,27 +1977,20 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { fprintf(f, "%s%s: %llu\n", prefix, rlimit_to_string(i), (unsigned long long) c->rlimit[i]->rlim_max); if (c->ioprio_set) { - char *class_str; - int r; + _cleanup_free_ char *class_str = NULL; - r = ioprio_class_to_string_alloc(IOPRIO_PRIO_CLASS(c->ioprio), &class_str); - if (r < 0) - class_str = NULL; + ioprio_class_to_string_alloc(IOPRIO_PRIO_CLASS(c->ioprio), &class_str); fprintf(f, "%sIOSchedulingClass: %s\n" "%sIOPriority: %i\n", prefix, strna(class_str), prefix, (int) IOPRIO_PRIO_DATA(c->ioprio)); - free(class_str); } if (c->cpu_sched_set) { - char *policy_str; - int r; + _cleanup_free_ char *policy_str = NULL; - r = sched_policy_to_string_alloc(c->cpu_sched_policy, &policy_str); - if (r < 0) - policy_str = NULL; + sched_policy_to_string_alloc(c->cpu_sched_policy, &policy_str); fprintf(f, "%sCPUSchedulingPolicy: %s\n" "%sCPUSchedulingPriority: %i\n" @@ -1986,7 +1998,6 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { prefix, strna(policy_str), prefix, c->cpu_sched_priority, prefix, yes_no(c->cpu_sched_reset_on_fork)); - free(policy_str); } if (c->cpuset) { @@ -2120,6 +2131,11 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { "%sSELinuxContext: %s%s\n", prefix, c->selinux_context_ignore ? "-" : "", c->selinux_context); + if (c->personality != 0xffffffffUL) + fprintf(f, + "%sPersonality: %s\n", + prefix, strna(personality_to_string(c->personality))); + if (c->syscall_filter) { #ifdef HAVE_SECCOMP Iterator j;