mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2025-09-07 19:27:00 +00:00
put abort functionality into get_config_path to further reduce code duplication
This commit is contained in:
12
src/common.c
12
src/common.c
@ -9,10 +9,15 @@ static int check_path(char *path) {
|
||||
return access(path, R_OK) != -1;
|
||||
}
|
||||
|
||||
char *get_config_path(char* pbuf, size_t bufsize) {
|
||||
char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
|
||||
char buf[512];
|
||||
// top priority: user defined path
|
||||
char *path = default_path;
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
// priority 1: env var PROXYCHAINS_CONF_FILE
|
||||
char *path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||
getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
@ -40,6 +45,9 @@ char *get_config_path(char* pbuf, size_t bufsize) {
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
perror("couldnt find configuration file");
|
||||
exit(1);
|
||||
|
||||
return NULL;
|
||||
have:
|
||||
return path;
|
||||
|
Reference in New Issue
Block a user