aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-25 20:15:58 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-25 20:15:58 +0000
commit9935d917ca2a9a34e9c6d1aa744744eaeb6dfd2e (patch)
tree763e2277ebd969d896c63d3735d82c7222518074 /src/vpn
parent1f1cee05703360688308f3a6cfab40673b891989 (diff)
downloadgnunet-9935d917ca2a9a34e9c6d1aa744744eaeb6dfd2e.tar.gz
gnunet-9935d917ca2a9a34e9c6d1aa744744eaeb6dfd2e.zip
-terminate test after a while, check for SUID helper
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-helper-vpn.c13
-rw-r--r--src/vpn/gnunet-service-vpn.c16
-rw-r--r--src/vpn/test_gnunet_vpn.c4
3 files changed, 30 insertions, 3 deletions
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c
index a6035d1d1..77512832d 100644
--- a/src/vpn/gnunet-helper-vpn.c
+++ b/src/vpn/gnunet-helper-vpn.c
@@ -45,6 +45,12 @@
45#include "gnunet_protocols.h" 45#include "gnunet_protocols.h"
46 46
47/** 47/**
48 * Should we print (interesting|debug) messages that can happen during
49 * normal operation?
50 */
51#define DEBUG GNUNET_NO
52
53/**
48 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) 54 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
49 */ 55 */
50#define MAX_SIZE 65536 56#define MAX_SIZE 65536
@@ -420,7 +426,10 @@ run (int fd_tun)
420 426
421 if (-1 == written) 427 if (-1 == written)
422 { 428 {
423 fprintf (stderr, "write-error to stdout: %s\n", strerror (errno)); 429#if !DEBUG
430 if (errno != EPIPE)
431#endif
432 fprintf (stderr, "write-error to stdout: %s\n", strerror (errno));
424 shutdown (fd_tun, SHUT_RD); 433 shutdown (fd_tun, SHUT_RD);
425 shutdown (1, SHUT_WR); 434 shutdown (1, SHUT_WR);
426 read_open = 0; 435 read_open = 0;
@@ -451,7 +460,9 @@ run (int fd_tun)
451 } 460 }
452 else if (0 == bufin_size) 461 else if (0 == bufin_size)
453 { 462 {
463#if DEBUG
454 fprintf (stderr, "EOF on stdin\n"); 464 fprintf (stderr, "EOF on stdin\n");
465#endif
455 shutdown (0, SHUT_RD); 466 shutdown (0, SHUT_RD);
456 shutdown (fd_tun, SHUT_WR); 467 shutdown (fd_tun, SHUT_WR);
457 write_open = 0; 468 write_open = 0;
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 8f4d11bc9..7f7dcbf1d 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -285,6 +285,11 @@ struct TunnelState
285 285
286 286
287/** 287/**
288 * Return value from 'main'.
289 */
290static int global_ret;
291
292/**
288 * Configuration we use. 293 * Configuration we use.
289 */ 294 */
290static const struct GNUNET_CONFIGURATION_Handle *cfg; 295static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -3002,6 +3007,15 @@ run (void *cls,
3002 struct in_addr v4; 3007 struct in_addr v4;
3003 struct in6_addr v6; 3008 struct in6_addr v6;
3004 3009
3010 if (GNUNET_YES !=
3011 GNUNET_OS_check_helper_binary ("gnunet-helper-vpn"))
3012 {
3013 fprintf (stderr,
3014 "`%s' is not SUID, refusing to run.\n",
3015 "gnunet-helper-vpn");
3016 global_ret = 1;
3017 return;
3018 }
3005 cfg = cfg_; 3019 cfg = cfg_;
3006 stats = GNUNET_STATISTICS_create ("vpn", cfg); 3020 stats = GNUNET_STATISTICS_create ("vpn", cfg);
3007 if (GNUNET_OK != 3021 if (GNUNET_OK !=
@@ -3112,7 +3126,7 @@ main (int argc, char *const *argv)
3112 return (GNUNET_OK == 3126 return (GNUNET_OK ==
3113 GNUNET_SERVICE_run (argc, argv, "vpn", 3127 GNUNET_SERVICE_run (argc, argv, "vpn",
3114 GNUNET_SERVICE_OPTION_NONE, 3128 GNUNET_SERVICE_OPTION_NONE,
3115 &run, NULL)) ? 0 : 1; 3129 &run, NULL)) ? global_ret : 1;
3116} 3130}
3117 3131
3118/* end of gnunet-service-vpn.c */ 3132/* end of gnunet-service-vpn.c */
diff --git a/src/vpn/test_gnunet_vpn.c b/src/vpn/test_gnunet_vpn.c
index 6b0377f48..c7ff832e7 100644
--- a/src/vpn/test_gnunet_vpn.c
+++ b/src/vpn/test_gnunet_vpn.c
@@ -35,6 +35,8 @@
35 35
36#define VERBOSE GNUNET_NO 36#define VERBOSE GNUNET_NO
37 37
38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45)
39
38struct PeerContext 40struct PeerContext
39{ 41{
40 struct GNUNET_CONFIGURATION_Handle *cfg; 42 struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -387,7 +389,7 @@ run (void *cls, char *const *args, const char *cfgfile,
387 GNUNET_YES, 389 GNUNET_YES,
388 GNUNET_TIME_UNIT_FOREVER_ABS, 390 GNUNET_TIME_UNIT_FOREVER_ABS,
389 &allocation_cb, NULL); 391 &allocation_cb, NULL);
390 ctrl_c_task_id = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 392 ctrl_c_task_id = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
391 &ctrl_c_shutdown, 393 &ctrl_c_shutdown,
392 NULL); 394 NULL);
393} 395}