diff options
Diffstat (limited to 'src/fldd/main.c')
-rw-r--r-- | src/fldd/main.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/fldd/main.c b/src/fldd/main.c index 9d91557c1..898e0f36a 100644 --- a/src/fldd/main.c +++ b/src/fldd/main.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2014-2021 Firejail Authors | 2 | * Copyright (C) 2014-2022 Firejail Authors |
3 | * | 3 | * |
4 | * This file is part of firejail project | 4 | * This file is part of firejail project |
5 | * | 5 | * |
@@ -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 | } |