-terminate test after a while, check for SUID helper
authorChristian Grothoff <christian@grothoff.org>
Wed, 25 Jan 2012 20:15:58 +0000 (20:15 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 25 Jan 2012 20:15:58 +0000 (20:15 +0000)
src/vpn/gnunet-helper-vpn.c
src/vpn/gnunet-service-vpn.c
src/vpn/test_gnunet_vpn.c

index a6035d1d182b68d57184dbe4421a6a92ee884745..77512832d3653f6a5b3b7798735683f7049d6ed1 100644 (file)
  */
 #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;
index 8f4d11bc9f5a99d2a9fe6c53d6876ee9988fdab2..7f7dcbf1d1ac781f49510005fd0e9c29e62631b0 100644 (file)
@@ -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 */
index 6b0377f48eaebaba9524d4f8f4907de79e37e28a..c7ff832e7d3a5a3f480f53d2fb692e35829c0e4e 100644 (file)
@@ -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);
 }