aboutsummaryrefslogtreecommitdiff
path: root/src/pt/test_gns_vpn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pt/test_gns_vpn.c')
-rw-r--r--src/pt/test_gns_vpn.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c
index adf8b7d85..a0b2d926f 100644
--- a/src/pt/test_gns_vpn.c
+++ b/src/pt/test_gns_vpn.c
@@ -217,9 +217,9 @@ curl_main ()
217 } 217 }
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n"); 218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n");
219 do_shutdown (); 219 do_shutdown ();
220 return; 220 return;
221 } 221 }
222 GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max)); 222 GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max));
223 if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) || 223 if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) ||
224 (-1 == timeout) ) 224 (-1 == timeout) )
225 delay = GNUNET_TIME_UNIT_SECONDS; 225 delay = GNUNET_TIME_UNIT_SECONDS;
@@ -236,14 +236,14 @@ curl_main ()
236 &nrs, 236 &nrs,
237 &nws, 237 &nws,
238 &curl_task, 238 &curl_task,
239 NULL); 239 NULL);
240} 240}
241 241
242 242
243static void 243static void
244start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 244start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
245{ 245{
246 GNUNET_asprintf (&url, 246 GNUNET_asprintf (&url,
247 "http://%s/hello_world", 247 "http://%s/hello_world",
248 TEST_DOMAIN); 248 TEST_DOMAIN);
249 curl = curl_easy_init (); 249 curl = curl_easy_init ();
@@ -280,7 +280,7 @@ disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
280 * will match 'result_af' from the request 280 * will match 'result_af' from the request
281 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af') 281 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
282 * that the VPN allocated for the redirection; 282 * that the VPN allocated for the redirection;
283 * traffic to this IP will now be redirected to the 283 * traffic to this IP will now be redirected to the
284 * specified target peer; NULL on error 284 * specified target peer; NULL on error
285 */ 285 */
286static void 286static void
@@ -290,11 +290,11 @@ commence_testing (void *cls, int32_t success, const char *emsg)
290 290
291 if ((emsg != NULL) && (GNUNET_YES != success)) 291 if ((emsg != NULL) && (GNUNET_YES != success))
292 { 292 {
293 fprintf (stderr, 293 fprintf (stderr,
294 "NS failed to create record %s\n", emsg); 294 "NS failed to create record %s\n", emsg);
295 GNUNET_SCHEDULER_shutdown (); 295 GNUNET_SCHEDULER_shutdown ();
296 return; 296 return;
297 } 297 }
298 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &start_curl, NULL); 298 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &start_curl, NULL);
299} 299}
300 300
@@ -302,7 +302,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
302/** 302/**
303 * Function to keep the HTTP server running. 303 * Function to keep the HTTP server running.
304 */ 304 */
305static void 305static void
306mhd_main (void); 306mhd_main (void);
307 307
308 308
@@ -316,7 +316,7 @@ mhd_task (void *cls,
316} 316}
317 317
318 318
319static void 319static void
320mhd_main () 320mhd_main ()
321{ 321{
322 struct GNUNET_NETWORK_FDSet nrs; 322 struct GNUNET_NETWORK_FDSet nrs;
@@ -351,7 +351,7 @@ mhd_main ()
351 &nrs, 351 &nrs,
352 &nws, 352 &nws,
353 &mhd_task, 353 &mhd_task,
354 NULL); 354 NULL);
355} 355}
356 356
357 357
@@ -367,7 +367,7 @@ run (void *cls,
367 struct GNUNET_NAMESTORE_RecordData rd; 367 struct GNUNET_NAMESTORE_RecordData rd;
368 char *rd_string; 368 char *rd_string;
369 char *zone_keyfile; 369 char *zone_keyfile;
370 370
371 GNUNET_TESTING_peer_get_identity (peer, &id); 371 GNUNET_TESTING_peer_get_identity (peer, &id);
372 GNUNET_CRYPTO_hash_to_enc ((struct GNUNET_HashCode*)&id, &peername); 372 GNUNET_CRYPTO_hash_to_enc ((struct GNUNET_HashCode*)&id, &peername);
373 373
@@ -383,7 +383,7 @@ run (void *cls,
383 MHD_OPTION_END); 383 MHD_OPTION_END);
384 GNUNET_assert (NULL != mhd); 384 GNUNET_assert (NULL != mhd);
385 mhd_main (); 385 mhd_main ();
386 386
387 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 387 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
388 "ZONEKEY", 388 "ZONEKEY",
389 &zone_keyfile)) 389 &zone_keyfile))
@@ -433,7 +433,7 @@ open_dev_null (int target_fd,
433 if (fd == target_fd) 433 if (fd == target_fd)
434 return; 434 return;
435 if (-1 == dup2 (fd, target_fd)) 435 if (-1 == dup2 (fd, target_fd))
436 { 436 {
437 (void) close (fd); 437 (void) close (fd);
438 abort (); 438 abort ();
439 } 439 }
@@ -443,13 +443,13 @@ open_dev_null (int target_fd,
443 443
444/** 444/**
445 * Run the given command and wait for it to complete. 445 * Run the given command and wait for it to complete.
446 * 446 *
447 * @param file name of the binary to run 447 * @param file name of the binary to run
448 * @param cmd command line arguments (as given to 'execv') 448 * @param cmd command line arguments (as given to 'execv')
449 * @return 0 on success, 1 on any error 449 * @return 0 on success, 1 on any error
450 */ 450 */
451static int 451static int
452fork_and_exec (const char *file, 452fork_and_exec (const char *file,
453 char *const cmd[]) 453 char *const cmd[])
454{ 454{
455 int status; 455 int status;
@@ -459,8 +459,8 @@ fork_and_exec (const char *file,
459 pid = fork (); 459 pid = fork ();
460 if (-1 == pid) 460 if (-1 == pid)
461 { 461 {
462 fprintf (stderr, 462 fprintf (stderr,
463 "fork failed: %s\n", 463 "fork failed: %s\n",
464 strerror (errno)); 464 strerror (errno));
465 return 1; 465 return 1;
466 } 466 }
@@ -469,25 +469,25 @@ fork_and_exec (const char *file,
469 /* we are the child process */ 469 /* we are the child process */
470 /* close stdin/stdout to not cause interference 470 /* close stdin/stdout to not cause interference
471 with the helper's main protocol! */ 471 with the helper's main protocol! */
472 (void) close (0); 472 (void) close (0);
473 open_dev_null (0, O_RDONLY); 473 open_dev_null (0, O_RDONLY);
474 (void) close (1); 474 (void) close (1);
475 open_dev_null (1, O_WRONLY); 475 open_dev_null (1, O_WRONLY);
476 (void) execv (file, cmd); 476 (void) execv (file, cmd);
477 /* can only get here on error */ 477 /* can only get here on error */
478 fprintf (stderr, 478 fprintf (stderr,
479 "exec `%s' failed: %s\n", 479 "exec `%s' failed: %s\n",
480 file, 480 file,
481 strerror (errno)); 481 strerror (errno));
482 _exit (1); 482 _exit (1);
483 } 483 }
484 /* keep running waitpid as long as the only error we get is 'EINTR' */ 484 /* keep running waitpid as long as the only error we get is 'EINTR' */
485 while ( (-1 == (ret = waitpid (pid, &status, 0))) && 485 while ( (-1 == (ret = waitpid (pid, &status, 0))) &&
486 (errno == EINTR) ); 486 (errno == EINTR) );
487 if (-1 == ret) 487 if (-1 == ret)
488 { 488 {
489 fprintf (stderr, 489 fprintf (stderr,
490 "waitpid failed: %s\n", 490 "waitpid failed: %s\n",
491 strerror (errno)); 491 strerror (errno));
492 return 1; 492 return 1;
493 } 493 }
@@ -508,19 +508,19 @@ main (int argc, char *const *argv)
508 { 508 {
509 "iptables", "-t", "mangle", "-L", "-v", NULL 509 "iptables", "-t", "mangle", "-L", "-v", NULL
510 }; 510 };
511 511
512 if (0 == access ("/sbin/iptables", X_OK)) 512 if (0 == access ("/sbin/iptables", X_OK))
513 sbin_iptables = "/sbin/iptables"; 513 sbin_iptables = "/sbin/iptables";
514 else if (0 == access ("/usr/sbin/iptables", X_OK)) 514 else if (0 == access ("/usr/sbin/iptables", X_OK))
515 sbin_iptables = "/usr/sbin/iptables"; 515 sbin_iptables = "/usr/sbin/iptables";
516 else 516 else
517 { 517 {
518 fprintf (stderr, 518 fprintf (stderr,
519 "Executable iptables not found in approved directories: %s, skipping\n", 519 "Executable iptables not found in approved directories: %s, skipping\n",
520 strerror (errno)); 520 strerror (errno));
521 return 0; 521 return 0;
522 } 522 }
523 523
524 if (0 != fork_and_exec (sbin_iptables, iptables_args)) 524 if (0 != fork_and_exec (sbin_iptables, iptables_args))
525 { 525 {
526 fprintf (stderr, 526 fprintf (stderr,
@@ -548,20 +548,20 @@ main (int argc, char *const *argv)
548 GNUNET_OS_check_helper_binary (bin_exit, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) || //no nat, ipv4 only 548 GNUNET_OS_check_helper_binary (bin_exit, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) || //no nat, ipv4 only
549 (GNUNET_YES != 549 (GNUNET_YES !=
550 GNUNET_OS_check_helper_binary (bin_dns, GNUNET_YES, NULL))) ) // TODO: once we have a windows-testcase, add test parameters here 550 GNUNET_OS_check_helper_binary (bin_dns, GNUNET_YES, NULL))) ) // TODO: once we have a windows-testcase, add test parameters here
551 { 551 {
552 fprintf (stderr, 552 fprintf (stderr,
553 "WARNING: gnunet-helper-{exit,vpn,dns} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n"); 553 "WARNING: gnunet-helper-{exit,vpn,dns} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n");
554 fprintf (stderr, 554 fprintf (stderr,
555 "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n"); 555 "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n");
556 GNUNET_free (bin_vpn); 556 GNUNET_free (bin_vpn);
557 GNUNET_free (bin_exit); 557 GNUNET_free (bin_exit);
558 GNUNET_free (bin_dns); 558 GNUNET_free (bin_dns);
559 return 0; 559 return 0;
560 } 560 }
561 GNUNET_free (bin_vpn); 561 GNUNET_free (bin_vpn);
562 GNUNET_free (bin_exit); 562 GNUNET_free (bin_exit);
563 GNUNET_free (bin_dns); 563 GNUNET_free (bin_dns);
564 564
565 dest_ip = "169.254.86.1"; 565 dest_ip = "169.254.86.1";
566 dest_af = AF_INET; 566 dest_af = AF_INET;
567 src_af = AF_INET; 567 src_af = AF_INET;
@@ -570,11 +570,11 @@ main (int argc, char *const *argv)
570 use_v6 = GNUNET_YES; 570 use_v6 = GNUNET_YES;
571 else 571 else
572 use_v6 = GNUNET_NO; 572 use_v6 = GNUNET_NO;
573 573
574 if ( (GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) || 574 if ( (GNUNET_OK != GNUNET_NETWORK_test_pf (src_af)) ||
575 (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)) ) 575 (GNUNET_OK != GNUNET_NETWORK_test_pf (dest_af)) )
576 { 576 {
577 fprintf (stderr, 577 fprintf (stderr,
578 "Required address families not supported by this system, skipping test.\n"); 578 "Required address families not supported by this system, skipping test.\n");
579 return 0; 579 return 0;
580 } 580 }