/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 mandos-client.c

mandos-client
        Better error handling for failing to start plugins
        Handle fork errors
password-request
        correct exit routine

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
  char *plus_options = NULL;
204
204
  char **plus_argv = NULL;
205
205
 
 
206
  errno = 0;
 
207
  
206
208
  /* Establish a signal handler */
207
209
  sigemptyset(&sigchld_action.sa_mask);
208
210
  ret = sigaddset(&sigchld_action.sa_mask, SIGCHLD);
455
457
    char *filename = malloc(d_name_len + strlen(plugindir) + 2);
456
458
    if (filename == NULL){
457
459
      perror("malloc");
458
 
      exitstatus = EXIT_FAILURE;
459
 
      goto end;
 
460
      continue;
460
461
    }
461
462
    strcpy(filename, plugindir); /* Spurious warning */
462
463
    strcat(filename, "/");      /* Spurious warning */
465
466
    ret = stat(filename, &st);
466
467
    if (ret == -1){
467
468
      perror("stat");
468
 
      exitstatus = EXIT_FAILURE;
469
 
      goto end;
 
469
      free(filename);
 
470
      continue;
470
471
    }
471
472
    
472
473
    if (not S_ISREG(st.st_mode) or (access(filename, X_OK) != 0)){
521
522
    }
522
523
    // Starting a new process to be watched
523
524
    pid_t pid = fork();
 
525
    if(pid == -1){
 
526
      perror("fork");
 
527
      exitstatus = EXIT_FAILURE;
 
528
      goto end;
 
529
    }
524
530
    if(pid == 0){
525
531
      /* this is the child process */
526
532
      ret = sigaction(SIGCHLD, &old_sigchld_action, NULL);
713
719
 end:
714
720
  
715
721
  if(process_list == NULL or exitstatus != EXIT_SUCCESS){
716
 
    /* Fallback if all plugins failed or an error occured */
 
722
    /* Fallback if all plugins failed, none are found or an error occured */
717
723
    bool bret;
718
724
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
719
725
    char *passwordbuffer = getpass("Password: ");