/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 15:42:41 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090127154241-x0kosjtvuo0iuptd
* plugins.d/mandos-client.c (main): Use separate bool variable instead
                                    of clumsy NUL character in
                                    "tempdir".  Bug fix: Don't try to
                                    remove temp directory if it was
                                    never created.

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 enigne keyring.
 
157
   * Helper function to insert pub and seckey to the engine 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;
835
836
    AvahiIfIndex if_index = AVAHI_IF_UNSPEC;
836
837
    const char *seckey = PATHDIR "/" SECKEY;
837
838
    const char *pubkey = PATHDIR "/" PUBKEY;
981
982
    
982
983
    if(mkdtemp(tempdir) == NULL){
983
984
      perror("mkdtemp");
984
 
      tempdir[0] = '\0';
985
985
      goto end;
986
986
    }
 
987
    tempdir_created = true;
987
988
    
988
989
    if(not init_gpgme(&mc, pubkey, seckey, tempdir)){
989
990
      fprintf(stderr, "init_gpgme failed\n");
996
997
    if_index = (AvahiIfIndex) if_nametoindex(interface);
997
998
    if(if_index == 0){
998
999
      fprintf(stderr, "No such interface: \"%s\"\n", interface);
999
 
      exit(EXIT_FAILURE);
 
1000
      exitcode = EXIT_FAILURE;
 
1001
      goto end;
1000
1002
    }
1001
1003
    
1002
1004
    if(connect_to != NULL){
1117
1119
    }
1118
1120
    
1119
1121
    /* Removes the temp directory used by GPGME */
1120
 
    if(tempdir[0] != '\0'){
 
1122
    if(tempdir_created){
1121
1123
      DIR *d;
1122
1124
      struct dirent *direntry;
1123
1125
      d = opendir(tempdir);