execute.c revision 47be870bd83fb3719dffc3ee9348a409ab762a14
486N/A along with systemd; If not, see <http://www.gnu.org/licenses/>.
#include "macro.h"
#include "util.h"
#include "log.h"
#include "ioprio.h"
#include "securebits.h"
DIR *d;
return -errno;
int fd;
goto finish;
if (except) {
bool found;
found = false;
for (i = 0; i < n_except; i++)
found = true;
if (found)
goto finish;
closedir(d);
if (n_fds <= 0)
start = 0;
int nfd;
return -errno;
restart_from = i;
if (restart_from < 0)
if (n_fds <= 0)
for (i = 0; i < n_fds; i++) {
int flags;
return -errno;
return -errno;
return -errno;
return -errno;
int nfd;
return -errno;
return -EIO;
case EXEC_OUTPUT_CONSOLE:
case EXEC_OUTPUT_NULL:
case EXEC_OUTPUT_KERNEL:
case EXEC_OUTPUT_SYSLOG: {
int fd;
} sa;
return -errno;
return -EIO;
return -errno;
return -errno;
return -errno;
return -EIO;
case EXEC_INPUT_CONSOLE:
case EXEC_INPUT_NULL:
int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, unsigned n_fds, pid_t *ret) {
return -errno;
if (pid == 0) {
char **e, **f = NULL;
r = EXIT_SIGNAL_MASK;
goto fail;
if (setpgid(0, 0) < 0) {
r = EXIT_PGID;
goto fail;
r = EXIT_INPUT;
goto fail;
r = EXIT_OUTPUT;
goto fail;
char_array_0(t);
r = EXIT_OOM_ADJUST;
goto fail;
r = EXIT_CHROOT;
goto fail;
r = EXIT_CHDIR;
goto fail;
r = EXIT_NICE;
goto fail;
r = EXIT_SETSCHEDULER;
goto fail;
r = EXIT_CPUAFFINITY;
goto fail;
r = EXIT_IOPRIO;
goto fail;
r = EXIT_TIMERSLACK;
goto fail;
r = EXIT_FDS;
goto fail;
for (i = 0; i < RLIMIT_NLIMITS; i++) {
r = EXIT_LIMITS;
goto fail;
r = EXIT_SECUREBITS;
goto fail;
if (n_fds > 0) {
r = EXIT_MEMORY;
goto fail;
e = listen_env;
r = EXIT_EXEC;
fail:
strv_free(f);
_exit(r);
assert(c);
c->oom_adjust = 0;
c->oom_adjust_set = false;
c->nice = 0;
c->nice_set = false;
c->ioprio_set = false;
c->cpu_sched_priority = 0;
c->cpu_sched_set = false;
c->cpu_affinity_set = false;
c->input = 0;
c->output = 0;
c->secure_bits = 0;
c->capability_bounding_set_drop = 0;
assert(c);
if (c->capabilities) {
ExecCommand *i;
free(i);
exec_command_free_list(c[i]);
c[i] = NULL;
assert(c);
assert(f);
if (!prefix)
fprintf(f,
if (c->environment)
for (e = c->environment; *e; e++)
if (c->nice_set)
fprintf(f,
if (c->oom_adjust_set)
fprintf(f,
for (i = 0; i < RLIM_NLIMITS; i++)
if (c->rlimit[i])
fprintf(f, "%s%s: %llu\n", prefix, rlimit_to_string(i), (unsigned long long) c->rlimit[i]->rlim_max);
if (c->ioprio_set)
fprintf(f,
if (c->cpu_sched_set)
fprintf(f,
if (c->cpu_affinity_set) {
for (i = 0; i < CPU_SETSIZE; i++)
if (c->timer_slack_ns_set)
fprintf(f,
fprintf(f,
if (c->capabilities) {
prefix, t);
cap_free(t);
if (c->secure_bits)
if (c->capability_bounding_set_drop) {
for (i = 0; i <= CAP_LAST_CAP; i++)
if ((t = cap_to_name(i))) {
free(t);
if (c->user)
if (c->group)
if (c->supplementary_groups) {
assert(s);
size_t k;
bool first = true;
assert(c);
if (!(n = new(char, k)))
return NULL;
if (!first)
first = false;
p = stpcpy(p, *a);
p = stpcpy(p, *a);
char *cmd;
assert(c);
assert(f);
if (!prefix)
fprintf(f,
assert(f);
if (!prefix)