From 3958bb3f395dd7cb1f730f6bb03133dce14e8c2d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Mar 2010 09:13:27 +0000 Subject: [PATCH] check stat return value --- src/transport/test_transport_api.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 46c3ba3af..93bfb8885 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -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; } } -- 2.25.1