helpers.cpp: fix find_executable

- function made the environment variable PATH broken
This commit is contained in:
[priv] M. Liebmann
2014-01-27 12:55:25 +01:00
committed by M. Liebmann
parent 1ee458e461
commit 356feceb9c

View File

@@ -293,9 +293,11 @@ bool get_mem_usage(unsigned long &kbtotal, unsigned long &kbfree)
std::string find_executable(const char *name) std::string find_executable(const char *name)
{ {
struct stat s; struct stat s;
char *path = getenv("PATH"); char *tmpPath = getenv("PATH");
char *p, *n; char *p, *n, *path;
if (! path) if (tmpPath)
path = strdupa(tmpPath);
else
path = strdupa("/bin:/usr/bin:/sbin:/usr/sbin"); path = strdupa("/bin:/usr/bin:/sbin:/usr/sbin");
if (name[0] == '/') { /* full path given */ if (name[0] == '/') { /* full path given */
if (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)) if (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode))