diff options
Diffstat (limited to 'src/transport/tcp_service_legacy.c')
-rw-r--r-- | src/transport/tcp_service_legacy.c | 458 |
1 files changed, 259 insertions, 199 deletions
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c index 19508a39f..e59fa4a1c 100644 --- a/src/transport/tcp_service_legacy.c +++ b/src/transport/tcp_service_legacy.c | |||
@@ -224,7 +224,6 @@ struct LEGACY_SERVICE_Context | |||
224 | * Our options. | 224 | * Our options. |
225 | */ | 225 | */ |
226 | enum LEGACY_SERVICE_Options options; | 226 | enum LEGACY_SERVICE_Options options; |
227 | |||
228 | }; | 227 | }; |
229 | 228 | ||
230 | 229 | ||
@@ -247,7 +246,7 @@ write_test (void *cls, size_t size, void *buf) | |||
247 | if (size < sizeof (struct GNUNET_MessageHeader)) | 246 | if (size < sizeof (struct GNUNET_MessageHeader)) |
248 | { | 247 | { |
249 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 248 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
250 | return 0; /* client disconnected */ | 249 | return 0; /* client disconnected */ |
251 | } | 250 | } |
252 | msg = (struct GNUNET_MessageHeader *) buf; | 251 | msg = (struct GNUNET_MessageHeader *) buf; |
253 | msg->type = htons (GNUNET_MESSAGE_TYPE_TEST); | 252 | msg->type = htons (GNUNET_MESSAGE_TYPE_TEST); |
@@ -265,7 +264,8 @@ write_test (void *cls, size_t size, void *buf) | |||
265 | * @param message the actual message | 264 | * @param message the actual message |
266 | */ | 265 | */ |
267 | static void | 266 | static void |
268 | handle_test (void *cls, struct GNUNET_SERVER_Client *client, | 267 | handle_test (void *cls, |
268 | struct GNUNET_SERVER_Client *client, | ||
269 | const struct GNUNET_MessageHeader *message) | 269 | const struct GNUNET_MessageHeader *message) |
270 | { | 270 | { |
271 | /* simply bounce message back to acknowledge */ | 271 | /* simply bounce message back to acknowledge */ |
@@ -273,7 +273,8 @@ handle_test (void *cls, struct GNUNET_SERVER_Client *client, | |||
273 | GNUNET_SERVER_notify_transmit_ready (client, | 273 | GNUNET_SERVER_notify_transmit_ready (client, |
274 | sizeof (struct GNUNET_MessageHeader), | 274 | sizeof (struct GNUNET_MessageHeader), |
275 | GNUNET_TIME_UNIT_FOREVER_REL, | 275 | GNUNET_TIME_UNIT_FOREVER_REL, |
276 | &write_test, client)) | 276 | &write_test, |
277 | client)) | ||
277 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 278 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
278 | } | 279 | } |
279 | 280 | ||
@@ -283,11 +284,12 @@ handle_test (void *cls, struct GNUNET_SERVER_Client *client, | |||
283 | * "callback_cls" fields will be replaced with the specific service | 284 | * "callback_cls" fields will be replaced with the specific service |
284 | * struct. | 285 | * struct. |
285 | */ | 286 | */ |
286 | static const struct GNUNET_SERVER_MessageHandler defhandlers[] = { | 287 | static const struct GNUNET_SERVER_MessageHandler defhandlers[] = |
287 | {&handle_test, NULL, GNUNET_MESSAGE_TYPE_TEST, | 288 | {{&handle_test, |
288 | sizeof (struct GNUNET_MessageHeader)}, | 289 | NULL, |
289 | {NULL, NULL, 0, 0} | 290 | GNUNET_MESSAGE_TYPE_TEST, |
290 | }; | 291 | sizeof (struct GNUNET_MessageHeader)}, |
292 | {NULL, NULL, 0, 0}}; | ||
291 | 293 | ||
292 | 294 | ||
293 | /* ****************** service core routines ************** */ | 295 | /* ****************** service core routines ************** */ |
@@ -304,8 +306,10 @@ static const struct GNUNET_SERVER_MessageHandler defhandlers[] = { | |||
304 | * for unknown address family (will be denied). | 306 | * for unknown address family (will be denied). |
305 | */ | 307 | */ |
306 | static int | 308 | static int |
307 | check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, | 309 | check_access (void *cls, |
308 | const struct sockaddr *addr, socklen_t addrlen) | 310 | const struct GNUNET_CONNECTION_Credentials *uc, |
311 | const struct sockaddr *addr, | ||
312 | socklen_t addrlen) | ||
309 | { | 313 | { |
310 | struct LEGACY_SERVICE_Context *sctx = cls; | 314 | struct LEGACY_SERVICE_Context *sctx = cls; |
311 | const struct sockaddr_in *i4; | 315 | const struct sockaddr_in *i4; |
@@ -319,32 +323,33 @@ check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, | |||
319 | i4 = (const struct sockaddr_in *) addr; | 323 | i4 = (const struct sockaddr_in *) addr; |
320 | ret = ((NULL == sctx->v4_allowed) || | 324 | ret = ((NULL == sctx->v4_allowed) || |
321 | (check_ipv4_listed (sctx->v4_allowed, &i4->sin_addr))) && | 325 | (check_ipv4_listed (sctx->v4_allowed, &i4->sin_addr))) && |
322 | ((NULL == sctx->v4_denied) || | 326 | ((NULL == sctx->v4_denied) || |
323 | (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr))); | 327 | (! check_ipv4_listed (sctx->v4_denied, &i4->sin_addr))); |
324 | break; | 328 | break; |
325 | case AF_INET6: | 329 | case AF_INET6: |
326 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); | 330 | GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); |
327 | i6 = (const struct sockaddr_in6 *) addr; | 331 | i6 = (const struct sockaddr_in6 *) addr; |
328 | ret = ((NULL == sctx->v6_allowed) || | 332 | ret = ((NULL == sctx->v6_allowed) || |
329 | (check_ipv6_listed (sctx->v6_allowed, &i6->sin6_addr))) && | 333 | (check_ipv6_listed (sctx->v6_allowed, &i6->sin6_addr))) && |
330 | ((NULL == sctx->v6_denied) || | 334 | ((NULL == sctx->v6_denied) || |
331 | (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); | 335 | (! check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); |
332 | break; | 336 | break; |
333 | #ifndef WINDOWS | 337 | #ifndef WINDOWS |
334 | case AF_UNIX: | 338 | case AF_UNIX: |
335 | ret = GNUNET_OK; /* controlled using file-system ACL now */ | 339 | ret = GNUNET_OK; /* controlled using file-system ACL now */ |
336 | break; | 340 | break; |
337 | #endif | 341 | #endif |
338 | default: | 342 | default: |
339 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Unknown address family %d\n"), | 343 | LOG (GNUNET_ERROR_TYPE_WARNING, |
344 | _ ("Unknown address family %d\n"), | ||
340 | addr->sa_family); | 345 | addr->sa_family); |
341 | return GNUNET_SYSERR; | 346 | return GNUNET_SYSERR; |
342 | } | 347 | } |
343 | if (GNUNET_OK != ret) | 348 | if (GNUNET_OK != ret) |
344 | { | 349 | { |
345 | LOG (GNUNET_ERROR_TYPE_WARNING, | 350 | LOG (GNUNET_ERROR_TYPE_WARNING, |
346 | _("Access from `%s' denied to service `%s'\n"), | 351 | _ ("Access from `%s' denied to service `%s'\n"), |
347 | GNUNET_a2s (addr, addrlen), | 352 | GNUNET_a2s (addr, addrlen), |
348 | sctx->service_name); | 353 | sctx->service_name); |
349 | } | 354 | } |
350 | return ret; | 355 | return ret; |
@@ -363,9 +368,10 @@ get_pid_file_name (struct LEGACY_SERVICE_Context *sctx) | |||
363 | { | 368 | { |
364 | char *pif; | 369 | char *pif; |
365 | 370 | ||
366 | if (GNUNET_OK != | 371 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, |
367 | GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name, | 372 | sctx->service_name, |
368 | "PIDFILE", &pif)) | 373 | "PIDFILE", |
374 | &pif)) | ||
369 | return NULL; | 375 | return NULL; |
370 | return pif; | 376 | return pif; |
371 | } | 377 | } |
@@ -387,7 +393,7 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, | |||
387 | { | 393 | { |
388 | char *opt; | 394 | char *opt; |
389 | 395 | ||
390 | if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option)) | 396 | if (! GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option)) |
391 | { | 397 | { |
392 | *ret = NULL; | 398 | *ret = NULL; |
393 | return GNUNET_OK; | 399 | return GNUNET_OK; |
@@ -395,12 +401,15 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, | |||
395 | GNUNET_break (GNUNET_OK == | 401 | GNUNET_break (GNUNET_OK == |
396 | GNUNET_CONFIGURATION_get_value_string (sctx->cfg, | 402 | GNUNET_CONFIGURATION_get_value_string (sctx->cfg, |
397 | sctx->service_name, | 403 | sctx->service_name, |
398 | option, &opt)); | 404 | option, |
405 | &opt)); | ||
399 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv4_policy (opt))) | 406 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv4_policy (opt))) |
400 | { | 407 | { |
401 | LOG (GNUNET_ERROR_TYPE_WARNING, | 408 | LOG (GNUNET_ERROR_TYPE_WARNING, |
402 | _("Could not parse IPv4 network specification `%s' for `%s:%s'\n"), | 409 | _ ("Could not parse IPv4 network specification `%s' for `%s:%s'\n"), |
403 | opt, sctx->service_name, option); | 410 | opt, |
411 | sctx->service_name, | ||
412 | option); | ||
404 | GNUNET_free (opt); | 413 | GNUNET_free (opt); |
405 | return GNUNET_SYSERR; | 414 | return GNUNET_SYSERR; |
406 | } | 415 | } |
@@ -425,7 +434,7 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, | |||
425 | { | 434 | { |
426 | char *opt; | 435 | char *opt; |
427 | 436 | ||
428 | if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option)) | 437 | if (! GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option)) |
429 | { | 438 | { |
430 | *ret = NULL; | 439 | *ret = NULL; |
431 | return GNUNET_OK; | 440 | return GNUNET_OK; |
@@ -433,12 +442,15 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, | |||
433 | GNUNET_break (GNUNET_OK == | 442 | GNUNET_break (GNUNET_OK == |
434 | GNUNET_CONFIGURATION_get_value_string (sctx->cfg, | 443 | GNUNET_CONFIGURATION_get_value_string (sctx->cfg, |
435 | sctx->service_name, | 444 | sctx->service_name, |
436 | option, &opt)); | 445 | option, |
446 | &opt)); | ||
437 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv6_policy (opt))) | 447 | if (NULL == (*ret = GNUNET_STRINGS_parse_ipv6_policy (opt))) |
438 | { | 448 | { |
439 | LOG (GNUNET_ERROR_TYPE_WARNING, | 449 | LOG (GNUNET_ERROR_TYPE_WARNING, |
440 | _("Could not parse IPv6 network specification `%s' for `%s:%s'\n"), | 450 | _ ("Could not parse IPv6 network specification `%s' for `%s:%s'\n"), |
441 | opt, sctx->service_name, option); | 451 | opt, |
452 | sctx->service_name, | ||
453 | option); | ||
442 | GNUNET_free (opt); | 454 | GNUNET_free (opt); |
443 | return GNUNET_SYSERR; | 455 | return GNUNET_SYSERR; |
444 | } | 456 | } |
@@ -507,10 +519,11 @@ add_unixpath (struct sockaddr **saddrs, | |||
507 | * set to NULL). | 519 | * set to NULL). |
508 | */ | 520 | */ |
509 | int | 521 | int |
510 | LEGACY_SERVICE_get_server_addresses (const char *service_name, | 522 | LEGACY_SERVICE_get_server_addresses ( |
511 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 523 | const char *service_name, |
512 | struct sockaddr ***addrs, | 524 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
513 | socklen_t ** addr_lens) | 525 | struct sockaddr ***addrs, |
526 | socklen_t **addr_lens) | ||
514 | { | 527 | { |
515 | int disablev6; | 528 | int disablev6; |
516 | struct GNUNET_NETWORK_Handle *desc; | 529 | struct GNUNET_NETWORK_Handle *desc; |
@@ -534,8 +547,9 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
534 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6")) | 547 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6")) |
535 | { | 548 | { |
536 | if (GNUNET_SYSERR == | 549 | if (GNUNET_SYSERR == |
537 | (disablev6 = | 550 | (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
538 | GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6"))) | 551 | service_name, |
552 | "DISABLEV6"))) | ||
539 | return GNUNET_SYSERR; | 553 | return GNUNET_SYSERR; |
540 | } | 554 | } |
541 | else | 555 | else |
@@ -554,8 +568,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
554 | return GNUNET_SYSERR; | 568 | return GNUNET_SYSERR; |
555 | } | 569 | } |
556 | LOG (GNUNET_ERROR_TYPE_INFO, | 570 | LOG (GNUNET_ERROR_TYPE_INFO, |
557 | _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"), | 571 | _ ( |
558 | service_name, STRERROR (errno)); | 572 | "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"), |
573 | service_name, | ||
574 | strerror (errno)); | ||
559 | disablev6 = GNUNET_YES; | 575 | disablev6 = GNUNET_YES; |
560 | } | 576 | } |
561 | else | 577 | else |
@@ -568,18 +584,19 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
568 | port = 0; | 584 | port = 0; |
569 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) | 585 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) |
570 | { | 586 | { |
571 | if (GNUNET_OK != | 587 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, |
572 | GNUNET_CONFIGURATION_get_value_number (cfg, service_name, | 588 | service_name, |
573 | "PORT", &port)) | 589 | "PORT", |
590 | &port)) | ||
574 | { | 591 | { |
575 | LOG (GNUNET_ERROR_TYPE_ERROR, | 592 | LOG (GNUNET_ERROR_TYPE_ERROR, |
576 | _("Require valid port number for service `%s' in configuration!\n"), | 593 | _ ("Require valid port number for service `%s' in configuration!\n"), |
577 | service_name); | 594 | service_name); |
578 | } | 595 | } |
579 | if (port > 65535) | 596 | if (port > 65535) |
580 | { | 597 | { |
581 | LOG (GNUNET_ERROR_TYPE_ERROR, | 598 | LOG (GNUNET_ERROR_TYPE_ERROR, |
582 | _("Require valid port number for service `%s' in configuration!\n"), | 599 | _ ("Require valid port number for service `%s' in configuration!\n"), |
583 | service_name); | 600 | service_name); |
584 | return GNUNET_SYSERR; | 601 | return GNUNET_SYSERR; |
585 | } | 602 | } |
@@ -588,8 +605,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
588 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO")) | 605 | if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO")) |
589 | { | 606 | { |
590 | GNUNET_break (GNUNET_OK == | 607 | GNUNET_break (GNUNET_OK == |
591 | GNUNET_CONFIGURATION_get_value_string (cfg, service_name, | 608 | GNUNET_CONFIGURATION_get_value_string (cfg, |
592 | "BINDTO", &hostname)); | 609 | service_name, |
610 | "BINDTO", | ||
611 | &hostname)); | ||
593 | } | 612 | } |
594 | else | 613 | else |
595 | hostname = NULL; | 614 | hostname = NULL; |
@@ -599,9 +618,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
599 | #ifdef AF_UNIX | 618 | #ifdef AF_UNIX |
600 | if ((GNUNET_YES == | 619 | if ((GNUNET_YES == |
601 | GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && | 620 | GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && |
602 | (GNUNET_OK == | 621 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, |
603 | GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", | 622 | service_name, |
604 | &unixpath)) && | 623 | "UNIXPATH", |
624 | &unixpath)) && | ||
605 | (0 < strlen (unixpath))) | 625 | (0 < strlen (unixpath))) |
606 | { | 626 | { |
607 | /* probe UNIX support */ | 627 | /* probe UNIX support */ |
@@ -610,12 +630,11 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
610 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) | 630 | if (strlen (unixpath) >= sizeof (s_un.sun_path)) |
611 | { | 631 | { |
612 | LOG (GNUNET_ERROR_TYPE_WARNING, | 632 | LOG (GNUNET_ERROR_TYPE_WARNING, |
613 | _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath, | 633 | _ ("UNIXPATH `%s' too long, maximum length is %llu\n"), |
634 | unixpath, | ||
614 | (unsigned long long) sizeof (s_un.sun_path)); | 635 | (unsigned long long) sizeof (s_un.sun_path)); |
615 | unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); | 636 | unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); |
616 | LOG (GNUNET_ERROR_TYPE_INFO, | 637 | LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath); |
617 | _("Using `%s' instead\n"), | ||
618 | unixpath); | ||
619 | } | 638 | } |
620 | #ifdef LINUX | 639 | #ifdef LINUX |
621 | abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 640 | abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
@@ -624,12 +643,9 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
624 | if (GNUNET_SYSERR == abstract) | 643 | if (GNUNET_SYSERR == abstract) |
625 | abstract = GNUNET_NO; | 644 | abstract = GNUNET_NO; |
626 | #endif | 645 | #endif |
627 | if ((GNUNET_YES != abstract) | 646 | if ((GNUNET_YES != abstract) && |
628 | && (GNUNET_OK != | 647 | (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath))) |
629 | GNUNET_DISK_directory_create_for_file (unixpath))) | 648 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath); |
630 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
631 | "mkdir", | ||
632 | unixpath); | ||
633 | } | 649 | } |
634 | if (NULL != unixpath) | 650 | if (NULL != unixpath) |
635 | { | 651 | { |
@@ -645,9 +661,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
645 | return GNUNET_SYSERR; | 661 | return GNUNET_SYSERR; |
646 | } | 662 | } |
647 | LOG (GNUNET_ERROR_TYPE_INFO, | 663 | LOG (GNUNET_ERROR_TYPE_INFO, |
648 | _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"), | 664 | _ ( |
665 | "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"), | ||
649 | service_name, | 666 | service_name, |
650 | STRERROR (errno)); | 667 | strerror (errno)); |
651 | GNUNET_free (unixpath); | 668 | GNUNET_free (unixpath); |
652 | unixpath = NULL; | 669 | unixpath = NULL; |
653 | } | 670 | } |
@@ -662,7 +679,8 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
662 | if ((0 == port) && (NULL == unixpath)) | 679 | if ((0 == port) && (NULL == unixpath)) |
663 | { | 680 | { |
664 | LOG (GNUNET_ERROR_TYPE_ERROR, | 681 | LOG (GNUNET_ERROR_TYPE_ERROR, |
665 | _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), | 682 | _ ( |
683 | "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), | ||
666 | service_name); | 684 | service_name); |
667 | GNUNET_free_non_null (hostname); | 685 | GNUNET_free_non_null (hostname); |
668 | return GNUNET_SYSERR; | 686 | return GNUNET_SYSERR; |
@@ -693,7 +711,7 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
693 | (NULL == res)) | 711 | (NULL == res)) |
694 | { | 712 | { |
695 | LOG (GNUNET_ERROR_TYPE_ERROR, | 713 | LOG (GNUNET_ERROR_TYPE_ERROR, |
696 | _("Failed to resolve `%s': %s\n"), | 714 | _ ("Failed to resolve `%s': %s\n"), |
697 | hostname, | 715 | hostname, |
698 | gai_strerror (ret)); | 716 | gai_strerror (ret)); |
699 | GNUNET_free (hostname); | 717 | GNUNET_free (hostname); |
@@ -712,7 +730,7 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
712 | if (0 == i) | 730 | if (0 == i) |
713 | { | 731 | { |
714 | LOG (GNUNET_ERROR_TYPE_ERROR, | 732 | LOG (GNUNET_ERROR_TYPE_ERROR, |
715 | _("Failed to find %saddress for `%s'.\n"), | 733 | _ ("Failed to find %saddress for `%s'.\n"), |
716 | disablev6 ? "IPv4 " : "", | 734 | disablev6 ? "IPv4 " : "", |
717 | hostname); | 735 | hostname); |
718 | freeaddrinfo (res); | 736 | freeaddrinfo (res); |
@@ -738,11 +756,13 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name, | |||
738 | if ((disablev6) && (AF_INET6 == pos->ai_family)) | 756 | if ((disablev6) && (AF_INET6 == pos->ai_family)) |
739 | continue; | 757 | continue; |
740 | if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol)) | 758 | if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol)) |
741 | continue; /* not TCP */ | 759 | continue; /* not TCP */ |
742 | if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype)) | 760 | if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype)) |
743 | continue; /* huh? */ | 761 | continue; /* huh? */ |
744 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n", | 762 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
745 | service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen)); | 763 | "Service `%s' will bind to `%s'\n", |
764 | service_name, | ||
765 | GNUNET_a2s (pos->ai_addr, pos->ai_addrlen)); | ||
746 | if (AF_INET == pos->ai_family) | 766 | if (AF_INET == pos->ai_family) |
747 | { | 767 | { |
748 | GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen); | 768 | GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen); |
@@ -854,7 +874,7 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx) | |||
854 | * to create a GNUnet API that boxes a HANDLE (the way it is done with socks) | 874 | * to create a GNUnet API that boxes a HANDLE (the way it is done with socks) |
855 | */ | 875 | */ |
856 | lsocks_pipe = (HANDLE) strtoul (env_buf, NULL, 10); | 876 | lsocks_pipe = (HANDLE) strtoul (env_buf, NULL, 10); |
857 | if ( (0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe)) | 877 | if ((0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe)) |
858 | return GNUNET_NO; | 878 | return GNUNET_NO; |
859 | fail = 1; | 879 | fail = 1; |
860 | do | 880 | do |
@@ -867,7 +887,7 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx) | |||
867 | if ((0 == ret) || (sizeof (count) != rd) || (0 == count)) | 887 | if ((0 == ret) || (sizeof (count) != rd) || (0 == count)) |
868 | break; | 888 | break; |
869 | sctx->lsocks = | 889 | sctx->lsocks = |
870 | GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (count + 1)); | 890 | GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (count + 1)); |
871 | 891 | ||
872 | fail2 = 1; | 892 | fail2 = 1; |
873 | for (i = 0; i < count; i++) | 893 | for (i = 0; i < count; i++) |
@@ -877,12 +897,17 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx) | |||
877 | SOCKET s; | 897 | SOCKET s; |
878 | 898 | ||
879 | ret = ReadFile (lsocks_pipe, &size, sizeof (size), &rd, NULL); | 899 | ret = ReadFile (lsocks_pipe, &size, sizeof (size), &rd, NULL); |
880 | if ( (0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size) ) | 900 | if ((0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size)) |
881 | break; | 901 | break; |
882 | ret = ReadFile (lsocks_pipe, &pi, sizeof (pi), &rd, NULL); | 902 | ret = ReadFile (lsocks_pipe, &pi, sizeof (pi), &rd, NULL); |
883 | if ( (0 == ret) || (sizeof (pi) != rd)) | 903 | if ((0 == ret) || (sizeof (pi) != rd)) |
884 | break; | 904 | break; |
885 | s = WSASocketA (pi.iAddressFamily, pi.iSocketType, pi.iProtocol, &pi, 0, WSA_FLAG_OVERLAPPED); | 905 | s = WSASocketA (pi.iAddressFamily, |
906 | pi.iSocketType, | ||
907 | pi.iProtocol, | ||
908 | &pi, | ||
909 | 0, | ||
910 | WSA_FLAG_OVERLAPPED); | ||
886 | sctx->lsocks[i] = GNUNET_NETWORK_socket_box_native (s); | 911 | sctx->lsocks[i] = GNUNET_NETWORK_socket_box_native (s); |
887 | if (NULL == sctx->lsocks[i]) | 912 | if (NULL == sctx->lsocks[i]) |
888 | break; | 913 | break; |
@@ -893,15 +918,14 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx) | |||
893 | break; | 918 | break; |
894 | sctx->lsocks[count] = NULL; | 919 | sctx->lsocks[count] = NULL; |
895 | fail = 0; | 920 | fail = 0; |
896 | } | 921 | } while (fail); |
897 | while (fail); | ||
898 | 922 | ||
899 | CloseHandle (lsocks_pipe); | 923 | CloseHandle (lsocks_pipe); |
900 | 924 | ||
901 | if (fail) | 925 | if (fail) |
902 | { | 926 | { |
903 | LOG (GNUNET_ERROR_TYPE_ERROR, | 927 | LOG (GNUNET_ERROR_TYPE_ERROR, |
904 | _("Could not access a pre-bound socket, will try to bind myself\n")); | 928 | _ ("Could not access a pre-bound socket, will try to bind myself\n")); |
905 | for (i = 0; (i < count) && (NULL != sctx->lsocks[i]); i++) | 929 | for (i = 0; (i < count) && (NULL != sctx->lsocks[i]); i++) |
906 | GNUNET_break (0 == GNUNET_NETWORK_socket_close (sctx->lsocks[i])); | 930 | GNUNET_break (0 == GNUNET_NETWORK_socket_close (sctx->lsocks[i])); |
907 | GNUNET_free_non_null (sctx->lsocks); | 931 | GNUNET_free_non_null (sctx->lsocks); |
@@ -943,15 +967,19 @@ setup_service (struct LEGACY_SERVICE_Context *sctx) | |||
943 | int flags; | 967 | int flags; |
944 | #endif | 968 | #endif |
945 | 969 | ||
946 | if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, "TIMEOUT")) | 970 | if (GNUNET_CONFIGURATION_have_value (sctx->cfg, |
971 | sctx->service_name, | ||
972 | "TIMEOUT")) | ||
947 | { | 973 | { |
948 | if (GNUNET_OK != | 974 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (sctx->cfg, |
949 | GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->service_name, | 975 | sctx->service_name, |
950 | "TIMEOUT", &idleout)) | 976 | "TIMEOUT", |
977 | &idleout)) | ||
951 | { | 978 | { |
952 | LOG (GNUNET_ERROR_TYPE_ERROR, | 979 | LOG (GNUNET_ERROR_TYPE_ERROR, |
953 | _("Specified value for `%s' of service `%s' is invalid\n"), | 980 | _ ("Specified value for `%s' of service `%s' is invalid\n"), |
954 | "TIMEOUT", sctx->service_name); | 981 | "TIMEOUT", |
982 | sctx->service_name); | ||
955 | return GNUNET_SYSERR; | 983 | return GNUNET_SYSERR; |
956 | } | 984 | } |
957 | sctx->timeout = idleout; | 985 | sctx->timeout = idleout; |
@@ -959,17 +987,19 @@ setup_service (struct LEGACY_SERVICE_Context *sctx) | |||
959 | else | 987 | else |
960 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 988 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
961 | 989 | ||
962 | if (GNUNET_CONFIGURATION_have_value | 990 | if (GNUNET_CONFIGURATION_have_value (sctx->cfg, |
963 | (sctx->cfg, sctx->service_name, "TOLERANT")) | 991 | sctx->service_name, |
992 | "TOLERANT")) | ||
964 | { | 993 | { |
965 | if (GNUNET_SYSERR == | 994 | if (GNUNET_SYSERR == |
966 | (tolerant = | 995 | (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, |
967 | GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name, | 996 | sctx->service_name, |
968 | "TOLERANT"))) | 997 | "TOLERANT"))) |
969 | { | 998 | { |
970 | LOG (GNUNET_ERROR_TYPE_ERROR, | 999 | LOG (GNUNET_ERROR_TYPE_ERROR, |
971 | _("Specified value for `%s' of service `%s' is invalid\n"), | 1000 | _ ("Specified value for `%s' of service `%s' is invalid\n"), |
972 | "TOLERANT", sctx->service_name); | 1001 | "TOLERANT", |
1002 | sctx->service_name); | ||
973 | return GNUNET_SYSERR; | 1003 | return GNUNET_SYSERR; |
974 | } | 1004 | } |
975 | } | 1005 | } |
@@ -979,11 +1009,11 @@ setup_service (struct LEGACY_SERVICE_Context *sctx) | |||
979 | #ifndef MINGW | 1009 | #ifndef MINGW |
980 | errno = 0; | 1010 | errno = 0; |
981 | if ((NULL != (nfds = getenv ("LISTEN_FDS"))) && | 1011 | if ((NULL != (nfds = getenv ("LISTEN_FDS"))) && |
982 | (1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && | 1012 | (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && |
983 | (cnt + 4 < FD_SETSIZE)) | 1013 | (cnt + 4 < FD_SETSIZE)) |
984 | { | 1014 | { |
985 | sctx->lsocks = | 1015 | sctx->lsocks = |
986 | GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1)); | 1016 | GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1)); |
987 | while (0 < cnt--) | 1017 | while (0 < cnt--) |
988 | { | 1018 | { |
989 | flags = fcntl (3 + cnt, F_GETFD); | 1019 | flags = fcntl (3 + cnt, F_GETFD); |
@@ -992,8 +1022,8 @@ setup_service (struct LEGACY_SERVICE_Context *sctx) | |||
992 | (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) | 1022 | (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) |
993 | { | 1023 | { |
994 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1024 | LOG (GNUNET_ERROR_TYPE_ERROR, |
995 | _ | 1025 | _ ( |
996 | ("Could not access pre-bound socket %u, will try to bind myself\n"), | 1026 | "Could not access pre-bound socket %u, will try to bind myself\n"), |
997 | (unsigned int) 3 + cnt); | 1027 | (unsigned int) 3 + cnt); |
998 | cnt++; | 1028 | cnt++; |
999 | while (sctx->lsocks[cnt] != NULL) | 1029 | while (sctx->lsocks[cnt] != NULL) |
@@ -1014,17 +1044,18 @@ setup_service (struct LEGACY_SERVICE_Context *sctx) | |||
1014 | #endif | 1044 | #endif |
1015 | 1045 | ||
1016 | if ((NULL == sctx->lsocks) && | 1046 | if ((NULL == sctx->lsocks) && |
1017 | (GNUNET_SYSERR == | 1047 | (GNUNET_SYSERR == LEGACY_SERVICE_get_server_addresses (sctx->service_name, |
1018 | LEGACY_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg, | 1048 | sctx->cfg, |
1019 | &sctx->addrs, &sctx->addrlens))) | 1049 | &sctx->addrs, |
1050 | &sctx->addrlens))) | ||
1020 | return GNUNET_SYSERR; | 1051 | return GNUNET_SYSERR; |
1021 | sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; | 1052 | sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; |
1022 | sctx->match_uid = | 1053 | sctx->match_uid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, |
1023 | GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name, | 1054 | sctx->service_name, |
1024 | "UNIX_MATCH_UID"); | 1055 | "UNIX_MATCH_UID"); |
1025 | sctx->match_gid = | 1056 | sctx->match_gid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, |
1026 | GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name, | 1057 | sctx->service_name, |
1027 | "UNIX_MATCH_GID"); | 1058 | "UNIX_MATCH_GID"); |
1028 | process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM"); | 1059 | process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM"); |
1029 | process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM"); | 1060 | process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM"); |
1030 | process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6"); | 1061 | process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6"); |
@@ -1046,9 +1077,10 @@ get_user_name (struct LEGACY_SERVICE_Context *sctx) | |||
1046 | { | 1077 | { |
1047 | char *un; | 1078 | char *un; |
1048 | 1079 | ||
1049 | if (GNUNET_OK != | 1080 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, |
1050 | GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name, | 1081 | sctx->service_name, |
1051 | "USERNAME", &un)) | 1082 | "USERNAME", |
1083 | &un)) | ||
1052 | return NULL; | 1084 | return NULL; |
1053 | return un; | 1085 | return un; |
1054 | } | 1086 | } |
@@ -1071,14 +1103,14 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid) | |||
1071 | int len; | 1103 | int len; |
1072 | 1104 | ||
1073 | if (NULL == (pif = get_pid_file_name (sctx))) | 1105 | if (NULL == (pif = get_pid_file_name (sctx))) |
1074 | return GNUNET_OK; /* no file desired */ | 1106 | return GNUNET_OK; /* no file desired */ |
1075 | user = get_user_name (sctx); | 1107 | user = get_user_name (sctx); |
1076 | rdir = GNUNET_strdup (pif); | 1108 | rdir = GNUNET_strdup (pif); |
1077 | len = strlen (rdir); | 1109 | len = strlen (rdir); |
1078 | while ((len > 0) && (rdir[len] != DIR_SEPARATOR)) | 1110 | while ((len > 0) && (rdir[len] != DIR_SEPARATOR)) |
1079 | len--; | 1111 | len--; |
1080 | rdir[len] = '\0'; | 1112 | rdir[len] = '\0'; |
1081 | if (0 != ACCESS (rdir, F_OK)) | 1113 | if (0 != access (rdir, F_OK)) |
1082 | { | 1114 | { |
1083 | /* we get to create a directory -- and claim it | 1115 | /* we get to create a directory -- and claim it |
1084 | * as ours! */ | 1116 | * as ours! */ |
@@ -1086,7 +1118,7 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid) | |||
1086 | if ((NULL != user) && (0 < strlen (user))) | 1118 | if ((NULL != user) && (0 < strlen (user))) |
1087 | GNUNET_DISK_file_change_owner (rdir, user); | 1119 | GNUNET_DISK_file_change_owner (rdir, user); |
1088 | } | 1120 | } |
1089 | if (0 != ACCESS (rdir, W_OK | X_OK)) | 1121 | if (0 != access (rdir, W_OK | X_OK)) |
1090 | { | 1122 | { |
1091 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", rdir); | 1123 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", rdir); |
1092 | GNUNET_free (rdir); | 1124 | GNUNET_free (rdir); |
@@ -1095,7 +1127,7 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid) | |||
1095 | return GNUNET_SYSERR; | 1127 | return GNUNET_SYSERR; |
1096 | } | 1128 | } |
1097 | GNUNET_free (rdir); | 1129 | GNUNET_free (rdir); |
1098 | pidfd = FOPEN (pif, "w"); | 1130 | pidfd = fopen (pif, "w"); |
1099 | if (NULL == pidfd) | 1131 | if (NULL == pidfd) |
1100 | { | 1132 | { |
1101 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "fopen", pif); | 1133 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "fopen", pif); |
@@ -1103,9 +1135,9 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid) | |||
1103 | GNUNET_free_non_null (user); | 1135 | GNUNET_free_non_null (user); |
1104 | return GNUNET_SYSERR; | 1136 | return GNUNET_SYSERR; |
1105 | } | 1137 | } |
1106 | if (0 > FPRINTF (pidfd, "%u", pid)) | 1138 | if (0 > fprintf (pidfd, "%u", pid)) |
1107 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif); | 1139 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif); |
1108 | GNUNET_break (0 == FCLOSE (pidfd)); | 1140 | GNUNET_break (0 == fclose (pidfd)); |
1109 | if ((NULL != user) && (0 < strlen (user))) | 1141 | if ((NULL != user) && (0 < strlen (user))) |
1110 | GNUNET_DISK_file_change_owner (pif, user); | 1142 | GNUNET_DISK_file_change_owner (pif, user); |
1111 | GNUNET_free_non_null (user); | 1143 | GNUNET_free_non_null (user); |
@@ -1146,29 +1178,37 @@ service_task (void *cls) | |||
1146 | 1178 | ||
1147 | GNUNET_RESOLVER_connect (sctx->cfg); | 1179 | GNUNET_RESOLVER_connect (sctx->cfg); |
1148 | if (NULL != sctx->lsocks) | 1180 | if (NULL != sctx->lsocks) |
1149 | sctx->server | 1181 | sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, |
1150 | = GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, | 1182 | sctx, |
1151 | sctx->timeout, sctx->require_found); | 1183 | sctx->lsocks, |
1184 | sctx->timeout, | ||
1185 | sctx->require_found); | ||
1152 | else | 1186 | else |
1153 | sctx->server | 1187 | sctx->server = GNUNET_SERVER_create (&check_access, |
1154 | = GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, | 1188 | sctx, |
1155 | sctx->timeout, sctx->require_found); | 1189 | sctx->addrs, |
1190 | sctx->addrlens, | ||
1191 | sctx->timeout, | ||
1192 | sctx->require_found); | ||
1156 | if (NULL == sctx->server) | 1193 | if (NULL == sctx->server) |
1157 | { | 1194 | { |
1158 | if (NULL != sctx->addrs) | 1195 | if (NULL != sctx->addrs) |
1159 | for (i = 0; NULL != sctx->addrs[i]; i++) | 1196 | for (i = 0; NULL != sctx->addrs[i]; i++) |
1160 | LOG (GNUNET_ERROR_TYPE_INFO, | 1197 | LOG (GNUNET_ERROR_TYPE_INFO, |
1161 | _("Failed to start `%s' at `%s'\n"), | 1198 | _ ("Failed to start `%s' at `%s'\n"), |
1162 | sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); | 1199 | sctx->service_name, |
1200 | GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); | ||
1163 | sctx->ret = GNUNET_SYSERR; | 1201 | sctx->ret = GNUNET_SYSERR; |
1164 | return; | 1202 | return; |
1165 | } | 1203 | } |
1166 | #ifndef WINDOWS | 1204 | #ifndef WINDOWS |
1167 | if (NULL != sctx->addrs) | 1205 | if (NULL != sctx->addrs) |
1168 | for (i = 0; NULL != sctx->addrs[i]; i++) | 1206 | for (i = 0; NULL != sctx->addrs[i]; i++) |
1169 | if ((AF_UNIX == sctx->addrs[i]->sa_family) | 1207 | if ((AF_UNIX == sctx->addrs[i]->sa_family) && |
1170 | && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0])) | 1208 | ('\0' != ((const struct sockaddr_un *) sctx->addrs[i])->sun_path[0])) |
1171 | GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path, | 1209 | GNUNET_DISK_fix_permissions (((const struct sockaddr_un *) |
1210 | sctx->addrs[i]) | ||
1211 | ->sun_path, | ||
1172 | sctx->match_uid, | 1212 | sctx->match_uid, |
1173 | sctx->match_gid); | 1213 | sctx->match_gid); |
1174 | #endif | 1214 | #endif |
@@ -1178,8 +1218,7 @@ service_task (void *cls) | |||
1178 | { | 1218 | { |
1179 | /* install a task that will kill the server | 1219 | /* install a task that will kill the server |
1180 | * process if the scheduler ever gets a shutdown signal */ | 1220 | * process if the scheduler ever gets a shutdown signal */ |
1181 | sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1221 | sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, sctx); |
1182 | sctx); | ||
1183 | } | 1222 | } |
1184 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); | 1223 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); |
1185 | GNUNET_memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); | 1224 | GNUNET_memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); |
@@ -1189,8 +1228,8 @@ service_task (void *cls) | |||
1189 | GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers); | 1228 | GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers); |
1190 | if (-1 != sctx->ready_confirm_fd) | 1229 | if (-1 != sctx->ready_confirm_fd) |
1191 | { | 1230 | { |
1192 | GNUNET_break (1 == WRITE (sctx->ready_confirm_fd, ".", 1)); | 1231 | GNUNET_break (1 == write (sctx->ready_confirm_fd, ".", 1)); |
1193 | GNUNET_break (0 == CLOSE (sctx->ready_confirm_fd)); | 1232 | GNUNET_break (0 == close (sctx->ready_confirm_fd)); |
1194 | sctx->ready_confirm_fd = -1; | 1233 | sctx->ready_confirm_fd = -1; |
1195 | write_pid_file (sctx, getpid ()); | 1234 | write_pid_file (sctx, getpid ()); |
1196 | } | 1235 | } |
@@ -1199,8 +1238,10 @@ service_task (void *cls) | |||
1199 | i = 0; | 1238 | i = 0; |
1200 | while (NULL != sctx->addrs[i]) | 1239 | while (NULL != sctx->addrs[i]) |
1201 | { | 1240 | { |
1202 | LOG (GNUNET_ERROR_TYPE_INFO, _("Service `%s' runs at %s\n"), | 1241 | LOG (GNUNET_ERROR_TYPE_INFO, |
1203 | sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); | 1242 | _ ("Service `%s' runs at %s\n"), |
1243 | sctx->service_name, | ||
1244 | GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); | ||
1204 | i++; | 1245 | i++; |
1205 | } | 1246 | } |
1206 | } | 1247 | } |
@@ -1222,7 +1263,7 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx) | |||
1222 | int nullfd; | 1263 | int nullfd; |
1223 | int filedes[2]; | 1264 | int filedes[2]; |
1224 | 1265 | ||
1225 | if (0 != PIPE (filedes)) | 1266 | if (0 != pipe (filedes)) |
1226 | { | 1267 | { |
1227 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe"); | 1268 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe"); |
1228 | return GNUNET_SYSERR; | 1269 | return GNUNET_SYSERR; |
@@ -1238,9 +1279,9 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx) | |||
1238 | /* Parent */ | 1279 | /* Parent */ |
1239 | char c; | 1280 | char c; |
1240 | 1281 | ||
1241 | GNUNET_break (0 == CLOSE (filedes[1])); | 1282 | GNUNET_break (0 == close (filedes[1])); |
1242 | c = 'X'; | 1283 | c = 'X'; |
1243 | if (1 != READ (filedes[0], &c, sizeof (char))) | 1284 | if (1 != read (filedes[0], &c, sizeof (char))) |
1244 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "read"); | 1285 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "read"); |
1245 | fflush (stdout); | 1286 | fflush (stdout); |
1246 | switch (c) | 1287 | switch (c) |
@@ -1248,33 +1289,34 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx) | |||
1248 | case '.': | 1289 | case '.': |
1249 | exit (0); | 1290 | exit (0); |
1250 | case 'I': | 1291 | case 'I': |
1251 | LOG (GNUNET_ERROR_TYPE_INFO, _("Service process failed to initialize\n")); | 1292 | LOG (GNUNET_ERROR_TYPE_INFO, |
1293 | _ ("Service process failed to initialize\n")); | ||
1252 | break; | 1294 | break; |
1253 | case 'S': | 1295 | case 'S': |
1254 | LOG (GNUNET_ERROR_TYPE_INFO, | 1296 | LOG (GNUNET_ERROR_TYPE_INFO, |
1255 | _("Service process could not initialize server function\n")); | 1297 | _ ("Service process could not initialize server function\n")); |
1256 | break; | 1298 | break; |
1257 | case 'X': | 1299 | case 'X': |
1258 | LOG (GNUNET_ERROR_TYPE_INFO, | 1300 | LOG (GNUNET_ERROR_TYPE_INFO, |
1259 | _("Service process failed to report status\n")); | 1301 | _ ("Service process failed to report status\n")); |
1260 | break; | 1302 | break; |
1261 | } | 1303 | } |
1262 | exit (1); /* child reported error */ | 1304 | exit (1); /* child reported error */ |
1263 | } | 1305 | } |
1264 | GNUNET_break (0 == CLOSE (0)); | 1306 | GNUNET_break (0 == close (0)); |
1265 | GNUNET_break (0 == CLOSE (1)); | 1307 | GNUNET_break (0 == close (1)); |
1266 | GNUNET_break (0 == CLOSE (filedes[0])); | 1308 | GNUNET_break (0 == close (filedes[0])); |
1267 | nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND); | 1309 | nullfd = open ("/dev/null", O_RDWR | O_APPEND); |
1268 | if (nullfd < 0) | 1310 | if (nullfd < 0) |
1269 | return GNUNET_SYSERR; | 1311 | return GNUNET_SYSERR; |
1270 | /* set stdin/stdout to /dev/null */ | 1312 | /* set stdin/stdout to /dev/null */ |
1271 | if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0)) | 1313 | if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0)) |
1272 | { | 1314 | { |
1273 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2"); | 1315 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2"); |
1274 | (void) CLOSE (nullfd); | 1316 | (void) close (nullfd); |
1275 | return GNUNET_SYSERR; | 1317 | return GNUNET_SYSERR; |
1276 | } | 1318 | } |
1277 | (void) CLOSE (nullfd); | 1319 | (void) close (nullfd); |
1278 | /* Detach from controlling terminal */ | 1320 | /* Detach from controlling terminal */ |
1279 | pid = setsid (); | 1321 | pid = setsid (); |
1280 | if (-1 == pid) | 1322 | if (-1 == pid) |
@@ -1301,7 +1343,7 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx) | |||
1301 | char *user; | 1343 | char *user; |
1302 | 1344 | ||
1303 | if (NULL == (user = get_user_name (sctx))) | 1345 | if (NULL == (user = get_user_name (sctx))) |
1304 | return GNUNET_OK; /* keep */ | 1346 | return GNUNET_OK; /* keep */ |
1305 | #ifndef MINGW | 1347 | #ifndef MINGW |
1306 | struct passwd *pws; | 1348 | struct passwd *pws; |
1307 | 1349 | ||
@@ -1310,8 +1352,9 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx) | |||
1310 | if (NULL == pws) | 1352 | if (NULL == pws) |
1311 | { | 1353 | { |
1312 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1354 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1313 | _("Cannot obtain information about user `%s': %s\n"), user, | 1355 | _ ("Cannot obtain information about user `%s': %s\n"), |
1314 | errno == 0 ? _("No such user") : STRERROR (errno)); | 1356 | user, |
1357 | errno == 0 ? _ ("No such user") : strerror (errno)); | ||
1315 | GNUNET_free (user); | 1358 | GNUNET_free (user); |
1316 | return GNUNET_SYSERR; | 1359 | return GNUNET_SYSERR; |
1317 | } | 1360 | } |
@@ -1324,8 +1367,10 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx) | |||
1324 | if ((0 != setregid (pws->pw_gid, pws->pw_gid)) || | 1367 | if ((0 != setregid (pws->pw_gid, pws->pw_gid)) || |
1325 | (0 != setreuid (pws->pw_uid, pws->pw_uid))) | 1368 | (0 != setreuid (pws->pw_uid, pws->pw_uid))) |
1326 | { | 1369 | { |
1327 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot change user/group to `%s': %s\n"), | 1370 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1328 | user, STRERROR (errno)); | 1371 | _ ("Cannot change user/group to `%s': %s\n"), |
1372 | user, | ||
1373 | strerror (errno)); | ||
1329 | GNUNET_free (user); | 1374 | GNUNET_free (user); |
1330 | return GNUNET_SYSERR; | 1375 | return GNUNET_SYSERR; |
1331 | } | 1376 | } |
@@ -1347,8 +1392,8 @@ pid_file_delete (struct LEGACY_SERVICE_Context *sctx) | |||
1347 | char *pif = get_pid_file_name (sctx); | 1392 | char *pif = get_pid_file_name (sctx); |
1348 | 1393 | ||
1349 | if (NULL == pif) | 1394 | if (NULL == pif) |
1350 | return; /* no PID file */ | 1395 | return; /* no PID file */ |
1351 | if (0 != UNLINK (pif)) | 1396 | if (0 != unlink (pif)) |
1352 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", pif); | 1397 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", pif); |
1353 | GNUNET_free (pif); | 1398 | GNUNET_free (pif); |
1354 | } | 1399 | } |
@@ -1368,13 +1413,19 @@ pid_file_delete (struct LEGACY_SERVICE_Context *sctx) | |||
1368 | * if we shutdown nicely | 1413 | * if we shutdown nicely |
1369 | */ | 1414 | */ |
1370 | int | 1415 | int |
1371 | LEGACY_SERVICE_run (int argc, char *const *argv, | 1416 | LEGACY_SERVICE_run (int argc, |
1417 | char *const *argv, | ||
1372 | const char *service_name, | 1418 | const char *service_name, |
1373 | enum LEGACY_SERVICE_Options options, | 1419 | enum LEGACY_SERVICE_Options options, |
1374 | LEGACY_SERVICE_Main task, | 1420 | LEGACY_SERVICE_Main task, |
1375 | void *task_cls) | 1421 | void *task_cls) |
1376 | { | 1422 | { |
1377 | #define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0) | 1423 | #define HANDLE_ERROR \ |
1424 | do \ | ||
1425 | { \ | ||
1426 | GNUNET_break (0); \ | ||
1427 | goto shutdown; \ | ||
1428 | } while (0) | ||
1378 | 1429 | ||
1379 | int err; | 1430 | int err; |
1380 | int ret; | 1431 | int ret; |
@@ -1391,18 +1442,18 @@ LEGACY_SERVICE_run (int argc, char *const *argv, | |||
1391 | struct GNUNET_CONFIGURATION_Handle *cfg; | 1442 | struct GNUNET_CONFIGURATION_Handle *cfg; |
1392 | const char *xdg; | 1443 | const char *xdg; |
1393 | 1444 | ||
1394 | struct GNUNET_GETOPT_CommandLineOption service_options[] = { | 1445 | struct GNUNET_GETOPT_CommandLineOption service_options[] = |
1395 | GNUNET_GETOPT_option_cfgfile (&opt_cfg_fn), | 1446 | {GNUNET_GETOPT_option_cfgfile (&opt_cfg_fn), |
1396 | GNUNET_GETOPT_option_flag ('d', | 1447 | GNUNET_GETOPT_option_flag ('d', |
1397 | "daemonize", | 1448 | "daemonize", |
1398 | gettext_noop ("do daemonize (detach from terminal)"), | 1449 | gettext_noop ( |
1399 | &do_daemonize), | 1450 | "do daemonize (detach from terminal)"), |
1400 | GNUNET_GETOPT_option_help (NULL), | 1451 | &do_daemonize), |
1401 | GNUNET_GETOPT_option_loglevel (&loglev), | 1452 | GNUNET_GETOPT_option_help (NULL), |
1402 | GNUNET_GETOPT_option_logfile (&logfile), | 1453 | GNUNET_GETOPT_option_loglevel (&loglev), |
1403 | GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION), | 1454 | GNUNET_GETOPT_option_logfile (&logfile), |
1404 | GNUNET_GETOPT_OPTION_END | 1455 | GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION), |
1405 | }; | 1456 | GNUNET_GETOPT_OPTION_END}; |
1406 | err = 1; | 1457 | err = 1; |
1407 | do_daemonize = 0; | 1458 | do_daemonize = 0; |
1408 | logfile = NULL; | 1459 | logfile = NULL; |
@@ -1445,7 +1496,7 @@ LEGACY_SERVICE_run (int argc, char *const *argv, | |||
1445 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, opt_cfg_fn)) | 1496 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, opt_cfg_fn)) |
1446 | { | 1497 | { |
1447 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1498 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1448 | _("Malformed configuration file `%s', exit ...\n"), | 1499 | _ ("Malformed configuration file `%s', exit ...\n"), |
1449 | opt_cfg_fn); | 1500 | opt_cfg_fn); |
1450 | goto shutdown; | 1501 | goto shutdown; |
1451 | } | 1502 | } |
@@ -1455,13 +1506,13 @@ LEGACY_SERVICE_run (int argc, char *const *argv, | |||
1455 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, NULL)) | 1506 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, NULL)) |
1456 | { | 1507 | { |
1457 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1508 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1458 | _("Malformed configuration, exit ...\n")); | 1509 | _ ("Malformed configuration, exit ...\n")); |
1459 | goto shutdown; | 1510 | goto shutdown; |
1460 | } | 1511 | } |
1461 | if (0 != strcmp (opt_cfg_fn, cfg_fn)) | 1512 | if (0 != strcmp (opt_cfg_fn, cfg_fn)) |
1462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1513 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1463 | _("Could not access configuration file `%s'\n"), | 1514 | _ ("Could not access configuration file `%s'\n"), |
1464 | opt_cfg_fn); | 1515 | opt_cfg_fn); |
1465 | } | 1516 | } |
1466 | if (GNUNET_OK != setup_service (&sctx)) | 1517 | if (GNUNET_OK != setup_service (&sctx)) |
1467 | goto shutdown; | 1518 | goto shutdown; |
@@ -1473,12 +1524,14 @@ LEGACY_SERVICE_run (int argc, char *const *argv, | |||
1473 | "Service `%s' runs with configuration from `%s'\n", | 1524 | "Service `%s' runs with configuration from `%s'\n", |
1474 | service_name, | 1525 | service_name, |
1475 | opt_cfg_fn); | 1526 | opt_cfg_fn); |
1476 | if ((GNUNET_OK == | 1527 | if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg, |
1477 | GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING", | 1528 | "TESTING", |
1478 | "SKEW_OFFSET", &skew_offset)) && | 1529 | "SKEW_OFFSET", |
1479 | (GNUNET_OK == | 1530 | &skew_offset)) && |
1480 | GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING", | 1531 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg, |
1481 | "SKEW_VARIANCE", &skew_variance))) | 1532 | "TESTING", |
1533 | "SKEW_VARIANCE", | ||
1534 | &skew_variance))) | ||
1482 | { | 1535 | { |
1483 | clock_offset = skew_offset - skew_variance; | 1536 | clock_offset = skew_offset - skew_variance; |
1484 | GNUNET_TIME_set_offset (clock_offset); | 1537 | GNUNET_TIME_set_offset (clock_offset); |
@@ -1495,21 +1548,21 @@ LEGACY_SERVICE_run (int argc, char *const *argv, | |||
1495 | shutdown: | 1548 | shutdown: |
1496 | if (-1 != sctx.ready_confirm_fd) | 1549 | if (-1 != sctx.ready_confirm_fd) |
1497 | { | 1550 | { |
1498 | if (1 != WRITE (sctx.ready_confirm_fd, err ? "I" : "S", 1)) | 1551 | if (1 != write (sctx.ready_confirm_fd, err ? "I" : "S", 1)) |
1499 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write"); | 1552 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write"); |
1500 | GNUNET_break (0 == CLOSE (sctx.ready_confirm_fd)); | 1553 | GNUNET_break (0 == close (sctx.ready_confirm_fd)); |
1501 | } | 1554 | } |
1502 | #if HAVE_MALLINFO | 1555 | #if HAVE_MALLINFO |
1503 | { | 1556 | { |
1504 | char *counter; | 1557 | char *counter; |
1505 | 1558 | ||
1506 | if ( (GNUNET_YES == | 1559 | if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sctx.cfg, |
1507 | GNUNET_CONFIGURATION_have_value (sctx.cfg, service_name, | 1560 | service_name, |
1508 | "GAUGER_HEAP")) && | 1561 | "GAUGER_HEAP")) && |
1509 | (GNUNET_OK == | 1562 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sctx.cfg, |
1510 | GNUNET_CONFIGURATION_get_value_string (sctx.cfg, service_name, | 1563 | service_name, |
1511 | "GAUGER_HEAP", | 1564 | "GAUGER_HEAP", |
1512 | &counter)) ) | 1565 | &counter))) |
1513 | { | 1566 | { |
1514 | struct mallinfo mi; | 1567 | struct mallinfo mi; |
1515 | 1568 | ||
@@ -1551,13 +1604,13 @@ shutdown: | |||
1551 | struct LEGACY_SERVICE_Context * | 1604 | struct LEGACY_SERVICE_Context * |
1552 | LEGACY_SERVICE_start (const char *service_name, | 1605 | LEGACY_SERVICE_start (const char *service_name, |
1553 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1606 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1554 | enum LEGACY_SERVICE_Options options) | 1607 | enum LEGACY_SERVICE_Options options) |
1555 | { | 1608 | { |
1556 | int i; | 1609 | int i; |
1557 | struct LEGACY_SERVICE_Context *sctx; | 1610 | struct LEGACY_SERVICE_Context *sctx; |
1558 | 1611 | ||
1559 | sctx = GNUNET_new (struct LEGACY_SERVICE_Context); | 1612 | sctx = GNUNET_new (struct LEGACY_SERVICE_Context); |
1560 | sctx->ready_confirm_fd = -1; /* no daemonizing */ | 1613 | sctx->ready_confirm_fd = -1; /* no daemonizing */ |
1561 | sctx->ret = GNUNET_OK; | 1614 | sctx->ret = GNUNET_OK; |
1562 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1615 | sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
1563 | sctx->service_name = service_name; | 1616 | sctx->service_name = service_name; |
@@ -1571,13 +1624,18 @@ LEGACY_SERVICE_start (const char *service_name, | |||
1571 | return NULL; | 1624 | return NULL; |
1572 | } | 1625 | } |
1573 | if (NULL != sctx->lsocks) | 1626 | if (NULL != sctx->lsocks) |
1574 | sctx->server = | 1627 | sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, |
1575 | GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, | 1628 | sctx, |
1576 | sctx->timeout, sctx->require_found); | 1629 | sctx->lsocks, |
1630 | sctx->timeout, | ||
1631 | sctx->require_found); | ||
1577 | else | 1632 | else |
1578 | sctx->server = | 1633 | sctx->server = GNUNET_SERVER_create (&check_access, |
1579 | GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, | 1634 | sctx, |
1580 | sctx->timeout, sctx->require_found); | 1635 | sctx->addrs, |
1636 | sctx->addrlens, | ||
1637 | sctx->timeout, | ||
1638 | sctx->require_found); | ||
1581 | 1639 | ||
1582 | if (NULL == sctx->server) | 1640 | if (NULL == sctx->server) |
1583 | { | 1641 | { |
@@ -1587,9 +1645,11 @@ LEGACY_SERVICE_start (const char *service_name, | |||
1587 | #ifndef WINDOWS | 1645 | #ifndef WINDOWS |
1588 | if (NULL != sctx->addrs) | 1646 | if (NULL != sctx->addrs) |
1589 | for (i = 0; NULL != sctx->addrs[i]; i++) | 1647 | for (i = 0; NULL != sctx->addrs[i]; i++) |
1590 | if ((AF_UNIX == sctx->addrs[i]->sa_family) | 1648 | if ((AF_UNIX == sctx->addrs[i]->sa_family) && |
1591 | && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0])) | 1649 | ('\0' != ((const struct sockaddr_un *) sctx->addrs[i])->sun_path[0])) |
1592 | GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path, | 1650 | GNUNET_DISK_fix_permissions (((const struct sockaddr_un *) |
1651 | sctx->addrs[i]) | ||
1652 | ->sun_path, | ||
1593 | sctx->match_uid, | 1653 | sctx->match_uid, |
1594 | sctx->match_gid); | 1654 | sctx->match_gid); |
1595 | #endif | 1655 | #endif |
@@ -1624,7 +1684,7 @@ LEGACY_SERVICE_get_server (struct LEGACY_SERVICE_Context *ctx) | |||
1624 | * @return NULL if there are no listen sockets, otherwise NULL-terminated | 1684 | * @return NULL if there are no listen sockets, otherwise NULL-terminated |
1625 | * array of listen sockets. | 1685 | * array of listen sockets. |
1626 | */ | 1686 | */ |
1627 | struct GNUNET_NETWORK_Handle *const* | 1687 | struct GNUNET_NETWORK_Handle *const * |
1628 | LEGACY_SERVICE_get_listen_sockets (struct LEGACY_SERVICE_Context *ctx) | 1688 | LEGACY_SERVICE_get_listen_sockets (struct LEGACY_SERVICE_Context *ctx) |
1629 | { | 1689 | { |
1630 | return ctx->lsocks; | 1690 | return ctx->lsocks; |
@@ -1645,13 +1705,13 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx) | |||
1645 | { | 1705 | { |
1646 | char *counter; | 1706 | char *counter; |
1647 | 1707 | ||
1648 | if ( (GNUNET_YES == | 1708 | if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sctx->cfg, |
1649 | GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, | 1709 | sctx->service_name, |
1650 | "GAUGER_HEAP")) && | 1710 | "GAUGER_HEAP")) && |
1651 | (GNUNET_OK == | 1711 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sctx->cfg, |
1652 | GNUNET_CONFIGURATION_get_value_string (sctx->cfg, sctx->service_name, | 1712 | sctx->service_name, |
1653 | "GAUGER_HEAP", | 1713 | "GAUGER_HEAP", |
1654 | &counter)) ) | 1714 | &counter))) |
1655 | { | 1715 | { |
1656 | struct mallinfo mi; | 1716 | struct mallinfo mi; |
1657 | 1717 | ||