/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/password-request.c

  • Committer: Teddy Hogeborn
  • Date: 2008-09-06 00:19:53 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080906001953-5nk5uti6shzuyqdr
* plugins.d/password-prompt.c (main): If successful, output an extra
                                      newline to the console before
                                      exiting, to change to a new line
                                      away from the prompt.

* plugins.d/password-request.c (main): Bug fix: Moved calls to
                                       "init_gnutls_global()",
                                       "mkdtemp()", and "init_gpgme()"
                                       to *after* changing user &
                                       group.

Show diffs side-by-side

added added

removed removed

Lines of Context:
315
315
  
316
316
  /* Seek back to the beginning of the GPGME plaintext data buffer */
317
317
  if (gpgme_data_seek(dh_plain, (off_t) 0, SEEK_SET) == -1){
318
 
    perror("gpgme_data_seek");
 
318
    perror("pgpme_data_seek");
319
319
    plaintext_length = -1;
320
320
    goto decrypt_end;
321
321
  }
451
451
  
452
452
  gnutls_certificate_free_credentials(mc->cred);
453
453
  gnutls_global_deinit();
454
 
  gnutls_dh_params_deinit(mc->dh_params);
455
454
  return -1;
456
455
}
457
456
 
831
830
                          .dh_bits = 1024, .priority = "SECURE256"
832
831
                          ":!CTYPE-X.509:+CTYPE-OPENPGP" };
833
832
    bool gnutls_initalized = false;
834
 
    bool gpgme_initalized = false;
 
833
    bool pgpme_initalized = false;
835
834
    
836
835
    {
837
836
      struct argp_option options[] = {
919
918
      }
920
919
    }
921
920
    
922
 
    ret = init_gnutls_global(&mc, pubkey, seckey);
923
 
    if (ret == -1){
924
 
      fprintf(stderr, "init_gnutls_global failed\n");
925
 
      exitcode = EXIT_FAILURE;
926
 
      goto end;
927
 
    } else {
928
 
      gnutls_initalized = true;
929
 
    }
930
 
 
931
 
    if(mkdtemp(tempdir) == NULL){
932
 
      perror("mkdtemp");
933
 
      tempdir[0] = '\0';
934
 
      goto end;
935
 
    }
936
 
    
937
 
    if(not init_gpgme(&mc, pubkey, seckey, tempdir)){
938
 
      fprintf(stderr, "gpgme_initalized failed\n");
939
 
      exitcode = EXIT_FAILURE;
940
 
      goto end;
941
 
    } else {
942
 
      gpgme_initalized = true;
943
 
    }
944
 
    
945
921
    /* If the interface is down, bring it up */
946
922
    {
947
923
      sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);
985
961
      perror("setgid");
986
962
    }
987
963
    
 
964
    ret = init_gnutls_global(&mc, pubkey, seckey);
 
965
    if (ret == -1){
 
966
      fprintf(stderr, "init_gnutls_global failed\n");
 
967
      exitcode = EXIT_FAILURE;
 
968
      goto end;
 
969
    } else {
 
970
      gnutls_initalized = true;
 
971
    }
 
972
    
 
973
    if(mkdtemp(tempdir) == NULL){
 
974
      perror("mkdtemp");
 
975
      tempdir[0] = '\0';
 
976
      goto end;
 
977
    }
 
978
    
 
979
    if(not init_gpgme(&mc, pubkey, seckey, tempdir)){
 
980
      fprintf(stderr, "pgpme_initalized failed\n");
 
981
      exitcode = EXIT_FAILURE;
 
982
      goto end;
 
983
    } else {
 
984
      pgpme_initalized = true;
 
985
    }
 
986
    
988
987
    if_index = (AvahiIfIndex) if_nametoindex(interface);
989
988
    if(if_index == 0){
990
989
      fprintf(stderr, "No such interface: \"%s\"\n", interface);
1099
1098
    if (gnutls_initalized){
1100
1099
      gnutls_certificate_free_credentials(mc.cred);
1101
1100
      gnutls_global_deinit ();
1102
 
      gnutls_dh_params_deinit(mc.dh_params);
1103
1101
    }
1104
1102
 
1105
 
    if(gpgme_initalized){
 
1103
    if(pgpme_initalized){
1106
1104
      gpgme_release(mc.ctx);
1107
1105
    }
1108
1106
 
1135
1133
            free(fullname);
1136
1134
          }
1137
1135
        }
1138
 
        closedir(d);
1139
1136
      }
1140
1137
      ret = rmdir(tempdir);
1141
1138
      if(ret == -1){