… | |
… | |
24 | #include <cstring> |
24 | #include <cstring> |
25 | |
25 | |
26 | #include <errno.h> |
26 | #include <errno.h> |
27 | #include <signal.h> |
27 | #include <signal.h> |
28 | #include <sys/types.h> |
28 | #include <sys/types.h> |
|
|
29 | #include <sys/wait.h> |
29 | #include <unistd.h> |
30 | #include <unistd.h> |
30 | #include <time.h> |
31 | #include <time.h> |
31 | #include <sys/socket.h> |
32 | #include <sys/socket.h> |
32 | #include <netinet/in.h> |
33 | #include <netinet/in.h> |
33 | #include <arpa/inet.h> |
34 | #include <arpa/inet.h> |
34 | |
35 | |
|
|
36 | |
35 | #include <sys/mman.h> |
37 | #include <sys/mman.h> |
36 | |
|
|
37 | #include <openssl/rand.h> |
|
|
38 | #include <openssl/rsa.h> |
|
|
39 | #include <openssl/pem.h> |
|
|
40 | #include <openssl/evp.h> |
|
|
41 | |
38 | |
42 | #include "gettext.h" |
39 | #include "gettext.h" |
43 | #include "pidfile.h" |
40 | #include "pidfile.h" |
44 | #include "dropin.h" |
41 | #include "dropin.h" |
45 | |
42 | |
… | |
… | |
140 | |
137 | |
141 | if (!confbase) |
138 | if (!confbase) |
142 | asprintf (&confbase, "%s/vpe", CONFDIR); |
139 | asprintf (&confbase, "%s/vpe", CONFDIR); |
143 | } |
140 | } |
144 | |
141 | |
|
|
142 | void run_script (const run_script_cb &cb, bool wait) |
|
|
143 | { |
|
|
144 | int pid; |
|
|
145 | |
|
|
146 | if ((pid = fork ()) == 0) |
|
|
147 | { |
|
|
148 | char *filename; |
|
|
149 | asprintf (&filename, "%s/%s", confbase, cb(0)); |
|
|
150 | execl (filename, filename, (char *) 0); |
|
|
151 | exit (255); |
|
|
152 | } |
|
|
153 | else if (pid > 0) |
|
|
154 | { |
|
|
155 | if (wait) |
|
|
156 | { |
|
|
157 | waitpid (pid, 0, 0); |
|
|
158 | /* TODO: check status */ |
|
|
159 | } |
|
|
160 | } |
|
|
161 | } |