/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

merge

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;
202
202
                                      .sa_flags = SA_NOCLDSTOP };
203
203
  char *plus_options = NULL;
204
204
  char **plus_argv = NULL;
205
 
 
 
205
  
206
206
  /* Establish a signal handler */
207
207
  sigemptyset(&sigchld_action.sa_mask);
208
208
  ret = sigaddset(&sigchld_action.sa_mask, SIGCHLD);
455
455
    char *filename = malloc(d_name_len + strlen(plugindir) + 2);
456
456
    if (filename == NULL){
457
457
      perror("malloc");
458
 
      continue;
 
458
      exitstatus = EXIT_FAILURE;
 
459
      goto end;
459
460
    }
460
461
    strcpy(filename, plugindir); /* Spurious warning */
461
462
    strcat(filename, "/");      /* Spurious warning */
464
465
    ret = stat(filename, &st);
465
466
    if (ret == -1){
466
467
      perror("stat");
467
 
      free(filename);
468
 
      continue;
 
468
      exitstatus = EXIT_FAILURE;
 
469
      goto end;
469
470
    }
470
471
    
471
472
    if (not S_ISREG(st.st_mode) or (access(filename, X_OK) != 0)){
520
521
    }
521
522
    // Starting a new process to be watched
522
523
    pid_t pid = fork();
523
 
    if(pid == -1){
524
 
      perror("fork");
525
 
      exitstatus = EXIT_FAILURE;
526
 
      goto end;
527
 
    }
528
524
    if(pid == 0){
529
525
      /* this is the child process */
530
526
      ret = sigaction(SIGCHLD, &old_sigchld_action, NULL);
712
708
      }
713
709
    }
714
710
  }
715
 
 
716
 
 
717
 
 end:
718
711
  
719
 
  if(process_list == NULL or exitstatus != EXIT_SUCCESS){
720
 
    /* Fallback if all plugins failed, none are found or an error occured */
 
712
  if(process_list == NULL){
721
713
    bool bret;
722
714
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
723
715
    char *passwordbuffer = getpass("Password: ");
728
720
      goto end;
729
721
    }
730
722
  }
 
723
 
 
724
 end:
731
725
  
732
726
  /* Restore old signal handler */
733
727
  sigaction(SIGCHLD, &old_sigchld_action, NULL);