… | |
… | |
127 | slog (L_INFO, _("gvpe daemon %s (%s %s) starting"), VERSION, __DATE__, __TIME__); |
127 | slog (L_INFO, _("gvpe daemon %s (%s %s) starting"), VERSION, __DATE__, __TIME__); |
128 | |
128 | |
129 | return 0; |
129 | return 0; |
130 | } |
130 | } |
131 | |
131 | |
132 | void run_script (const run_script_cb &cb, bool wait) |
132 | bool run_script (const run_script_cb &cb, bool wait) |
133 | { |
133 | { |
134 | int pid; |
134 | int pid; |
135 | |
135 | |
136 | if ((pid = fork ()) == 0) |
136 | if ((pid = fork ()) == 0) |
137 | { |
137 | { |
138 | char *filename; |
138 | execl ("/bin/sh", "/bin/sh", "-c", cb (), (char *) 0); |
139 | asprintf (&filename, "%s/%s", confbase, cb()); |
139 | exit (EXIT_FAILURE); |
140 | execl (filename, filename, (char *) 0); |
|
|
141 | exit (126); |
|
|
142 | } |
140 | } |
143 | else if (pid > 0) |
141 | else if (pid > 0) |
144 | { |
142 | { |
145 | if (wait) |
143 | if (wait) |
146 | { |
144 | { |
|
|
145 | int status; |
|
|
146 | |
147 | waitpid (pid, 0, 0); |
147 | if (waitpid (pid, &status, 0) < 0) |
148 | /* TODO: check status */ |
148 | { |
|
|
149 | slog (L_WARN, _("waiting for an external command failed: %s."), |
|
|
150 | strerror (errno)); |
|
|
151 | return false; |
|
|
152 | } |
|
|
153 | else if (!WIFEXITED (status) || WEXITSTATUS (status) != EXIT_SUCCESS) |
|
|
154 | { |
|
|
155 | slog (L_WARN, _("external command returned with exit status %d (%04x)."), |
|
|
156 | WEXITSTATUS (status), status); |
|
|
157 | return false; |
|
|
158 | } |
149 | } |
159 | } |
150 | } |
160 | } |
|
|
161 | |
|
|
162 | return true; |
151 | } |
163 | } |
152 | |
164 | |
153 | #if ENABLE_HTTP_PROXY |
165 | #if ENABLE_HTTP_PROXY |
154 | // works like strdup |
166 | // works like strdup |
155 | u8 * |
167 | u8 * |