]> git.ipfire.org Git - people/ms/systemd.git/blame - execute.h
implement proper logging for services
[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>
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 */
5cb5a6ff
LP
47 int oom_adjust;
48 int nice;
034c6ed7
LP
49 char *directory;
50
071830ff
LP
51 ExecOutput output;
52 int syslog_priority;
53 char *syslog_identifier;
54
55 /* FIXME: all privs related settings need parser and enforcer */
034c6ed7
LP
56 cap_t capabilities;
57 bool capabilities_set:1;
5cb5a6ff
LP
58
59 /* since resolving these names might might involve socket
60 * connections and we don't want to deadlock ourselves these
61 * names are resolved on execution only. */
62 char *user;
63 char *group;
64 char **supplementary_groups;
65};
66
034c6ed7
LP
67typedef enum ExitStatus {
68 /* EXIT_SUCCESS defined by libc */
69 /* EXIT_FAILURE defined by libc */
70 EXIT_INVALIDARGUMENT = 2,
71 EXIT_NOTIMPLEMENTED = 3,
72 EXIT_NOPERMISSION = 4,
73 EXIT_NOTINSTALLED = 5,
74 EXIT_NOTCONFIGURED = 6,
75 EXIT_NOTRUNNING = 7,
76
77 /* The LSB suggests that error codes >= 200 are "reserved". We
78 * use them here under the assumption that they hence are
79 * unused by init scripts.
80 *
81 * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html */
82
83 EXIT_CHDIR = 200,
84 EXIT_NICE,
85 EXIT_FDS,
86 EXIT_EXEC,
87 EXIT_MEMORY,
88 EXIT_LIMITS,
309bff19 89 EXIT_OOM_ADJUST,
071830ff
LP
90 EXIT_SIGNAL_MASK,
91 EXIT_OUTPUT
034c6ed7
LP
92} ExitStatus;
93
94int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, unsigned n_fds, pid_t *ret);
5cb5a6ff 95
5cb5a6ff 96void exec_command_free_list(ExecCommand *c);
034c6ed7 97void exec_command_free_array(ExecCommand **c, unsigned n);
5cb5a6ff 98
44d8db9e
LP
99char *exec_command_line(ExecCommand *c);
100void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
101void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
102
034c6ed7
LP
103void exec_context_init(ExecContext *c);
104void exec_context_done(ExecContext *c);
5cb5a6ff
LP
105void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
106
034c6ed7 107void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status);
5cb5a6ff
LP
108
109#endif