]> git.ipfire.org Git - thirdparty/systemd.git/blame - execute.h
monitor udev for device changes
[thirdparty/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>
15
16#include "list.h"
034c6ed7 17#include "util.h"
5cb5a6ff 18
071830ff
LP
19/* Abstract namespace! */
20#define LOGGER_SOCKET "/systemd/logger"
21
22typedef enum ExecOutput {
23 EXEC_CONSOLE,
24 EXEC_NULL,
25 EXEC_SYSLOG,
26 EXEC_KERNEL
27} ExecOutput;
28
5cb5a6ff
LP
29struct ExecStatus {
30 pid_t pid;
034c6ed7 31 usec_t timestamp;
9152c765
LP
32 int code; /* as in siginfo_t::si_code */
33 int status; /* as in sigingo_t::si_status */
5cb5a6ff
LP
34};
35
36struct ExecCommand {
37 char *path;
38 char **argv;
034c6ed7
LP
39 ExecStatus exec_status;
40 LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */
5cb5a6ff
LP
41};
42
43struct ExecContext {
44 char **environment;
45 mode_t umask;
071830ff 46 struct rlimit *rlimit[RLIMIT_NLIMITS]; /* FIXME: load-fragment parser missing */
fb33a393 47 char *directory;
5cb5a6ff
LP
48 int oom_adjust;
49 int nice;
fb33a393
LP
50
51 bool oom_adjust_set:1;
52 bool nice_set:1;
034c6ed7 53
071830ff
LP
54 ExecOutput output;
55 int syslog_priority;
56 char *syslog_identifier;
57
58 /* FIXME: all privs related settings need parser and enforcer */
034c6ed7
LP
59 cap_t capabilities;
60 bool capabilities_set:1;
5cb5a6ff
LP
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
034c6ed7
LP
70typedef 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,
309bff19 92 EXIT_OOM_ADJUST,
071830ff
LP
93 EXIT_SIGNAL_MASK,
94 EXIT_OUTPUT
034c6ed7
LP
95} ExitStatus;
96
97int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, unsigned n_fds, pid_t *ret);
5cb5a6ff 98
5cb5a6ff 99void exec_command_free_list(ExecCommand *c);
034c6ed7 100void exec_command_free_array(ExecCommand **c, unsigned n);
5cb5a6ff 101
44d8db9e
LP
102char *exec_command_line(ExecCommand *c);
103void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
104void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
105
034c6ed7
LP
106void exec_context_init(ExecContext *c);
107void exec_context_done(ExecContext *c);
5cb5a6ff
LP
108void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
109
034c6ed7 110void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status);
5cb5a6ff
LP
111
112#endif