]> git.ipfire.org Git - thirdparty/systemd.git/blob - execute.h
add mount enumerator
[thirdparty/systemd.git] / execute.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef fooexecutehfoo
4 #define fooexecutehfoo
5
6 typedef struct ExecStatus ExecStatus;
7 typedef struct ExecCommand ExecCommand;
8 typedef struct ExecContext ExecContext;
9
10 #include <sys/time.h>
11 #include <sys/resource.h>
12 #include <sys/capability.h>
13 #include <stdbool.h>
14 #include <stdio.h>
15
16 #include "list.h"
17 #include "util.h"
18
19 /* Abstract namespace! */
20 #define LOGGER_SOCKET "/systemd/logger"
21
22 typedef enum ExecOutput {
23 EXEC_CONSOLE,
24 EXEC_NULL,
25 EXEC_SYSLOG,
26 EXEC_KERNEL
27 } ExecOutput;
28
29 struct ExecStatus {
30 pid_t pid;
31 usec_t timestamp;
32 int code; /* as in siginfo_t::si_code */
33 int status; /* as in sigingo_t::si_status */
34 };
35
36 struct ExecCommand {
37 char *path;
38 char **argv;
39 ExecStatus exec_status;
40 LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */
41 };
42
43 struct ExecContext {
44 char **environment;
45 mode_t umask;
46 struct rlimit *rlimit[RLIMIT_NLIMITS]; /* FIXME: load-fragment parser missing */
47 char *directory;
48 int oom_adjust;
49 int nice;
50
51 bool oom_adjust_set:1;
52 bool nice_set:1;
53
54 ExecOutput output;
55 int syslog_priority;
56 char *syslog_identifier;
57
58 /* FIXME: all privs related settings need parser and enforcer */
59 cap_t capabilities;
60 bool capabilities_set:1;
61
62 /* since resolving these names might might involve socket
63 * connections and we don't want to deadlock ourselves these
64 * names are resolved on execution only. */
65 char *user;
66 char *group;
67 char **supplementary_groups;
68 };
69
70 typedef enum ExitStatus {
71 /* EXIT_SUCCESS defined by libc */
72 /* EXIT_FAILURE defined by libc */
73 EXIT_INVALIDARGUMENT = 2,
74 EXIT_NOTIMPLEMENTED = 3,
75 EXIT_NOPERMISSION = 4,
76 EXIT_NOTINSTALLED = 5,
77 EXIT_NOTCONFIGURED = 6,
78 EXIT_NOTRUNNING = 7,
79
80 /* The LSB suggests that error codes >= 200 are "reserved". We
81 * use them here under the assumption that they hence are
82 * unused by init scripts.
83 *
84 * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html */
85
86 EXIT_CHDIR = 200,
87 EXIT_NICE,
88 EXIT_FDS,
89 EXIT_EXEC,
90 EXIT_MEMORY,
91 EXIT_LIMITS,
92 EXIT_OOM_ADJUST,
93 EXIT_SIGNAL_MASK,
94 EXIT_OUTPUT
95 } ExitStatus;
96
97 int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, unsigned n_fds, pid_t *ret);
98
99 void exec_command_free_list(ExecCommand *c);
100 void exec_command_free_array(ExecCommand **c, unsigned n);
101
102 char *exec_command_line(ExecCommand *c);
103 void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
104 void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
105
106 void exec_context_init(ExecContext *c);
107 void exec_context_done(ExecContext *c);
108 void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
109
110 void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status);
111
112 #endif