execute.c revision 5b6319dceedd81f3f1ce7eb70ea5defaef43bcec
/*-*- Mode: C; c-basic-offset: 8 -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
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 <string.h>
#include <signal.h>
#include <grp.h>
#include <pwd.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
#endif
#include "execute.h"
#include "strv.h"
#include "macro.h"
#include "util.h"
#include "log.h"
#include "ioprio.h"
#include "securebits.h"
#include "cgroup.h"
#include "namespace.h"
#include "tcpwrap.h"
/* This assumes there is a 'tty' group */
#define TTY_MODE 0620
int start, restart_from;
if (n_fds <= 0)
return 0;
/* Modifies the fds array! (sorts it) */
start = 0;
for (;;) {
int i;
restart_from = -1;
int nfd;
/* Already at right index? */
if (fds[i] == i+3)
continue;
return -errno;
close_nointr_nofail(fds[i]);
/* Hmm, the fd we wanted isn't free? Then
* let's remember that and try again from here*/
restart_from = i;
}
if (restart_from < 0)
break;
}
return 0;
}
unsigned i;
int r;
if (n_fds <= 0)
return 0;
for (i = 0; i < n_fds; i++) {
return r;
/* We unconditionally drop FD_CLOEXEC from the fds,
* since after all we want to pass these fds to our
* children */
if ((r = fd_cloexec(fds[i], false)) < 0)
return r;
}
return 0;
}
}
int fd, r;
return -errno;
} else
r = nfd;
return r;
}
static int connect_logger_as(const ExecContext *context, ExecOutput output, const char *ident, int nfd) {
int fd, r;
union {
struct sockaddr_un un;
} sa;
assert(ident);
return -errno;
return -errno;
}
return -errno;
}
/* We speak a very simple protocol between log server
* and client: one line for the log destination (kmsg
* or syslog), followed by the priority field,
* followed by the process name. Since we replaced
* it. Note that we use stderr, to minimize buffer
* flushing issues. */
"%s\n"
"%i\n"
"%s\n"
"%i\n",
} else
r = nfd;
return r;
}
int fd, r;
return fd;
} else
r = nfd;
return r;
}
static bool is_terminal_input(ExecInput i) {
return
i == EXEC_INPUT_TTY ||
i == EXEC_INPUT_TTY_FORCE ||
i == EXEC_INPUT_TTY_FAIL;
}
return EXEC_INPUT_NULL;
return std_input;
}
return EXEC_OUTPUT_INHERIT;
return std_output;
}
ExecInput i;
switch (i) {
case EXEC_INPUT_NULL:
case EXEC_INPUT_TTY:
case EXEC_INPUT_TTY_FORCE:
case EXEC_INPUT_TTY_FAIL: {
int fd, r;
if ((fd = acquire_terminal(
i == EXEC_INPUT_TTY_FAIL,
i == EXEC_INPUT_TTY_FORCE,
false)) < 0)
return fd;
if (fd != STDIN_FILENO) {
} else
r = STDIN_FILENO;
return r;
}
case EXEC_INPUT_SOCKET:
default:
assert_not_reached("Unknown input type");
}
}
ExecOutput o;
ExecInput i;
assert(ident);
/* This expects the input is already set up */
switch (o) {
case EXEC_OUTPUT_INHERIT:
/* If the input is connected to a terminal, inherit that... */
if (i != EXEC_INPUT_NULL)
* hence reopen the console if out parent is PID1. */
if (getppid() == 1)
return STDOUT_FILENO;
case EXEC_OUTPUT_NULL:
case EXEC_OUTPUT_TTY:
if (is_terminal_input(i))
/* We don't reset the terminal if this is just about output */
case EXEC_OUTPUT_SYSLOG:
case EXEC_OUTPUT_KMSG:
case EXEC_OUTPUT_SOCKET:
default:
assert_not_reached("Unknown output type");
}
}
ExecOutput o, e;
ExecInput i;
assert(ident);
/* This expects the input and output are already set up */
/* Don't change the stderr file descriptor if we inherit all
* the way and are not on a tty */
if (e == EXEC_OUTPUT_INHERIT &&
o == EXEC_OUTPUT_INHERIT &&
i != EXEC_INPUT_NULL &&
getppid () != 1)
return STDERR_FILENO;
/* Duplicate form stdout if possible */
if (e == o || e == EXEC_OUTPUT_INHERIT)
switch (e) {
case EXEC_OUTPUT_NULL:
case EXEC_OUTPUT_TTY:
if (is_terminal_input(i))
/* We don't reset the terminal if this is just about output */
case EXEC_OUTPUT_SYSLOG:
case EXEC_OUTPUT_KMSG:
case EXEC_OUTPUT_SOCKET:
default:
assert_not_reached("Unknown error type");
}
}
/* This might fail. What matters are the results. */
return -errno;
return -EPERM;
return 0;
}
int *_saved_stdin,
int *_saved_stdout) {
/* This returns positive EXIT_xxx return values instead of
* negative errno style values! */
return EXIT_STDIN;
r = EXIT_STDOUT;
goto fail;
}
if ((fd = acquire_terminal(
false)) < 0) {
r = EXIT_STDIN;
goto fail;
}
r = EXIT_STDIN;
goto fail;
}
r = EXIT_STDIN;
goto fail;
}
r = EXIT_STDOUT;
goto fail;
}
if (fd >= 2)
return 0;
fail:
if (saved_stdout >= 0)
if (saved_stdin >= 0)
if (fd >= 0)
return r;
}
int *saved_stdin,
int *saved_stdout,
bool *keep_stdin,
bool *keep_stdout) {
assert(*saved_stdin >= 0);
assert(*saved_stdout >= 0);
/* This returns positive EXIT_xxx return values instead of
* negative errno style values! */
/* The service wants terminal input. */
*keep_stdin = true;
*keep_stdout =
} else {
/* If the service doesn't want a controlling terminal,
* then we need to get rid entirely of what we have
* already. */
if (release_terminal() < 0)
return EXIT_STDIN;
return EXIT_STDIN;
return EXIT_STDOUT;
*keep_stdout = *keep_stdin = false;
}
return 0;
}
struct group *g;
unsigned long lu;
/* We enforce some special rules for gid=0: in order to avoid
* NSS lookups for root we hardcode its data. */
*gid = 0;
return 0;
}
errno = 0;
} else {
errno = 0;
}
if (!g)
return 0;
}
struct passwd *p;
unsigned long lu;
/* We enforce some special rules for uid=0: in order to avoid
* NSS lookups for root we hardcode its data. */
*username = "root";
*uid = 0;
*gid = 0;
*home = "/root";
return 0;
}
errno = 0;
/* If there are multiple users with the same id, make
* sure to leave $USER to the configured value instead
* of the first occurence in the database. However if
* the uid was configured by a numeric uid, then let's
if (*username && p)
} else {
errno = 0;
}
if (!p)
return 0;
}
bool keep_groups = false;
int r;
/* Lookup and ser GID and supplementary group list. Here too
* we avoid NSS lookups for gid=0. */
return r;
return -errno;
keep_groups = true;
}
/* Second step, set our gids */
return -errno;
}
if (context->supplementary_groups) {
int ngroups_max, k;
char **i;
/* Final step, initialize any manually set supplementary groups */
return -ENOMEM;
if (keep_groups) {
return -errno;
}
} else
k = 0;
if (k >= ngroups_max) {
return -E2BIG;
}
if ((r = get_group_creds(*i, gids+k)) < 0) {
return r;
}
k++;
}
return -errno;
}
}
return 0;
}
int r;
/* Sets (but doesn't lookup) the uid and make sure we keep the
* capabilities while doing so. */
if (context->capabilities) {
cap_t d;
static const cap_value_t bits[] = {
CAP_SETUID, /* Necessary so that we can run setresuid() below */
CAP_SETPCAP /* Necessary so that we can set PR_SET_SECUREBITS later on */
};
/* First step: If we need to keep capabilities but
* drop privileges we need to make sure we keep our
* caps, whiel we drop priviliges. */
if (uid != 0) {
return -errno;
}
/* Second step: set the capabilites. This will reduce
* the capabilities to the minimum we need. */
return -errno;
r = -errno;
cap_free(d);
return r;
}
if (cap_set_proc(d) < 0) {
r = -errno;
cap_free(d);
return r;
}
cap_free(d);
}
/* Third step: actually set the uids */
return -errno;
/* At this point we should have all necessary capabilities but
are otherwise a normal user. However, the caps might got
corrupted due to the setresuid() so we need clean them up
later. This is done outside of this call. */
return 0;
}
#ifdef HAVE_PAM
static int null_conv(
int num_msg,
const struct pam_message **msg,
struct pam_response **resp,
void *appdata_ptr) {
/* We don't support conversations */
return PAM_CONV_ERR;
}
static int setup_pam(
const char *name,
const char *user,
const char *tty,
char ***pam_env,
.appdata_ptr = NULL
};
int pam_code = PAM_SUCCESS;
char **e = NULL;
bool close_session = false;
/* We set up PAM in the parent process, then fork. The child
* will then stay around untill killed via PR_GET_PDEATHSIG or
* systemd via the cgroup logic. It will then remove the PAM
* session again. The parent process will exec() the actual
* daemon. We do things this way to ensure that the main PID
* of the daemon is the one we initially fork()ed. */
goto fail;
}
if (tty)
goto fail;
goto fail;
goto fail;
close_session = true;
goto fail;
if ((!(e = pam_getenvlist(handle)))) {
goto fail;
}
/* Block SIGTERM, so that we know that it won't get lost in
* the child */
if (sigemptyset(&ss) < 0 ||
goto fail;
parent_pid = getpid();
goto fail;
if (pam_pid == 0) {
int sig;
int r = EXIT_PAM;
/* The child's job is to reset the PAM session on
* termination */
/* This string must fit in 10 chars (i.e. the length
rename_process("sd:pam");
/* Make sure we don't keep open the passed fds in this
child. We assume that otherwise only those fds are
open here that have been opened by PAM. */
/* Wait until our parent died. This will most likely
* not work since the kernel does not allow
* unpriviliged paretns kill their priviliged children
* this way. We rely on the control groups kill logic
* to do the rest for us. */
goto child_finish;
/* Check if our parent process might already have
* died? */
if (getppid() == parent_pid) {
goto child_finish;
}
/* Only if our parent died we'll end the session */
if (getppid() != parent_pid)
goto child_finish;
r = 0;
_exit(r);
}
/* If the child was forked off successfully it will do all the
* cleanups, so forget about the handle here. */
/* Unblock SIGSUR1 again in the parent */
goto fail;
/* We close the log explicitly here, since the PAM modules
* might have opened it, but we don't want this fd around. */
closelog();
return 0;
fail:
if (handle) {
if (close_session)
}
strv_free(e);
closelog();
if (pam_pid > 1)
return EXIT_PAM;
}
#endif
char **argv,
const ExecContext *context,
char **environment,
bool apply_permissions,
bool apply_chroot,
bool confirm_spawn,
int r;
char *line;
int socket_fd;
if (n_fds != 1)
return -EINVAL;
n_fds = 0;
} else
socket_fd = -1;
if (!argv)
return -ENOMEM;
if (cgroup_bondings)
if ((r = cgroup_bonding_realize_list(cgroup_bondings)))
return r;
return -errno;
if (pid == 0) {
int i;
unsigned n_env = 0;
bool keep_stdout = false, keep_stdin = false;
/* child */
/* This string must fit in 10 chars (i.e. the length
rename_process("sd:exec");
/* We reset exactly these signals, since they are the
* only ones we set to SIG_IGN in the main daemon. All
* others we leave untouched because we set them to
* SIG_DFL or a valid handler initially, both of which
* will be demoted to SIG_DFL. */
SIGNALS_IGNORE, -1);
if (sigemptyset(&ss) < 0 ||
r = EXIT_SIGNAL_MASK;
goto fail;
}
if (setsid() < 0) {
r = EXIT_SETSID;
goto fail;
}
r = EXIT_TCPWRAP;
goto fail;
}
if (confirm_spawn) {
char response;
/* Set up terminal for the question */
if ((r = setup_confirm_stdio(context,
&saved_stdin, &saved_stdout)))
goto fail;
/* Now ask the question. */
r = EXIT_MEMORY;
goto fail;
}
if (r < 0 || response == 'n') {
r = EXIT_CONFIRM;
goto fail;
} else if (response == 's') {
r = 0;
goto fail;
}
/* Release terminal for the question */
if ((r = restore_confirm_stdio(context,
&keep_stdin, &keep_stdout)))
goto fail;
}
if (!keep_stdin)
r = EXIT_STDIN;
goto fail;
}
if (!keep_stdout)
r = EXIT_STDOUT;
goto fail;
}
r = EXIT_STDERR;
goto fail;
}
if (cgroup_bondings)
if ((r = cgroup_bonding_install_list(cgroup_bondings, 0)) < 0) {
r = EXIT_CGROUP;
goto fail;
}
if (context->oom_adjust_set) {
char t[16];
char_array_0(t);
if (write_one_line_file("/proc/self/oom_adj", t) < 0) {
r = EXIT_OOM_ADJUST;
goto fail;
}
}
r = EXIT_NICE;
goto fail;
}
if (context->cpu_sched_set) {
struct sched_param param;
r = EXIT_SETSCHEDULER;
goto fail;
}
}
if (context->cpu_affinity_set)
r = EXIT_CPUAFFINITY;
goto fail;
}
if (context->ioprio_set)
r = EXIT_IOPRIO;
goto fail;
}
if (context->timer_slack_ns_set)
r = EXIT_TIMERSLACK;
goto fail;
}
r = EXIT_USER;
goto fail;
}
r = EXIT_STDIN;
goto fail;
}
}
#ifdef HAVE_PAM
/* Make sure no fds leak into the PAM
* supervisor process. We will call this later
* on again to make sure that any fds leaked
* by the PAM modules get closed before our
* exec(). */
r = EXIT_FDS;
goto fail;
}
r = EXIT_PAM;
goto fail;
}
}
#endif
if (apply_permissions)
r = EXIT_GROUP;
goto fail;
}
if ((r = setup_namespace(
context->mount_flags)) < 0)
goto fail;
if (apply_chroot) {
if (context->root_directory)
r = EXIT_CHROOT;
goto fail;
}
r = EXIT_CHDIR;
goto fail;
}
} else {
char *d;
if (asprintf(&d, "%s/%s",
r = EXIT_MEMORY;
goto fail;
}
if (chdir(d) < 0) {
free(d);
r = EXIT_CHDIR;
goto fail;
}
free(d);
}
r = EXIT_FDS;
goto fail;
}
if (apply_permissions) {
for (i = 0; i < RLIMIT_NLIMITS; i++) {
continue;
r = EXIT_LIMITS;
goto fail;
}
}
r = EXIT_USER;
goto fail;
}
/* PR_GET_SECUREBITS is not priviliged, while
* PR_SET_SECUREBITS is. So to suppress
* potential EPERMs we'll try not to call
* PR_SET_SECUREBITS unless necessary. */
r = EXIT_SECUREBITS;
goto fail;
}
if (context->capabilities)
r = EXIT_CAPABILITIES;
goto fail;
}
}
r = EXIT_MEMORY;
goto fail;
}
if (n_fds > 0)
r = EXIT_MEMORY;
goto fail;
}
if (home)
r = EXIT_MEMORY;
goto fail;
}
if (username)
r = EXIT_MEMORY;
goto fail;
}
if (!(final_env = strv_env_merge(
4,
NULL))) {
r = EXIT_MEMORY;
goto fail;
}
r = EXIT_EXEC;
fail:
if (saved_stdin >= 0)
if (saved_stdout >= 0)
_exit(r);
}
/* We add the new process to the cgroup both in the child (so
* that we can be sure that no user code is ever executed
* outside of the cgroup) and in the parent (so that we can be
* sure that when we kill the cgroup the process will be
* killed too). */
if (cgroup_bondings)
return 0;
}
void exec_context_init(ExecContext *c) {
assert(c);
c->umask = 0002;
c->cpu_sched_policy = SCHED_OTHER;
c->mount_flags = MS_SHARED;
}
void exec_context_done(ExecContext *c) {
unsigned l;
assert(c);
strv_free(c->environment);
c->environment = NULL;
for (l = 0; l < ELEMENTSOF(c->rlimit); l++) {
}
free(c->working_directory);
c->working_directory = NULL;
free(c->root_directory);
c->root_directory = NULL;
free(c->tcpwrap_name);
c->tcpwrap_name = NULL;
free(c->syslog_identifier);
c->syslog_identifier = NULL;
c->supplementary_groups = NULL;
if (c->capabilities) {
cap_free(c->capabilities);
c->capabilities = NULL;
}
strv_free(c->read_only_dirs);
c->read_only_dirs = NULL;
strv_free(c->read_write_dirs);
c->read_write_dirs = NULL;
c->inaccessible_dirs = NULL;
}
void exec_command_done(ExecCommand *c) {
assert(c);
}
void exec_command_done_array(ExecCommand *c, unsigned n) {
unsigned i;
for (i = 0; i < n; i++)
exec_command_done(c+i);
}
void exec_command_free_list(ExecCommand *c) {
ExecCommand *i;
while ((i = c)) {
free(i);
}
}
void exec_command_free_array(ExecCommand **c, unsigned n) {
unsigned i;
for (i = 0; i < n; i++) {
exec_command_free_list(c[i]);
c[i] = NULL;
}
}
static void strv_fprintf(FILE *f, char **l) {
char **g;
assert(f);
STRV_FOREACH(g, l)
fprintf(f, " %s", *g);
}
char ** e;
unsigned i;
assert(c);
assert(f);
if (!prefix)
prefix = "";
fprintf(f,
"%sUMask: %04o\n"
"%sWorkingDirectory: %s\n"
"%sRootDirectory: %s\n"
"%sNonBlocking: %s\n"
"%sPrivateTmp: %s\n",
if (c->environment)
for (e = c->environment; *e; e++)
if (c->tcpwrap_name)
fprintf(f,
"%sTCPWrapName: %s\n",
prefix, c->tcpwrap_name);
if (c->nice_set)
fprintf(f,
"%sNice: %i\n",
if (c->oom_adjust_set)
fprintf(f,
"%sOOMAdjust: %i\n",
prefix, c->oom_adjust);
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,
"%sIOSchedulingClass: %s\n"
"%sIOPriority: %i\n",
if (c->cpu_sched_set)
fprintf(f,
"%sCPUSchedulingPolicy: %s\n"
"%sCPUSchedulingPriority: %i\n"
"%sCPUSchedulingResetOnFork: %s\n",
prefix, c->cpu_sched_priority,
if (c->cpu_affinity_set) {
for (i = 0; i < CPU_SETSIZE; i++)
if (CPU_ISSET(i, &c->cpu_affinity))
fprintf(f, " %i", i);
fputs("\n", f);
}
if (c->timer_slack_ns_set)
fprintf(f,
"%sStandardInput: %s\n"
"%sStandardOutput: %s\n"
"%sStandardError: %s\n",
if (c->tty_path)
fprintf(f,
"%sTTYPath: %s\n",
fprintf(f,
"%sSyslogFacility: %s\n"
"%sSyslogLevel: %s\n",
if (c->capabilities) {
char *t;
fprintf(f, "%sCapabilities: %s\n",
prefix, t);
cap_free(t);
}
}
if (c->secure_bits)
fprintf(f, "%sSecure Bits:%s%s%s%s%s%s\n",
if (c->capability_bounding_set_drop) {
for (i = 0; i <= CAP_LAST_CAP; i++)
if (c->capability_bounding_set_drop & (1 << i)) {
char *t;
if ((t = cap_to_name(i))) {
fprintf(f, " %s", t);
free(t);
}
}
fputs("\n", f);
}
if (c->user)
if (c->group)
if (strv_length(c->supplementary_groups) > 0) {
strv_fprintf(f, c->supplementary_groups);
fputs("\n", f);
}
if (c->pam_name)
if (strv_length(c->read_write_dirs) > 0) {
strv_fprintf(f, c->read_write_dirs);
fputs("\n", f);
}
if (strv_length(c->read_only_dirs) > 0) {
strv_fprintf(f, c->read_only_dirs);
fputs("\n", f);
}
if (strv_length(c->inaccessible_dirs) > 0) {
strv_fprintf(f, c->inaccessible_dirs);
fputs("\n", f);
}
}
assert(s);
}
char buf[FORMAT_TIMESTAMP_MAX];
assert(s);
assert(f);
if (!prefix)
prefix = "";
if (s->pid <= 0)
return;
fprintf(f,
"%sPID: %llu\n",
if (s->start_timestamp > 0)
fprintf(f,
"%sStart Timestamp: %s\n",
if (s->exit_timestamp > 0)
fprintf(f,
"%sExit Timestamp: %s\n"
"%sExit Code: %s\n"
"%sExit Status: %i\n",
}
char *exec_command_line(char **argv) {
size_t k;
char *n, *p, **a;
bool first = true;
k = 1;
STRV_FOREACH(a, argv)
k += strlen(*a)+3;
if (!(n = new(char, k)))
return NULL;
p = n;
STRV_FOREACH(a, argv) {
if (!first)
*(p++) = ' ';
else
first = false;
if (strpbrk(*a, WHITESPACE)) {
*(p++) = '\'';
p = stpcpy(p, *a);
*(p++) = '\'';
} else
p = stpcpy(p, *a);
}
*p = 0;
/* FIXME: this doesn't really handle arguments that have
* spaces and ticks in them */
return n;
}
char *p2;
const char *prefix2;
char *cmd;
assert(c);
assert(f);
if (!prefix)
prefix = "";
fprintf(f,
"%sCommand Line: %s\n",
}
assert(f);
if (!prefix)
prefix = "";
LIST_FOREACH(command, c, c)
exec_command_dump(c, f, prefix);
}
assert(l);
assert(e);
if (*l) {
/* It's kinda important that we keep the order here */
} else
*l = e;
}
char **l, *p;
assert(c);
if (!l)
return -ENOMEM;
strv_free(l);
return -ENOMEM;
}
c->path = p;
c->argv = l;
return 0;
}
/* We cast to int here, so that -Wenum doesn't complain that
* EXIT_SUCCESS/EXIT_FAILURE aren't in the enum */
switch ((int) status) {
case EXIT_SUCCESS:
return "SUCCESS";
case EXIT_FAILURE:
return "FAILURE";
case EXIT_INVALIDARGUMENT:
return "INVALIDARGUMENT";
case EXIT_NOTIMPLEMENTED:
return "NOTIMPLEMENTED";
case EXIT_NOPERMISSION:
return "NOPERMISSION";
case EXIT_NOTINSTALLED:
return "NOTINSSTALLED";
case EXIT_NOTCONFIGURED:
return "NOTCONFIGURED";
case EXIT_NOTRUNNING:
return "NOTRUNNING";
case EXIT_CHDIR:
return "CHDIR";
case EXIT_NICE:
return "NICE";
case EXIT_FDS:
return "FDS";
case EXIT_EXEC:
return "EXEC";
case EXIT_MEMORY:
return "MEMORY";
case EXIT_LIMITS:
return "LIMITS";
case EXIT_OOM_ADJUST:
return "OOM_ADJUST";
case EXIT_SIGNAL_MASK:
return "SIGNAL_MASK";
case EXIT_STDIN:
return "STDIN";
case EXIT_STDOUT:
return "STDOUT";
case EXIT_CHROOT:
return "CHROOT";
case EXIT_IOPRIO:
return "IOPRIO";
case EXIT_TIMERSLACK:
return "TIMERSLACK";
case EXIT_SECUREBITS:
return "SECUREBITS";
case EXIT_SETSCHEDULER:
return "SETSCHEDULER";
case EXIT_CPUAFFINITY:
return "CPUAFFINITY";
case EXIT_GROUP:
return "GROUP";
case EXIT_USER:
return "USER";
case EXIT_CAPABILITIES:
return "CAPABILITIES";
case EXIT_CGROUP:
return "CGROUP";
case EXIT_SETSID:
return "SETSID";
case EXIT_CONFIRM:
return "CONFIRM";
case EXIT_STDERR:
return "STDERR";
case EXIT_TCPWRAP:
return "TCPWRAP";
case EXIT_PAM:
return "PAM";
default:
return NULL;
}
}
static const char* const exec_input_table[_EXEC_INPUT_MAX] = {
[EXEC_INPUT_NULL] = "null",
[EXEC_INPUT_TTY] = "tty",
[EXEC_INPUT_TTY_FORCE] = "tty-force",
[EXEC_INPUT_TTY_FAIL] = "tty-fail",
[EXEC_INPUT_SOCKET] = "socket"
};
static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = {
[EXEC_OUTPUT_INHERIT] = "inherit",
[EXEC_OUTPUT_NULL] = "null",
[EXEC_OUTPUT_TTY] = "tty",
[EXEC_OUTPUT_SYSLOG] = "syslog",
[EXEC_OUTPUT_KMSG] = "kmsg",
[EXEC_OUTPUT_SOCKET] = "socket"
};