aboutsummaryrefslogtreecommitdiff
path: root/src/arm/gnunet-service-arm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm/gnunet-service-arm.c')
-rw-r--r--src/arm/gnunet-service-arm.c210
1 files changed, 135 insertions, 75 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index bf5982d10..bc138e6fc 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2011, 2015, 2016 GNUnet e.V. 3 Copyright (C) 2009-2011, 2015, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
@@ -237,6 +235,11 @@ static struct GNUNET_DISK_PipeHandle *sigpipe;
237static int in_shutdown; 235static int in_shutdown;
238 236
239/** 237/**
238 * Return value from main
239 */
240static int global_ret;
241
242/**
240 * Are we starting user services? 243 * Are we starting user services?
241 */ 244 */
242static int start_user = GNUNET_YES; 245static int start_user = GNUNET_YES;
@@ -348,11 +351,15 @@ get_server_addresses (const char *service_name,
348 *addrs = NULL; 351 *addrs = NULL;
349 *addr_lens = NULL; 352 *addr_lens = NULL;
350 desc = NULL; 353 desc = NULL;
351 if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6")) 354 if (GNUNET_CONFIGURATION_have_value (cfg,
355 service_name,
356 "DISABLEV6"))
352 { 357 {
353 if (GNUNET_SYSERR == 358 if (GNUNET_SYSERR ==
354 (disablev6 = 359 (disablev6 =
355 GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6"))) 360 GNUNET_CONFIGURATION_get_value_yesno (cfg,
361 service_name,
362 "DISABLEV6")))
356 return GNUNET_SYSERR; 363 return GNUNET_SYSERR;
357 } 364 }
358 else 365 else
@@ -361,18 +368,24 @@ get_server_addresses (const char *service_name,
361 if (! disablev6) 368 if (! disablev6)
362 { 369 {
363 /* probe IPv6 support */ 370 /* probe IPv6 support */
364 desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); 371 desc = GNUNET_NETWORK_socket_create (PF_INET6,
372 SOCK_STREAM,
373 0);
365 if (NULL == desc) 374 if (NULL == desc)
366 { 375 {
367 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) || 376 if ( (ENOBUFS == errno) ||
368 (EACCES == errno)) 377 (ENOMEM == errno) ||
378 (ENFILE == errno) ||
379 (EACCES == errno) )
369 { 380 {
370 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket"); 381 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
382 "socket");
371 return GNUNET_SYSERR; 383 return GNUNET_SYSERR;
372 } 384 }
373 LOG (GNUNET_ERROR_TYPE_INFO, 385 LOG (GNUNET_ERROR_TYPE_INFO,
374 _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"), 386 _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
375 service_name, STRERROR (errno)); 387 service_name,
388 STRERROR (errno));
376 disablev6 = GNUNET_YES; 389 disablev6 = GNUNET_YES;
377 } 390 }
378 else 391 else
@@ -383,11 +396,15 @@ get_server_addresses (const char *service_name,
383 } 396 }
384 397
385 port = 0; 398 port = 0;
386 if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) 399 if (GNUNET_CONFIGURATION_have_value (cfg,
400 service_name,
401 "PORT"))
387 { 402 {
388 if (GNUNET_OK != 403 if (GNUNET_OK !=
389 GNUNET_CONFIGURATION_get_value_number (cfg, service_name, 404 GNUNET_CONFIGURATION_get_value_number (cfg,
390 "PORT", &port)) 405 service_name,
406 "PORT",
407 &port))
391 { 408 {
392 LOG (GNUNET_ERROR_TYPE_ERROR, 409 LOG (GNUNET_ERROR_TYPE_ERROR,
393 _("Require valid port number for service `%s' in configuration!\n"), 410 _("Require valid port number for service `%s' in configuration!\n"),
@@ -402,11 +419,15 @@ get_server_addresses (const char *service_name,
402 } 419 }
403 } 420 }
404 421
405 if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO")) 422 if (GNUNET_CONFIGURATION_have_value (cfg,
423 service_name,
424 "BINDTO"))
406 { 425 {
407 GNUNET_break (GNUNET_OK == 426 GNUNET_break (GNUNET_OK ==
408 GNUNET_CONFIGURATION_get_value_string (cfg, service_name, 427 GNUNET_CONFIGURATION_get_value_string (cfg,
409 "BINDTO", &hostname)); 428 service_name,
429 "BINDTO",
430 &hostname));
410 } 431 }
411 else 432 else
412 hostname = NULL; 433 hostname = NULL;
@@ -415,10 +436,14 @@ get_server_addresses (const char *service_name,
415 abstract = GNUNET_NO; 436 abstract = GNUNET_NO;
416#ifdef AF_UNIX 437#ifdef AF_UNIX
417 if ((GNUNET_YES == 438 if ((GNUNET_YES ==
418 GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) && 439 GNUNET_CONFIGURATION_have_value (cfg,
440 service_name,
441 "UNIXPATH")) &&
419 (GNUNET_OK == 442 (GNUNET_OK ==
420 GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH", 443 GNUNET_CONFIGURATION_get_value_filename (cfg,
421 &unixpath)) && 444 service_name,
445 "UNIXPATH",
446 &unixpath)) &&
422 (0 < strlen (unixpath))) 447 (0 < strlen (unixpath)))
423 { 448 {
424 /* probe UNIX support */ 449 /* probe UNIX support */
@@ -427,7 +452,8 @@ get_server_addresses (const char *service_name,
427 if (strlen (unixpath) >= sizeof (s_un.sun_path)) 452 if (strlen (unixpath) >= sizeof (s_un.sun_path))
428 { 453 {
429 LOG (GNUNET_ERROR_TYPE_WARNING, 454 LOG (GNUNET_ERROR_TYPE_WARNING,
430 _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath, 455 _("UNIXPATH `%s' too long, maximum length is %llu\n"),
456 unixpath,
431 (unsigned long long) sizeof (s_un.sun_path)); 457 (unsigned long long) sizeof (s_un.sun_path));
432 unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); 458 unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
433 LOG (GNUNET_ERROR_TYPE_INFO, 459 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -441,9 +467,9 @@ get_server_addresses (const char *service_name,
441 if (GNUNET_SYSERR == abstract) 467 if (GNUNET_SYSERR == abstract)
442 abstract = GNUNET_NO; 468 abstract = GNUNET_NO;
443#endif 469#endif
444 if ((GNUNET_YES != abstract) 470 if ( (GNUNET_YES != abstract) &&
445 && (GNUNET_OK != 471 (GNUNET_OK !=
446 GNUNET_DISK_directory_create_for_file (unixpath))) 472 GNUNET_DISK_directory_create_for_file (unixpath)) )
447 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 473 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
448 "mkdir", 474 "mkdir",
449 unixpath); 475 unixpath);
@@ -453,8 +479,10 @@ get_server_addresses (const char *service_name,
453 desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); 479 desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
454 if (NULL == desc) 480 if (NULL == desc)
455 { 481 {
456 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) || 482 if ( (ENOBUFS == errno) ||
457 (EACCES == errno)) 483 (ENOMEM == errno) ||
484 (ENFILE == errno) ||
485 (EACCES == errno) )
458 { 486 {
459 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket"); 487 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
460 GNUNET_free_non_null (hostname); 488 GNUNET_free_non_null (hostname);
@@ -476,19 +504,29 @@ get_server_addresses (const char *service_name,
476 } 504 }
477#endif 505#endif
478 506
479 if ((0 == port) && (NULL == unixpath)) 507 if ( (0 == port) &&
508 (NULL == unixpath) )
480 { 509 {
481 LOG (GNUNET_ERROR_TYPE_ERROR, 510 if (GNUNET_YES ==
482 _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), 511 GNUNET_CONFIGURATION_get_value_yesno (cfg,
483 service_name); 512 service_name,
513 "START_ON_DEMAND"))
514 LOG (GNUNET_ERROR_TYPE_ERROR,
515 _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
516 service_name);
484 GNUNET_free_non_null (hostname); 517 GNUNET_free_non_null (hostname);
485 return GNUNET_SYSERR; 518 return GNUNET_SYSERR;
486 } 519 }
487 if (0 == port) 520 if (0 == port)
488 { 521 {
489 saddrs = GNUNET_malloc (2 * sizeof (struct sockaddr *)); 522 saddrs = GNUNET_new_array (2,
490 saddrlens = GNUNET_malloc (2 * sizeof (socklen_t)); 523 struct sockaddr *);
491 add_unixpath (saddrs, saddrlens, unixpath, abstract); 524 saddrlens = GNUNET_new_array (2,
525 socklen_t);
526 add_unixpath (saddrs,
527 saddrlens,
528 unixpath,
529 abstract);
492 GNUNET_free_non_null (unixpath); 530 GNUNET_free_non_null (unixpath);
493 GNUNET_free_non_null (hostname); 531 GNUNET_free_non_null (hostname);
494 *addrs = saddrs; 532 *addrs = saddrs;
@@ -506,7 +544,10 @@ get_server_addresses (const char *service_name,
506 if (disablev6) 544 if (disablev6)
507 hints.ai_family = AF_INET; 545 hints.ai_family = AF_INET;
508 hints.ai_protocol = IPPROTO_TCP; 546 hints.ai_protocol = IPPROTO_TCP;
509 if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) || 547 if ((0 != (ret = getaddrinfo (hostname,
548 NULL,
549 &hints,
550 &res))) ||
510 (NULL == res)) 551 (NULL == res))
511 { 552 {
512 LOG (GNUNET_ERROR_TYPE_ERROR, 553 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -540,8 +581,10 @@ get_server_addresses (const char *service_name,
540 resi = i; 581 resi = i;
541 if (NULL != unixpath) 582 if (NULL != unixpath)
542 resi++; 583 resi++;
543 saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *)); 584 saddrs = GNUNET_new_array (resi + 1,
544 saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t)); 585 struct sockaddr *);
586 saddrlens = GNUNET_new_array (resi + 1,
587 socklen_t);
545 i = 0; 588 i = 0;
546 if (NULL != unixpath) 589 if (NULL != unixpath)
547 { 590 {
@@ -593,8 +636,10 @@ get_server_addresses (const char *service_name,
593 if (NULL != unixpath) 636 if (NULL != unixpath)
594 resi++; 637 resi++;
595 i = 0; 638 i = 0;
596 saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *)); 639 saddrs = GNUNET_new_array (resi + 1,
597 saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t)); 640 struct sockaddr *);
641 saddrlens = GNUNET_new_array (resi + 1,
642 socklen_t);
598 if (NULL != unixpath) 643 if (NULL != unixpath)
599 { 644 {
600 add_unixpath (saddrs, saddrlens, unixpath, abstract); 645 add_unixpath (saddrs, saddrlens, unixpath, abstract);
@@ -614,12 +659,17 @@ get_server_addresses (const char *service_name,
614 resi = 2; 659 resi = 2;
615 if (NULL != unixpath) 660 if (NULL != unixpath)
616 resi++; 661 resi++;
617 saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *)); 662 saddrs = GNUNET_new_array (resi + 1,
618 saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t)); 663 struct sockaddr *);
664 saddrlens = GNUNET_new_array (resi + 1,
665 socklen_t);
619 i = 0; 666 i = 0;
620 if (NULL != unixpath) 667 if (NULL != unixpath)
621 { 668 {
622 add_unixpath (saddrs, saddrlens, unixpath, abstract); 669 add_unixpath (saddrs,
670 saddrlens,
671 unixpath,
672 abstract);
623 i++; 673 i++;
624 } 674 }
625 saddrlens[i] = sizeof (struct sockaddr_in6); 675 saddrlens[i] = sizeof (struct sockaddr_in6);
@@ -665,6 +715,7 @@ signal_result (struct GNUNET_SERVICE_Client *client,
665 struct GNUNET_MQ_Envelope *env; 715 struct GNUNET_MQ_Envelope *env;
666 struct GNUNET_ARM_ResultMessage *msg; 716 struct GNUNET_ARM_ResultMessage *msg;
667 717
718 (void) name;
668 env = GNUNET_MQ_msg (msg, 719 env = GNUNET_MQ_msg (msg,
669 GNUNET_MESSAGE_TYPE_ARM_RESULT); 720 GNUNET_MESSAGE_TYPE_ARM_RESULT);
670 msg->result = htonl (result); 721 msg->result = htonl (result);
@@ -1186,6 +1237,7 @@ check_start (void *cls,
1186 uint16_t size; 1237 uint16_t size;
1187 const char *servicename; 1238 const char *servicename;
1188 1239
1240 (void) cls;
1189 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message); 1241 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
1190 servicename = (const char *) &amsg[1]; 1242 servicename = (const char *) &amsg[1];
1191 if ( (0 == size) || 1243 if ( (0 == size) ||
@@ -1256,6 +1308,7 @@ handle_start (void *cls,
1256static void 1308static void
1257trigger_shutdown (void *cls) 1309trigger_shutdown (void *cls)
1258{ 1310{
1311 (void) cls;
1259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1260 "Triggering shutdown\n"); 1313 "Triggering shutdown\n");
1261 GNUNET_SCHEDULER_shutdown (); 1314 GNUNET_SCHEDULER_shutdown ();
@@ -1277,6 +1330,7 @@ check_stop (void *cls,
1277 uint16_t size; 1330 uint16_t size;
1278 const char *servicename; 1331 const char *servicename;
1279 1332
1333 (void) cls;
1280 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message); 1334 size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
1281 servicename = (const char *) &amsg[1]; 1335 servicename = (const char *) &amsg[1];
1282 if ( (0 == size) || 1336 if ( (0 == size) ||
@@ -1453,6 +1507,7 @@ handle_test (void *cls,
1453 struct GNUNET_MQ_Envelope *env; 1507 struct GNUNET_MQ_Envelope *env;
1454 struct GNUNET_MessageHeader *msg; 1508 struct GNUNET_MessageHeader *msg;
1455 1509
1510 (void) message;
1456 env = GNUNET_MQ_msg (msg, 1511 env = GNUNET_MQ_msg (msg,
1457 GNUNET_MESSAGE_TYPE_ARM_TEST); 1512 GNUNET_MESSAGE_TYPE_ARM_TEST);
1458 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 1513 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
@@ -1500,7 +1555,7 @@ list_count (struct ServiceList *running_head)
1500 struct ServiceList *i; 1555 struct ServiceList *i;
1501 unsigned int res; 1556 unsigned int res;
1502 1557
1503 for (res = 0, i = running_head; i; i = i->next, res++) 1558 for (res = 0, i = running_head; NULL != i; i = i->next, res++)
1504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1505 "%s\n", 1560 "%s\n",
1506 i->name); 1561 i->name);
@@ -1520,6 +1575,7 @@ shutdown_task (void *cls)
1520 struct ServiceList *nxt; 1575 struct ServiceList *nxt;
1521 struct ServiceListeningInfo *sli; 1576 struct ServiceListeningInfo *sli;
1522 1577
1578 (void) cls;
1523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1579 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1524 "First shutdown phase\n"); 1580 "First shutdown phase\n");
1525 if (NULL != child_restart_task) 1581 if (NULL != child_restart_task)
@@ -1591,6 +1647,7 @@ delayed_restart_task (void *cls)
1591 struct GNUNET_TIME_Relative lowestRestartDelay; 1647 struct GNUNET_TIME_Relative lowestRestartDelay;
1592 struct ServiceListeningInfo *sli; 1648 struct ServiceListeningInfo *sli;
1593 1649
1650 (void) cls;
1594 child_restart_task = NULL; 1651 child_restart_task = NULL;
1595 GNUNET_assert (GNUNET_NO == in_shutdown); 1652 GNUNET_assert (GNUNET_NO == in_shutdown);
1596 lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL; 1653 lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1658,7 +1715,7 @@ delayed_restart_task (void *cls)
1658 * Task triggered whenever we receive a SIGCHLD (child 1715 * Task triggered whenever we receive a SIGCHLD (child
1659 * process died). 1716 * process died).
1660 * 1717 *
1661 * @param cls closure, NULL if we need to self-restart 1718 * @param cls closure, NULL
1662 */ 1719 */
1663static void 1720static void
1664maint_child_death (void *cls) 1721maint_child_death (void *cls)
@@ -1674,6 +1731,7 @@ maint_child_death (void *cls)
1674 unsigned long statusCode; 1731 unsigned long statusCode;
1675 const struct GNUNET_DISK_FileHandle *pr; 1732 const struct GNUNET_DISK_FileHandle *pr;
1676 1733
1734 (void) cls;
1677 pr = GNUNET_DISK_pipe_handle (sigpipe, 1735 pr = GNUNET_DISK_pipe_handle (sigpipe,
1678 GNUNET_DISK_PIPE_END_READ); 1736 GNUNET_DISK_PIPE_END_READ);
1679 child_death_task = NULL; 1737 child_death_task = NULL;
@@ -1916,6 +1974,7 @@ setup_service (void *cls,
1916 socklen_t *addr_lens; 1974 socklen_t *addr_lens;
1917 int ret; 1975 int ret;
1918 1976
1977 (void) cls;
1919 if (0 == strcasecmp (section, 1978 if (0 == strcasecmp (section,
1920 "arm")) 1979 "arm"))
1921 return; 1980 return;
@@ -1931,11 +1990,11 @@ setup_service (void *cls,
1931 if ((GNUNET_YES == 1990 if ((GNUNET_YES ==
1932 GNUNET_CONFIGURATION_have_value (cfg, 1991 GNUNET_CONFIGURATION_have_value (cfg,
1933 section, 1992 section,
1934 "USER_SERVICE")) && 1993 "RUN_PER_USER")) &&
1935 (GNUNET_YES == 1994 (GNUNET_YES ==
1936 GNUNET_CONFIGURATION_get_value_yesno (cfg, 1995 GNUNET_CONFIGURATION_get_value_yesno (cfg,
1937 section, 1996 section,
1938 "USER_SERVICE"))) 1997 "RUN_PER_USER")))
1939 { 1998 {
1940 if (GNUNET_NO == start_user) 1999 if (GNUNET_NO == start_user)
1941 { 2000 {
@@ -2003,7 +2062,7 @@ setup_service (void *cls,
2003 if (GNUNET_YES == 2062 if (GNUNET_YES ==
2004 GNUNET_CONFIGURATION_get_value_yesno (cfg, 2063 GNUNET_CONFIGURATION_get_value_yesno (cfg,
2005 section, 2064 section,
2006 "FORCESTART")) 2065 "IMMEDIATE_START"))
2007 { 2066 {
2008 sl->force_start = GNUNET_YES; 2067 sl->force_start = GNUNET_YES;
2009 if (GNUNET_YES == 2068 if (GNUNET_YES ==
@@ -2017,7 +2076,7 @@ setup_service (void *cls,
2017 if (GNUNET_YES != 2076 if (GNUNET_YES !=
2018 GNUNET_CONFIGURATION_get_value_yesno (cfg, 2077 GNUNET_CONFIGURATION_get_value_yesno (cfg,
2019 section, 2078 section,
2020 "AUTOSTART")) 2079 "START_ON_DEMAND"))
2021 return; 2080 return;
2022 } 2081 }
2023 if (0 >= (ret = get_server_addresses (section, 2082 if (0 >= (ret = get_server_addresses (section,
@@ -2026,7 +2085,7 @@ setup_service (void *cls,
2026 &addr_lens))) 2085 &addr_lens)))
2027 return; 2086 return;
2028 /* this will free (or capture) addrs[i] */ 2087 /* this will free (or capture) addrs[i] */
2029 for (unsigned int i = 0; i < ret; i++) 2088 for (unsigned int i = 0; i < (unsigned int) ret; i++)
2030 create_listen_socket (addrs[i], 2089 create_listen_socket (addrs[i],
2031 addr_lens[i], 2090 addr_lens[i],
2032 sl); 2091 sl);
@@ -2051,6 +2110,8 @@ client_connect_cb (void *cls,
2051 /* All clients are considered to be of the "monitor" kind 2110 /* All clients are considered to be of the "monitor" kind
2052 * (that is, they don't affect ARM shutdown). 2111 * (that is, they don't affect ARM shutdown).
2053 */ 2112 */
2113 (void) cls;
2114 (void) mq;
2054 GNUNET_SERVICE_client_mark_monitor (client); 2115 GNUNET_SERVICE_client_mark_monitor (client);
2055 return client; 2116 return client;
2056} 2117}
@@ -2068,11 +2129,9 @@ client_disconnect_cb (void *cls,
2068 struct GNUNET_SERVICE_Client *client, 2129 struct GNUNET_SERVICE_Client *client,
2069 void *app_ctx) 2130 void *app_ctx)
2070{ 2131{
2071 struct ServiceList *sl; 2132 (void) cls;
2072
2073 GNUNET_assert (client == app_ctx); 2133 GNUNET_assert (client == app_ctx);
2074 2134 for (struct ServiceList *sl = running_head; NULL != sl; sl = sl->next)
2075 for (sl = running_head; NULL != sl; sl = sl->next)
2076 if (sl->killing_client == client) 2135 if (sl->killing_client == client)
2077 sl->killing_client = NULL; 2136 sl->killing_client = NULL;
2078} 2137}
@@ -2092,6 +2151,7 @@ handle_monitor (void *cls,
2092{ 2151{
2093 struct GNUNET_SERVICE_Client *client = cls; 2152 struct GNUNET_SERVICE_Client *client = cls;
2094 2153
2154 (void) message;
2095 /* FIXME: might want to start by letting monitor know about 2155 /* FIXME: might want to start by letting monitor know about
2096 services that are already running */ 2156 services that are already running */
2097 /* Removal is handled by the server implementation, internally. */ 2157 /* Removal is handled by the server implementation, internally. */
@@ -2107,7 +2167,7 @@ handle_monitor (void *cls,
2107/** 2167/**
2108 * Process arm requests. 2168 * Process arm requests.
2109 * 2169 *
2110 * @param cls closure 2170 * @param cls closure, NULL
2111 * @param serv the initialized service 2171 * @param serv the initialized service
2112 * @param c configuration to use 2172 * @param c configuration to use
2113 */ 2173 */
@@ -2118,6 +2178,7 @@ run (void *cls,
2118{ 2178{
2119 struct ServiceList *sl; 2179 struct ServiceList *sl;
2120 2180
2181 (void) cls;
2121 cfg = c; 2182 cfg = c;
2122 service = serv; 2183 service = serv;
2123 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 2184 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
@@ -2163,21 +2224,20 @@ run (void *cls,
2163 else 2224 else
2164 final_option = GNUNET_CONFIGURATION_expand_dollar (cfg, 2225 final_option = GNUNET_CONFIGURATION_expand_dollar (cfg,
2165 final_option); 2226 final_option);
2166 if (GNUNET_YES == 2227 start_user = GNUNET_CONFIGURATION_get_value_yesno (cfg,
2167 GNUNET_CONFIGURATION_get_value_yesno (cfg,
2168 "ARM", 2228 "ARM",
2169 "USER_ONLY")) 2229 "START_USER_SERVICES");
2170 { 2230 start_system = GNUNET_CONFIGURATION_get_value_yesno (cfg,
2171 GNUNET_break (GNUNET_YES == start_user);
2172 start_system = GNUNET_NO;
2173 }
2174 if (GNUNET_YES ==
2175 GNUNET_CONFIGURATION_get_value_yesno (cfg,
2176 "ARM", 2231 "ARM",
2177 "SYSTEM_ONLY")) 2232 "START_SYSTEM_SERVICES");
2233 if ( (GNUNET_NO == start_user) &&
2234 (GNUNET_NO == start_system) )
2178 { 2235 {
2179 GNUNET_break (GNUNET_YES == start_system); 2236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2180 start_user = GNUNET_NO; 2237 "Please configure either START_USER_SERVICES or START_SYSTEM_SERVICES or both.\n");
2238 GNUNET_SCHEDULER_shutdown ();
2239 global_ret = 1;
2240 return;
2181 } 2241 }
2182 GNUNET_CONFIGURATION_iterate_sections (cfg, 2242 GNUNET_CONFIGURATION_iterate_sections (cfg,
2183 &setup_service, 2243 &setup_service,
@@ -2204,7 +2264,6 @@ int
2204main (int argc, 2264main (int argc,
2205 char *const *argv) 2265 char *const *argv)
2206{ 2266{
2207 int ret;
2208 struct GNUNET_SIGNAL_Context *shc_chld; 2267 struct GNUNET_SIGNAL_Context *shc_chld;
2209 struct GNUNET_MQ_MessageHandler handlers[] = { 2268 struct GNUNET_MQ_MessageHandler handlers[] = {
2210 GNUNET_MQ_hd_var_size (start, 2269 GNUNET_MQ_hd_var_size (start,
@@ -2238,7 +2297,7 @@ main (int argc,
2238 shc_chld = 2297 shc_chld =
2239 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, 2298 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
2240 &sighandler_child_death); 2299 &sighandler_child_death);
2241 ret = GNUNET_SERVICE_run_ (argc, 2300 if ( GNUNET_OK != GNUNET_SERVICE_run_ (argc,
2242 argv, 2301 argv,
2243 "arm", 2302 "arm",
2244 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, 2303 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN,
@@ -2246,7 +2305,8 @@ main (int argc,
2246 &client_connect_cb, 2305 &client_connect_cb,
2247 &client_disconnect_cb, 2306 &client_disconnect_cb,
2248 NULL, 2307 NULL,
2249 handlers); 2308 handlers))
2309 global_ret = 2;
2250#if HAVE_WAIT4 2310#if HAVE_WAIT4
2251 if (NULL != wait_file) 2311 if (NULL != wait_file)
2252 { 2312 {
@@ -2263,7 +2323,7 @@ main (int argc,
2263 shc_chld = NULL; 2323 shc_chld = NULL;
2264 GNUNET_DISK_pipe_close (sigpipe); 2324 GNUNET_DISK_pipe_close (sigpipe);
2265 sigpipe = NULL; 2325 sigpipe = NULL;
2266 return ret; 2326 return global_ret;
2267} 2327}
2268 2328
2269 2329