From 9935d917ca2a9a34e9c6d1aa744744eaeb6dfd2e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 25 Jan 2012 20:15:58 +0000 Subject: -terminate test after a while, check for SUID helper --- src/vpn/gnunet-helper-vpn.c | 13 ++++++++++++- src/vpn/gnunet-service-vpn.c | 16 +++++++++++++++- src/vpn/test_gnunet_vpn.c | 4 +++- 3 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src/vpn') 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 @@ -44,6 +44,12 @@ */ #include "gnunet_protocols.h" +/** + * Should we print (interesting|debug) messages that can happen during + * normal operation? + */ +#define DEBUG GNUNET_NO + /** * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) */ @@ -420,7 +426,10 @@ run (int fd_tun) if (-1 == written) { - fprintf (stderr, "write-error to stdout: %s\n", strerror (errno)); +#if !DEBUG + if (errno != EPIPE) +#endif + fprintf (stderr, "write-error to stdout: %s\n", strerror (errno)); shutdown (fd_tun, SHUT_RD); shutdown (1, SHUT_WR); read_open = 0; @@ -451,7 +460,9 @@ run (int fd_tun) } else if (0 == bufin_size) { +#if DEBUG fprintf (stderr, "EOF on stdin\n"); +#endif shutdown (0, SHUT_RD); shutdown (fd_tun, SHUT_WR); 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 @@ -284,6 +284,11 @@ struct TunnelState }; +/** + * Return value from 'main'. + */ +static int global_ret; + /** * Configuration we use. */ @@ -3002,6 +3007,15 @@ run (void *cls, struct in_addr v4; struct in6_addr v6; + if (GNUNET_YES != + GNUNET_OS_check_helper_binary ("gnunet-helper-vpn")) + { + fprintf (stderr, + "`%s' is not SUID, refusing to run.\n", + "gnunet-helper-vpn"); + global_ret = 1; + return; + } cfg = cfg_; stats = GNUNET_STATISTICS_create ("vpn", cfg); if (GNUNET_OK != @@ -3112,7 +3126,7 @@ main (int argc, char *const *argv) return (GNUNET_OK == GNUNET_SERVICE_run (argc, argv, "vpn", GNUNET_SERVICE_OPTION_NONE, - &run, NULL)) ? 0 : 1; + &run, NULL)) ? global_ret : 1; } /* 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 @@ #define VERBOSE GNUNET_NO +#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45) + struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; @@ -387,7 +389,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_YES, GNUNET_TIME_UNIT_FOREVER_ABS, &allocation_cb, NULL); - ctrl_c_task_id = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + ctrl_c_task_id = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &ctrl_c_shutdown, NULL); } -- cgit v1.2.3