symlinked folders are excluded from $PATH if the actual folder is included

This commit is contained in:
Scoopta 2020-01-28 17:46:16 -08:00
parent 46b8a23c2f
commit 2de5c8fa48

View File

@ -78,9 +78,20 @@ void wofi_run_init(struct mode* this, struct map* config) {
char* path = strdup(getenv("PATH")); char* path = strdup(getenv("PATH"));
struct map* paths = map_init();
char* save_ptr; char* save_ptr;
char* str = strtok_r(path, ":", &save_ptr); char* str = strtok_r(path, ":", &save_ptr);
do { do {
str = realpath(str, NULL);
if(map_contains(paths, str)) {
free(str);
continue;
}
map_put(paths, str, "true");
DIR* dir = opendir(str); DIR* dir = opendir(str);
if(dir == NULL) { if(dir == NULL) {
continue; continue;
@ -105,9 +116,11 @@ void wofi_run_init(struct mode* this, struct map* config) {
} }
free(full_path); free(full_path);
} }
free(str);
closedir(dir); closedir(dir);
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL); } while((str = strtok_r(NULL, ":", &save_ptr)) != NULL);
free(path); free(path);
map_free(paths);
map_free(cached); map_free(cached);
map_free(entries); map_free(entries);
} }