diff --git a/src/main.c b/src/main.c index e63ecf5..b7c5581 100644 --- a/src/main.c +++ b/src/main.c @@ -41,8 +41,10 @@ int check_path(char* path) { static const char* dll_name = "libproxychains4.so"; +static char own_dir[256]; static const char* dll_dirs[] = { ".", + own_dir, LIB_DIR, "/lib", "/usr/lib", @@ -51,6 +53,17 @@ static const char* dll_dirs[] = { NULL }; +static void set_own_dir(const char* argv0) { + size_t l = strlen(argv0); + while(l && argv0[l - 1] != '/') l--; + if(l == 0) + memcpy(own_dir, ".", 2); + else { + memcpy(own_dir, argv0, l - 1); + own_dir[l] = 0; + } +} + int main(int argc, char *argv[]) { char *path = NULL; char buf[256]; @@ -114,6 +127,8 @@ int main(int argc, char *argv[]) { size_t i = 0; const char* prefix = NULL; + set_own_dir(argv[0]); + while(dll_dirs[i]) { snprintf(buf, sizeof(buf), "%s/%s", dll_dirs[i], dll_name); if(access(buf, R_OK) != -1) {