check stat return value
authorChristian Grothoff <christian@grothoff.org>
Thu, 4 Mar 2010 09:13:27 +0000 (09:13 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 4 Mar 2010 09:13:27 +0000 (09:13 +0000)
src/transport/test_transport_api.c

index 46c3ba3afb83eadcf90cc9f503a0bac254f99aa0..93bfb8885e92a6c2beb4f1e5e03bf2dc2c105ada 100644 (file)
@@ -379,19 +379,17 @@ get_path_from_PATH ()
 }
 
 
-static int check_gnunet_nat_server()
+static int 
+check_gnunet_nat_server()
 {
   struct stat statbuf;
 
-  stat(get_path_from_PATH(), &statbuf);
-  if ((statbuf.st_mode & S_ISUID) && (statbuf.st_uid == 0))
-    {
-      return GNUNET_YES;
-    }
-  else
-    {
-      return GNUNET_NO;
-    }
+  if (0 != STAT (get_path_from_PATH(), &statbuf))
+    return GNUNET_SYSERR;
+  if ( (0 != (statbuf.st_mode & S_ISUID)) && 
+       (statbuf.st_uid == 0) )    
+    return GNUNET_YES;
+  return GNUNET_NO;
 }
 
 int
@@ -408,10 +406,11 @@ main (int argc, char *argv[])
   else if (strstr(argv[0], "udp_nat") != NULL)
     {
       is_udp_nat = GNUNET_YES;
-      if (check_gnunet_nat_server() == GNUNET_NO)
+      if (check_gnunet_nat_server() != GNUNET_OK)
         {
           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                      "gnunet-nat-server not installed as root, but not failing!\n");
+                      "`%s' not properly installed, cannot run NAT test!\n",
+                     "gnunet-nat-server");
           return 0;
         }
     }