X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fnat%2Fnat.c;h=dd63224c0a425890bc9904a7a3d4e2c91f175af3;hb=70466ec3c34f9a920e9e798e3169f886e9486a59;hp=79604da7d2180779b651057badf3216b1acc0cb2;hpb=16546613251edfcd595e4f584b1a2d2a414d0b1a;p=oweals%2Fgnunet.git diff --git a/src/nat/nat.c b/src/nat/nat.c index 79604da7d..dd63224c0 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -759,11 +759,7 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) h->server_stdout = NULL; h->server_stdout_handle = NULL; /* now try to restart it */ - h->server_retry_delay = - GNUNET_TIME_relative_multiply (h->server_retry_delay, 2); - h->server_retry_delay = - GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_HOURS, - h->server_retry_delay); + h->server_retry_delay = GNUNET_TIME_STD_BACKOFF (h->server_retry_delay); h->server_read_task = GNUNET_SCHEDULER_add_delayed (h->server_retry_delay, &restart_nat_server, h); @@ -825,6 +821,8 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void start_gnunet_nat_server (struct GNUNET_NAT_Handle *h) { + char *binary; + if ((h->behind_nat == GNUNET_YES) && (h->enable_nat_server == GNUNET_YES) && (h->internal_address != NULL) && (NULL != @@ -834,11 +832,13 @@ start_gnunet_nat_server (struct GNUNET_NAT_Handle *h) LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting `%s' at `%s'\n", "gnunet-helper-nat-server", h->internal_address); /* Start the server process */ + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); h->server_proc = - GNUNET_OS_start_process (GNUNET_NO, NULL, h->server_stdout, - "gnunet-helper-nat-server", + GNUNET_OS_start_process (GNUNET_NO, 0, NULL, h->server_stdout, + binary, "gnunet-helper-nat-server", h->internal_address, NULL); + GNUNET_free (binary); if (h->server_proc == NULL) { LOG (GNUNET_ERROR_TYPE_WARNING, "nat", _("Failed to start %s\n"), @@ -1070,6 +1070,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, struct GNUNET_NAT_Handle *h; struct in_addr in_addr; unsigned int i; + char *binary; LOG (GNUNET_ERROR_TYPE_DEBUG, "Registered with NAT service at port %u with %u IP bound local addresses\n", @@ -1107,9 +1108,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, if ((h->internal_address != NULL) && (inet_pton (AF_INET, h->internal_address, &in_addr) != 1)) { - LOG (GNUNET_ERROR_TYPE_WARNING, "nat", - _("Malformed %s `%s' given in configuration!\n"), "INTERNAL_ADDRESS", - h->internal_address); + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, + "nat", "INTERNAL_ADDRESS", + _("malformed")); GNUNET_free (h->internal_address); h->internal_address = NULL; } @@ -1167,9 +1168,10 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, } /* Test for SUID binaries */ + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); if ((h->behind_nat == GNUNET_YES) && (GNUNET_YES == h->enable_nat_server) && (GNUNET_YES != - GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server"))) + GNUNET_OS_check_helper_binary (binary))) { h->enable_nat_server = GNUNET_NO; LOG (GNUNET_ERROR_TYPE_WARNING, @@ -1177,9 +1179,11 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, ("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), "gnunet-helper-nat-server"); } + GNUNET_free (binary); + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client"); if ((GNUNET_YES == h->enable_nat_client) && (GNUNET_YES != - GNUNET_OS_check_helper_binary ("gnunet-helper-nat-client"))) + GNUNET_OS_check_helper_binary (binary))) { h->enable_nat_client = GNUNET_NO; LOG (GNUNET_ERROR_TYPE_WARNING, @@ -1187,7 +1191,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, ("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), "gnunet-helper-nat-client"); } - + GNUNET_free (binary); start_gnunet_nat_server (h); /* FIXME: add support for UPnP, etc */ @@ -1310,6 +1314,7 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, char inet4[INET_ADDRSTRLEN]; char port_as_string[6]; struct GNUNET_OS_Process *proc; + char *binary; if (GNUNET_YES != h->enable_nat_client) return GNUNET_NO; /* not permitted / possible */ @@ -1331,11 +1336,13 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, LOG (GNUNET_ERROR_TYPE_DEBUG, _("Running gnunet-helper-nat-client %s %s %u\n"), h->internal_address, inet4, (unsigned int) h->adv_port); + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client"); proc = - GNUNET_OS_start_process (GNUNET_NO, - NULL, NULL, "gnunet-helper-nat-client", + GNUNET_OS_start_process (GNUNET_NO, 0, NULL, NULL, + binary, "gnunet-helper-nat-client", h->internal_address, inet4, port_as_string, NULL); + GNUNET_free (binary); if (NULL == proc) return GNUNET_SYSERR; /* we know that the gnunet-helper-nat-client will terminate virtually