From 2ab3c347974b33e0715ce1fad0f42d4846da3aee Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 23 Sep 2010 07:49:34 +0000 Subject: [PATCH] mantis 1606 --- src/monkey/gdbmi_connect.c | 4 ++-- src/transport/plugin_transport_tcp.c | 25 ++++++++++++++++++++++++- src/transport/plugin_transport_udp.c | 24 +++++++++++++++++++++++- src/transport/test_transport_api.c | 2 +- src/util/os_installation.c | 2 +- src/vpn/gnunet-vpn-pretty-print.c | 2 +- 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/monkey/gdbmi_connect.c b/src/monkey/gdbmi_connect.c index a39fdf27f..501d1f064 100644 --- a/src/monkey/gdbmi_connect.c +++ b/src/monkey/gdbmi_connect.c @@ -626,7 +626,7 @@ char *mi_search_in_path(const char *file) if (!path) return NULL; pt=strdup(path); - r=strtok(pt,":"); + r=strtok(pt,PATH_SEPARATOR_STR); while (r) { strcpy(test,r); @@ -637,7 +637,7 @@ char *mi_search_in_path(const char *file) free(pt); return strdup(test); } - r=strtok(NULL,":"); + r=strtok(NULL,PATH_SEPARATOR_STR); } free(pt); return NULL; diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 47ef1a91f..2b4553930 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2238,28 +2238,36 @@ get_path_from_PATH (char *binary) p = getenv ("PATH"); if (p == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH is NULL, returning.\n"); return NULL; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH is `%s', PATH_SEPARATOR is '%c'\n", p, PATH_SEPARATOR); path = GNUNET_strdup (p); /* because we write on it */ buf = GNUNET_malloc (strlen (path) + 20); pos = path; - while (NULL != (end = strchr (pos, ':'))) + while (NULL != (end = strchr (pos, PATH_SEPARATOR))) { *end = '\0'; sprintf (buf, "%s/%s", pos, binary); if (GNUNET_DISK_file_test (buf) == GNUNET_YES) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have succeeded.\n", buf); GNUNET_free (path); return buf; } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have failed.\n", buf); pos = end + 1; } sprintf (buf, "%s/%s", pos, binary); if (GNUNET_DISK_file_test (buf) == GNUNET_YES) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have succeeded.\n", buf); GNUNET_free (path); return buf; } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' have failed.\n", buf); GNUNET_free (buf); GNUNET_free (path); return NULL; @@ -2281,11 +2289,22 @@ check_gnunet_nat_binary(char *binary) SOCKET rawsock; #endif +#ifdef MINGW + char *binaryexe; + GNUNET_asprintf (&binaryexe, "%s.exe", binary); + p = get_path_from_PATH (binaryexe); + free (binaryexe); +#else p = get_path_from_PATH (binary); +#endif if (p == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "get_path_from_PATH (%s) have failed!\n", binary); return GNUNET_NO; + } if (0 != STAT (p, &statbuf)) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STAT (%s, &statbuf) have failed!\n", p); GNUNET_free (p); return GNUNET_SYSERR; } @@ -2298,7 +2317,11 @@ check_gnunet_nat_binary(char *binary) #else rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP); if (INVALID_SOCKET == rawsock) + { + DWORD err = GetLastError (); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err); return GNUNET_NO; /* not running as administrator */ + } closesocket (rawsock); return GNUNET_YES; #endif diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 3f2b83b05..b5beb157f 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -1999,7 +1999,7 @@ get_path_from_PATH (char *binary) buf = GNUNET_malloc (strlen (path) + 20); pos = path; - while (NULL != (end = strchr (pos, ':'))) + while (NULL != (end = strchr (pos, PATH_SEPARATOR))) { *end = '\0'; sprintf (buf, "%s/%s", pos, binary); @@ -2033,8 +2033,18 @@ check_gnunet_nat_binary(char *binary) { struct stat statbuf; char *p; +#ifdef MINGW + SOCKET rawsock; +#endif +#ifdef MINGW + char *binaryexe; + GNUNET_asprintf (&binaryexe, "%s.exe", binary); + p = get_path_from_PATH (binaryexe); + free (binaryexe); +#else p = get_path_from_PATH (binary); +#endif if (p == NULL) return GNUNET_NO; if (0 != STAT (p, &statbuf)) @@ -2043,10 +2053,22 @@ check_gnunet_nat_binary(char *binary) return GNUNET_SYSERR; } GNUNET_free (p); +#ifndef MINGW if ( (0 != (statbuf.st_mode & S_ISUID)) && (statbuf.st_uid == 0) ) return GNUNET_YES; return GNUNET_NO; +#else + rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP); + if (INVALID_SOCKET == rawsock) + { + DWORD err = GetLastError (); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err); + return GNUNET_NO; /* not running as administrator */ + } + closesocket (rawsock); + return GNUNET_YES; +#endif } /** diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 671e28bfc..bf574ab04 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -470,7 +470,7 @@ get_path_from_PATH () buf = GNUNET_malloc (strlen (path) + 20); pos = path; - while (NULL != (end = strchr (pos, ':'))) + while (NULL != (end = strchr (pos, PATH_SEPARATOR))) { *end = '\0'; sprintf (buf, "%s/%s", pos, "gnunet-nat-server"); diff --git a/src/util/os_installation.c b/src/util/os_installation.c index ce8d0aac7..cbbc61433 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -209,7 +209,7 @@ get_path_from_PATH () buf = GNUNET_malloc (strlen (path) + 20); pos = path; - while (NULL != (end = strchr (pos, ':'))) + while (NULL != (end = strchr (pos, PATH_SEPARATOR))) { *end = '\0'; sprintf (buf, "%s/%s", pos, "gnunet-arm"); diff --git a/src/vpn/gnunet-vpn-pretty-print.c b/src/vpn/gnunet-vpn-pretty-print.c index da95af4e9..577db5098 100644 --- a/src/vpn/gnunet-vpn-pretty-print.c +++ b/src/vpn/gnunet-vpn-pretty-print.c @@ -4,7 +4,7 @@ #include #include #ifndef _WIN32 - #include +#include #else #include #endif -- 2.25.1