aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-07-30 08:22:22 -0400
committerLibravatar netblue30 <netblue30@protonmail.com>2021-07-30 08:22:22 -0400
commit56e0c9ff0788fbd462b25b087417b15eaaa762d7 (patch)
tree926fcf0425c562ef2a8f3669b316bc27f1c23610 /src
parentmerge (diff)
downloadfirejail-56e0c9ff0788fbd462b25b087417b15eaaa762d7.tar.gz
firejail-56e0c9ff0788fbd462b25b087417b15eaaa762d7.tar.zst
firejail-56e0c9ff0788fbd462b25b087417b15eaaa762d7.zip
private-lib: fix double symlink
Diffstat (limited to 'src')
-rw-r--r--src/fldd/main.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/fldd/main.c b/src/fldd/main.c
index 9d91557c1..b71145793 100644
--- a/src/fldd/main.c
+++ b/src/fldd/main.c
@@ -261,12 +261,21 @@ static void walk_directory(const char *dirname) {
261 261
262 // check directory 262 // check directory
263 // entry->d_type field is supported in glibc since version 2.19 (Feb 2014) 263 // entry->d_type field is supported in glibc since version 2.19 (Feb 2014)
264 // we'll use stat to check for directories 264 // we'll use stat to check for directories using the real path
265 // (sometimes the path is a double symlink to a real file and stat would fail)
266 char *rpath = realpath(path, NULL);
267 if (!rpath) {
268 free(path);
269 continue;
270 }
271 free(path);
272
265 struct stat s; 273 struct stat s;
266 if (stat(path, &s) == -1) 274 if (stat(rpath, &s) == -1)
267 errExit("stat"); 275 errExit("stat");
268 if (S_ISDIR(s.st_mode)) 276 if (S_ISDIR(s.st_mode))
269 walk_directory(path); 277 walk_directory(rpath);
278 free(rpath);
270 } 279 }
271 closedir(dir); 280 closedir(dir);
272 } 281 }