110
110
init_gnutls_session(),
112
112
#include <gnutls/openpgp.h>
113
/* gnutls_certificate_set_openpgp_key_file(),
114
GNUTLS_OPENPGP_FMT_BASE64 */
113
/* gnutls_certificate_set_openpgp_key_file(),
114
GNUTLS_OPENPGP_FMT_BASE64 */
117
117
#include <gpgme.h> /* All GPGME types, constants and
173
174
perror(print_text);
177
int fprintf_plus(FILE *stream, const char *format, ...){
179
va_start (ap, format);
181
TEMP_FAILURE_RETRY(fprintf(stream, "Mandos plugin %s: ", program_invocation_short_name));
182
return TEMP_FAILURE_RETRY(vfprintf(stream, format, ap));
177
186
* Make additional room in "buffer" for at least BUFFER_SIZE more
178
187
* bytes. "buffer_capacity" is how much is currently allocated,
179
188
* "buffer_length" is how much is already used.
181
190
size_t incbuffer(char **buffer, size_t buffer_length,
182
size_t buffer_capacity){
191
size_t buffer_capacity){
183
192
if(buffer_length + BUFFER_SIZE > buffer_capacity){
184
193
*buffer = realloc(*buffer, buffer_capacity + BUFFER_SIZE);
185
194
if(buffer == NULL){
254
262
rc = gpgme_data_new_from_fd(&pgp_data, fd);
255
263
if(rc != GPG_ERR_NO_ERROR){
256
fprintf(stderr, "Mandos plugin mandos-client: "
257
"bad gpgme_data_new_from_fd: %s: %s\n",
264
fprintf_plus(stderr, "bad gpgme_data_new_from_fd: %s: %s\n",
258
265
gpgme_strsource(rc), gpgme_strerror(rc));
262
269
rc = gpgme_op_import(mc.ctx, pgp_data);
263
270
if(rc != GPG_ERR_NO_ERROR){
264
fprintf(stderr, "Mandos plugin mandos-client: "
265
"bad gpgme_op_import: %s: %s\n",
271
fprintf_plus(stderr, "bad gpgme_op_import: %s: %s\n",
266
272
gpgme_strsource(rc), gpgme_strerror(rc));
279
fprintf(stderr, "Mandos plugin mandos-client: "
280
"Initializing GPGME\n");
285
fprintf_plus(stderr, "Initializing GPGME\n");
284
289
gpgme_check_version(NULL);
285
290
rc = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP);
286
291
if(rc != GPG_ERR_NO_ERROR){
287
fprintf(stderr, "Mandos plugin mandos-client: "
288
"bad gpgme_engine_check_version: %s: %s\n",
292
fprintf_plus(stderr, "bad gpgme_engine_check_version: %s: %s\n",
289
293
gpgme_strsource(rc), gpgme_strerror(rc));
293
297
/* Set GPGME home directory for the OpenPGP engine only */
294
298
rc = gpgme_get_engine_info(&engine_info);
295
299
if(rc != GPG_ERR_NO_ERROR){
296
fprintf(stderr, "Mandos plugin mandos-client: "
297
"bad gpgme_get_engine_info: %s: %s\n",
300
fprintf_plus(stderr, "bad gpgme_get_engine_info: %s: %s\n",
298
301
gpgme_strsource(rc), gpgme_strerror(rc));
307
310
engine_info = engine_info->next;
309
312
if(engine_info == NULL){
310
fprintf(stderr, "Mandos plugin mandos-client: "
311
"Could not set GPGME home dir to %s\n", tempdir);
313
fprintf_plus(stderr, "Could not set GPGME home dir to %s\n", tempdir);
315
317
/* Create new GPGME "context" */
316
318
rc = gpgme_new(&(mc.ctx));
317
319
if(rc != GPG_ERR_NO_ERROR){
318
fprintf(stderr, "Mandos plugin mandos-client: "
320
fprintf_plus(stderr, "Mandos plugin mandos-client: "
319
321
"bad gpgme_new: %s: %s\n", gpgme_strsource(rc),
320
322
gpgme_strerror(rc));
342
344
ssize_t plaintext_length = 0;
345
fprintf(stderr, "Mandos plugin mandos-client: "
346
"Trying to decrypt OpenPGP data\n");
347
fprintf_plus(stderr, "Trying to decrypt OpenPGP data\n");
349
350
/* Create new GPGME data buffer from memory cryptotext */
350
351
rc = gpgme_data_new_from_mem(&dh_crypto, cryptotext, crypto_size,
352
353
if(rc != GPG_ERR_NO_ERROR){
353
fprintf(stderr, "Mandos plugin mandos-client: "
354
"bad gpgme_data_new_from_mem: %s: %s\n",
354
fprintf_plus(stderr, "bad gpgme_data_new_from_mem: %s: %s\n",
355
355
gpgme_strsource(rc), gpgme_strerror(rc));
359
359
/* Create new empty GPGME data buffer for the plaintext */
360
360
rc = gpgme_data_new(&dh_plain);
361
361
if(rc != GPG_ERR_NO_ERROR){
362
fprintf(stderr, "Mandos plugin mandos-client: "
362
fprintf_plus(stderr, "Mandos plugin mandos-client: "
363
363
"bad gpgme_data_new: %s: %s\n",
364
364
gpgme_strsource(rc), gpgme_strerror(rc));
365
365
gpgme_data_release(dh_crypto);
371
371
rc = gpgme_op_decrypt(mc.ctx, dh_crypto, dh_plain);
372
372
if(rc != GPG_ERR_NO_ERROR){
373
fprintf(stderr, "Mandos plugin mandos-client: "
374
"bad gpgme_op_decrypt: %s: %s\n",
373
fprintf_plus(stderr, "bad gpgme_op_decrypt: %s: %s\n",
375
374
gpgme_strsource(rc), gpgme_strerror(rc));
376
375
plaintext_length = -1;
378
377
gpgme_decrypt_result_t result;
379
378
result = gpgme_op_decrypt_result(mc.ctx);
380
379
if(result == NULL){
381
fprintf(stderr, "Mandos plugin mandos-client: "
382
"gpgme_op_decrypt_result failed\n");
380
fprintf_plus(stderr, "gpgme_op_decrypt_result failed\n");
384
fprintf(stderr, "Mandos plugin mandos-client: "
385
"Unsupported algorithm: %s\n",
382
fprintf_plus(stderr, "Unsupported algorithm: %s\n",
386
383
result->unsupported_algorithm);
387
fprintf(stderr, "Mandos plugin mandos-client: "
388
"Wrong key usage: %u\n",
384
fprintf_plus(stderr, "Wrong key usage: %u\n",
389
385
result->wrong_key_usage);
390
386
if(result->file_name != NULL){
391
fprintf(stderr, "Mandos plugin mandos-client: "
392
"File name: %s\n", result->file_name);
387
fprintf_plus(stderr, "File name: %s\n", result->file_name);
394
389
gpgme_recipient_t recipient;
395
390
recipient = result->recipients;
396
391
while(recipient != NULL){
397
fprintf(stderr, "Mandos plugin mandos-client: "
398
"Public key algorithm: %s\n",
392
fprintf_plus(stderr, "Public key algorithm: %s\n",
399
393
gpgme_pubkey_algo_name(recipient->pubkey_algo));
400
fprintf(stderr, "Mandos plugin mandos-client: "
401
"Key ID: %s\n", recipient->keyid);
402
fprintf(stderr, "Mandos plugin mandos-client: "
403
"Secret key available: %s\n",
394
fprintf_plus(stderr, "Key ID: %s\n", recipient->keyid);
395
fprintf_plus(stderr, "Secret key available: %s\n",
404
396
recipient->status == GPG_ERR_NO_SECKEY
406
398
recipient = recipient->next;
425
416
*plaintext = NULL;
427
418
plaintext_capacity = incbuffer(plaintext,
428
(size_t)plaintext_length,
419
(size_t)plaintext_length,
430
421
if(plaintext_capacity == 0){
431
perror_plus("incbuffer");
432
plaintext_length = -1;
422
perror_plus("incbuffer");
423
plaintext_length = -1;
436
427
ret = gpgme_data_read(dh_plain, *plaintext + plaintext_length,
478
468
/* GnuTLS log function callback */
479
469
static void debuggnutls(__attribute__((unused)) int level,
480
470
const char* string){
481
fprintf(stderr, "Mandos plugin mandos-client: GnuTLS: %s", string);
471
fprintf_plus(stderr, "GnuTLS: %s", string);
484
474
static int init_gnutls_global(const char *pubkeyfilename,
489
fprintf(stderr, "Mandos plugin mandos-client: "
490
"Initializing GnuTLS\n");
479
fprintf_plus(stderr, "Initializing GnuTLS\n");
493
482
ret = gnutls_global_init();
494
483
if(ret != GNUTLS_E_SUCCESS){
495
fprintf(stderr, "Mandos plugin mandos-client: "
496
"GnuTLS global_init: %s\n", safer_gnutls_strerror(ret));
484
fprintf_plus(stderr, "GnuTLS global_init: %s\n", safer_gnutls_strerror(ret));
508
496
/* OpenPGP credentials */
509
497
ret = gnutls_certificate_allocate_credentials(&mc.cred);
510
498
if(ret != GNUTLS_E_SUCCESS){
511
fprintf(stderr, "Mandos plugin mandos-client: "
512
"GnuTLS memory error: %s\n", safer_gnutls_strerror(ret));
499
fprintf_plus(stderr, "GnuTLS memory error: %s\n", safer_gnutls_strerror(ret));
513
500
gnutls_global_deinit();
518
fprintf(stderr, "Mandos plugin mandos-client: "
519
"Attempting to use OpenPGP public key %s and"
505
fprintf_plus(stderr, "Attempting to use OpenPGP public key %s and"
520
506
" secret key %s as GnuTLS credentials\n", pubkeyfilename,
525
511
(mc.cred, pubkeyfilename, seckeyfilename,
526
512
GNUTLS_OPENPGP_FMT_BASE64);
527
513
if(ret != GNUTLS_E_SUCCESS){
529
"Mandos plugin mandos-client: "
530
"Error[%d] while reading the OpenPGP key pair ('%s',"
531
" '%s')\n", ret, pubkeyfilename, seckeyfilename);
532
fprintf(stderr, "Mandos plugin mandos-client: "
533
"The GnuTLS error is: %s\n", safer_gnutls_strerror(ret));
515
"Error[%d] while reading the OpenPGP key pair ('%s',"
516
" '%s')\n", ret, pubkeyfilename, seckeyfilename);
517
fprintf_plus(stderr, "The GnuTLS error is: %s\n", safer_gnutls_strerror(ret));
537
521
/* GnuTLS server initialization */
538
522
ret = gnutls_dh_params_init(&mc.dh_params);
539
523
if(ret != GNUTLS_E_SUCCESS){
540
fprintf(stderr, "Mandos plugin mandos-client: "
541
"Error in GnuTLS DH parameter initialization:"
524
fprintf_plus(stderr, "Error in GnuTLS DH parameter initialization:"
542
525
" %s\n", safer_gnutls_strerror(ret));
545
528
ret = gnutls_dh_params_generate2(mc.dh_params, mc.dh_bits);
546
529
if(ret != GNUTLS_E_SUCCESS){
547
fprintf(stderr, "Mandos plugin mandos-client: "
548
"Error in GnuTLS prime generation: %s\n",
530
fprintf_plus(stderr, "Error in GnuTLS prime generation: %s\n",
549
531
safer_gnutls_strerror(ret));
573
555
} while(ret == GNUTLS_E_INTERRUPTED or ret == GNUTLS_E_AGAIN);
574
556
if(ret != GNUTLS_E_SUCCESS){
575
fprintf(stderr, "Mandos plugin mandos-client: "
576
"Error in GnuTLS session initialization: %s\n",
557
fprintf_plus(stderr, "Error in GnuTLS session initialization: %s\n",
577
558
safer_gnutls_strerror(ret));
588
569
} while(ret == GNUTLS_E_INTERRUPTED or ret == GNUTLS_E_AGAIN);
589
570
if(ret != GNUTLS_E_SUCCESS){
590
fprintf(stderr, "Mandos plugin mandos-client: "
591
"Syntax error at: %s\n", err);
592
fprintf(stderr, "Mandos plugin mandos-client: "
593
"GnuTLS error: %s\n", safer_gnutls_strerror(ret));
571
fprintf_plus(stderr, "Syntax error at: %s\n", err);
572
fprintf_plus(stderr, "GnuTLS error: %s\n", safer_gnutls_strerror(ret));
594
573
gnutls_deinit(*session);
606
585
} while(ret == GNUTLS_E_INTERRUPTED or ret == GNUTLS_E_AGAIN);
607
586
if(ret != GNUTLS_E_SUCCESS){
608
fprintf(stderr, "Mandos plugin mandos-client: "
609
"Error setting GnuTLS credentials: %s\n",
587
fprintf_plus(stderr, "Error setting GnuTLS credentials: %s\n",
610
588
safer_gnutls_strerror(ret));
611
589
gnutls_deinit(*session);
717
692
if(IN6_IS_ADDR_LINKLOCAL /* Spurious warnings from */
718
693
(&to.in6.sin6_addr)){ /* -Wstrict-aliasing=2 or lower and
720
695
if(if_index == AVAHI_IF_UNSPEC){
721
fprintf(stderr, "Mandos plugin mandos-client: "
722
"An IPv6 link-local address is incomplete"
696
fprintf_plus(stderr, "An IPv6 link-local address is incomplete"
723
697
" without a network interface\n");
744
718
if(if_indextoname((unsigned int)if_index, interface) == NULL){
745
719
perror_plus("if_indextoname");
747
fprintf(stderr, "Mandos plugin mandos-client: "
748
"Connection to: %s%%%s, port %" PRIu16 "\n",
721
fprintf_plus(stderr, "Connection to: %s%%%s, port %" PRIu16 "\n",
749
722
ip, interface, port);
752
fprintf(stderr, "Mandos plugin mandos-client: "
753
"Connection to: %s, port %" PRIu16 "\n", ip, port);
725
fprintf_plus(stderr, "Connection to: %s, port %" PRIu16 "\n", ip, port);
755
727
char addrstr[(INET_ADDRSTRLEN > INET6_ADDRSTRLEN) ?
756
728
INET_ADDRSTRLEN : INET6_ADDRSTRLEN] = "";
766
738
perror_plus("inet_ntop");
768
740
if(strcmp(addrstr, ip) != 0){
769
fprintf(stderr, "Mandos plugin mandos-client: "
770
"Canonical address form: %s\n", addrstr);
741
fprintf_plus(stderr, "Canonical address form: %s\n", addrstr);
911
879
} while(ret == GNUTLS_E_AGAIN or ret == GNUTLS_E_INTERRUPTED);
913
fprintf(stderr, "Mandos plugin mandos-client: "
914
"*** GnuTLS Re-handshake failed ***\n");
881
fprintf_plus(stderr, "*** GnuTLS Re-handshake failed ***\n");
915
882
gnutls_perror(ret);
921
fprintf(stderr, "Mandos plugin mandos-client: "
922
"Unknown error while reading data from"
888
fprintf_plus(stderr, "Unknown error while reading data from"
923
889
" encrypted session with Mandos server\n");
924
890
gnutls_bye(session, GNUTLS_SHUT_RDWR);
1035
998
case AVAHI_RESOLVER_FAILURE:
1036
fprintf(stderr, "Mandos plugin mandos-client: "
1037
"(Avahi Resolver) Failed to resolve service '%s'"
999
fprintf_plus(stderr, "(Avahi Resolver) Failed to resolve service '%s'"
1038
1000
" of type '%s' in domain '%s': %s\n", name, type, domain,
1039
1001
avahi_strerror(avahi_server_errno(mc.server)));
1044
1006
char ip[AVAHI_ADDRESS_STR_MAX];
1045
1007
avahi_address_snprint(ip, sizeof(ip), address);
1047
fprintf(stderr, "Mandos plugin mandos-client: "
1048
"Mandos server \"%s\" found on %s (%s, %"
1009
fprintf_plus(stderr, "Mandos server \"%s\" found on %s (%s, %"
1049
1010
PRIdMAX ") on port %" PRIu16 "\n", name, host_name,
1050
1011
ip, (intmax_t)interface, port);
1100
1060
if(avahi_s_service_resolver_new(mc.server, interface, protocol,
1101
1061
name, type, domain, protocol, 0,
1102
1062
resolve_callback, NULL) == NULL)
1103
fprintf(stderr, "Mandos plugin mandos-client: "
1104
"Avahi: Failed to resolve service '%s': %s\n",
1063
fprintf_plus(stderr, "Avahi: Failed to resolve service '%s': %s\n",
1105
1064
name, avahi_strerror(avahi_server_errno(mc.server)));
1111
1070
case AVAHI_BROWSER_ALL_FOR_NOW:
1112
1071
case AVAHI_BROWSER_CACHE_EXHAUSTED:
1114
fprintf(stderr, "Mandos plugin mandos-client: "
1115
"No Mandos server found, still searching...\n");
1073
fprintf_plus(stderr, "No Mandos server found, still searching...\n");
1157
1115
/* Reject the loopback device */
1158
1116
if(ifr->ifr_flags & IFF_LOOPBACK){
1160
fprintf(stderr, "Mandos plugin mandos-client: "
1161
"Rejecting loopback interface \"%s\"\n", ifname);
1118
fprintf_plus(stderr, "Rejecting loopback interface \"%s\"\n", ifname);
1165
1122
/* Accept point-to-point devices only if connect_to is specified */
1166
1123
if(connect_to != NULL and (ifr->ifr_flags & IFF_POINTOPOINT)){
1168
fprintf(stderr, "Mandos plugin mandos-client: "
1169
"Accepting point-to-point interface \"%s\"\n", ifname);
1125
fprintf_plus(stderr, "Accepting point-to-point interface \"%s\"\n", ifname);
1173
1129
/* Otherwise, reject non-broadcast-capable devices */
1174
1130
if(not (ifr->ifr_flags & IFF_BROADCAST)){
1176
fprintf(stderr, "Mandos plugin mandos-client: "
1177
"Rejecting non-broadcast interface \"%s\"\n", ifname);
1132
fprintf_plus(stderr, "Rejecting non-broadcast interface \"%s\"\n", ifname);
1181
1136
/* Reject non-ARP interfaces (including dummy interfaces) */
1182
1137
if(ifr->ifr_flags & IFF_NOARP){
1184
fprintf(stderr, "Mandos plugin mandos-client: "
1185
"Rejecting non-ARP interface \"%s\"\n", ifname);
1139
fprintf_plus(stderr, "Rejecting non-ARP interface \"%s\"\n", ifname);
1190
1144
/* Accept this device */
1192
fprintf(stderr, "Mandos plugin mandos-client: "
1193
"Interface \"%s\" is good\n", ifname);
1146
fprintf_plus(stderr, "Interface \"%s\" is good\n", ifname);
1254
1204
/* Reject non-running interfaces */
1255
1205
if(not (ifr.ifr_flags & IFF_RUNNING)){
1257
fprintf(stderr, "Mandos plugin mandos-client: "
1258
"Rejecting non-running interface \"%s\"\n",
1207
fprintf_plus(stderr, "Rejecting non-running interface \"%s\"\n",
1259
1208
if_entry->d_name);
1291
/* Save pointer to last character */
1292
char *end = strchr(direntry->d_name, '\0')-1;
1299
if(((direntry->d_name)[0] == '#')
1301
/* Temporary #name# */
1305
/* XXX more rules here */
1307
ret = stat(direntry->d_name, &st);
1241
sret = strspn(direntry->d_name, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1242
"abcdefghijklmnopqrstuvwxyz"
1245
if((direntry->d_name)[sret] != '\0'){
1246
/* Contains non-allowed characters */
1248
fprintf_plus(stderr, "Ignoring hook \"%s\" with bad name\n",
1254
char *fullname = NULL;
1255
ret = asprintf(&fullname, "%s/%s", hookdir, direntry->d_name);
1257
perror_plus("asprintf");
1261
ret = stat(fullname, &st);
1310
perror_plus("Could not stat plugin");
1264
perror_plus("Could not stat hook");
1314
1268
if(not (S_ISREG(st.st_mode))){
1315
1269
/* Not a regular file */
1271
fprintf_plus(stderr, "Ignoring hook \"%s\" - not a file\n",
1318
1276
if(not (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))){
1319
1277
/* Not executable */
1279
fprintf_plus(stderr, "Ignoring hook \"%s\" - not executable\n",
1332
1294
if(mc.current_server == NULL){
1334
fprintf(stderr, "Mandos plugin mandos-client: "
1335
"Wait until first server is found. No timeout!\n");
1296
fprintf_plus(stderr, "Wait until first server is found. No timeout!\n");
1337
1298
ret = avahi_simple_poll_iterate(s, -1);
1340
fprintf(stderr, "Mandos plugin mandos-client: "
1341
"Check current_server if we should run it,"
1301
fprintf_plus(stderr, "Check current_server if we should run it,"
1344
1304
/* the current time */
1551
1517
argp_state_help(state, state->out_stream,
1552
1518
ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
1553
1519
case 'V': /* --version */
1554
fprintf(state->out_stream, "Mandos plugin mandos-client: ");
1555
fprintf(state->out_stream, "%s\n", argp_program_version);
1520
fprintf_plus(state->out_stream, "Mandos plugin mandos-client: ");
1521
fprintf_plus(state->out_stream, "%s\n", argp_program_version);
1556
1522
exit(argp_err_exit_status);
1707
1677
if(WIFEXITED(status)){
1708
1678
if(WEXITSTATUS(status) != 0){
1709
fprintf(stderr, "Mandos plugin mandos-client: "
1710
"Warning: network hook \"%s\" exited"
1679
fprintf_plus(stderr, "Warning: network hook \"%s\" exited"
1711
1680
" with status %d\n", direntry->d_name,
1712
1681
WEXITSTATUS(status));
1713
1682
free(fullname);
1716
1685
} else if(WIFSIGNALED(status)){
1717
fprintf(stderr, "Mandos plugin mandos-client: "
1718
"Warning: network hook \"%s\" died by"
1686
fprintf_plus(stderr, "Warning: network hook \"%s\" died by"
1719
1687
" signal %d\n", direntry->d_name,
1720
1688
WTERMSIG(status));
1721
1689
free(fullname);
1724
fprintf(stderr, "Mandos plugin mandos-client: "
1725
"Warning: network hook \"%s\" crashed\n",
1692
fprintf_plus(stderr, "Warning: network hook \"%s\" crashed\n",
1726
1693
direntry->d_name);
1727
1694
free(fullname);
1756
1723
/* Pick the first interface returned */
1757
1724
interface = strdup(direntries[0]->d_name);
1759
fprintf(stderr, "Mandos plugin mandos-client: "
1760
"Using interface \"%s\"\n", interface);
1726
fprintf_plus(stderr, "Using interface \"%s\"\n", interface);
1762
1728
if(interface == NULL){
1763
1729
perror_plus("malloc");
1781
1746
srand((unsigned int) time(NULL));
1782
1747
mc.simple_poll = avahi_simple_poll_new();
1783
1748
if(mc.simple_poll == NULL){
1784
fprintf(stderr, "Mandos plugin mandos-client: "
1785
"Avahi: Failed to create simple poll object.\n");
1749
fprintf_plus(stderr, "Avahi: Failed to create simple poll object.\n");
1786
1750
exitcode = EX_UNAVAILABLE;
1854
1818
if(strcmp(interface, "none") != 0){
1855
1819
if_index = (AvahiIfIndex) if_nametoindex(interface);
1856
1820
if(if_index == 0){
1857
fprintf(stderr, "Mandos plugin mandos-client: "
1858
"No such interface: \"%s\"\n", interface);
1821
fprintf_plus(stderr, "No such interface: \"%s\"\n", interface);
1859
1822
exitcode = EX_UNAVAILABLE;
2132
2090
/* Check if creating the Avahi server object succeeded */
2133
2091
if(mc.server == NULL){
2134
fprintf(stderr, "Mandos plugin mandos-client: "
2135
"Failed to create Avahi server: %s\n",
2092
fprintf_plus(stderr, "Failed to create Avahi server: %s\n",
2136
2093
avahi_strerror(error));
2137
2094
exitcode = EX_UNAVAILABLE;
2147
2104
AVAHI_PROTO_UNSPEC, "_mandos._tcp",
2148
2105
NULL, 0, browse_callback, NULL);
2149
2106
if(sb == NULL){
2150
fprintf(stderr, "Mandos plugin mandos-client: "
2151
"Failed to create service browser: %s\n",
2107
fprintf_plus(stderr, "Failed to create service browser: %s\n",
2152
2108
avahi_strerror(avahi_server_errno(mc.server)));
2153
2109
exitcode = EX_UNAVAILABLE;
2161
2117
/* Run the main loop */
2164
fprintf(stderr, "Mandos plugin mandos-client: "
2165
"Starting Avahi loop search\n");
2120
fprintf_plus(stderr, "Starting Avahi loop search\n");
2168
2123
ret = avahi_loop_with_timeout(mc.simple_poll,
2169
2124
(int)(retry_interval * 1000));
2171
fprintf(stderr, "Mandos plugin mandos-client: "
2172
"avahi_loop_with_timeout exited %s\n",
2126
fprintf_plus(stderr, "avahi_loop_with_timeout exited %s\n",
2173
2127
(ret == 0) ? "successfully" : "with error");
2179
fprintf(stderr, "Mandos plugin mandos-client: "
2180
"%s exiting\n", argv[0]);
2133
fprintf_plus(stderr, "%s exiting\n", argv[0]);
2183
2136
/* Cleanup things */