aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Duncaen <mail@duncano.de>2015-10-25 15:30:09 +0100
committerLibravatar Duncaen <mail@duncano.de>2015-10-25 16:28:35 +0100
commit14b435a43ab54a718f1a899573fe1ce6bb06fe7a (patch)
tree536b5455d4a3ee172b5dda21e45b34cb8d6dd858
parentRevert "fix struct stat64 problem for musl libc" (diff)
downloadfirejail-14b435a43ab54a718f1a899573fe1ce6bb06fe7a.tar.gz
firejail-14b435a43ab54a718f1a899573fe1ce6bb06fe7a.tar.zst
firejail-14b435a43ab54a718f1a899573fe1ce6bb06fe7a.zip
libtrace: only include fopen64, freopen64 and stat64 if __GLIBC__ is defined
-rw-r--r--src/libtrace/libtrace.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c
index 1eb1cf931..12a8c7f4a 100644
--- a/src/libtrace/libtrace.c
+++ b/src/libtrace/libtrace.c
@@ -312,6 +312,7 @@ FILE *fopen(const char *pathname, const char *mode) {
312 return rv; 312 return rv;
313} 313}
314 314
315#ifdef __GLIBC__
315FILE *fopen64(const char *pathname, const char *mode) { 316FILE *fopen64(const char *pathname, const char *mode) {
316 if (!orig_fopen64) 317 if (!orig_fopen64)
317 orig_fopen64 = (orig_fopen_t)dlsym(RTLD_NEXT, "fopen64"); 318 orig_fopen64 = (orig_fopen_t)dlsym(RTLD_NEXT, "fopen64");
@@ -320,6 +321,7 @@ FILE *fopen64(const char *pathname, const char *mode) {
320 printf("%u:%s:fopen64 %s\n", pid(), name(), pathname); 321 printf("%u:%s:fopen64 %s\n", pid(), name(), pathname);
321 return rv; 322 return rv;
322} 323}
324#endif /* __GLIBC__ */
323 325
324 326
325// freopen 327// freopen
@@ -334,6 +336,7 @@ FILE *freopen(const char *pathname, const char *mode, FILE *stream) {
334 return rv; 336 return rv;
335} 337}
336 338
339#ifdef __GLIBC__
337typedef FILE *(*orig_freopen64_t)(const char *pathname, const char *mode, FILE *stream); 340typedef FILE *(*orig_freopen64_t)(const char *pathname, const char *mode, FILE *stream);
338static orig_freopen64_t orig_freopen64 = NULL; 341static orig_freopen64_t orig_freopen64 = NULL;
339FILE *freopen64(const char *pathname, const char *mode, FILE *stream) { 342FILE *freopen64(const char *pathname, const char *mode, FILE *stream) {
@@ -344,6 +347,7 @@ FILE *freopen64(const char *pathname, const char *mode, FILE *stream) {
344 printf("%u:%s:freopen64 %s\n", pid(), name(), pathname); 347 printf("%u:%s:freopen64 %s\n", pid(), name(), pathname);
345 return rv; 348 return rv;
346} 349}
350#endif /* __GLIBC__ */
347 351
348// unlink 352// unlink
349typedef int (*orig_unlink_t)(const char *pathname); 353typedef int (*orig_unlink_t)(const char *pathname);
@@ -414,6 +418,7 @@ int stat(const char *pathname, struct stat *buf) {
414 return rv; 418 return rv;
415} 419}
416 420
421#ifdef __GLIBC__
417typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf); 422typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf);
418static orig_stat64_t orig_stat64 = NULL; 423static orig_stat64_t orig_stat64 = NULL;
419int stat64(const char *pathname, struct stat64 *buf) { 424int stat64(const char *pathname, struct stat64 *buf) {
@@ -424,6 +429,7 @@ int stat64(const char *pathname, struct stat64 *buf) {
424 printf("%u:%s:stat %s\n", pid(), name(), pathname); 429 printf("%u:%s:stat %s\n", pid(), name(), pathname);
425 return rv; 430 return rv;
426} 431}
432#endif /* __GLIBC__ */
427 433
428 434
429// access 435// access
@@ -625,4 +631,4 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid) {
625 printf("%u:%s:setresgid %d %d %d\n", pid(), name(), rgid, egid, sgid); 631 printf("%u:%s:setresgid %d %d %d\n", pid(), name(), rgid, egid, sgid);
626 632
627 return rv; 633 return rv;
628} \ No newline at end of file 634}