/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

Fixed fallback on error in mandos-client
fixed a bug in password-request

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 
67
67
#define BUFFER_SIZE 256
68
68
 
69
 
const char *argp_program_version = "plugin-runner 1.0";
 
69
const char *argp_program_version = "mandos-client 1.0";
70
70
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
71
71
 
72
72
struct process;
186
186
}
187
187
 
188
188
int main(int argc, char *argv[]){
189
 
  const char *plugindir = "/lib/mandos/plugins.d";
 
189
  const char *plugindir = "/conf/conf.d/mandos/plugins.d";
190
190
  size_t d_name_len;
191
191
  DIR *dir = NULL;
192
192
  struct dirent *dirst;
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
 
      continue;
 
460
      exitstatus = EXIT_FAILURE;
 
461
      goto end;
459
462
    }
460
463
    strcpy(filename, plugindir); /* Spurious warning */
461
464
    strcat(filename, "/");      /* Spurious warning */
464
467
    ret = stat(filename, &st);
465
468
    if (ret == -1){
466
469
      perror("stat");
467
 
      free(filename);
468
 
      continue;
 
470
      exitstatus = EXIT_FAILURE;
 
471
      goto end;
469
472
    }
470
473
    
471
474
    if (not S_ISREG(st.st_mode) or (access(filename, X_OK) != 0)){
520
523
    }
521
524
    // Starting a new process to be watched
522
525
    pid_t pid = fork();
523
 
    if(pid == -1){
524
 
      perror("fork");
525
 
      exitstatus = EXIT_FAILURE;
526
 
      goto end;
527
 
    }
528
526
    if(pid == 0){
529
527
      /* this is the child process */
530
528
      ret = sigaction(SIGCHLD, &old_sigchld_action, NULL);
717
715
 end:
718
716
  
719
717
  if(process_list == NULL or exitstatus != EXIT_SUCCESS){
720
 
    /* Fallback if all plugins failed, none are found or an error occured */
 
718
    /* Fallback if all plugins failed or an error occured */
721
719
    bool bret;
722
720
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
723
721
    char *passwordbuffer = getpass("Password: ");