1
1
/* -*- coding: utf-8 -*- */
3
* Mandos client - get and decrypt data from a Mandos server
3
* Mandos-client - get and decrypt data from a Mandos server
5
5
* This program is partly derived from an example program for an Avahi
6
6
* service browser, downloaded from
9
9
* "browse_callback", and parts of "main".
11
11
* Everything else is
12
* Copyright © 2007-2008 Teddy Hogeborn & Björn Påhlsson
12
* Copyright © 2008,2009 Teddy Hogeborn
13
* Copyright © 2008,2009 Björn Påhlsson
14
15
* This program is free software: you can redistribute it and/or
15
16
* modify it under the terms of the GNU General Public License as
35
36
#define _GNU_SOURCE /* TEMP_FAILURE_RETRY(), asprintf() */
37
38
#include <stdio.h> /* fprintf(), stderr, fwrite(),
39
stdout, ferror(), sscanf */
39
40
#include <stdint.h> /* uint16_t, uint32_t */
40
41
#include <stddef.h> /* NULL, size_t, ssize_t */
41
42
#include <stdlib.h> /* free(), EXIT_SUCCESS, EXIT_FAILURE,
47
48
#include <sys/types.h> /* socket(), inet_pton(), sockaddr,
48
49
sockaddr_in6, PF_INET6,
49
50
SOCK_STREAM, INET6_ADDRSTRLEN,
50
uid_t, gid_t, open(), opendir(), DIR */
51
uid_t, gid_t, open(), opendir(),
51
53
#include <sys/stat.h> /* open() */
52
54
#include <sys/socket.h> /* socket(), struct sockaddr_in6,
53
55
struct in6_addr, inet_pton(),
55
57
#include <fcntl.h> /* open() */
56
#include <dirent.h> /* opendir(), struct dirent, readdir() */
57
#include <inttypes.h> /* PRIu16 */
58
#include <dirent.h> /* opendir(), struct dirent, readdir()
60
#include <inttypes.h> /* PRIu16, intmax_t, SCNdMAX */
58
61
#include <assert.h> /* assert() */
59
62
#include <errno.h> /* perror(), errno */
60
#include <time.h> /* time() */
63
#include <time.h> /* time(), nanosleep() */
61
64
#include <net/if.h> /* ioctl, ifreq, SIOCGIFFLAGS, IFF_UP,
62
65
SIOCSIFFLAGS, if_indextoname(),
63
66
if_nametoindex(), IF_NAMESIZE */
66
69
getuid(), getgid(), setuid(),
68
71
#include <arpa/inet.h> /* inet_pton(), htons */
69
#include <iso646.h> /* not, and */
72
#include <iso646.h> /* not, and, or */
70
73
#include <argp.h> /* struct argp_option, error_t, struct
71
74
argp_state, struct argp,
72
75
argp_parse(), ARGP_KEY_ARG,
73
76
ARGP_KEY_END, ARGP_ERR_UNKNOWN */
77
#include <sys/klog.h> /* klogctl() */
76
80
/* All Avahi types, constants and functions
90
94
init_gnutls_session(),
92
#include <gnutls/openpgp.h> /* gnutls_certificate_set_openpgp_key_file(),
96
#include <gnutls/openpgp.h>
97
/* gnutls_certificate_set_openpgp_key_file(),
93
98
GNUTLS_OPENPGP_FMT_BASE64 */
102
107
#define BUFFER_SIZE 256
105
#define PATHDIR "/conf/conf.d/mandos"
108
109
#define PATHDIR "/conf/conf.d/mandos"
109
110
#define SECKEY "seckey.txt"
110
111
#define PUBKEY "pubkey.txt"
112
113
bool debug = false;
113
114
static const char mandos_protocol_version[] = "1";
114
const char *argp_program_version = "mandos-client 1.0";
115
const char *argp_program_version = "mandos-client " VERSION;
115
116
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
117
118
/* Used for passing in values through the Avahi callback functions */
133
134
size_t adjustbuffer(char **buffer, size_t buffer_length,
134
135
size_t buffer_capacity){
135
if (buffer_length + BUFFER_SIZE > buffer_capacity){
136
if(buffer_length + BUFFER_SIZE > buffer_capacity){
136
137
*buffer = realloc(*buffer, buffer_capacity + BUFFER_SIZE);
140
141
buffer_capacity += BUFFER_SIZE;
160
161
gpgme_data_t pgp_data;
162
fd = TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
163
fd = (int)TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
168
169
rc = gpgme_data_new_from_fd(&pgp_data, fd);
169
if (rc != GPG_ERR_NO_ERROR){
170
if(rc != GPG_ERR_NO_ERROR){
170
171
fprintf(stderr, "bad gpgme_data_new_from_fd: %s: %s\n",
171
172
gpgme_strsource(rc), gpgme_strerror(rc));
175
176
rc = gpgme_op_import(mc->ctx, pgp_data);
176
if (rc != GPG_ERR_NO_ERROR){
177
if(rc != GPG_ERR_NO_ERROR){
177
178
fprintf(stderr, "bad gpgme_op_import: %s: %s\n",
178
179
gpgme_strsource(rc), gpgme_strerror(rc));
182
ret = TEMP_FAILURE_RETRY(close(fd));
183
ret = (int)TEMP_FAILURE_RETRY(close(fd));
191
192
fprintf(stderr, "Initialize gpgme\n");
195
196
gpgme_check_version(NULL);
196
197
rc = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP);
197
if (rc != GPG_ERR_NO_ERROR){
198
if(rc != GPG_ERR_NO_ERROR){
198
199
fprintf(stderr, "bad gpgme_engine_check_version: %s: %s\n",
199
200
gpgme_strsource(rc), gpgme_strerror(rc));
203
204
/* Set GPGME home directory for the OpenPGP engine only */
204
rc = gpgme_get_engine_info (&engine_info);
205
if (rc != GPG_ERR_NO_ERROR){
205
rc = gpgme_get_engine_info(&engine_info);
206
if(rc != GPG_ERR_NO_ERROR){
206
207
fprintf(stderr, "bad gpgme_get_engine_info: %s: %s\n",
207
208
gpgme_strsource(rc), gpgme_strerror(rc));
223
224
/* Create new GPGME "context" */
224
225
rc = gpgme_new(&(mc->ctx));
225
if (rc != GPG_ERR_NO_ERROR){
226
if(rc != GPG_ERR_NO_ERROR){
226
227
fprintf(stderr, "bad gpgme_new: %s: %s\n",
227
228
gpgme_strsource(rc), gpgme_strerror(rc));
231
if (not import_key(pubkey) or not import_key(seckey)){
232
if(not import_key(pubkey) or not import_key(seckey)){
239
240
* Decrypt OpenPGP data.
240
241
* Returns -1 on error
242
static ssize_t pgp_packet_decrypt (const mandos_context *mc,
243
const char *cryptotext,
243
static ssize_t pgp_packet_decrypt(const mandos_context *mc,
244
const char *cryptotext,
246
247
gpgme_data_t dh_crypto, dh_plain;
247
248
gpgme_error_t rc;
249
250
size_t plaintext_capacity = 0;
250
251
ssize_t plaintext_length = 0;
253
254
fprintf(stderr, "Trying to decrypt OpenPGP data\n");
256
257
/* Create new GPGME data buffer from memory cryptotext */
257
258
rc = gpgme_data_new_from_mem(&dh_crypto, cryptotext, crypto_size,
259
if (rc != GPG_ERR_NO_ERROR){
260
if(rc != GPG_ERR_NO_ERROR){
260
261
fprintf(stderr, "bad gpgme_data_new_from_mem: %s: %s\n",
261
262
gpgme_strsource(rc), gpgme_strerror(rc));
265
266
/* Create new empty GPGME data buffer for the plaintext */
266
267
rc = gpgme_data_new(&dh_plain);
267
if (rc != GPG_ERR_NO_ERROR){
268
if(rc != GPG_ERR_NO_ERROR){
268
269
fprintf(stderr, "bad gpgme_data_new: %s: %s\n",
269
270
gpgme_strsource(rc), gpgme_strerror(rc));
270
271
gpgme_data_release(dh_crypto);
274
275
/* Decrypt data from the cryptotext data buffer to the plaintext
276
277
rc = gpgme_op_decrypt(mc->ctx, dh_crypto, dh_plain);
277
if (rc != GPG_ERR_NO_ERROR){
278
if(rc != GPG_ERR_NO_ERROR){
278
279
fprintf(stderr, "bad gpgme_op_decrypt: %s: %s\n",
279
280
gpgme_strsource(rc), gpgme_strerror(rc));
280
281
plaintext_length = -1;
282
283
gpgme_decrypt_result_t result;
283
284
result = gpgme_op_decrypt_result(mc->ctx);
285
286
fprintf(stderr, "gpgme_op_decrypt_result failed\n");
287
288
fprintf(stderr, "Unsupported algorithm: %s\n",
316
317
/* Seek back to the beginning of the GPGME plaintext data buffer */
317
if (gpgme_data_seek(dh_plain, (off_t) 0, SEEK_SET) == -1){
318
perror("pgpme_data_seek");
318
if(gpgme_data_seek(dh_plain, (off_t)0, SEEK_SET) == -1){
319
perror("gpgme_data_seek");
319
320
plaintext_length = -1;
320
321
goto decrypt_end;
325
326
plaintext_capacity = adjustbuffer(plaintext,
326
327
(size_t)plaintext_length,
327
328
plaintext_capacity);
328
if (plaintext_capacity == 0){
329
if(plaintext_capacity == 0){
329
330
perror("adjustbuffer");
330
331
plaintext_length = -1;
331
332
goto decrypt_end;
364
365
return plaintext_length;
367
static const char * safer_gnutls_strerror (int value) {
368
const char *ret = gnutls_strerror (value); /* Spurious warning */
368
static const char * safer_gnutls_strerror(int value) {
369
const char *ret = gnutls_strerror(value); /* Spurious warning from
370
-Wunreachable-code */
370
372
ret = "(unknown)";
389
391
ret = gnutls_global_init();
390
if (ret != GNUTLS_E_SUCCESS) {
391
fprintf (stderr, "GnuTLS global_init: %s\n",
392
safer_gnutls_strerror(ret));
392
if(ret != GNUTLS_E_SUCCESS) {
393
fprintf(stderr, "GnuTLS global_init: %s\n",
394
safer_gnutls_strerror(ret));
397
399
/* "Use a log level over 10 to enable all debugging options."
398
400
* - GnuTLS manual
404
406
/* OpenPGP credentials */
405
407
gnutls_certificate_allocate_credentials(&mc->cred);
406
if (ret != GNUTLS_E_SUCCESS){
407
fprintf (stderr, "GnuTLS memory error: %s\n", /* Spurious
409
safer_gnutls_strerror(ret));
410
gnutls_global_deinit ();
408
if(ret != GNUTLS_E_SUCCESS){
409
fprintf(stderr, "GnuTLS memory error: %s\n", /* Spurious warning
413
safer_gnutls_strerror(ret));
414
gnutls_global_deinit();
420
424
ret = gnutls_certificate_set_openpgp_key_file
421
425
(mc->cred, pubkeyfilename, seckeyfilename,
422
426
GNUTLS_OPENPGP_FMT_BASE64);
423
if (ret != GNUTLS_E_SUCCESS) {
427
if(ret != GNUTLS_E_SUCCESS) {
425
429
"Error[%d] while reading the OpenPGP key pair ('%s',"
426
430
" '%s')\n", ret, pubkeyfilename, seckeyfilename);
432
436
/* GnuTLS server initialization */
433
437
ret = gnutls_dh_params_init(&mc->dh_params);
434
if (ret != GNUTLS_E_SUCCESS) {
435
fprintf (stderr, "Error in GnuTLS DH parameter initialization:"
436
" %s\n", safer_gnutls_strerror(ret));
438
if(ret != GNUTLS_E_SUCCESS) {
439
fprintf(stderr, "Error in GnuTLS DH parameter initialization:"
440
" %s\n", safer_gnutls_strerror(ret));
439
443
ret = gnutls_dh_params_generate2(mc->dh_params, mc->dh_bits);
440
if (ret != GNUTLS_E_SUCCESS) {
441
fprintf (stderr, "Error in GnuTLS prime generation: %s\n",
442
safer_gnutls_strerror(ret));
444
if(ret != GNUTLS_E_SUCCESS) {
445
fprintf(stderr, "Error in GnuTLS prime generation: %s\n",
446
safer_gnutls_strerror(ret));
460
465
/* GnuTLS session creation */
461
466
ret = gnutls_init(session, GNUTLS_SERVER);
462
if (ret != GNUTLS_E_SUCCESS){
467
if(ret != GNUTLS_E_SUCCESS){
463
468
fprintf(stderr, "Error in GnuTLS session initialization: %s\n",
464
469
safer_gnutls_strerror(ret));
469
474
ret = gnutls_priority_set_direct(*session, mc->priority, &err);
470
if (ret != GNUTLS_E_SUCCESS) {
475
if(ret != GNUTLS_E_SUCCESS) {
471
476
fprintf(stderr, "Syntax error at: %s\n", err);
472
477
fprintf(stderr, "GnuTLS error: %s\n",
473
478
safer_gnutls_strerror(ret));
474
gnutls_deinit (*session);
479
gnutls_deinit(*session);
479
484
ret = gnutls_credentials_set(*session, GNUTLS_CRD_CERTIFICATE,
481
if (ret != GNUTLS_E_SUCCESS) {
486
if(ret != GNUTLS_E_SUCCESS) {
482
487
fprintf(stderr, "Error setting GnuTLS credentials: %s\n",
483
488
safer_gnutls_strerror(ret));
484
gnutls_deinit (*session);
489
gnutls_deinit(*session);
488
493
/* ignore client certificate if any. */
489
gnutls_certificate_server_set_request (*session,
494
gnutls_certificate_server_set_request(*session,
492
gnutls_dh_set_prime_bits (*session, mc->dh_bits);
497
gnutls_dh_set_prime_bits(*session, mc->dh_bits);
514
520
char interface[IF_NAMESIZE];
515
521
gnutls_session_t session;
517
ret = init_gnutls_session (mc, &session);
523
ret = init_gnutls_session(mc, &session);
551
557
fprintf(stderr, "Bad address: %s\n", ip);
554
to.in6.sin6_port = htons(port); /* Spurious warning */
560
to.in6.sin6_port = htons(port); /* Spurious warnings from
562
-Wunreachable-code */
556
564
to.in6.sin6_scope_id = (uint32_t)if_index;
572
580
ret = connect(tcp_sd, &to.in, sizeof(to));
574
582
perror("connect");
578
586
const char *out = mandos_protocol_version;
581
589
size_t out_size = strlen(out);
582
ret = TEMP_FAILURE_RETRY(write(tcp_sd, out + written,
590
ret = (int)TEMP_FAILURE_RETRY(write(tcp_sd, out + written,
583
591
out_size - written));
603
611
fprintf(stderr, "Establishing TLS session with %s\n", ip);
606
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) tcp_sd);
614
gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t) tcp_sd);
609
ret = gnutls_handshake (session);
617
ret = gnutls_handshake(session);
610
618
} while(ret == GNUTLS_E_AGAIN or ret == GNUTLS_E_INTERRUPTED);
612
if (ret != GNUTLS_E_SUCCESS){
620
if(ret != GNUTLS_E_SUCCESS){
614
622
fprintf(stderr, "*** GnuTLS Handshake failed ***\n");
629
637
buffer_capacity = adjustbuffer(&buffer, buffer_length,
630
638
buffer_capacity);
631
if (buffer_capacity == 0){
639
if(buffer_capacity == 0){
632
640
perror("adjustbuffer");
637
ret = gnutls_record_recv(session, buffer+buffer_length,
645
sret = gnutls_record_recv(session, buffer+buffer_length,
644
652
case GNUTLS_E_INTERRUPTED:
645
653
case GNUTLS_E_AGAIN:
647
655
case GNUTLS_E_REHANDSHAKE:
649
ret = gnutls_handshake (session);
657
ret = gnutls_handshake(session);
650
658
} while(ret == GNUTLS_E_AGAIN or ret == GNUTLS_E_INTERRUPTED);
652
660
fprintf(stderr, "*** GnuTLS Re-handshake failed ***\n");
659
667
fprintf(stderr, "Unknown error while reading data from"
660
668
" encrypted session with Mandos server\n");
662
gnutls_bye (session, GNUTLS_SHUT_RDWR);
670
gnutls_bye(session, GNUTLS_SHUT_RDWR);
666
buffer_length += (size_t) ret;
674
buffer_length += (size_t) sret;
671
679
fprintf(stderr, "Closing TLS session\n");
674
gnutls_bye (session, GNUTLS_SHUT_RDWR);
682
gnutls_bye(session, GNUTLS_SHUT_RDWR);
676
if (buffer_length > 0){
684
if(buffer_length > 0){
677
685
decrypted_buffer_size = pgp_packet_decrypt(mc, buffer,
679
687
&decrypted_buffer);
680
if (decrypted_buffer_size >= 0){
688
if(decrypted_buffer_size >= 0){
682
690
while(written < (size_t) decrypted_buffer_size){
683
ret = (int)fwrite (decrypted_buffer + written, 1,
684
(size_t)decrypted_buffer_size - written,
691
ret = (int)fwrite(decrypted_buffer + written, 1,
692
(size_t)decrypted_buffer_size - written,
686
694
if(ret == 0 and ferror(stdout)){
688
696
fprintf(stderr, "Error writing encrypted data: %s\n",
747
755
avahi_address_snprint(ip, sizeof(ip), address);
749
757
fprintf(stderr, "Mandos server \"%s\" found on %s (%s, %"
750
PRIu16 ") on port %d\n", name, host_name, ip,
758
PRIdMAX ") on port %" PRIu16 "\n", name, host_name,
759
ip, (intmax_t)interface, port);
753
761
int ret = start_mandos_communication(ip, port, interface, mc);
755
763
avahi_simple_poll_quit(mc->simple_poll);
790
798
the callback function is called the Avahi server will free the
791
799
resolver for us. */
793
if (!(avahi_s_service_resolver_new(mc->server, interface,
801
if(!(avahi_s_service_resolver_new(mc->server, interface,
794
802
protocol, name, type, domain,
795
803
AVAHI_PROTO_INET6, 0,
796
804
resolve_callback, mc)))
830
840
.dh_bits = 1024, .priority = "SECURE256"
831
841
":!CTYPE-X.509:+CTYPE-OPENPGP" };
832
842
bool gnutls_initalized = false;
833
bool pgpme_initalized = false;
843
bool gpgme_initalized = false;
836
847
struct argp_option options[] = {
863
874
.doc = "GnuTLS priority string for the TLS handshake",
876
{ .name = "delay", .key = 131,
878
.doc = "Maximum delay to wait for interface startup",
868
error_t parse_opt (int key, char *arg,
869
struct argp_state *state) {
870
/* Get the INPUT argument from `argp_parse', which we know is
871
a pointer to our plugin list pointer. */
883
error_t parse_opt(int key, char *arg,
884
struct argp_state *state) {
873
886
case 128: /* --debug */
888
901
case 129: /* --dh-bits */
890
mc.dh_bits = (unsigned int) strtol(arg, NULL, 10);
902
ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
903
if(ret < 1 or tmpmax != (typeof(mc.dh_bits))tmpmax
904
or arg[numchars] != '\0'){
905
fprintf(stderr, "Bad number of DH bits\n");
893
906
exit(EXIT_FAILURE);
908
mc.dh_bits = (typeof(mc.dh_bits))tmpmax;
896
910
case 130: /* --priority */
897
911
mc.priority = arg;
913
case 131: /* --delay */
914
ret = sscanf(arg, "%lf%n", &delay, &numchars);
915
if(ret < 1 or arg[numchars] != '\0'){
916
fprintf(stderr, "Bad delay\n");
899
920
case ARGP_KEY_ARG:
901
922
case ARGP_KEY_END:
911
932
.doc = "Mandos client -- Get and decrypt"
912
933
" passwords from a Mandos server" };
913
ret = argp_parse (&argp, argc, argv, 0, 0, NULL);
914
if (ret == ARGP_ERR_UNKNOWN){
934
ret = argp_parse(&argp, argc, argv, 0, 0, NULL);
935
if(ret == ARGP_ERR_UNKNOWN){
915
936
fprintf(stderr, "Unknown error while parsing arguments\n");
916
937
exitcode = EXIT_FAILURE;
921
942
/* If the interface is down, bring it up */
944
// Lower kernel loglevel to KERN_NOTICE to avoid
945
// KERN_INFO messages to mess up the prompt
946
ret = klogctl(8, NULL, 5);
923
951
sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);
925
953
perror("socket");
926
954
exitcode = EXIT_FAILURE;
955
ret = klogctl(7, NULL, 0);
929
961
strcpy(network.ifr_name, interface);
930
962
ret = ioctl(sd, SIOCGIFFLAGS, &network);
932
964
perror("ioctl SIOCGIFFLAGS");
965
ret = klogctl(7, NULL, 0);
933
969
exitcode = EXIT_FAILURE;
940
976
perror("ioctl SIOCSIFFLAGS");
941
977
exitcode = EXIT_FAILURE;
978
ret = klogctl(7, NULL, 0);
945
ret = TEMP_FAILURE_RETRY(close(sd));
985
// sleep checking until interface is running
986
for(int i=0; i < delay * 4; i++){
987
ret = ioctl(sd, SIOCGIFFLAGS, &network);
989
perror("ioctl SIOCGIFFLAGS");
990
} else if(network.ifr_flags & IFF_RUNNING){
993
struct timespec sleeptime = { .tv_nsec = 250000000 };
994
nanosleep(&sleeptime, NULL);
996
ret = (int)TEMP_FAILURE_RETRY(close(sd));
1000
// Restores kernel loglevel to default
1001
ret = klogctl(7, NULL, 0);
954
1010
ret = setuid(uid);
956
1012
perror("setuid");
961
1017
perror("setgid");
964
1020
ret = init_gnutls_global(&mc, pubkey, seckey);
966
1022
fprintf(stderr, "init_gnutls_global failed\n");
967
1023
exitcode = EXIT_FAILURE;
979
1035
if(not init_gpgme(&mc, pubkey, seckey, tempdir)){
980
fprintf(stderr, "pgpme_initalized failed\n");
1036
fprintf(stderr, "gpgme_initalized failed\n");
981
1037
exitcode = EXIT_FAILURE;
984
pgpme_initalized = true;
1040
gpgme_initalized = true;
987
1043
if_index = (AvahiIfIndex) if_nametoindex(interface);
999
1055
exitcode = EXIT_FAILURE;
1003
uint16_t port = (uint16_t) strtol(address+1, NULL, 10);
1005
perror("Bad port number");
1059
ret = sscanf(address+1, "%" SCNdMAX "%n", &tmpmax, &numchars);
1060
if(ret < 1 or tmpmax != (uint16_t)tmpmax
1061
or address[numchars+1] != '\0'){
1062
fprintf(stderr, "Bad port number\n");
1006
1063
exitcode = EXIT_FAILURE;
1066
port = (uint16_t)tmpmax;
1009
1067
*address = '\0';
1010
1068
address = connect_to;
1011
1069
ret = start_mandos_communication(address, port, if_index, &mc);
1027
1085
/* Allocate main Avahi loop object */
1028
1086
mc.simple_poll = avahi_simple_poll_new();
1029
if (mc.simple_poll == NULL) {
1087
if(mc.simple_poll == NULL) {
1030
1088
fprintf(stderr, "Avahi: Failed to create simple poll"
1032
1090
exitcode = EXIT_FAILURE;
1074
1132
/* Run the main loop */
1077
1135
fprintf(stderr, "Starting Avahi loop search\n");
1080
1138
avahi_simple_poll_loop(mc.simple_poll);
1085
1143
fprintf(stderr, "%s exiting\n", argv[0]);
1088
1146
/* Cleanup things */
1090
1148
avahi_s_service_browser_free(sb);
1092
if (mc.server != NULL)
1150
if(mc.server != NULL)
1093
1151
avahi_server_free(mc.server);
1095
if (mc.simple_poll != NULL)
1153
if(mc.simple_poll != NULL)
1096
1154
avahi_simple_poll_free(mc.simple_poll);
1098
if (gnutls_initalized){
1156
if(gnutls_initalized){
1099
1157
gnutls_certificate_free_credentials(mc.cred);
1100
gnutls_global_deinit ();
1158
gnutls_global_deinit();
1159
gnutls_dh_params_deinit(mc.dh_params);
1103
if(pgpme_initalized){
1162
if(gpgme_initalized){
1104
1163
gpgme_release(mc.ctx);
1110
1169
struct dirent *direntry;
1111
1170
d = opendir(tempdir);
1172
if(errno != ENOENT){
1116
1177
direntry = readdir(d);
1117
1178
if(direntry == NULL){
1120
if (direntry->d_type == DT_REG){
1181
if(direntry->d_type == DT_REG){
1121
1182
char *fullname = NULL;
1122
1183
ret = asprintf(&fullname, "%s/%s", tempdir,
1123
1184
direntry->d_name);