/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/plymouth.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:
114
114
  va_list ap;
115
115
  char *text;
116
116
  int ret;
117
 
  
 
117
 
118
118
  va_start(ap, formatstring);
119
119
  ret = vasprintf(&text, formatstring, ap);
120
120
  if(ret == -1){
139
139
  const char *const crypttarget = getenv("crypttarget");
140
140
  const char prompt_start[] = "Unlocking the disk";
141
141
  const char prompt_end[] = "Enter passphrase";
142
 
  
 
142
 
143
143
  if(cryptsource == NULL){
144
144
    if(crypttarget == NULL){
145
145
      ret = asprintf(&prompt, "%s\n%s", prompt_start, prompt_end);
172
172
  if(ret == -1){
173
173
    error_plus(0, errno, "setuid");
174
174
  }
175
 
    
 
175
 
176
176
  setsid();
177
177
  ret = chdir("/");
178
178
  if(ret == -1){
213
213
        _exit(EX_OSERR);
214
214
      }
215
215
    }
216
 
    
 
216
 
217
217
    char **new_argv = malloc(sizeof(const char *));
218
218
    if(new_argv == NULL){
219
219
      error_plus(0, errno, "malloc");
243
243
      new_argv[i] = strdup(argv[i]);
244
244
    }
245
245
    new_argv[i] = NULL;
246
 
    
 
246
 
247
247
    execv(path, (char *const *)new_argv);
248
248
    error_plus(0, errno, "execv");
249
249
    _exit(EXIT_FAILURE);
302
302
    error_plus(0, errno, "asprintf");
303
303
    return 0;
304
304
  }
305
 
  
 
305
 
306
306
  struct stat exe_stat;
307
307
  ret = lstat(exe_link, &exe_stat);
308
308
  if(ret == -1){
312
312
    }
313
313
    return 0;
314
314
  }
315
 
  
 
315
 
316
316
  if(not S_ISLNK(exe_stat.st_mode)
317
317
     or exe_stat.st_uid != 0
318
318
     or exe_stat.st_gid != 0){
319
319
    free(exe_link);
320
320
    return 0;
321
321
  }
322
 
  
 
322
 
323
323
  ssize_t sret = readlink(exe_link, exe_target, sizeof(exe_target));
324
324
  free(exe_link);
325
325
  if((sret != (ssize_t)sizeof(plymouthd_path)-1) or
392
392
  if((uintmax_t)pid == proc_id){
393
393
    return pid;
394
394
  }
395
 
  
 
395
 
396
396
  return 0;
397
397
}
398
398
 
401
401
  char *cmdline_filename;
402
402
  ssize_t sret;
403
403
  int ret;
404
 
  
 
404
 
405
405
  ret = asprintf(&cmdline_filename, "/proc/%" PRIuMAX "/cmdline",
406
406
                 (uintmax_t)pid);
407
407
  if(ret == -1){
408
408
    error_plus(0, errno, "asprintf");
409
409
    return NULL;
410
410
  }
411
 
  
 
411
 
412
412
  /* Open /proc/<pid>/cmdline  */
413
413
  cl_fd = open(cmdline_filename, O_RDONLY);
414
414
  free(cmdline_filename);
416
416
    error_plus(0, errno, "open");
417
417
    return NULL;
418
418
  }
419
 
  
 
419
 
420
420
  size_t cmdline_allocated = 0;
421
421
  size_t cmdline_len = 0;
422
422
  char *cmdline = NULL;
435
435
      cmdline = tmp;
436
436
      cmdline_allocated += blocksize;
437
437
    }
438
 
    
 
438
 
439
439
    /* Read data */
440
440
    sret = read(cl_fd, cmdline + cmdline_len,
441
441
                cmdline_allocated - cmdline_len);
453
453
    free(cmdline);
454
454
    return NULL;
455
455
  }
456
 
  
 
456
 
457
457
  /* we got cmdline and cmdline_len, ignore rest... */
458
458
  char **argv = malloc((argz_count(cmdline, cmdline_len) + 1)
459
459
                       * sizeof(char *)); /* Get number of args */
482
482
        .doc = "Debug mode" },
483
483
      { .name = NULL }
484
484
    };
485
 
    
 
485
 
486
486
    __attribute__((nonnull(3)))
487
487
    error_t parse_opt (int key, char *arg, __attribute__((unused))
488
488
                       struct argp_state *state){
502
502
      }
503
503
      return errno;
504
504
    }
505
 
    
 
505
 
506
506
    struct argp argp = { .options = options, .parser = parse_opt,
507
507
                         .args_doc = "",
508
508
                         .doc = "Mandos plymouth -- Read and"
521
521
      return EX_USAGE;
522
522
    }
523
523
  }
524
 
  
 
524
 
525
525
  /* test -x /bin/plymouth */
526
526
  ret = access(plymouth_path, X_OK);
527
527
  if(ret == -1){
533
533
    }
534
534
    exit(EX_UNAVAILABLE);
535
535
  }
536
 
  
 
536
 
537
537
  { /* Add signal handlers */
538
538
    struct sigaction old_action,
539
539
      new_action = { .sa_handler = termination_handler,
557
557
      }
558
558
    }
559
559
  }
560
 
  
 
560
 
561
561
  /* plymouth --ping */
562
562
  bret = exec_and_wait(&plymouth_command_pid, plymouth_path,
563
563
                       (const char *[])
575
575
    }
576
576
    exit(EX_UNAVAILABLE);
577
577
  }
578
 
  
 
578
 
579
579
  if(prompt != NULL){
580
580
    ret = asprintf(&prompt_arg, "--prompt=%s", prompt);
581
581
  } else {
586
586
  if(ret == -1){
587
587
    error_plus(EX_OSERR, errno, "asprintf");
588
588
  }
589
 
  
 
589
 
590
590
  /* plymouth ask-for-password --prompt="$prompt" */
591
591
  if(debug){
592
592
    fprintf_plus(stderr, "Prompting for password via Plymouth\n");
605
605
    exit(EXIT_FAILURE);
606
606
  }
607
607
  kill_and_wait(plymouth_command_pid);
608
 
  
 
608
 
609
609
  char **plymouthd_argv = NULL;
610
610
  pid_t pid = get_pid();
611
611
  if(pid == 0){
613
613
  } else {
614
614
    plymouthd_argv = getargv(pid);
615
615
  }
616
 
  
 
616
 
617
617
  bret = exec_and_wait(NULL, plymouth_path, (const char *[])
618
618
                       { plymouth_path, "quit", NULL },
619
619
                       false, false);