diff options
author | lurchi <lurchi@strangeplace.net> | 2019-06-29 12:59:02 +0200 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2019-06-29 12:59:02 +0200 |
commit | 8c057274e457ad64aefaf2e3d08925617c928752 (patch) | |
tree | 1af6cd402e2587175bf8cfca945b54e6dbcc45f1 /src/nat | |
parent | 9c7302e9d253a243b7bb2887bb6e62c31a874278 (diff) | |
download | gnunet-8c057274e457ad64aefaf2e3d08925617c928752.tar.gz gnunet-8c057274e457ad64aefaf2e3d08925617c928752.zip |
use GNUNET_OS_get_suid_binary_path to construct suid helper paths
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-service-nat.c | 6 | ||||
-rw-r--r-- | src/nat/gnunet-service-nat_helper.c | 20 | ||||
-rw-r--r-- | src/nat/gnunet-service-nat_helper.h | 8 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index 8d771f474..2498a990a 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c | |||
@@ -1063,7 +1063,8 @@ run_scan (void *cls) | |||
1063 | sizeof (*s4))); | 1063 | sizeof (*s4))); |
1064 | pos->hc = GN_start_gnunet_nat_server_ (&s4->sin_addr, | 1064 | pos->hc = GN_start_gnunet_nat_server_ (&s4->sin_addr, |
1065 | &reversal_callback, | 1065 | &reversal_callback, |
1066 | pos); | 1066 | pos, |
1067 | cfg); | ||
1067 | } | 1068 | } |
1068 | } | 1069 | } |
1069 | } | 1070 | } |
@@ -1826,7 +1827,8 @@ handle_request_connection_reversal (void *cls, | |||
1826 | GNUNET_break_op (AF_INET == r4.sin_family); | 1827 | GNUNET_break_op (AF_INET == r4.sin_family); |
1827 | ret = GN_request_connection_reversal (&l4.sin_addr, | 1828 | ret = GN_request_connection_reversal (&l4.sin_addr, |
1828 | ntohs (l4.sin_port), | 1829 | ntohs (l4.sin_port), |
1829 | &r4.sin_addr); | 1830 | &r4.sin_addr, |
1831 | cfg); | ||
1830 | if (GNUNET_OK != ret) | 1832 | if (GNUNET_OK != ret) |
1831 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1833 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1832 | _("Connection reversal request failed\n")); | 1834 | _("Connection reversal request failed\n")); |
diff --git a/src/nat/gnunet-service-nat_helper.c b/src/nat/gnunet-service-nat_helper.c index 56090bcea..43ac54adf 100644 --- a/src/nat/gnunet-service-nat_helper.c +++ b/src/nat/gnunet-service-nat_helper.c | |||
@@ -74,6 +74,11 @@ struct HelperContext | |||
74 | * stdout file handle (for reading) for the gnunet-helper-nat-server process | 74 | * stdout file handle (for reading) for the gnunet-helper-nat-server process |
75 | */ | 75 | */ |
76 | const struct GNUNET_DISK_FileHandle *server_stdout_handle; | 76 | const struct GNUNET_DISK_FileHandle *server_stdout_handle; |
77 | |||
78 | /** | ||
79 | * Handle to the GNUnet configuration | ||
80 | */ | ||
81 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
77 | }; | 82 | }; |
78 | 83 | ||
79 | 84 | ||
@@ -227,8 +232,7 @@ restart_nat_server (void *cls) | |||
227 | ia, | 232 | ia, |
228 | sizeof (ia))); | 233 | sizeof (ia))); |
229 | /* Start the server process */ | 234 | /* Start the server process */ |
230 | binary | 235 | binary = GNUNET_OS_get_suid_binary_path (h->cfg, "gnunet-helper-nat-server"); |
231 | = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | ||
232 | if (GNUNET_YES != | 236 | if (GNUNET_YES != |
233 | GNUNET_OS_check_helper_binary (binary, | 237 | GNUNET_OS_check_helper_binary (binary, |
234 | GNUNET_YES, | 238 | GNUNET_YES, |
@@ -298,12 +302,14 @@ restart_nat_server (void *cls) | |||
298 | * @param internal_address | 302 | * @param internal_address |
299 | * @param cb function to call if we receive a request | 303 | * @param cb function to call if we receive a request |
300 | * @param cb_cls closure for @a cb | 304 | * @param cb_cls closure for @a cb |
305 | * @param cfg Handle to the GNUnet configuration | ||
301 | * @return NULL on error | 306 | * @return NULL on error |
302 | */ | 307 | */ |
303 | struct HelperContext * | 308 | struct HelperContext * |
304 | GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, | 309 | GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, |
305 | GN_ReversalCallback cb, | 310 | GN_ReversalCallback cb, |
306 | void *cb_cls) | 311 | void *cb_cls, |
312 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
307 | { | 313 | { |
308 | struct HelperContext *h; | 314 | struct HelperContext *h; |
309 | 315 | ||
@@ -311,6 +317,7 @@ GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, | |||
311 | h->cb = cb; | 317 | h->cb = cb; |
312 | h->cb_cls = cb_cls; | 318 | h->cb_cls = cb_cls; |
313 | h->internal_address = *internal_address; | 319 | h->internal_address = *internal_address; |
320 | h->cfg = cfg; | ||
314 | restart_nat_server (h); | 321 | restart_nat_server (h); |
315 | if (NULL == h->server_stdout) | 322 | if (NULL == h->server_stdout) |
316 | { | 323 | { |
@@ -366,13 +373,15 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h) | |||
366 | * @param internal_address out internal address to use | 373 | * @param internal_address out internal address to use |
367 | * @param internal_port port to use | 374 | * @param internal_port port to use |
368 | * @param remote_v4 the address of the peer (IPv4-only) | 375 | * @param remote_v4 the address of the peer (IPv4-only) |
376 | * @param cfg handle to the GNUnet configuration | ||
369 | * @return #GNUNET_SYSERR on error, | 377 | * @return #GNUNET_SYSERR on error, |
370 | * #GNUNET_OK otherwise | 378 | * #GNUNET_OK otherwise |
371 | */ | 379 | */ |
372 | int | 380 | int |
373 | GN_request_connection_reversal (const struct in_addr *internal_address, | 381 | GN_request_connection_reversal (const struct in_addr *internal_address, |
374 | uint16_t internal_port, | 382 | uint16_t internal_port, |
375 | const struct in_addr *remote_v4) | 383 | const struct in_addr *remote_v4, |
384 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
376 | { | 385 | { |
377 | char intv4[INET_ADDRSTRLEN]; | 386 | char intv4[INET_ADDRSTRLEN]; |
378 | char remv4[INET_ADDRSTRLEN]; | 387 | char remv4[INET_ADDRSTRLEN]; |
@@ -407,8 +416,7 @@ GN_request_connection_reversal (const struct in_addr *internal_address, | |||
407 | intv4, | 416 | intv4, |
408 | remv4, | 417 | remv4, |
409 | internal_port); | 418 | internal_port); |
410 | binary | 419 | binary = GNUNET_OS_get_suid_binary_path (cfg, "gnunet-helper-nat-client"); |
411 | = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client"); | ||
412 | proc | 420 | proc |
413 | = GNUNET_OS_start_process (GNUNET_NO, | 421 | = GNUNET_OS_start_process (GNUNET_NO, |
414 | 0, | 422 | 0, |
diff --git a/src/nat/gnunet-service-nat_helper.h b/src/nat/gnunet-service-nat_helper.h index d9294d949..4c39a374c 100644 --- a/src/nat/gnunet-service-nat_helper.h +++ b/src/nat/gnunet-service-nat_helper.h | |||
@@ -53,12 +53,14 @@ typedef void | |||
53 | * @param internal_address | 53 | * @param internal_address |
54 | * @param cb function to call if we receive a request | 54 | * @param cb function to call if we receive a request |
55 | * @param cb_cls closure for @a cb | 55 | * @param cb_cls closure for @a cb |
56 | * @param cfg handle to the GNUnet configuration | ||
56 | * @return NULL on error | 57 | * @return NULL on error |
57 | */ | 58 | */ |
58 | struct HelperContext * | 59 | struct HelperContext * |
59 | GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, | 60 | GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, |
60 | GN_ReversalCallback cb, | 61 | GN_ReversalCallback cb, |
61 | void *cb_cls); | 62 | void *cb_cls, |
63 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
62 | 64 | ||
63 | 65 | ||
64 | /** | 66 | /** |
@@ -79,13 +81,15 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h); | |||
79 | * @param internal_address out internal address to use | 81 | * @param internal_address out internal address to use |
80 | * @param internal_port internal port to use | 82 | * @param internal_port internal port to use |
81 | * @param remote_v4 the address of the peer (IPv4-only) | 83 | * @param remote_v4 the address of the peer (IPv4-only) |
84 | * @param cfg handle to the GNUnet configuration | ||
82 | * @return #GNUNET_SYSERR on error, | 85 | * @return #GNUNET_SYSERR on error, |
83 | * #GNUNET_OK otherwise | 86 | * #GNUNET_OK otherwise |
84 | */ | 87 | */ |
85 | int | 88 | int |
86 | GN_request_connection_reversal (const struct in_addr *internal_address, | 89 | GN_request_connection_reversal (const struct in_addr *internal_address, |
87 | uint16_t internal_port, | 90 | uint16_t internal_port, |
88 | const struct in_addr *sa); | 91 | const struct in_addr *remote_v4, |
92 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
89 | 93 | ||
90 | 94 | ||
91 | /* end of gnunet-service-nat_helper.h */ | 95 | /* end of gnunet-service-nat_helper.h */ |