29
29
SIG_IGN, kill(), SIGKILL */
30
30
#include <stddef.h> /* NULL */
31
31
#include <stdlib.h> /* getenv() */
32
#include <stdio.h> /* asprintf() */
32
#include <stdio.h> /* asprintf(), perror() */
33
33
#include <stdlib.h> /* EXIT_FAILURE, free(),
35
35
#include <sys/types.h> /* pid_t, DIR, struct dirent,
43
43
STDOUT_FILENO, _exit(),
45
45
#include <string.h> /* memcmp() */
46
#include <errno.h> /* errno, EACCES, ENOTDIR, ELOOP,
47
ENOENT, ENAMETOOLONG, EMFILE,
48
ENFILE, ENOMEM, ENOEXEC, EINVAL,
49
E2BIG, EFAULT, EIO, ETXTBSY,
50
EISDIR, ELIBBAD, EPERM, EINTR,
52
#include <error.h> /* error() */
46
#include <errno.h> /* errno */
53
47
#include <sys/wait.h> /* waitpid(), WIFEXITED(),
55
50
#include <sysexits.h> /* EX_OSERR, EX_OSFILE,
214
209
sigemptyset(&new_action.sa_mask);
215
210
ret = sigaddset(&new_action.sa_mask, SIGINT);
217
error(0, errno, "sigaddset");
218
213
exitstatus = EX_OSERR;
221
216
ret = sigaddset(&new_action.sa_mask, SIGHUP);
223
error(0, errno, "sigaddset");
224
219
exitstatus = EX_OSERR;
227
222
ret = sigaddset(&new_action.sa_mask, SIGTERM);
229
error(0, errno, "sigaddset");
230
225
exitstatus = EX_OSERR;
233
228
ret = sigaction(SIGINT, NULL, &old_action);
235
error(0, errno, "sigaction");
236
231
exitstatus = EX_OSERR;
239
234
if(old_action.sa_handler != SIG_IGN){
240
235
ret = sigaction(SIGINT, &new_action, NULL);
242
error(0, errno, "sigaction");
243
238
exitstatus = EX_OSERR;
247
242
ret = sigaction(SIGHUP, NULL, &old_action);
249
error(0, errno, "sigaction");
250
245
exitstatus = EX_OSERR;
253
248
if(old_action.sa_handler != SIG_IGN){
254
249
ret = sigaction(SIGHUP, &new_action, NULL);
256
error(0, errno, "sigaction");
257
252
exitstatus = EX_OSERR;
261
256
ret = sigaction(SIGTERM, NULL, &old_action);
263
error(0, errno, "sigaction");
264
259
exitstatus = EX_OSERR;
267
262
if(old_action.sa_handler != SIG_IGN){
268
263
ret = sigaction(SIGTERM, &new_action, NULL);
270
error(0, errno, "sigaction");
271
266
exitstatus = EX_OSERR;
293
288
if(not interrupted_by_signal){
294
289
const char splashy_command[] = "/sbin/splashy_update";
295
290
execl(splashy_command, splashy_command, prompt, (char *)NULL);
297
error(0, errno, "execl");
303
_exit(EX_UNAVAILABLE);
323
294
_exit(EXIT_FAILURE);
380
351
the real user ID (_mandos) */
381
352
ret = setuid(geteuid());
383
error(0, errno, "setuid");
387
358
ret = chdir("/");
389
error(0, errno, "chdir");
391
362
/* if(fork() != 0){ */
392
363
/* _exit(EXIT_SUCCESS); */
394
365
ret = dup2(STDERR_FILENO, STDOUT_FILENO); /* replace stdout */
396
error(0, errno, "dup2");
400
371
execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL);
403
error(0, errno, "execl");
426
397
ret = (int)TEMP_FAILURE_RETRY(sigaction(signal_received,
427
398
&signal_action, NULL));
429
error(0, errno, "sigaction");
432
403
ret = raise(signal_received);
433
404
} while(ret != 0 and errno == EINTR);
435
error(0, errno, "raise");
438
409
TEMP_FAILURE_RETRY(pause());