/mandos/release

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

« back to all changes in this revision

Viewing changes to plugins.d/plymouth.c

  • Committer: Teddy Hogeborn
  • Date: 2017-08-20 18:53:16 UTC
  • mfrom: (237.7.458 trunk)
  • Revision ID: teddy@recompile.se-20170820185316-3i5080cpg08f0e8q
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
      error_plus(0, errno, "scandir");
300
300
    }
301
301
    if(ret > 0){
302
 
      for(int i = ret-1; i >= 0; i--){
303
 
        if(proc_id == 0){
304
 
          ret = sscanf(direntries[i]->d_name, "%" SCNuMAX, &proc_id);
305
 
          if(ret < 0){
306
 
            error_plus(0, errno, "sscanf");
307
 
          }
308
 
        }
309
 
        free(direntries[i]);
 
302
      ret = sscanf(direntries[0]->d_name, "%" SCNuMAX, &proc_id);
 
303
      if(ret < 0){
 
304
        error_plus(0, errno, "sscanf");
310
305
      }
311
306
    }
312
307
    /* scandir might preallocate for this variable (man page unclear).
322
317
  return 0;
323
318
}
324
319
 
325
 
char **getargv(pid_t pid){
 
320
const char * const * getargv(pid_t pid){
326
321
  int cl_fd;
327
322
  char *cmdline_filename;
328
323
  ssize_t sret;
389
384
    return NULL;
390
385
  }
391
386
  argz_extract(cmdline, cmdline_len, argv); /* Create argv */
392
 
  return argv;
 
387
  return (const char * const *)argv;
393
388
}
394
389
 
395
390
int main(__attribute__((unused))int argc,
470
465
  }
471
466
  kill_and_wait(plymouth_command_pid);
472
467
  
473
 
  char **plymouthd_argv = NULL;
 
468
  const char * const *plymouthd_argv;
474
469
  pid_t pid = get_pid();
475
470
  if(pid == 0){
476
471
    error_plus(0, 0, "plymouthd pid not found");
 
472
    plymouthd_argv = plymouthd_default_argv;
477
473
  } else {
478
474
    plymouthd_argv = getargv(pid);
479
475
  }
482
478
                       { plymouth_path, "quit", NULL },
483
479
                       false, false);
484
480
  if(not bret){
485
 
    if(plymouthd_argv != NULL){
486
 
      free(*plymouthd_argv);
487
 
      free(plymouthd_argv);
488
 
    }
489
481
    exit(EXIT_FAILURE);
490
482
  }
491
 
  bret = exec_and_wait(NULL, plymouthd_path,
492
 
                       (plymouthd_argv != NULL)
493
 
                       ? (const char * const *)plymouthd_argv
494
 
                       : plymouthd_default_argv,
 
483
  bret = exec_and_wait(NULL, plymouthd_path, plymouthd_argv,
495
484
                       false, true);
496
 
  if(plymouthd_argv != NULL){
497
 
    free(*plymouthd_argv);
498
 
    free(plymouthd_argv);
499
 
  }
500
485
  if(not bret){
501
486
    exit(EXIT_FAILURE);
502
487
  }