/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: 2016-02-28 13:09:43 UTC
  • Revision ID: teddy@recompile.se-20160228130943-6ofi0xgek1xd7qmy
Use GnuPG 2 if available

* debian/control (Package: mandos/Depends): Change "gnupg (<< 2)" to
                                            "gnupg".
  (Package: mandos-client/Depends): Remove "gnupg (<< 2)"; it will be
                                    depended on by libgpgme11, which
                                    will be added automatically by
                                    ${shlibs:Depends}.
* mandos (PGPEngine.__init__): Try to run "gpgconf" and set 'self.gpg'
                               to any binary found.  Also change
                               "--home" to "--homedir".
  (PGPEngine.encrypt, PGPEngine.decrypt): Use the 'self.gpg' attribute
                                          instead of "gpg".

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Mandos plugin runner - Run Mandos plugins
4
4
 *
5
 
 * Copyright © 2008-2014 Teddy Hogeborn
6
 
 * Copyright © 2008-2014 Björn Påhlsson
 
5
 * Copyright © 2008-2015 Teddy Hogeborn
 
6
 * Copyright © 2008-2015 Björn Påhlsson
7
7
 * 
8
8
 * This program is free software: you can redistribute it and/or
9
9
 * modify it under the terms of the GNU General Public License as
701
701
        custom_argc += 1;
702
702
        {
703
703
          char **new_argv = realloc(custom_argv, sizeof(char *)
704
 
                                    * ((unsigned int)
705
 
                                       custom_argc + 1));
 
704
                                    * ((size_t)custom_argc + 1));
706
705
          if(new_argv == NULL){
707
706
            error(0, errno, "realloc");
708
707
            exitstatus = EX_OSERR;
827
826
          }
828
827
        }
829
828
      }
830
 
      TEMP_FAILURE_RETRY(close(plugindir_fd));
 
829
      close(plugindir_fd);
831
830
    }
832
831
  }
833
832
  
925
924
    ret = (int)TEMP_FAILURE_RETRY(fstat(plugin_fd, &st));
926
925
    if(ret == -1){
927
926
      error(0, errno, "stat");
928
 
      TEMP_FAILURE_RETRY(close(plugin_fd));
 
927
      close(plugin_fd);
929
928
      free(direntries[i]);
930
929
      continue;
931
930
    }
940
939
                plugindir != NULL ? plugindir : PDIR,
941
940
                direntries[i]->d_name);
942
941
      }
943
 
      TEMP_FAILURE_RETRY(close(plugin_fd));
 
942
      close(plugin_fd);
944
943
      free(direntries[i]);
945
944
      continue;
946
945
    }
948
947
    plugin *p = getplugin(direntries[i]->d_name);
949
948
    if(p == NULL){
950
949
      error(0, errno, "getplugin");
951
 
      TEMP_FAILURE_RETRY(close(plugin_fd));
 
950
      close(plugin_fd);
952
951
      free(direntries[i]);
953
952
      continue;
954
953
    }
957
956
        fprintf(stderr, "Ignoring disabled plugin \"%s\"\n",
958
957
                direntries[i]->d_name);
959
958
      }
960
 
      TEMP_FAILURE_RETRY(close(plugin_fd));
 
959
      close(plugin_fd);
961
960
      free(direntries[i]);
962
961
      continue;
963
962
    }
1003
1002
    if(pipefd[0] >= FD_SETSIZE){
1004
1003
      fprintf(stderr, "pipe()[0] (%d) >= FD_SETSIZE (%d)", pipefd[0],
1005
1004
              FD_SETSIZE);
1006
 
      TEMP_FAILURE_RETRY(close(pipefd[0]));
1007
 
      TEMP_FAILURE_RETRY(close(pipefd[1]));
 
1005
      close(pipefd[0]);
 
1006
      close(pipefd[1]);
1008
1007
      exitstatus = EX_OSERR;
1009
1008
      free(direntries[i]);
1010
1009
      goto fallback;
1014
1013
    ret = set_cloexec_flag(pipefd[0]);
1015
1014
    if(ret < 0){
1016
1015
      error(0, errno, "set_cloexec_flag");
1017
 
      TEMP_FAILURE_RETRY(close(pipefd[0]));
1018
 
      TEMP_FAILURE_RETRY(close(pipefd[1]));
 
1016
      close(pipefd[0]);
 
1017
      close(pipefd[1]);
1019
1018
      exitstatus = EX_OSERR;
1020
1019
      free(direntries[i]);
1021
1020
      goto fallback;
1023
1022
    ret = set_cloexec_flag(pipefd[1]);
1024
1023
    if(ret < 0){
1025
1024
      error(0, errno, "set_cloexec_flag");
1026
 
      TEMP_FAILURE_RETRY(close(pipefd[0]));
1027
 
      TEMP_FAILURE_RETRY(close(pipefd[1]));
 
1025
      close(pipefd[0]);
 
1026
      close(pipefd[1]);
1028
1027
      exitstatus = EX_OSERR;
1029
1028
      free(direntries[i]);
1030
1029
      goto fallback;
1049
1048
      error(0, errno, "fork");
1050
1049
      TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
1051
1050
                                     &sigchld_action.sa_mask, NULL));
1052
 
      TEMP_FAILURE_RETRY(close(pipefd[0]));
1053
 
      TEMP_FAILURE_RETRY(close(pipefd[1]));
 
1051
      close(pipefd[0]);
 
1052
      close(pipefd[1]);
1054
1053
      exitstatus = EX_OSERR;
1055
1054
      free(direntries[i]);
1056
1055
      goto fallback;
1084
1083
      /* no return */
1085
1084
    }
1086
1085
    /* Parent process */
1087
 
    TEMP_FAILURE_RETRY(close(pipefd[1])); /* Close unused write end of
1088
 
                                             pipe */
1089
 
    TEMP_FAILURE_RETRY(close(plugin_fd));
 
1086
    close(pipefd[1]);           /* Close unused write end of pipe */
 
1087
    close(plugin_fd);
1090
1088
    plugin *new_plugin = getplugin(direntries[i]->d_name);
1091
1089
    if(new_plugin == NULL){
1092
1090
      error(0, errno, "getplugin");
1138
1136
  
1139
1137
  free(direntries);
1140
1138
  direntries = NULL;
1141
 
  TEMP_FAILURE_RETRY(close(dir_fd));
 
1139
  close(dir_fd);
1142
1140
  dir_fd = -1;
1143
1141
  free_plugin(getplugin(NULL));
1144
1142
  
1342
1340
  free(direntries);
1343
1341
  
1344
1342
  if(dir_fd != -1){
1345
 
    TEMP_FAILURE_RETRY(close(dir_fd));
 
1343
    close(dir_fd);
1346
1344
  }
1347
1345
  
1348
1346
  /* Kill the processes */