From 2de5c8fa48b9d454f0928c6b6b20212947c28fb2 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Tue, 28 Jan 2020 17:46:16 -0800 Subject: [PATCH] symlinked folders are excluded from $PATH if the actual folder is included --- modes/run.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modes/run.c b/modes/run.c index f0f86da..26c4aa4 100644 --- a/modes/run.c +++ b/modes/run.c @@ -78,9 +78,20 @@ void wofi_run_init(struct mode* this, struct map* config) { char* path = strdup(getenv("PATH")); + struct map* paths = map_init(); + char* save_ptr; char* str = strtok_r(path, ":", &save_ptr); do { + + str = realpath(str, NULL); + if(map_contains(paths, str)) { + free(str); + continue; + } + + map_put(paths, str, "true"); + DIR* dir = opendir(str); if(dir == NULL) { continue; @@ -105,9 +116,11 @@ void wofi_run_init(struct mode* this, struct map* config) { } free(full_path); } + free(str); closedir(dir); } while((str = strtok_r(NULL, ":", &save_ptr)) != NULL); free(path); + map_free(paths); map_free(cached); map_free(entries); }