X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fexecute.c;h=f8b7521ff9ceb20b4a8f81b96036d40cb37c2e68;hb=d4fdc205a4610965cee46408dbd046c922e7620c;hp=4b1177a7e5eb5eb198ecb333215c1c72c1223d08;hpb=e9642be2cce7f5e90406980092a6f71f504a16af;p=elogind.git diff --git a/src/core/execute.c b/src/core/execute.c index 4b1177a7e..f8b7521ff 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #undef basename @@ -1372,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); @@ -1683,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) { @@ -1968,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" @@ -1996,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) { @@ -2130,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;