summaryrefslogtreecommitdiff
path: root/src/util/os_installation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r--src/util/os_installation.c378
1 files changed, 171 insertions, 207 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index f51bfd287..8dacd431d 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -44,9 +44,14 @@
#endif
-#define LOG(kind,...) GNUNET_log_from (kind, "util-os-installation", __VA_ARGS__)
+#define LOG(kind, ...) \
+ GNUNET_log_from (kind, "util-os-installation", __VA_ARGS__)
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util-os-installation", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+ GNUNET_log_from_strerror_file (kind, \
+ "util-os-installation", \
+ syscall, \
+ filename)
/**
@@ -99,13 +104,13 @@ const struct GNUNET_OS_ProjectData *
GNUNET_OS_project_data_get ()
{
if (0 == gettextinit)
- {
- char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
- if (NULL != path)
- BINDTEXTDOMAIN (PACKAGE, path);
- GNUNET_free(path);
- gettextinit = 1;
- }
+ {
+ char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
+ if (NULL != path)
+ BINDTEXTDOMAIN (PACKAGE, path);
+ GNUNET_free (path);
+ gettextinit = 1;
+ }
return current_pd;
}
@@ -119,13 +124,13 @@ void
GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd)
{
if (0 == gettextinit)
- {
- char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
- if (NULL != path)
- BINDTEXTDOMAIN (PACKAGE, path);
- GNUNET_free(path);
- gettextinit = 1;
- }
+ {
+ char *path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
+ if (NULL != path)
+ BINDTEXTDOMAIN (PACKAGE, path);
+ GNUNET_free (path);
+ gettextinit = 1;
+ }
GNUNET_assert (NULL != pd);
current_pd = pd;
}
@@ -151,10 +156,10 @@ get_path_from_proc_maps ()
return NULL;
while (NULL != fgets (line, sizeof (line), f))
{
- if ((1 ==
- SSCANF (line, "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s", dir)) &&
- (NULL != (lgu = strstr (dir,
- current_pd->libname))))
+ if ((1 == SSCANF (line,
+ "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s",
+ dir)) &&
+ (NULL != (lgu = strstr (dir, current_pd->libname))))
{
lgu[0] = '\0';
FCLOSE (f);
@@ -179,35 +184,24 @@ get_path_from_proc_exe ()
ssize_t size;
char *lep;
- GNUNET_snprintf (fn,
- sizeof (fn),
- "/proc/%u/exe",
- getpid ());
- size = readlink (fn,
- lnk,
- sizeof (lnk) - 1);
+ GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/exe", getpid ());
+ size = readlink (fn, lnk, sizeof (lnk) - 1);
if (size <= 0)
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
- "readlink",
- fn);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
return NULL;
}
- GNUNET_assert ( ((size_t) size) < sizeof (lnk));
+ GNUNET_assert (((size_t) size) < sizeof (lnk));
lnk[size] = '\0';
while ((lnk[size] != '/') && (size > 0))
size--;
- GNUNET_asprintf (&lep,
- "/%s/libexec/",
- current_pd->project_dirname);
+ GNUNET_asprintf (&lep, "/%s/libexec/", current_pd->project_dirname);
/* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
- if ( (((size_t) size) > strlen (lep)) &&
- (0 == strcmp (lep,
- &lnk[size - strlen (lep)])) )
+ if ((((size_t) size) > strlen (lep)) &&
+ (0 == strcmp (lep, &lnk[size - strlen (lep)])))
size -= strlen (lep) - 1;
GNUNET_free (lep);
- if ( (size < 4) ||
- (lnk[size - 4] != '/') )
+ if ((size < 4) || (lnk[size - 4] != '/'))
{
/* not installed in "/bin/" -- binary path probably useless */
return NULL;
@@ -228,21 +222,19 @@ static HINSTANCE dll_instance;
* and hInstance saving.
*/
BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
+DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
- case DLL_PROCESS_ATTACH:
- dll_instance = hinstDLL;
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
+ case DLL_PROCESS_ATTACH:
+ dll_instance = hinstDLL;
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ break;
}
return TRUE;
}
@@ -271,13 +263,11 @@ get_path_from_module_filename ()
do
{
pathlen = pathlen * 2;
- modulepath = GNUNET_realloc (modulepath,
- pathlen * sizeof (wchar_t));
+ modulepath = GNUNET_realloc (modulepath, pathlen * sizeof (wchar_t));
SetLastError (0);
- real_pathlen = GetModuleFileNameW (dll_instance,
- modulepath,
- pathlen * sizeof (wchar_t));
- } while (real_pathlen >= pathlen && pathlen < 16*1024);
+ real_pathlen =
+ GetModuleFileNameW (dll_instance, modulepath, pathlen * sizeof (wchar_t));
+ } while (real_pathlen >= pathlen && pathlen < 16 * 1024);
if (real_pathlen >= pathlen)
GNUNET_assert (0);
/* To be safe */
@@ -319,7 +309,8 @@ get_path_from_module_filename ()
}
/* modulepath is GNUNET_PREFIX */
- u8_string = u16_to_u8 (modulepath, wcslen (modulepath), NULL, &u8_string_length);
+ u8_string =
+ u16_to_u8 (modulepath, wcslen (modulepath), NULL, &u8_string_length);
if (NULL == u8_string)
GNUNET_assert (0);
@@ -343,9 +334,7 @@ get_path_from_module_filename ()
* @param number of bytes available in @a buf
* @return 0 on success, otherwise desired number of bytes is stored in 'bufsize'
*/
-typedef int
-(*MyNSGetExecutablePathProto) (char *buf,
- size_t *bufsize);
+typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize);
/**
@@ -362,8 +351,9 @@ get_path_from_NSGetExecutablePath ()
MyNSGetExecutablePathProto func;
path = NULL;
- if (NULL == (func =
- (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT, "_NSGetExecutablePath")))
+ if (NULL ==
+ (func = (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT,
+ "_NSGetExecutablePath")))
return NULL;
path = &zero;
len = 0;
@@ -403,10 +393,10 @@ get_path_from_dyld_image ()
for (i = 0; i < c; i++)
{
if (((const void *) _dyld_get_image_header (i)) !=
- ((const void *) &_mh_dylib_header) )
+ ((const void *) &_mh_dylib_header))
continue;
path = _dyld_get_image_name (i);
- if ( (NULL == path) || (0 == strlen (path)) )
+ if ((NULL == path) || (0 == strlen (path)))
continue;
p = GNUNET_strdup (path);
s = p + strlen (p);
@@ -443,7 +433,7 @@ get_path_from_PATH (const char *binary)
/* On W32 look in CWD first. */
GNUNET_asprintf (&path, ".%c%s", PATH_SEPARATOR, p);
#else
- path = GNUNET_strdup (p); /* because we write on it */
+ path = GNUNET_strdup (p); /* because we write on it */
#endif
buf = GNUNET_malloc (strlen (path) + strlen (binary) + 1 + 1);
pos = path;
@@ -485,11 +475,11 @@ get_path_from_GNUNET_PREFIX ()
{
const char *p;
- if ( (NULL != current_pd->env_varname) &&
- (NULL != (p = getenv (current_pd->env_varname))) )
+ if ((NULL != current_pd->env_varname) &&
+ (NULL != (p = getenv (current_pd->env_varname))))
return GNUNET_strdup (p);
- if ( (NULL != current_pd->env_varname_alt) &&
- (NULL != (p = getenv (current_pd->env_varname_alt))) )
+ if ((NULL != current_pd->env_varname_alt) &&
+ (NULL != (p = getenv (current_pd->env_varname_alt))))
return GNUNET_strdup (p);
return NULL;
}
@@ -512,8 +502,8 @@ os_get_gnunet_path ()
if (NULL != (ret = get_path_from_proc_maps ()))
return ret;
/* try path *first*, before /proc/exe, as /proc/exe can be wrong */
- if ( (NULL != current_pd->binary_name) &&
- (NULL != (ret = get_path_from_PATH (current_pd->binary_name))) )
+ if ((NULL != current_pd->binary_name) &&
+ (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
return ret;
if (NULL != (ret = get_path_from_proc_exe ()))
return ret;
@@ -528,12 +518,13 @@ os_get_gnunet_path ()
if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
return ret;
#endif
- if ( (NULL != current_pd->binary_name) &&
- (NULL != (ret = get_path_from_PATH (current_pd->binary_name))) )
+ if ((NULL != current_pd->binary_name) &&
+ (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
return ret;
/* other attempts here */
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Could not determine installation path for %s. Set `%s' environment variable.\n"),
+ _ (
+ "Could not determine installation path for %s. Set `%s' environment variable.\n"),
current_pd->project_dirname,
current_pd->env_varname);
return NULL;
@@ -606,12 +597,11 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
execpath[--n] = '\0';
isbasedir = 1;
- if ((n > 6) &&
- ((0 == strcasecmp (&execpath[n - 6], "/lib32")) ||
- (0 == strcasecmp (&execpath[n - 6], "/lib64"))))
+ if ((n > 6) && ((0 == strcasecmp (&execpath[n - 6], "/lib32")) ||
+ (0 == strcasecmp (&execpath[n - 6], "/lib64"))))
{
- if ( (GNUNET_OS_IPK_LIBDIR != dirkind) &&
- (GNUNET_OS_IPK_LIBEXECDIR != dirkind) )
+ if ((GNUNET_OS_IPK_LIBDIR != dirkind) &&
+ (GNUNET_OS_IPK_LIBEXECDIR != dirkind))
{
/* strip '/lib32' or '/lib64' */
execpath[n - 6] = '\0';
@@ -620,9 +610,8 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
else
isbasedir = 0;
}
- else if ((n > 4) &&
- ((0 == strcasecmp (&execpath[n - 4], "/bin")) ||
- (0 == strcasecmp (&execpath[n - 4], "/lib"))))
+ else if ((n > 4) && ((0 == strcasecmp (&execpath[n - 4], "/bin")) ||
+ (0 == strcasecmp (&execpath[n - 4], "/lib"))))
{
/* strip '/bin' or '/lib' */
execpath[n - 4] = '\0';
@@ -635,9 +624,11 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
here we need to re-add 'multiarch' to lib and libexec paths later! */
multiarch = &libdir[5];
if (NULL == strchr (multiarch, '/'))
- libdir[0] = '\0'; /* Debian multiarch format, cut of from 'execpath' but preserve in multicarch */
+ libdir[0] =
+ '\0'; /* Debian multiarch format, cut of from 'execpath' but preserve in multicarch */
else
- multiarch = NULL; /* maybe not, multiarch still has a '/', which is not OK */
+ multiarch =
+ NULL; /* maybe not, multiarch still has a '/', which is not OK */
}
/* in case this was a directory named foo-bin, remove "foo-" */
while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR))
@@ -663,8 +654,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
DIR_SEPARATOR_STR,
current_pd->project_dirname,
DIR_SEPARATOR_STR);
- if (GNUNET_YES ==
- GNUNET_DISK_directory_test (tmp, GNUNET_YES))
+ if (GNUNET_YES == GNUNET_DISK_directory_test (tmp, GNUNET_YES))
{
GNUNET_free (execpath);
return tmp;
@@ -674,28 +664,23 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
dirname = NULL;
if (4 == sizeof (void *))
{
- GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
+ GNUNET_asprintf (&dirname,
+ DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
+ "%s" DIR_SEPARATOR_STR,
current_pd->project_dirname);
- GNUNET_asprintf (&tmp,
- "%s%s",
- execpath,
- dirname);
+ GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
}
if (8 == sizeof (void *))
{
GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
+ DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
+ "%s" DIR_SEPARATOR_STR,
current_pd->project_dirname);
- GNUNET_asprintf (&tmp,
- "%s%s",
- execpath,
- dirname);
+ GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
}
- if ( (NULL != tmp) &&
- (GNUNET_YES ==
- GNUNET_DISK_directory_test (tmp, GNUNET_YES)) )
+ if ((NULL != tmp) &&
+ (GNUNET_YES == GNUNET_DISK_directory_test (tmp, GNUNET_YES)))
{
GNUNET_free (execpath);
GNUNET_free_non_null (dirname);
@@ -710,25 +695,31 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
break;
case GNUNET_OS_IPK_DATADIR:
GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
+ DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
+ "%s" DIR_SEPARATOR_STR,
current_pd->project_dirname);
break;
case GNUNET_OS_IPK_LOCALEDIR:
- dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "locale" DIR_SEPARATOR_STR);
+ dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
+ "locale" DIR_SEPARATOR_STR);
break;
case GNUNET_OS_IPK_ICONDIR:
- dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "icons" DIR_SEPARATOR_STR);
+ dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
+ "icons" DIR_SEPARATOR_STR);
break;
case GNUNET_OS_IPK_DOCDIR:
GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "doc" DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
+ DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
+ "doc" DIR_SEPARATOR_STR
+ "%s" DIR_SEPARATOR_STR,
current_pd->project_dirname);
break;
case GNUNET_OS_IPK_LIBEXECDIR:
if (isbasedir)
{
GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR "libexec" DIR_SEPARATOR_STR,
+ DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
+ "libexec" DIR_SEPARATOR_STR,
current_pd->project_dirname);
GNUNET_asprintf (&tmp,
"%s%s%s%s",
@@ -736,8 +727,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR,
(NULL != multiarch) ? multiarch : "",
dirname);
- if (GNUNET_YES ==
- GNUNET_DISK_directory_test (tmp, GNUNET_YES))
+ if (GNUNET_YES == GNUNET_DISK_directory_test (tmp, GNUNET_YES))
{
GNUNET_free (execpath);
GNUNET_free (dirname);
@@ -749,26 +739,23 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
if (4 == sizeof (void *))
{
GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR "libexec" DIR_SEPARATOR_STR,
+ DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
+ "%s" DIR_SEPARATOR_STR
+ "libexec" DIR_SEPARATOR_STR,
current_pd->project_dirname);
- GNUNET_asprintf (&tmp,
- "%s%s",
- execpath,
- dirname);
+ GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
}
if (8 == sizeof (void *))
{
- GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR "libexec" DIR_SEPARATOR_STR,
+ GNUNET_asprintf (&dirname,
+ DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
+ "%s" DIR_SEPARATOR_STR
+ "libexec" DIR_SEPARATOR_STR,
current_pd->project_dirname);
- GNUNET_asprintf (&tmp,
- "%s%s",
- execpath,
- dirname);
+ GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
}
- if ( (NULL != tmp) &&
- (GNUNET_YES ==
- GNUNET_DISK_directory_test (tmp, GNUNET_YES)) )
+ if ((NULL != tmp) &&
+ (GNUNET_YES == GNUNET_DISK_directory_test (tmp, GNUNET_YES)))
{
GNUNET_free (execpath);
GNUNET_free_non_null (dirname);
@@ -778,17 +765,15 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
GNUNET_free_non_null (dirname);
}
GNUNET_asprintf (&dirname,
- DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR "libexec" DIR_SEPARATOR_STR,
+ DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
+ "libexec" DIR_SEPARATOR_STR,
current_pd->project_dirname);
break;
default:
GNUNET_free (execpath);
return NULL;
}
- GNUNET_asprintf (&tmp,
- "%s%s",
- execpath,
- dirname);
+ GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
GNUNET_free (dirname);
GNUNET_free (execpath);
return tmp;
@@ -810,11 +795,9 @@ GNUNET_OS_get_libexec_binary_path (const char *progname)
char *libexecdir;
char *binary;
- if ( (DIR_SEPARATOR == progname[0]) ||
- (GNUNET_YES ==
- GNUNET_STRINGS_path_is_absolute (progname,
- GNUNET_NO,
- NULL, NULL)) )
+ if ((DIR_SEPARATOR == progname[0]) ||
+ (GNUNET_YES ==
+ GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL)))
return GNUNET_strdup (progname);
if (NULL != cache)
libexecdir = cache;
@@ -822,10 +805,7 @@ GNUNET_OS_get_libexec_binary_path (const char *progname)
libexecdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR);
if (NULL == libexecdir)
return GNUNET_strdup (progname);
- GNUNET_asprintf (&binary,
- "%s%s",
- libexecdir,
- progname);
+ GNUNET_asprintf (&binary, "%s%s", libexecdir, progname);
cache = libexecdir;
return binary;
}
@@ -853,9 +833,7 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
size_t path_len;
if (GNUNET_YES ==
- GNUNET_STRINGS_path_is_absolute (progname,
- GNUNET_NO,
- NULL, NULL))
+ GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL))
{
return GNUNET_strdup (progname);
}
@@ -866,14 +844,15 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
"PATHS",
"SUID_BINARY_PATH",
&path);
- if (NULL == path || 0 == strlen (path))
+ if ((NULL == path)||(0 == strlen (path)))
return GNUNET_OS_get_libexec_binary_path (progname);
path_len = strlen (path);
GNUNET_asprintf (&binary,
- "%s%s%s",
- path,
- (path[path_len - 1] == DIR_SEPARATOR) ? "" : DIR_SEPARATOR_STR,
- progname);
+ "%s%s%s",
+ path,
+ (path[path_len - 1] == DIR_SEPARATOR) ? ""
+ : DIR_SEPARATOR_STR,
+ progname);
cache = path;
return binary;
}
@@ -906,14 +885,10 @@ GNUNET_OS_check_helper_binary (const char *binary,
#ifdef MINGW
char *binaryexe;
- GNUNET_asprintf (&binaryexe,
- "%s.exe",
- binary);
- if ( (GNUNET_YES ==
- GNUNET_STRINGS_path_is_absolute (binaryexe,
- GNUNET_NO,
- NULL, NULL)) ||
- (0 == strncmp (binary, "./", 2)) )
+ GNUNET_asprintf (&binaryexe, "%s.exe", binary);
+ if ((GNUNET_YES ==
+ GNUNET_STRINGS_path_is_absolute (binaryexe, GNUNET_NO, NULL, NULL)) ||
+ (0 == strncmp (binary, "./", 2)))
p = GNUNET_strdup (binaryexe);
else
{
@@ -927,12 +902,9 @@ GNUNET_OS_check_helper_binary (const char *binary,
}
GNUNET_free (binaryexe);
#else
- if ( (GNUNET_YES ==
- GNUNET_STRINGS_path_is_absolute (binary,
- GNUNET_NO,
- NULL,
- NULL)) ||
- (0 == strncmp (binary, "./", 2)) )
+ if ((GNUNET_YES ==
+ GNUNET_STRINGS_path_is_absolute (binary, GNUNET_NO, NULL, NULL)) ||
+ (0 == strncmp (binary, "./", 2)))
{
p = GNUNET_strdup (binary);
}
@@ -941,10 +913,7 @@ GNUNET_OS_check_helper_binary (const char *binary,
p = get_path_from_PATH (binary);
if (NULL != p)
{
- GNUNET_asprintf (&pf,
- "%s/%s",
- p,
- binary);
+ GNUNET_asprintf (&pf, "%s/%s", p, binary);
GNUNET_free (p);
p = pf;
}
@@ -953,16 +922,13 @@ GNUNET_OS_check_helper_binary (const char *binary,
if (NULL == p)
{
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Could not find binary `%s' in PATH!\n"),
+ _ ("Could not find binary `%s' in PATH!\n"),
binary);
return GNUNET_SYSERR;
}
- if (0 != ACCESS (p,
- X_OK))
+ if (0 != ACCESS (p, X_OK))
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
- "access",
- p);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "access", p);
GNUNET_free (p);
return GNUNET_SYSERR;
}
@@ -974,12 +940,9 @@ GNUNET_OS_check_helper_binary (const char *binary,
return GNUNET_YES;
}
#endif
- if (0 != STAT (p,
- &statbuf))
+ if (0 != STAT (p, &statbuf))
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
- "stat",
- p);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", p);
GNUNET_free (p);
return GNUNET_SYSERR;
}
@@ -987,14 +950,13 @@ GNUNET_OS_check_helper_binary (const char *binary,
{
#ifndef MINGW
(void) params;
- if ( (0 != (statbuf.st_mode & S_ISUID)) &&
- (0 == statbuf.st_uid) )
+ if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid))
{
GNUNET_free (p);
return GNUNET_YES;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Binary `%s' exists, but is not SUID\n"),
+ _ ("Binary `%s' exists, but is not SUID\n"),
p);
/* binary exists, but not SUID */
#else
@@ -1003,50 +965,52 @@ GNUNET_OS_check_helper_binary (const char *binary,
PROCESS_INFORMATION proc;
DWORD exit_value;
- GNUNET_snprintf (parameters,
- sizeof (parameters),
- "-d %s", params);
+ GNUNET_snprintf (parameters, sizeof (parameters), "-d %s", params);
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
memset (&proc, 0, sizeof (proc));
// Start the child process.
- if ( ! (CreateProcess( p, // current windows (2k3 and up can handle / instead of \ in paths))
- parameters, // execute dryrun/priviliege checking mode
- NULL, // Process handle not inheritable
- NULL, // Thread handle not inheritable
- FALSE, // Set handle inheritance to FALSE
- CREATE_DEFAULT_ERROR_MODE, // No creation flags
- NULL, // Use parent's environment block
- NULL, // Use parent's starting directory
- &start, // Pointer to STARTUPINFO structure
- &proc ) // Pointer to PROCESS_INFORMATION structure
- ))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("CreateProcess failed for binary %s (%d).\n"),
- p, GetLastError());
- return GNUNET_SYSERR;
+ if (! (CreateProcess (
+ p, // current windows (2k3 and up can handle / instead of \ in paths))
+ parameters, // execute dryrun/priviliege checking mode
+ NULL, // Process handle not inheritable
+ NULL, // Thread handle not inheritable
+ FALSE, // Set handle inheritance to FALSE
+ CREATE_DEFAULT_ERROR_MODE, // No creation flags
+ NULL, // Use parent's environment block
+ NULL, // Use parent's starting directory
+ &start, // Pointer to STARTUPINFO structure
+ &proc) // Pointer to PROCESS_INFORMATION structure
+ ))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("CreateProcess failed for binary %s (%d).\n"),
+ p,
+ GetLastError ());
+ return GNUNET_SYSERR;
}
// Wait until child process exits.
- WaitForSingleObject( proc.hProcess, INFINITE );
+ WaitForSingleObject (proc.hProcess, INFINITE);
- if ( ! GetExitCodeProcess (proc.hProcess, &exit_value)){
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("GetExitCodeProcess failed for binary %s (%d).\n"),
- p, GetLastError() );
- return GNUNET_SYSERR;
- }
+ if (! GetExitCodeProcess (proc.hProcess, &exit_value))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("GetExitCodeProcess failed for binary %s (%d).\n"),
+ p,
+ GetLastError ());
+ return GNUNET_SYSERR;
+ }
// Close process and thread handles.
- CloseHandle( proc.hProcess );
- CloseHandle( proc.hThread );
+ CloseHandle (proc.hProcess);
+ CloseHandle (proc.hThread);
- if (!exit_value)
+ if (! exit_value)
return GNUNET_YES;
#endif
- }
+ }
GNUNET_free (p);
return GNUNET_NO;
}