chiark / gitweb /
implement proper binding on ports
[elogind.git] / execute.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #include <assert.h>
4
5 #include "execute.h"
6 #include "strv.h"
7 #include "macro.h"
8 #include "util.h"
9
10 int exec_spawn(const ExecCommand *command, const ExecContext *context, pid_t *ret) {
11         assert(command);
12         assert(context);
13         assert(ret);
14
15         return 0;
16 }
17
18 void exec_context_free(ExecContext *c) {
19         unsigned l;
20
21         assert(c);
22
23         strv_free(c->environment);
24
25         for (l = 0; l < ELEMENTSOF(c->rlimit); l++)
26                 free(c->rlimit[l]);
27
28         free(c->chdir);
29         free(c->user);
30         free(c->group);
31         free(c->supplementary_groups);
32 }
33
34 void exec_command_free_list(ExecCommand *c) {
35         ExecCommand *i;
36
37         while ((i = c)) {
38                 LIST_REMOVE(ExecCommand, c, i);
39
40                 free(i->path);
41                 free(i->argv);
42                 free(i);
43         }
44 }
45
46 void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
47         assert(c);
48         assert(f);
49
50         if (!prefix)
51                 prefix = "";
52
53         fprintf(f,
54                 "%sUmask: %04o\n"
55                 "%sDumpable: %s\n"
56                 "%sDirectory: %s\n",
57                 prefix, c->umask,
58                 prefix, yes_no(c->dumpable),
59                 prefix, c->chdir ? c->chdir : "/");
60 }
61
62 void exec_context_defaults(ExecContext *c) {
63         assert(c);
64
65         c->umask = 0002;
66         cap_clear(c->capabilities);
67         c->dumpable = true;
68 }