os_installation.c   os_installation.c 
skipping to change at line 59 skipping to change at line 59
static char * static char *
get_path_from_proc_maps () get_path_from_proc_maps ()
{ {
char fn[64]; char fn[64];
char line[1024]; char line[1024];
char dir[1024]; char dir[1024];
FILE *f; FILE *f;
char *lgu; char *lgu;
GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ()); GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ());
f = fopen (fn, "r"); f = FOPEN (fn, "r");
if (f == NULL) if (f == NULL)
return NULL; return NULL;
while (NULL != fgets (line, sizeof (line), f)) while (NULL != fgets (line, sizeof (line), f))
{ {
if ((1 == if ((1 ==
sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir )) && sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir )) &&
(NULL != (lgu = strstr (dir, "libgnunetutil")))) (NULL != (lgu = strstr (dir, "libgnunetutil"))))
{ {
lgu[0] = '\0'; lgu[0] = '\0';
fclose (f); FCLOSE (f);
return GNUNET_strdup (dir); return GNUNET_strdup (dir);
} }
} }
fclose (f); FCLOSE (f);
return NULL; return NULL;
} }
/** /**
* Try to determine path by reading /proc/PID/exe * Try to determine path by reading /proc/PID/exe
*/ */
static char * static char *
get_path_from_proc_exe () get_path_from_proc_exe ()
{ {
char fn[64]; char fn[64];
skipping to change at line 115 skipping to change at line 115
} }
#endif #endif
#if WINDOWS #if WINDOWS
/** /**
* Try to determine path with win32-specific function * Try to determine path with win32-specific function
*/ */
static char * static char *
get_path_from_module_filename () get_path_from_module_filename ()
{ {
char path[4097]; wchar_t path[4097];
char *idx; char upath[4097];
wchar_t *idx;
GetModuleFileName (NULL, path, sizeof (path) - 1);
idx = path + strlen (path); GetModuleFileNameW (NULL, path, sizeof (path) - 1);
while ((idx > path) && (*idx != '\\') && (*idx != '/')) idx = path + wcslen (path);
while ((idx > path) && (*idx != L'\\') && (*idx != L'/'))
idx--; idx--;
*idx = '\0'; *idx = L'\0';
return GNUNET_strdup (path); upath[0] = '\0';
WideCharToMultiByte (CP_UTF8, 0, path, -1, upath, 4097, NULL, NULL);
return GNUNET_strdup (upath);
} }
#endif #endif
#if DARWIN #if DARWIN
typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t * bufsize); typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t * bufsize);
static char * static char *
get_path_from_NSGetExecutablePath () get_path_from_NSGetExecutablePath ()
{ {
static char zero = '\0'; static char zero = '\0';
skipping to change at line 467 skipping to change at line 471
char *binaryexe; char *binaryexe;
GNUNET_asprintf (&binaryexe, "%s.exe", binary); GNUNET_asprintf (&binaryexe, "%s.exe", binary);
p = get_path_from_PATH (binaryexe); p = get_path_from_PATH (binaryexe);
if (p != NULL) if (p != NULL)
{ {
GNUNET_asprintf (&pf, "%s/%s", p, binaryexe); GNUNET_asprintf (&pf, "%s/%s", p, binaryexe);
GNUNET_free (p); GNUNET_free (p);
p = pf; p = pf;
} }
free (binaryexe); GNUNET_free (binaryexe);
#else #else
p = get_path_from_PATH (binary); p = get_path_from_PATH (binary);
if (p != NULL) if (p != NULL)
{ {
GNUNET_asprintf (&pf, "%s/%s", p, binary); GNUNET_asprintf (&pf, "%s/%s", p, binary);
GNUNET_free (p); GNUNET_free (p);
p = pf; p = pf;
} }
#endif #endif
if (p == NULL) if (p == NULL)
{ {
LOG (GNUNET_ERROR_TYPE_INFO, _("Could not find binary `%s' in PATH!\n") , LOG (GNUNET_ERROR_TYPE_INFO, _("Could not find binary `%s' in PATH!\n") ,
binary); binary);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (0 != ACCESS (p, X_OK))
{
LOG (GNUNET_ERROR_TYPE_WARNING, _("access (%s, X_OK) failed: %s\n"), p,
STRERROR (errno));
GNUNET_free (p);
return GNUNET_SYSERR;
}
#ifndef MINGW
if (0 == getuid ())
{
/* as we run as root, we don't insist on SUID */
GNUNET_free (p);
return GNUNET_OK;
}
#endif
if (0 != STAT (p, &statbuf)) if (0 != STAT (p, &statbuf))
{ {
LOG (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, LOG (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p,
STRERROR (errno)); STRERROR (errno));
GNUNET_free (p); GNUNET_free (p);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
#ifndef MINGW #ifndef MINGW
if ((0 != (statbuf.st_mode & S_ISUID)) && (statbuf.st_uid == 0)) if ((0 != (statbuf.st_mode & S_ISUID)) && (statbuf.st_uid == 0))
{ {
GNUNET_free (p); GNUNET_free (p);
return GNUNET_YES; return GNUNET_YES;
} }
if (0 == ACCESS (p, X_OK)) /* binary exists, but not SUID */
{
GNUNET_free (p);
return GNUNET_NO;
}
GNUNET_free (p); GNUNET_free (p);
return GNUNET_SYSERR; return GNUNET_NO;
#else #else
GNUNET_free (p); GNUNET_free (p);
rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP); rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
if (INVALID_SOCKET == rawsock) if (INVALID_SOCKET == rawsock)
{ {
DWORD err = GetLastError (); DWORD err = GetLastError ();
LOG (GNUNET_ERROR_TYPE_INFO, LOG (GNUNET_ERROR_TYPE_INFO,
"socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) failed! GLE = %d\n", err ); "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) failed! GLE = %d\n", err );
return GNUNET_NO; /* not running as administrator */ return GNUNET_NO; /* not running as administrator */
 End of changes. 9 change blocks. 
18 lines changed or deleted 33 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/