]> git.ipfire.org Git - people/ms/systemd.git/blame - execute.h
add basic (and not very useful) D-Bus support
[people/ms/systemd.git] / execute.h
CommitLineData
5cb5a6ff
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef fooexecutehfoo
4#define fooexecutehfoo
5
6typedef struct ExecStatus ExecStatus;
7typedef struct ExecCommand ExecCommand;
8typedef 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>
94f04347 15#include <sched.h>
5cb5a6ff
LP
16
17#include "list.h"
034c6ed7 18#include "util.h"
5cb5a6ff 19
071830ff 20/* Abstract namespace! */
ea430986 21#define LOGGER_SOCKET "/org/freedesktop.org/systemd1/logger"
071830ff
LP
22
23typedef enum ExecOutput {
94f04347
LP
24 EXEC_OUTPUT_CONSOLE,
25 EXEC_OUTPUT_NULL,
26 EXEC_OUTPUT_SYSLOG,
27 EXEC_OUTPUT_KERNEL,
28 _EXEC_OUTPUT_MAX,
29 _EXEC_OUTPUT_INVALID = -1
071830ff
LP
30} ExecOutput;
31
94f04347
LP
32typedef enum ExecInput {
33 EXEC_INPUT_NULL,
34 EXEC_INPUT_CONSOLE,
35 _EXEC_INPUT_MAX,
36 _EXEC_INPUT_INVALID = -1
37} ExecInput;
38
5cb5a6ff
LP
39struct ExecStatus {
40 pid_t pid;
034c6ed7 41 usec_t timestamp;
9152c765
LP
42 int code; /* as in siginfo_t::si_code */
43 int status; /* as in sigingo_t::si_status */
5cb5a6ff
LP
44};
45
46struct ExecCommand {
47 char *path;
48 char **argv;
034c6ed7
LP
49 ExecStatus exec_status;
50 LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */
5cb5a6ff
LP
51};
52
53struct ExecContext {
54 char **environment;
55 mode_t umask;
94f04347 56 struct rlimit *rlimit[RLIMIT_NLIMITS];
9eba9da4 57 char *working_directory, *root_directory;
5cb5a6ff
LP
58 int oom_adjust;
59 int nice;
9eba9da4 60 int ioprio;
94f04347
LP
61 int cpu_sched_policy;
62 int cpu_sched_priority;
63 cpu_set_t cpu_affinity;
64 unsigned long timer_slack_ns;
fb33a393
LP
65
66 bool oom_adjust_set:1;
67 bool nice_set:1;
9eba9da4 68 bool ioprio_set:1;
94f04347
LP
69 bool cpu_sched_set:1;
70 bool cpu_affinity_set:1;
71 bool timer_slack_ns_set:1;
034c6ed7 72
94f04347 73 ExecInput input;
071830ff
LP
74 ExecOutput output;
75 int syslog_priority;
76 char *syslog_identifier;
77
94f04347 78 /* FIXME: all privs related settings need to be enforced */
034c6ed7 79 cap_t capabilities;
94f04347
LP
80 int secure_bits;
81 uint64_t capability_bounding_set_drop;
5cb5a6ff 82
94f04347 83 /* Since resolving these names might might involve socket
5cb5a6ff 84 * connections and we don't want to deadlock ourselves these
94f04347
LP
85 * names are resolved on execution only and in the child
86 * process. */
5cb5a6ff
LP
87 char *user;
88 char *group;
89 char **supplementary_groups;
90};
91
034c6ed7
LP
92typedef enum ExitStatus {
93 /* EXIT_SUCCESS defined by libc */
94 /* EXIT_FAILURE defined by libc */
95 EXIT_INVALIDARGUMENT = 2,
96 EXIT_NOTIMPLEMENTED = 3,
97 EXIT_NOPERMISSION = 4,
98 EXIT_NOTINSTALLED = 5,
99 EXIT_NOTCONFIGURED = 6,
100 EXIT_NOTRUNNING = 7,
101
102 /* The LSB suggests that error codes >= 200 are "reserved". We
103 * use them here under the assumption that they hence are
104 * unused by init scripts.
105 *
106 * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html */
107
108 EXIT_CHDIR = 200,
109 EXIT_NICE,
110 EXIT_FDS,
111 EXIT_EXEC,
112 EXIT_MEMORY,
113 EXIT_LIMITS,
309bff19 114 EXIT_OOM_ADJUST,
071830ff 115 EXIT_SIGNAL_MASK,
94f04347 116 EXIT_INPUT,
9eba9da4
LP
117 EXIT_OUTPUT,
118 EXIT_CHROOT,
119 EXIT_PGID,
94f04347
LP
120 EXIT_IOPRIO,
121 EXIT_TIMERSLACK,
122 EXIT_SECUREBITS,
123 EXIT_SETSCHEDULER,
124 EXIT_CPUAFFINITY
034c6ed7
LP
125} ExitStatus;
126
127int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, unsigned n_fds, pid_t *ret);
5cb5a6ff 128
5cb5a6ff 129void exec_command_free_list(ExecCommand *c);
034c6ed7 130void exec_command_free_array(ExecCommand **c, unsigned n);
5cb5a6ff 131
44d8db9e
LP
132char *exec_command_line(ExecCommand *c);
133void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
134void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
135
034c6ed7
LP
136void exec_context_init(ExecContext *c);
137void exec_context_done(ExecContext *c);
5cb5a6ff
LP
138void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
139
034c6ed7 140void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status);
5cb5a6ff 141
94f04347
LP
142const char* exec_output_to_string(ExecOutput i);
143int exec_output_from_string(const char *s);
144
145const char* exec_input_to_string(ExecInput i);
146int exec_input_from_string(const char *s);
147
5cb5a6ff 148#endif