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

  • Committer: Teddy Hogeborn
  • Date: 2009-01-27 00:07:26 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090127000726-4cafcfy35g8kh2b8
* INSTALL (Prerequisites/Mandos Server): Added "PyGObject".

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
  
155
155
  
156
156
  /*
157
 
   * Helper function to insert pub and seckey to the engine keyring.
 
157
   * Helper function to insert pub and seckey to the enigne keyring.
158
158
   */
159
159
  bool import_key(const char *filename){
160
160
    int fd;
832
832
    gid_t gid;
833
833
    char *connect_to = NULL;
834
834
    char tempdir[] = "/tmp/mandosXXXXXX";
835
 
    bool tempdir_created = false;
836
835
    AvahiIfIndex if_index = AVAHI_IF_UNSPEC;
837
836
    const char *seckey = PATHDIR "/" SECKEY;
838
837
    const char *pubkey = PATHDIR "/" PUBKEY;
961
960
    uid = getuid();
962
961
    gid = getgid();
963
962
    
 
963
    ret = setuid(uid);
 
964
    if(ret == -1){
 
965
      perror("setuid");
 
966
    }
 
967
    
964
968
    setgid(gid);
965
969
    if(ret == -1){
966
970
      perror("setgid");
967
971
    }
968
972
    
969
 
    ret = setuid(uid);
970
 
    if(ret == -1){
971
 
      perror("setuid");
972
 
    }
973
 
    
974
973
    ret = init_gnutls_global(&mc, pubkey, seckey);
975
974
    if(ret == -1){
976
975
      fprintf(stderr, "init_gnutls_global failed\n");
982
981
    
983
982
    if(mkdtemp(tempdir) == NULL){
984
983
      perror("mkdtemp");
 
984
      tempdir[0] = '\0';
985
985
      goto end;
986
986
    }
987
 
    tempdir_created = true;
988
987
    
989
988
    if(not init_gpgme(&mc, pubkey, seckey, tempdir)){
990
989
      fprintf(stderr, "init_gpgme failed\n");
997
996
    if_index = (AvahiIfIndex) if_nametoindex(interface);
998
997
    if(if_index == 0){
999
998
      fprintf(stderr, "No such interface: \"%s\"\n", interface);
1000
 
      exitcode = EXIT_FAILURE;
1001
 
      goto end;
 
999
      exit(EXIT_FAILURE);
1002
1000
    }
1003
1001
    
1004
1002
    if(connect_to != NULL){
1119
1117
    }
1120
1118
    
1121
1119
    /* Removes the temp directory used by GPGME */
1122
 
    if(tempdir_created){
 
1120
    if(tempdir[0] != '\0'){
1123
1121
      DIR *d;
1124
1122
      struct dirent *direntry;
1125
1123
      d = opendir(tempdir);