aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-07-31 07:50:04 -0400
committerLibravatar GitHub <noreply@github.com>2016-07-31 07:50:04 -0400
commit2b74c3fa0a6792591e9526588890eb48bfaab571 (patch)
tree13fda7b53ea9e67913d22688f8035ccb89fa20f3
parentMerge pull request #663 from thomasjfox/make-dist-mkuid (diff)
parentlibtrace: Add support for lstat() / lstat64() (diff)
downloadfirejail-2b74c3fa0a6792591e9526588890eb48bfaab571.tar.gz
firejail-2b74c3fa0a6792591e9526588890eb48bfaab571.tar.zst
firejail-2b74c3fa0a6792591e9526588890eb48bfaab571.zip
Merge pull request #668 from thomasjfox/improve-trace
Improve libtrace / libtracelog
-rw-r--r--README2
-rw-r--r--src/libtrace/libtrace.c29
-rw-r--r--src/libtracelog/libtracelog.c4
3 files changed, 31 insertions, 4 deletions
diff --git a/README b/README
index 200a7ef72..dfd101b7e 100644
--- a/README
+++ b/README
@@ -35,6 +35,8 @@ Thomas Jarosch (https://github.com/thomasjfox)
35 - disable keepassx in disable-passwdmgr.inc 35 - disable keepassx in disable-passwdmgr.inc
36 - added uudeview profile 36 - added uudeview profile
37 - improved profile list 37 - improved profile list
38 - fixed small variable glitch in stat64() / lstat64() (libtracelog)
39 - added lstat() / lstat64() support to libtrace
38Niklas Haas (https://github.com/haasn) 40Niklas Haas (https://github.com/haasn)
39 - blacklisting for keybase.io's client 41 - blacklisting for keybase.io's client
40Aleksey Manevich (https://github.com/manevich) 42Aleksey Manevich (https://github.com/manevich)
diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c
index a3d1571f7..dde3df2ea 100644
--- a/src/libtrace/libtrace.c
+++ b/src/libtrace/libtrace.c
@@ -423,11 +423,36 @@ int stat(const char *pathname, struct stat *buf) {
423typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf); 423typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf);
424static orig_stat64_t orig_stat64 = NULL; 424static orig_stat64_t orig_stat64 = NULL;
425int stat64(const char *pathname, struct stat64 *buf) { 425int stat64(const char *pathname, struct stat64 *buf) {
426 if (!orig_stat) 426 if (!orig_stat64)
427 orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat64"); 427 orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat64");
428 428
429 int rv = orig_stat64(pathname, buf); 429 int rv = orig_stat64(pathname, buf);
430 printf("%u:%s:stat %s:%d\n", pid(), name(), pathname, rv); 430 printf("%u:%s:stat64 %s:%d\n", pid(), name(), pathname, rv);
431 return rv;
432}
433#endif /* __GLIBC__ */
434
435// lstat
436typedef int (*orig_lstat_t)(const char *pathname, struct stat *buf);
437static orig_lstat_t orig_lstat = NULL;
438int 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__
448typedef int (*orig_lstat64_t)(const char *pathname, struct stat64 *buf);
449static orig_lstat64_t orig_lstat64 = NULL;
450int 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);
431 return rv; 456 return rv;
432} 457}
433#endif /* __GLIBC__ */ 458#endif /* __GLIBC__ */
diff --git a/src/libtracelog/libtracelog.c b/src/libtracelog/libtracelog.c
index 3e65587c4..dedba5513 100644
--- a/src/libtracelog/libtracelog.c
+++ b/src/libtracelog/libtracelog.c
@@ -562,7 +562,7 @@ int stat64(const char *pathname, struct stat64 *buf) {
562#ifdef DEBUG 562#ifdef DEBUG
563 printf("%s %s\n", __FUNCTION__, pathname); 563 printf("%s %s\n", __FUNCTION__, pathname);
564#endif 564#endif
565 if (!orig_stat) 565 if (!orig_stat64)
566 orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat64"); 566 orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat64");
567 if (!blacklist_loaded) 567 if (!blacklist_loaded)
568 load_blacklist(); 568 load_blacklist();
@@ -598,7 +598,7 @@ int lstat64(const char *pathname, struct stat64 *buf) {
598#ifdef DEBUG 598#ifdef DEBUG
599 printf("%s %s\n", __FUNCTION__, pathname); 599 printf("%s %s\n", __FUNCTION__, pathname);
600#endif 600#endif
601 if (!orig_lstat) 601 if (!orig_lstat64)
602 orig_lstat64 = (orig_lstat64_t)dlsym(RTLD_NEXT, "lstat64"); 602 orig_lstat64 = (orig_lstat64_t)dlsym(RTLD_NEXT, "lstat64");
603 if (!blacklist_loaded) 603 if (!blacklist_loaded)
604 load_blacklist(); 604 load_blacklist();