diff options
author | Thomas Jarosch <thomas.jarosch@intra2net.com> | 2016-07-30 23:42:53 +0200 |
---|---|---|
committer | Thomas Jarosch <thomas.jarosch@intra2net.com> | 2016-07-31 00:06:49 +0200 |
commit | 183eb02508f538e8200b62bbefc1c48aa0675d28 (patch) | |
tree | 04fe7c84c7c06e67e1da63766d4d74ffe7a4fb68 /src/libtrace | |
parent | Fix wrong pointer variable in stat64 wrapper (diff) | |
download | firejail-183eb02508f538e8200b62bbefc1c48aa0675d28.tar.gz firejail-183eb02508f538e8200b62bbefc1c48aa0675d28.tar.zst firejail-183eb02508f538e8200b62bbefc1c48aa0675d28.zip |
libtrace: Add support for lstat() / lstat64()
Diffstat (limited to 'src/libtrace')
-rw-r--r-- | src/libtrace/libtrace.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c index 9f2622c00..dde3df2ea 100644 --- a/src/libtrace/libtrace.c +++ b/src/libtrace/libtrace.c | |||
@@ -432,6 +432,31 @@ int stat64(const char *pathname, struct stat64 *buf) { | |||
432 | } | 432 | } |
433 | #endif /* __GLIBC__ */ | 433 | #endif /* __GLIBC__ */ |
434 | 434 | ||
435 | // lstat | ||
436 | typedef int (*orig_lstat_t)(const char *pathname, struct stat *buf); | ||
437 | static orig_lstat_t orig_lstat = NULL; | ||
438 | int lstat(const char *pathname, struct stat *buf) { | ||
439 | if (!orig_lstat) | ||
440 | orig_lstat = (orig_lstat_t)dlsym(RTLD_NEXT, "lstat"); | ||
441 | |||
442 | int rv = orig_lstat(pathname, buf); | ||
443 | printf("%u:%s:lstat %s:%d\n", pid(), name(), pathname, rv); | ||
444 | return rv; | ||
445 | } | ||
446 | |||
447 | #ifdef __GLIBC__ | ||
448 | typedef int (*orig_lstat64_t)(const char *pathname, struct stat64 *buf); | ||
449 | static orig_lstat64_t orig_lstat64 = NULL; | ||
450 | int lstat64(const char *pathname, struct stat64 *buf) { | ||
451 | if (!orig_lstat64) | ||
452 | orig_lstat64 = (orig_lstat64_t)dlsym(RTLD_NEXT, "lstat64"); | ||
453 | |||
454 | int rv = orig_lstat64(pathname, buf); | ||
455 | printf("%u:%s:lstat64 %s:%d\n", pid(), name(), pathname, rv); | ||
456 | return rv; | ||
457 | } | ||
458 | #endif /* __GLIBC__ */ | ||
459 | |||
435 | // opendir | 460 | // opendir |
436 | typedef DIR *(*orig_opendir_t)(const char *pathname); | 461 | typedef DIR *(*orig_opendir_t)(const char *pathname); |
437 | static orig_opendir_t orig_opendir = NULL; | 462 | static orig_opendir_t orig_opendir = NULL; |