aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlurchi <lurchi@strangeplace.net>2019-06-29 12:59:02 +0200
committerlurchi <lurchi@strangeplace.net>2019-06-29 12:59:02 +0200
commit8c057274e457ad64aefaf2e3d08925617c928752 (patch)
tree1af6cd402e2587175bf8cfca945b54e6dbcc45f1 /src
parent9c7302e9d253a243b7bb2887bb6e62c31a874278 (diff)
downloadgnunet-8c057274e457ad64aefaf2e3d08925617c928752.tar.gz
gnunet-8c057274e457ad64aefaf2e3d08925617c928752.zip
use GNUNET_OS_get_suid_binary_path to construct suid helper paths
Diffstat (limited to 'src')
-rw-r--r--src/dns/gnunet-service-dns.c11
-rw-r--r--src/exit/gnunet-daemon-exit.c9
-rw-r--r--src/nat/gnunet-service-nat.c6
-rw-r--r--src/nat/gnunet-service-nat_helper.c20
-rw-r--r--src/nat/gnunet-service-nat_helper.h8
-rw-r--r--src/vpn/gnunet-service-vpn.c19
6 files changed, 53 insertions, 20 deletions
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index a63205ebf..dc9f37377 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -1082,7 +1082,8 @@ run (void *cls,
1082 _("need a valid IPv4 or IPv6 address\n")); 1082 _("need a valid IPv4 or IPv6 address\n"));
1083 GNUNET_free_non_null (dns_exit); 1083 GNUNET_free_non_null (dns_exit);
1084 } 1084 }
1085 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns"); 1085 binary = GNUNET_OS_get_suid_binary_path (cfg, "gnunet-helper-dns");
1086
1086 if (GNUNET_YES != 1087 if (GNUNET_YES !=
1087 GNUNET_OS_check_helper_binary (binary, 1088 GNUNET_OS_check_helper_binary (binary,
1088 GNUNET_YES, 1089 GNUNET_YES,
@@ -1106,6 +1107,7 @@ run (void *cls,
1106 { 1107 {
1107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1108 "No entry 'IFNAME' in configuration!\n"); 1109 "No entry 'IFNAME' in configuration!\n");
1110 GNUNET_free (binary);
1109 GNUNET_SCHEDULER_shutdown (); 1111 GNUNET_SCHEDULER_shutdown ();
1110 return; 1112 return;
1111 } 1113 }
@@ -1118,6 +1120,7 @@ run (void *cls,
1118 { 1120 {
1119 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1120 "No entry 'IPV6ADDR' in configuration!\n"); 1122 "No entry 'IPV6ADDR' in configuration!\n");
1123 GNUNET_free (binary);
1121 GNUNET_SCHEDULER_shutdown (); 1124 GNUNET_SCHEDULER_shutdown ();
1122 return; 1125 return;
1123 } 1126 }
@@ -1130,6 +1133,7 @@ run (void *cls,
1130 { 1133 {
1131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1134 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1132 "No entry 'IPV6PREFIX' in configuration!\n"); 1135 "No entry 'IPV6PREFIX' in configuration!\n");
1136 GNUNET_free (binary);
1133 GNUNET_SCHEDULER_shutdown (); 1137 GNUNET_SCHEDULER_shutdown ();
1134 return; 1138 return;
1135 } 1139 }
@@ -1143,6 +1147,7 @@ run (void *cls,
1143 { 1147 {
1144 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1145 "No entry 'IPV4ADDR' in configuration!\n"); 1149 "No entry 'IPV4ADDR' in configuration!\n");
1150 GNUNET_free (binary);
1146 GNUNET_SCHEDULER_shutdown (); 1151 GNUNET_SCHEDULER_shutdown ();
1147 return; 1152 return;
1148 } 1153 }
@@ -1153,6 +1158,7 @@ run (void *cls,
1153 { 1158 {
1154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1159 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1155 "No entry 'IPV4MASK' in configuration!\n"); 1160 "No entry 'IPV4MASK' in configuration!\n");
1161 GNUNET_free (binary);
1156 GNUNET_SCHEDULER_shutdown (); 1162 GNUNET_SCHEDULER_shutdown ();
1157 return; 1163 return;
1158 } 1164 }
@@ -1167,10 +1173,11 @@ run (void *cls,
1167 1173
1168 helper_argv[7] = NULL; 1174 helper_argv[7] = NULL;
1169 hijacker = GNUNET_HELPER_start (GNUNET_NO, 1175 hijacker = GNUNET_HELPER_start (GNUNET_NO,
1170 "gnunet-helper-dns", 1176 binary,
1171 helper_argv, 1177 helper_argv,
1172 &process_helper_messages, 1178 &process_helper_messages,
1173 NULL, NULL); 1179 NULL, NULL);
1180 GNUNET_free (binary);
1174} 1181}
1175 1182
1176 1183
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 5bcf53f57..ed49a5297 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -3790,9 +3790,9 @@ run (void *cls,
3790 &max_connections)) 3790 &max_connections))
3791 max_connections = 1024; 3791 max_connections = 1024;
3792 parse_ip_options (); 3792 parse_ip_options ();
3793 binary = GNUNET_OS_get_suid_binary_path (cfg, "gnunet-helper-exit");
3793 if ( (ipv4_exit) || (ipv6_exit) ) 3794 if ( (ipv4_exit) || (ipv6_exit) )
3794 { 3795 {
3795 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
3796 if (GNUNET_YES != 3796 if (GNUNET_YES !=
3797 GNUNET_OS_check_helper_binary (binary, 3797 GNUNET_OS_check_helper_binary (binary,
3798 GNUNET_YES, 3798 GNUNET_YES,
@@ -3807,10 +3807,10 @@ run (void *cls,
3807 global_ret = 1; 3807 global_ret = 1;
3808 return; 3808 return;
3809 } 3809 }
3810 GNUNET_free (binary);
3811 } 3810 }
3812 if (! (ipv4_enabled || ipv6_enabled)) 3811 if (! (ipv4_enabled || ipv6_enabled))
3813 { 3812 {
3813 GNUNET_free (binary);
3814 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3814 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3815 _("No useful service enabled. Exiting.\n")); 3815 _("No useful service enabled. Exiting.\n"));
3816 GNUNET_SCHEDULER_shutdown (); 3816 GNUNET_SCHEDULER_shutdown ();
@@ -3824,6 +3824,7 @@ run (void *cls,
3824 cadet_handle = GNUNET_CADET_connect (cfg); 3824 cadet_handle = GNUNET_CADET_connect (cfg);
3825 if (NULL == cadet_handle) 3825 if (NULL == cadet_handle)
3826 { 3826 {
3827 GNUNET_free (binary);
3827 GNUNET_SCHEDULER_shutdown (); 3828 GNUNET_SCHEDULER_shutdown ();
3828 return; 3829 return;
3829 } 3830 }
@@ -3831,6 +3832,7 @@ run (void *cls,
3831 if (GNUNET_OK != 3832 if (GNUNET_OK !=
3832 setup_exit_helper_args ()) 3833 setup_exit_helper_args ())
3833 { 3834 {
3835 GNUNET_free (binary);
3834 GNUNET_SCHEDULER_shutdown (); 3836 GNUNET_SCHEDULER_shutdown ();
3835 return; 3837 return;
3836 } 3838 }
@@ -3927,11 +3929,12 @@ run (void *cls,
3927 } 3929 }
3928 } 3930 }
3929 helper_handle = GNUNET_HELPER_start (GNUNET_NO, 3931 helper_handle = GNUNET_HELPER_start (GNUNET_NO,
3930 "gnunet-helper-exit", 3932 binary,
3931 exit_argv, 3933 exit_argv,
3932 &message_token, 3934 &message_token,
3933 NULL, 3935 NULL,
3934 NULL); 3936 NULL);
3937 GNUNET_free (binary);
3935} 3938}
3936 3939
3937 3940
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 */
303struct HelperContext * 308struct HelperContext *
304GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, 309GN_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 */
372int 380int
373GN_request_connection_reversal (const struct in_addr *internal_address, 381GN_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 */
58struct HelperContext * 59struct HelperContext *
59GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, 60GN_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 */
85int 88int
86GN_request_connection_reversal (const struct in_addr *internal_address, 89GN_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 */
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 91bc13fd8..f48022b5f 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -2936,7 +2936,8 @@ run (void *cls,
2936 struct in6_addr v6; 2936 struct in6_addr v6;
2937 char *binary; 2937 char *binary;
2938 2938
2939 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn"); 2939 cfg = cfg_;
2940 binary = GNUNET_OS_get_suid_binary_path (cfg, "gnunet-helper-vpn");
2940 2941
2941 if (GNUNET_YES != 2942 if (GNUNET_YES !=
2942 GNUNET_OS_check_helper_binary (binary, 2943 GNUNET_OS_check_helper_binary (binary,
@@ -2953,8 +2954,6 @@ run (void *cls,
2953 anything either */ 2954 anything either */
2954 return; 2955 return;
2955 } 2956 }
2956 GNUNET_free (binary);
2957 cfg = cfg_;
2958 stats = GNUNET_STATISTICS_create ("vpn", cfg); 2957 stats = GNUNET_STATISTICS_create ("vpn", cfg);
2959 if (GNUNET_OK != 2958 if (GNUNET_OK !=
2960 GNUNET_CONFIGURATION_get_value_number (cfg, 2959 GNUNET_CONFIGURATION_get_value_number (cfg,
@@ -2980,6 +2979,7 @@ run (void *cls,
2980 GNUNET_CONFIGURATION_get_value_string (cfg, "VPN", "IFNAME", &ifname)) 2979 GNUNET_CONFIGURATION_get_value_string (cfg, "VPN", "IFNAME", &ifname))
2981 { 2980 {
2982 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "VPN", "IFNAME"); 2981 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "VPN", "IFNAME");
2982 GNUNET_free (binary);
2983 GNUNET_SCHEDULER_shutdown (); 2983 GNUNET_SCHEDULER_shutdown ();
2984 return; 2984 return;
2985 } 2985 }
@@ -2994,6 +2994,7 @@ run (void *cls,
2994 { 2994 {
2995 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV6ADDR", 2995 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV6ADDR",
2996 _("Must specify valid IPv6 address")); 2996 _("Must specify valid IPv6 address"));
2997 GNUNET_free (binary);
2997 GNUNET_SCHEDULER_shutdown (); 2998 GNUNET_SCHEDULER_shutdown ();
2998 GNUNET_free_non_null (ipv6addr); 2999 GNUNET_free_non_null (ipv6addr);
2999 return; 3000 return;
@@ -3005,6 +3006,7 @@ run (void *cls,
3005 &ipv6prefix_s)) 3006 &ipv6prefix_s))
3006 { 3007 {
3007 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV6PREFIX"); 3008 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV6PREFIX");
3009 GNUNET_free (binary);
3008 GNUNET_SCHEDULER_shutdown (); 3010 GNUNET_SCHEDULER_shutdown ();
3009 GNUNET_free_non_null (ipv6prefix_s); 3011 GNUNET_free_non_null (ipv6prefix_s);
3010 return; 3012 return;
@@ -3018,6 +3020,7 @@ run (void *cls,
3018 { 3020 {
3019 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV4MASK", 3021 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV4MASK",
3020 _("Must specify valid IPv6 mask")); 3022 _("Must specify valid IPv6 mask"));
3023 GNUNET_free (binary);
3021 GNUNET_SCHEDULER_shutdown (); 3024 GNUNET_SCHEDULER_shutdown ();
3022 return; 3025 return;
3023 } 3026 }
@@ -3039,6 +3042,7 @@ run (void *cls,
3039 { 3042 {
3040 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV4ADDR", 3043 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV4ADDR",
3041 _("Must specify valid IPv4 address")); 3044 _("Must specify valid IPv4 address"));
3045 GNUNET_free (binary);
3042 GNUNET_SCHEDULER_shutdown (); 3046 GNUNET_SCHEDULER_shutdown ();
3043 GNUNET_free_non_null (ipv4addr); 3047 GNUNET_free_non_null (ipv4addr);
3044 return; 3048 return;
@@ -3052,6 +3056,7 @@ run (void *cls,
3052 { 3056 {
3053 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV4MASK", 3057 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "VPN", "IPV4MASK",
3054 _("Must specify valid IPv4 mask")); 3058 _("Must specify valid IPv4 mask"));
3059 GNUNET_free (binary);
3055 GNUNET_SCHEDULER_shutdown (); 3060 GNUNET_SCHEDULER_shutdown ();
3056 GNUNET_free_non_null (ipv4mask); 3061 GNUNET_free_non_null (ipv4mask);
3057 return; 3062 return;
@@ -3070,8 +3075,12 @@ run (void *cls,
3070 cadet_handle = GNUNET_CADET_connect (cfg_); 3075 cadet_handle = GNUNET_CADET_connect (cfg_);
3071 // FIXME never opens ports??? 3076 // FIXME never opens ports???
3072 helper_handle = GNUNET_HELPER_start (GNUNET_NO, 3077 helper_handle = GNUNET_HELPER_start (GNUNET_NO,
3073 "gnunet-helper-vpn", vpn_argv, 3078 binary,
3074 &message_token, NULL, NULL); 3079 vpn_argv,
3080 &message_token,
3081 NULL,
3082 NULL);
3083 GNUNET_free (binary);
3075 GNUNET_SCHEDULER_add_shutdown (&cleanup, 3084 GNUNET_SCHEDULER_add_shutdown (&cleanup,
3076 NULL); 3085 NULL);
3077} 3086}