175
177
sigaddset(&new_action.sa_mask, SIGINT);
177
179
perror("sigaddset");
180
183
sigaddset(&new_action.sa_mask, SIGHUP);
182
185
perror("sigaddset");
185
189
sigaddset(&new_action.sa_mask, SIGTERM);
187
191
perror("sigaddset");
190
195
ret = sigaction(SIGINT, NULL, &old_action);
192
197
perror("sigaction");
195
201
if(old_action.sa_handler != SIG_IGN){
196
202
ret = sigaction(SIGINT, &new_action, NULL);
198
204
perror("sigaction");
202
209
ret = sigaction(SIGHUP, NULL, &old_action);
204
211
perror("sigaction");
207
215
if(old_action.sa_handler != SIG_IGN){
208
216
ret = sigaction(SIGHUP, &new_action, NULL);
210
218
perror("sigaction");
214
223
ret = sigaction(SIGTERM, NULL, &old_action);
216
225
perror("sigaction");
219
229
if(old_action.sa_handler != SIG_IGN){
220
230
ret = sigaction(SIGTERM, &new_action, NULL);
222
232
perror("sigaction");
228
if(interrupted_by_signal){
232
239
/* Fork off the splashy command to prompt for password */
233
splashy_command_pid = fork();
234
if(splashy_command_pid != 0 and interrupted_by_signal){
237
if(splashy_command_pid == -1){
242
if(splashy_command_pid == 0){
243
if(not interrupted_by_signal){
240
pid_t splashy_command_pid = 0;
241
if(not interrupted_by_signal){
242
splashy_command_pid = fork();
243
if(splashy_command_pid == -1){
244
if(not interrupted_by_signal){
250
if(splashy_command_pid == 0){
244
251
const char splashy_command[] = "/sbin/splashy_update";
245
execl(splashy_command, splashy_command, prompt, (char *)NULL);
252
ret = execl(splashy_command, splashy_command, prompt,
254
if(not interrupted_by_signal){
256
if(interrupted_by_signal){
260
265
/* Wait for command to complete */
266
if(not interrupted_by_signal and splashy_command_pid != 0){
264
ret = waitpid(splashy_command_pid, &status, 0);
265
} while(ret == -1 and errno == EINTR
266
and not interrupted_by_signal);
267
if(interrupted_by_signal){
268
ret = waitpid(splashy_command_pid, &status, 0);
272
273
if(errno == ECHILD){
273
274
splashy_command_pid = 0;
276
277
/* The child process has exited */
277
278
splashy_command_pid = 0;
278
if(WIFEXITED(status) and WEXITSTATUS(status) == 0){
279
if(not interrupted_by_signal and WIFEXITED(status)
280
and WEXITSTATUS(status)==0){
279
281
return EXIT_SUCCESS;
288
if(proc_dir != NULL){
289
TEMP_FAILURE_RETRY(closedir(proc_dir));
292
if(splashy_command_pid != 0){
293
TEMP_FAILURE_RETRY(kill(splashy_command_pid, SIGTERM));
295
TEMP_FAILURE_RETRY(kill(splashy_pid, SIGTERM));
297
while(TEMP_FAILURE_RETRY(kill(splashy_pid, 0)) == 0){
298
TEMP_FAILURE_RETRY(kill(splashy_pid, SIGKILL));
301
pid_t new_splashy_pid = TEMP_FAILURE_RETRY(fork());
302
if(new_splashy_pid == 0){
303
/* Child; will become new splashy process */
305
/* Make the effective user ID (root) the only user ID instead of
306
the real user ID (_mandos) */
307
ret = setuid(geteuid());
317
/* if(fork() != 0){ */
318
/* _exit(EXIT_SUCCESS); */
320
ret = dup2(STDERR_FILENO, STDOUT_FILENO); /* replace stdout */
326
execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL);
285
kill(splashy_pid, SIGTERM);
286
if(interrupted_by_signal and splashy_command_pid != 0){
287
kill(splashy_command_pid, SIGTERM);
290
while(kill(splashy_pid, 0) == 0){
291
kill(splashy_pid, SIGKILL);
294
pid_t new_splashy_pid = fork();
295
if(new_splashy_pid == 0){
296
/* Child; will become new splashy process */
298
/* Make the effective user ID (root) the only user ID instead of
299
the real user ID (_mandos) */
300
ret = setuid(geteuid());
307
/* if(fork() != 0){ */
308
/* _exit(EXIT_SUCCESS); */
310
ret = dup2(STDERR_FILENO, STDOUT_FILENO); /* replace our stdout */
316
execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL);
317
if(not interrupted_by_signal){
332
if(interrupted_by_signal){
333
struct sigaction signal_action;
334
sigemptyset(&signal_action.sa_mask);
335
signal_action.sa_handler = SIG_DFL;
336
ret = TEMP_FAILURE_RETRY(sigaction(signal_received,
337
&signal_action, NULL));
342
ret = raise(signal_received);
343
} while(ret != 0 and errno == EINTR);
348
TEMP_FAILURE_RETRY(pause());
351
323
return EXIT_FAILURE;