/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/splashy.c

  • Committer: Teddy Hogeborn
  • Date: 2026-05-17 23:56:03 UTC
  • Revision ID: teddy@recompile.se-20260517235603-5ygymkxkh32rxjkf
Remove white space at end of most lines

Remove white space at end of most lines.  Except for where it is
significant, like in shell script "here documents" where the delimiter
word is prefixed by "-", in block comments, and in config file example
settings.  Also not in README files, the INSTALL file, the DBUS-API
file, or the COPYING file (the last of which was copied verbatim from
FSF).

* dbus-mandos.conf: Remove white space at end of lines.
* debian/mandos-client.postinst: - '' -
* debian/mandos-client.templates: - '' -
* debian/mandos.postinst: - '' -
* dracut-module/password-agent.c: - '' -
* dracut-module/password-agent.xml: - '' -
* intro.xml: - '' -
* legalnotice.xml: - '' -
* mandos-clients.conf.xml: - '' -
* mandos-ctl.xml: - '' -
* mandos-keygen: - '' -
* mandos-keygen.xml: - '' -
* mandos-monitor.xml: - '' -
* mandos-options.xml: - '' -
* mandos.conf.xml: - '' -
* mandos.xml: - '' -
* network-hooks.d/wireless: - '' -
* plugin-helpers/mandos-client-iprouteadddel.c: - '' -
* plugin-runner.c: - '' -
* plugin-runner.xml: - '' -
* plugins.d/askpass-fifo.c: - '' -
* plugins.d/askpass-fifo.xml: - '' -
* plugins.d/mandos-client.c: - '' -
* plugins.d/mandos-client.xml: - '' -
* plugins.d/password-prompt.c: - '' -
* plugins.d/password-prompt.xml: - '' -
* plugins.d/plymouth.c: - '' -
* plugins.d/plymouth.xml: - '' -
* plugins.d/splashy.c: - '' -
* plugins.d/splashy.xml: - '' -
* plugins.d/usplash.c: - '' -
* plugins.d/usplash.xml: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
  va_list ap;
74
74
  char *text;
75
75
  int ret;
76
 
  
 
76
 
77
77
  va_start(ap, formatstring);
78
78
  ret = vasprintf(&text, formatstring, ap);
79
79
  if(ret == -1){
107
107
  pid_t splashy_pid = 0;
108
108
  pid_t splashy_command_pid = 0;
109
109
  int exitstatus = EXIT_FAILURE;
110
 
  
 
110
 
111
111
  /* Create prompt string */
112
112
  {
113
113
    const char *const cryptsource = getenv("cryptsource");
114
114
    const char *const crypttarget = getenv("crypttarget");
115
115
    const char *const prompt_start = "getpass "
116
116
      "Enter passphrase to unlock the disk";
117
 
    
 
117
 
118
118
    if(cryptsource == NULL){
119
119
      if(crypttarget == NULL){
120
120
        ret = asprintf(&prompt, "%s: ", prompt_start);
136
136
      goto failure;
137
137
    }
138
138
  }
139
 
  
 
139
 
140
140
  /* Find splashy process */
141
141
  {
142
142
    const char splashy_name[] = "/sbin/splashy";
189
189
          exitstatus = EX_OSERR;
190
190
          goto failure;
191
191
        }
192
 
        
 
192
 
193
193
        /* Check that it refers to a symlink owned by root:root */
194
194
        struct stat exe_stat;
195
195
        ret = lstat(exe_link, &exe_stat);
220
220
          free(exe_link);
221
221
          continue;
222
222
        }
223
 
        
 
223
 
224
224
        sret = readlink(exe_link, exe_target, sizeof(exe_target));
225
225
        free(exe_link);
226
226
      }
238
238
    exitstatus = EX_UNAVAILABLE;
239
239
    goto failure;
240
240
  }
241
 
  
 
241
 
242
242
  /* Set up the signal handler */
243
243
  {
244
244
    struct sigaction old_action,
306
306
      }
307
307
    }
308
308
  }
309
 
  
 
309
 
310
310
  if(interrupted_by_signal){
311
311
    goto failure;
312
312
  }
313
 
  
 
313
 
314
314
  /* Fork off the splashy command to prompt for password */
315
315
  splashy_command_pid = fork();
316
316
  if(splashy_command_pid != 0 and interrupted_by_signal){
357
357
    free(prompt);
358
358
    _exit(EXIT_FAILURE);
359
359
  }
360
 
  
 
360
 
361
361
  /* Parent */
362
362
  free(prompt);
363
363
  prompt = NULL;
364
 
  
 
364
 
365
365
  if(interrupted_by_signal){
366
366
    goto failure;
367
367
  }
368
 
  
 
368
 
369
369
  /* Wait for command to complete */
370
370
  {
371
371
    int status;
389
389
      }
390
390
    }
391
391
  }
392
 
  
 
392
 
393
393
 failure:
394
 
  
 
394
 
395
395
  free(prompt);
396
 
  
 
396
 
397
397
  if(proc_dir != NULL){
398
398
    TEMP_FAILURE_RETRY(closedir(proc_dir));
399
399
  }
400
 
  
 
400
 
401
401
  if(splashy_command_pid != 0){
402
402
    TEMP_FAILURE_RETRY(kill(splashy_command_pid, SIGTERM));
403
 
    
 
403
 
404
404
    TEMP_FAILURE_RETRY(kill(splashy_pid, SIGTERM));
405
405
    sleep(2);
406
406
    while(TEMP_FAILURE_RETRY(kill(splashy_pid, 0)) == 0){
410
410
    pid_t new_splashy_pid = (pid_t)TEMP_FAILURE_RETRY(fork());
411
411
    if(new_splashy_pid == 0){
412
412
      /* Child; will become new splashy process */
413
 
      
 
413
 
414
414
      /* Make the effective user ID (root) the only user ID instead of
415
415
         the real user ID (_mandos) */
416
416
      ret = setuid(geteuid());
417
417
      if(ret == -1){
418
418
        error_plus(0, errno, "setuid");
419
419
      }
420
 
      
 
420
 
421
421
      setsid();
422
422
      ret = chdir("/");
423
423
      if(ret == -1){
431
431
        error_plus(0, errno, "dup2");
432
432
        _exit(EX_OSERR);
433
433
      }
434
 
      
 
434
 
435
435
      execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL);
436
436
      {
437
437
        int e = errno;
453
453
      }
454
454
    }
455
455
  }
456
 
  
 
456
 
457
457
  if(interrupted_by_signal){
458
458
    struct sigaction signal_action;
459
459
    sigemptyset(&signal_action.sa_mask);
472
472
    }
473
473
    TEMP_FAILURE_RETRY(pause());
474
474
  }
475
 
  
 
475
 
476
476
  return exitstatus;
477
477
}