3
3
 * Splashy - Read a password from splashy and output it
 
5
 
 * Copyright © 2008-2010 Teddy Hogeborn
 
6
 
 * Copyright © 2008-2010 Björn Påhlsson
 
 
5
 * Copyright © 2008,2009 Teddy Hogeborn
 
 
6
 * Copyright © 2008,2009 Björn Påhlsson
 
8
8
 * This program is free software: you can redistribute it and/or
 
9
9
 * modify it under the terms of the GNU General Public License as
 
 
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,
 
 
49
49
                                   E2BIG, EFAULT, EIO, ETXTBSY,
 
50
50
                                   EISDIR, ELIBBAD, EPERM, EINTR,
 
52
 
#include <error.h>              /* error() */
 
53
52
#include <sys/wait.h>           /* waitpid(), WIFEXITED(),
 
55
54
#include <sysexits.h>           /* EX_OSERR, EX_OSFILE,
 
 
214
213
    sigemptyset(&new_action.sa_mask);
 
215
214
    ret = sigaddset(&new_action.sa_mask, SIGINT);
 
217
 
      error(0, errno, "sigaddset");
 
218
217
      exitstatus = EX_OSERR;
 
221
220
    ret = sigaddset(&new_action.sa_mask, SIGHUP);
 
223
 
      error(0, errno, "sigaddset");
 
224
223
      exitstatus = EX_OSERR;
 
227
226
    ret = sigaddset(&new_action.sa_mask, SIGTERM);
 
229
 
      error(0, errno, "sigaddset");
 
230
229
      exitstatus = EX_OSERR;
 
233
232
    ret = sigaction(SIGINT, NULL, &old_action);
 
235
 
      error(0, errno, "sigaction");
 
236
235
      exitstatus = EX_OSERR;
 
239
238
    if(old_action.sa_handler != SIG_IGN){
 
240
239
      ret = sigaction(SIGINT, &new_action, NULL);
 
242
 
        error(0, errno, "sigaction");
 
243
242
        exitstatus = EX_OSERR;
 
247
246
    ret = sigaction(SIGHUP, NULL, &old_action);
 
249
 
      error(0, errno, "sigaction");
 
250
249
      exitstatus = EX_OSERR;
 
253
252
    if(old_action.sa_handler != SIG_IGN){
 
254
253
      ret = sigaction(SIGHUP, &new_action, NULL);
 
256
 
        error(0, errno, "sigaction");
 
257
256
        exitstatus = EX_OSERR;
 
261
260
    ret = sigaction(SIGTERM, NULL, &old_action);
 
263
 
      error(0, errno, "sigaction");
 
264
263
      exitstatus = EX_OSERR;
 
267
266
    if(old_action.sa_handler != SIG_IGN){
 
268
267
      ret = sigaction(SIGTERM, &new_action, NULL);
 
270
 
        error(0, errno, "sigaction");
 
271
270
        exitstatus = EX_OSERR;
 
 
294
293
      const char splashy_command[] = "/sbin/splashy_update";
 
295
294
      execl(splashy_command, splashy_command, prompt, (char *)NULL);
 
297
 
      error(0, errno, "execl");
 
 
380
379
         the real user ID (_mandos) */
 
381
380
      ret = setuid(geteuid());
 
383
 
        error(0, errno, "setuid");
 
387
386
      ret = chdir("/");
 
389
 
        error(0, errno, "chdir");
 
391
390
/*       if(fork() != 0){ */
 
392
391
/*      _exit(EXIT_SUCCESS); */
 
394
393
      ret = dup2(STDERR_FILENO, STDOUT_FILENO); /* replace stdout */
 
396
 
        error(0, errno, "dup2");
 
400
399
      execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL);
 
403
 
        error(0, errno, "execl");
 
 
426
425
    ret = (int)TEMP_FAILURE_RETRY(sigaction(signal_received,
 
427
426
                                            &signal_action, NULL));
 
429
 
      error(0, errno, "sigaction");
 
432
431
      ret = raise(signal_received);
 
433
432
    } while(ret != 0 and errno == EINTR);
 
435
 
      error(0, errno, "raise");
 
438
437
    TEMP_FAILURE_RETRY(pause());