/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 plugin-runner.c

  • Committer: Teddy Hogeborn
  • Date: 2008-08-14 02:24:59 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080814022459-rq3jt4q409l3qbj3
* Makefile (PREFIX, CONFDIR): New.

* initramfs-tools-hook: Search for Mandos in /usr/local as well as in
                        /usr.  Also copy plugin-runner.  Also chmod
                        the config dir.
  (DESTCONFDIR): Removed.
  (MANDOSDIR): New.
  (PLUGINDIR): Changed to "${MANDOSDIR}/plugins.d".

* initramfs-tools-script: New.

* mandos-client.c: Renamed to "plugin-runner.c".  All references
                   changed.
  (plugindir): Changed to "/lib/mandos/plugins.d".

* plugins.d/usplash: New.

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