Skip to content

Commit

Permalink
try to get config file in own_dir if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
soflare authored and Aven committed Jun 24, 2021
1 parent fae39b1 commit 6fa846b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,18 @@ int main(int argc, char *argv[]) {
if(start_argv >= argc)
return usage(argv);

Dl_info dli;
dladdr(own_dir, &dli);
if (dli.dli_fname[0] == '/')
set_own_dir(dli.dli_fname);
else if (readlink("/proc/self/exe", own_dir, sizeof(own_dir)) < sizeof(own_dir))
set_own_dir(own_dir);
else
set_own_dir(argv[0]);

/* check if path of config file has not been passed via command line */
if (!path)
snprintf((path=pbuf), sizeof(pbuf), "%s/"PROXYCHAINS_CONF_FILE, own_dir);
path = get_config_path(path, pbuf, sizeof(pbuf));

if(!quiet)
Expand All @@ -114,15 +125,6 @@ int main(int argc, char *argv[]) {

// search DLL

Dl_info dli;
dladdr(own_dir, &dli);
if (dli.dli_fname[0] == '/')
set_own_dir(dli.dli_fname);
else if (readlink("/proc/self/exe", own_dir, sizeof(own_dir)) < sizeof(own_dir))
set_own_dir(own_dir);
else
set_own_dir(argv[0]);

i = 0;

while(dll_dirs[i]) {
Expand Down

0 comments on commit 6fa846b

Please sign in to comment.