aboutsummaryrefslogtreecommitdiff
path: root/src/arm/gnunet-service-arm.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-02-28 21:17:53 +0000
committerFlorian Dold <florian.dold@gmail.com>2016-02-28 21:17:53 +0000
commitdf3c24884b5dab5cffa11294274ba24da3d86010 (patch)
tree76ff06d9522844b43216acf8bfccf3496c6777fb /src/arm/gnunet-service-arm.c
parent862d43bb260b87ec5cd3072a8b486c90eaab3519 (diff)
downloadgnunet-df3c24884b5dab5cffa11294274ba24da3d86010.tar.gz
gnunet-df3c24884b5dab5cffa11294274ba24da3d86010.zip
Make ARM understand the TYPE option for services
Setting the TYPE option for a service to SIMPLE makes ARM start the service without any GNUnet-specific command line options. The TYPE option defaults to GNUNET, which is the usual behavior (with config / log level arguments to the binary).
Diffstat (limited to 'src/arm/gnunet-service-arm.c')
-rw-r--r--src/arm/gnunet-service-arm.c97
1 files changed, 66 insertions, 31 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 6614d0ce3..628bbc99b 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -419,6 +419,7 @@ start_process (struct ServiceList *sl,
419 char *optend; 419 char *optend;
420 const char *next; 420 const char *next;
421 int use_debug; 421 int use_debug;
422 int is_simple_service;
422 char b; 423 char b;
423 char *val; 424 char *val;
424 struct ServiceListeningInfo *sli; 425 struct ServiceListeningInfo *sli;
@@ -493,46 +494,80 @@ start_process (struct ServiceList *sl,
493 } 494 }
494 use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG"); 495 use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");
495 496
496 /* actually start process */ 497 {
497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 498 const char *service_type = NULL;
498 "Starting service `%s' using binary `%s' and configuration `%s'\n", 499 const char *choices[] = { "GNUNET", "SIMPLE", NULL };
499 sl->name, sl->binary, sl->config); 500 is_simple_service = GNUNET_NO;
500 binary = GNUNET_OS_get_libexec_binary_path (sl->binary); 501 if ( (GNUNET_OK ==
501 GNUNET_asprintf (&quotedbinary, 502 GNUNET_CONFIGURATION_get_value_choice (cfg,
502 "\"%s\"", 503 sl->name,
503 binary); 504 "TYPE",
505 choices,
506 &service_type)) &&
507 (0 == strcasecmp (service_type, "SIMPLE")) )
508 is_simple_service = GNUNET_YES;
509 }
504 510
505 GNUNET_assert (NULL == sl->proc); 511 GNUNET_assert (NULL == sl->proc);
506 if (GNUNET_YES == use_debug) 512 if (GNUNET_YES == is_simple_service)
507 { 513 {
508 if (NULL == sl->config) 514 /* A simple service will receive no GNUnet specific
509 sl->proc = 515 command line options. */
510 GNUNET_OS_start_process_s (sl->pipe_control, 516 binary = GNUNET_strdup (sl->binary);
511 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 517 GNUNET_asprintf (&quotedbinary,
512 lsocks, loprefix, quotedbinary, "-L", 518 "\"%s\"",
513 "DEBUG", options, NULL); 519 sl->binary);
514 else 520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
515 sl->proc = 521 "Starting simple service `%s' using binary `%s'\n",
516 GNUNET_OS_start_process_s (sl->pipe_control, 522 sl->name, sl->binary);
517 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 523 sl->proc =
518 lsocks, loprefix, quotedbinary, "-c", 524 GNUNET_OS_start_process_s (sl->pipe_control,
519 sl->config, "-L", 525 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
520 "DEBUG", options, NULL); 526 lsocks, loprefix, quotedbinary,
527 options, NULL);
521 } 528 }
522 else 529 else
523 { 530 {
524 if (NULL == sl->config) 531 /* actually start process */
525 sl->proc = 532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
533 "Starting service `%s' using binary `%s' and configuration `%s'\n",
534 sl->name, sl->binary, sl->config);
535 binary = GNUNET_OS_get_libexec_binary_path (sl->binary);
536 GNUNET_asprintf (&quotedbinary,
537 "\"%s\"",
538 binary);
539
540 if (GNUNET_YES == use_debug)
541 {
542 if (NULL == sl->config)
543 sl->proc =
526 GNUNET_OS_start_process_s (sl->pipe_control, 544 GNUNET_OS_start_process_s (sl->pipe_control,
527 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 545 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
528 lsocks, loprefix, quotedbinary, 546 lsocks, loprefix, quotedbinary, "-L",
529 options, NULL); 547 "DEBUG", options, NULL);
548 else
549 sl->proc =
550 GNUNET_OS_start_process_s (sl->pipe_control,
551 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
552 lsocks, loprefix, quotedbinary, "-c",
553 sl->config, "-L",
554 "DEBUG", options, NULL);
555 }
530 else 556 else
531 sl->proc = 557 {
532 GNUNET_OS_start_process_s (sl->pipe_control, 558 if (NULL == sl->config)
533 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 559 sl->proc =
534 lsocks, loprefix, quotedbinary, "-c", 560 GNUNET_OS_start_process_s (sl->pipe_control,
535 sl->config, options, NULL); 561 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
562 lsocks, loprefix, quotedbinary,
563 options, NULL);
564 else
565 sl->proc =
566 GNUNET_OS_start_process_s (sl->pipe_control,
567 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
568 lsocks, loprefix, quotedbinary, "-c",
569 sl->config, options, NULL);
570 }
536 } 571 }
537 GNUNET_free (binary); 572 GNUNET_free (binary);
538 GNUNET_free (quotedbinary); 573 GNUNET_free (quotedbinary);