while (NULL != fgets (line, sizeof (line), f))
{
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%*[ ]%1023s", dir)) &&
(NULL != (lgu = strstr (dir, "libgnunetutil"))))
{
lgu[0] = '\0';
return TRUE;
}
+
/**
* Try to determine path with win32-specific function
*
#if LINUX
if (NULL != (ret = get_path_from_proc_maps ()))
return ret;
+ /* try path *first*, before /proc/exe, as /proc/exe can be wrong */
+ if (NULL != (ret = get_path_from_PATH ("gnunet-arm")))
+ return ret;
if (NULL != (ret = get_path_from_proc_exe ()))
return ret;
#endif
static char *
os_get_exec_path ()
{
- char *ret;
+ char *ret = NULL;
#if LINUX
if (NULL != (ret = get_path_from_proc_exe ()))
return ret;
#endif
/* other attempts here */
- return NULL;
+ return ret;
}
execpath[--n] = '\0';
isbasedir = 1;
- if ((n > 5) &&
- ((0 == strcasecmp (&execpath[n - 5], "lib32")) ||
- (0 == strcasecmp (&execpath[n - 5], "lib64"))))
+ if ((n > 6) &&
+ ((0 == strcasecmp (&execpath[n - 6], "/lib32")) ||
+ (0 == strcasecmp (&execpath[n - 6], "/lib64"))))
{
- if (GNUNET_OS_IPK_LIBDIR != dirkind)
+ if ( (GNUNET_OS_IPK_LIBDIR != dirkind) &&
+ (GNUNET_OS_IPK_LIBEXECDIR != dirkind) )
{
/* strip '/lib32' or '/lib64' */
- execpath[n - 5] = '\0';
- n -= 5;
+ execpath[n - 6] = '\0';
+ n -= 6;
}
else
isbasedir = 0;
}
- else if ((n > 3) &&
- ((0 == strcasecmp (&execpath[n - 3], "bin")) ||
- (0 == strcasecmp (&execpath[n - 3], "lib"))))
+ else if ((n > 4) &&
+ ((0 == strcasecmp (&execpath[n - 4], "/bin")) ||
+ (0 == strcasecmp (&execpath[n - 4], "/lib"))))
{
/* strip '/bin' or '/lib' */
- execpath[n - 3] = '\0';
- n -= 3;
+ execpath[n - 4] = '\0';
+ n -= 4;
}
/* in case this was a directory named foo-bin, remove "foo-" */
while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR))
break;
case GNUNET_OS_IPK_LIBDIR:
if (isbasedir)
+ {
dirname =
DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR;
+ tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1);
+ sprintf (tmp, "%s%s", execpath, dirname);
+ if ( (GNUNET_YES !=
+ GNUNET_DISK_directory_test (tmp, GNUNET_YES)) &&
+ (4 == sizeof (void *)) )
+ {
+ GNUNET_free (tmp);
+ dirname =
+ DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR;
+ tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1);
+ sprintf (tmp, "%s%s", execpath, dirname);
+ }
+ if ( (GNUNET_YES !=
+ GNUNET_DISK_directory_test (tmp, GNUNET_YES)) &&
+ (8 == sizeof (void *)) )
+ {
+ dirname =
+ DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR;
+ }
+ GNUNET_free (tmp);
+ }
else
dirname = DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR;
break;
"gnunet" DIR_SEPARATOR_STR;
break;
case GNUNET_OS_IPK_LIBEXECDIR:
- dirname =
+ if (isbasedir)
+ {
+ dirname =
DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR \
"libexec" DIR_SEPARATOR_STR;
+ tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1);
+ sprintf (tmp, "%s%s", execpath, dirname);
+ if ( (GNUNET_YES !=
+ GNUNET_DISK_directory_test (tmp, GNUNET_YES)) &&
+ (4 == sizeof (void *)) )
+ {
+ GNUNET_free (tmp);
+ dirname =
+ DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR \
+ "libexec" DIR_SEPARATOR_STR;
+ tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1);
+ sprintf (tmp, "%s%s", execpath, dirname);
+ }
+ if ( (GNUNET_YES !=
+ GNUNET_DISK_directory_test (tmp, GNUNET_YES)) &&
+ (8 == sizeof (void *)) )
+ {
+ dirname =
+ DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR \
+ "libexec" DIR_SEPARATOR_STR;
+ }
+ GNUNET_free (tmp);
+ }
+ else
+ dirname =
+ DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR \
+ "libexec" DIR_SEPARATOR_STR;
break;
default:
GNUNET_free (execpath);
char *libexecdir;
char *binary;
+ if (DIR_SEPARATOR == progname[0])
+ return GNUNET_strdup (progname);
libexecdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR);
if (NULL == libexecdir)
return GNUNET_strdup (progname);