View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001606 | GNUnet | transport service | public | 2010-09-22 09:10 | 2024-05-03 13:59 |
| Reporter | LRN | Assigned To | Christian Grothoff | ||
| Priority | normal | Severity | block | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Summary | 0001606: TCP/UDP transports fail to initialize | ||||
| Description | Because unported get_path_from_PATH() fails on NT. | ||||
| Additional Information | Attached a diff. What it does: * Fix plibc.h to define correct path separator (the only reason it worked so far is because PATH_SEPARATOR was never ever used anywhere) * Use PATH_SEPARATOR and PATH_SEPARATOR_STR throughout gnunet instead of ':' and ":" * Append '.exe' extension to binary name in check_gnunet_nat_binary() when running on NT * Add more debug logging everywhere * Fix #include indentation in gnunet-vpn-pretty-print.c | ||||
| Tags | No tags attached. | ||||
| Attached Files | get_path_from_PATH.diff (6,524 bytes)
Index: src/include/plibc.h
===================================================================
--- src/include/plibc.h (revision 13056)
+++ src/include/plibc.h (working copy)
@@ -463,8 +463,8 @@
#ifndef WINDOWS
#define DIR_SEPARATOR '/'
#define DIR_SEPARATOR_STR "/"
- #define PATH_SEPARATOR ';'
- #define PATH_SEPARATOR_STR ";"
+ #define PATH_SEPARATOR ':'
+ #define PATH_SEPARATOR_STR ":"
#define NEWLINE "\n"
#ifdef ENABLE_NLS
@@ -556,8 +556,8 @@
#else
#define DIR_SEPARATOR '\\'
#define DIR_SEPARATOR_STR "\\"
- #define PATH_SEPARATOR ':'
- #define PATH_SEPARATOR_STR ":"
+ #define PATH_SEPARATOR ';'
+ #define PATH_SEPARATOR_STR ";"
#define NEWLINE "\r\n"
#ifdef ENABLE_NLS
Index: src/transport/plugin_transport_udp.c
===================================================================
--- src/transport/plugin_transport_udp.c (revision 13056)
+++ src/transport/plugin_transport_udp.c (working copy)
@@ -1999,7 +1999,7 @@
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 @@
{
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 @@
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
}
/**
Index: src/transport/test_transport_api.c
===================================================================
--- src/transport/test_transport_api.c (revision 13056)
+++ src/transport/test_transport_api.c (working copy)
@@ -470,7 +470,7 @@
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");
Index: src/transport/plugin_transport_tcp.c
===================================================================
--- src/transport/plugin_transport_tcp.c (revision 13056)
+++ src/transport/plugin_transport_tcp.c (working copy)
@@ -2238,28 +2238,36 @@
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 @@
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 @@
#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
Index: src/monkey/gdbmi_connect.c
===================================================================
--- src/monkey/gdbmi_connect.c (revision 13056)
+++ src/monkey/gdbmi_connect.c (working copy)
@@ -626,7 +626,7 @@
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 @@
free(pt);
return strdup(test);
}
- r=strtok(NULL,":");
+ r=strtok(NULL,PATH_SEPARATOR_STR);
}
free(pt);
return NULL;
Index: src/vpn/gnunet-vpn-pretty-print.c
===================================================================
--- src/vpn/gnunet-vpn-pretty-print.c (revision 13051)
+++ src/vpn/gnunet-vpn-pretty-print.c (working copy)
@@ -4,7 +4,7 @@
#include <ctype.h>
#include <malloc.h>
#ifndef _WIN32
- #include <arpa/inet.h>
+#include <arpa/inet.h>
#else
#include <ws2tcpip.h>
#endif
Index: src/util/os_installation.c
===================================================================
--- src/util/os_installation.c (revision 13056)
+++ src/util/os_installation.c (working copy)
@@ -209,7 +209,7 @@
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");
get_path_from_PATH-ndu1.diff (5,779 bytes)
Index: src/transport/plugin_transport_udp.c
===================================================================
--- src/transport/plugin_transport_udp.c (revision 13056)
+++ src/transport/plugin_transport_udp.c (working copy)
@@ -1999,7 +1999,7 @@
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 @@
{
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 @@
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) failed! GLE = %d\n", err);
+ return GNUNET_NO; /* not running as administrator */
+ }
+ closesocket (rawsock);
+ return GNUNET_YES;
+#endif
}
/**
Index: src/transport/test_transport_api.c
===================================================================
--- src/transport/test_transport_api.c (revision 13056)
+++ src/transport/test_transport_api.c (working copy)
@@ -470,7 +470,7 @@
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");
Index: src/transport/plugin_transport_tcp.c
===================================================================
--- src/transport/plugin_transport_tcp.c (revision 13056)
+++ src/transport/plugin_transport_tcp.c (working copy)
@@ -2238,28 +2238,36 @@
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' succeeded.\n", buf);
GNUNET_free (path);
return buf;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' 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' succeeded.\n", buf);
GNUNET_free (path);
return buf;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Check for `%s' failed.\n", buf);
GNUNET_free (buf);
GNUNET_free (path);
return NULL;
@@ -2281,11 +2289,22 @@
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) failed!\n", binary);
return GNUNET_NO;
+ }
if (0 != STAT (p, &statbuf))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STAT (%s, &statbuf) failed!\n", p);
GNUNET_free (p);
return GNUNET_SYSERR;
}
@@ -2298,7 +2317,11 @@
#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) failed! GLE = %d\n", err);
return GNUNET_NO; /* not running as administrator */
+ }
closesocket (rawsock);
return GNUNET_YES;
#endif
Index: src/monkey/gdbmi_connect.c
===================================================================
--- src/monkey/gdbmi_connect.c (revision 13056)
+++ src/monkey/gdbmi_connect.c (working copy)
@@ -626,7 +626,7 @@
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 @@
free(pt);
return strdup(test);
}
- r=strtok(NULL,":");
+ r=strtok(NULL,PATH_SEPARATOR_STR);
}
free(pt);
return NULL;
Index: src/vpn/gnunet-vpn-pretty-print.c
===================================================================
--- src/vpn/gnunet-vpn-pretty-print.c (revision 13051)
+++ src/vpn/gnunet-vpn-pretty-print.c (working copy)
@@ -4,7 +4,7 @@
#include <ctype.h>
#include <malloc.h>
#ifndef _WIN32
- #include <arpa/inet.h>
+#include <arpa/inet.h>
#else
#include <ws2tcpip.h>
#endif
Index: src/util/os_installation.c
===================================================================
--- src/util/os_installation.c (revision 13056)
+++ src/util/os_installation.c (working copy)
@@ -209,7 +209,7 @@
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");
| ||||
|
|
removed plibc patch, fixed messages. I'm not happy with the privege check, but don't have a better idea (yet?). |
|
|
Applied patch as SVN 13072. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2010-09-22 09:10 | LRN | New Issue | |
| 2010-09-22 09:10 | LRN | File Added: get_path_from_PATH.diff | |
| 2010-09-23 09:42 | NDurner | File Added: get_path_from_PATH-ndu1.diff | |
| 2010-09-23 09:44 | NDurner | Note Added: 0004124 | |
| 2010-09-23 09:49 | Christian Grothoff | Note Added: 0004125 | |
| 2010-09-23 09:50 | Christian Grothoff | Status | new => resolved |
| 2010-09-23 09:50 | Christian Grothoff | Fixed in Version | => Git master |
| 2010-09-23 09:50 | Christian Grothoff | Resolution | open => fixed |
| 2010-09-23 09:50 | Christian Grothoff | Assigned To | => Christian Grothoff |
| 2010-10-21 15:47 | Christian Grothoff | Status | resolved => closed |
| 2011-09-19 10:45 | Christian Grothoff | Fixed in Version | Git master => 0.9.0pre3 |
| 2011-09-19 10:45 | Christian Grothoff | Target Version | => 0.9.0pre3 |
| 2024-05-03 13:59 | Christian Grothoff | Category | TCP transport => transport service |