From d49889d24686fff901392b6dd1f9c6a5214e8464 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sun, 25 Oct 2015 14:37:11 +0100 Subject: Revert "fix struct stat64 problem for musl libc" This reverts commit 801164566924c41d18d66bdc9ca8b2305103fb82. --- configure | 23 +++------------------ configure.ac | 15 +++----------- src/libtrace/Makefile.in | 3 +-- src/libtrace/libtrace.c | 14 ------------- src/libtrace/musl_defs.h | 52 ------------------------------------------------ 5 files changed, 7 insertions(+), 100 deletions(-) delete mode 100644 src/libtrace/musl_defs.h diff --git a/configure b/configure index e7b573c25..9625cdb61 100755 --- a/configure +++ b/configure @@ -628,7 +628,6 @@ HAVE_SECCOMP_H EGREP GREP CPP -HAVE_MUSL_LIBC HAVE_FATAL_WARNINGS HAVE_BIND HAVE_CHROOT @@ -689,7 +688,6 @@ enable_seccomp enable_chroot enable_bind enable_fatal_warnings -enable_musl_libc ' ac_precious_vars='build_alias host_alias @@ -1309,11 +1307,10 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-seccomp disable seccomp - --disable-chroot disable chroot - --disable-bind disable bind + --disable-seccomp Disable seccomp + --disable-chroot Disable chroot + --disable-bind Disable bind --enable-fatal-warnings -W -Wall -Werror - --enable-musl-libc ugly hack to allow compilation with musl libc Some influential environment variables: CC C compiler command @@ -3101,19 +3098,6 @@ if test "x$enable_fatal_warnings" = "xyes"; then : HAVE_FATAL_WARNINGS="-W -Wall -Werror" -fi - -HAVE_MUSL_LIBC="" -# Check whether --enable-musl_libc was given. -if test "${enable_musl_libc+set}" = set; then : - enableval=$enable_musl_libc; -fi - -if test "x$enable_musl_libc" = "xyes"; then : - - HAVE_MUSL_LIBC="-DHAVE_MUSL_LIBC" - - fi # checking pthread library @@ -4752,5 +4736,4 @@ echo " : $HAVE_SECCOMP_H" echo " chroot: $HAVE_CHROOT" echo " bind: $HAVE_BIND" echo " fatal warnings: $HAVE_FATAL_WARNINGS" -echo " musl libc: $HAVE_MUSL_LIBC" echo diff --git a/configure.ac b/configure.ac index 52048757c..b2fa22fd7 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_PROG_RANLIB HAVE_SECCOMP="" AC_ARG_ENABLE([seccomp], - AS_HELP_STRING([--disable-seccomp], [disable seccomp])) + AS_HELP_STRING([--disable-seccomp], [Disable seccomp])) AS_IF([test "x$enable_seccomp" != "xno"], [ HAVE_SECCOMP="-DHAVE_SECCOMP" AC_SUBST(HAVE_SECCOMP) @@ -19,7 +19,7 @@ AS_IF([test "x$enable_seccomp" != "xno"], [ HAVE_CHROOT="" AC_ARG_ENABLE([chroot], - AS_HELP_STRING([--disable-chroot], [disable chroot])) + AS_HELP_STRING([--disable-chroot], [Disable chroot])) AS_IF([test "x$enable_chroot" != "xno"], [ HAVE_CHROOT="-DHAVE_CHROOT" AC_SUBST(HAVE_CHROOT) @@ -27,7 +27,7 @@ AS_IF([test "x$enable_chroot" != "xno"], [ HAVE_BIND="" AC_ARG_ENABLE([bind], - AS_HELP_STRING([--disable-bind], [disable bind])) + AS_HELP_STRING([--disable-bind], [Disable bind])) AS_IF([test "x$enable_bind" != "xno"], [ HAVE_BIND="-DHAVE_BIND" AC_SUBST(HAVE_BIND) @@ -41,14 +41,6 @@ AS_IF([test "x$enable_fatal_warnings" = "xyes"], [ AC_SUBST(HAVE_FATAL_WARNINGS) ]) -HAVE_MUSL_LIBC="" -AC_ARG_ENABLE([musl_libc], - AS_HELP_STRING([--enable-musl-libc], [ugly hack to allow compilation with musl libc])) -AS_IF([test "x$enable_musl_libc" = "xyes"], [ - HAVE_MUSL_LIBC="-DHAVE_MUSL_LIBC" - AC_SUBST(HAVE_MUSL_LIBC) -]) - # checking pthread library AC_CHECK_LIB([pthread], [main], [], AC_MSG_ERROR([*** POSIX thread support not installed ***])) AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed ***])) @@ -65,5 +57,4 @@ echo " : $HAVE_SECCOMP_H" echo " chroot: $HAVE_CHROOT" echo " bind: $HAVE_BIND" echo " fatal warnings: $HAVE_FATAL_WARNINGS" -echo " musl libc: $HAVE_MUSL_LIBC" echo diff --git a/src/libtrace/Makefile.in b/src/libtrace/Makefile.in index 8bc57cddf..3924bdf3f 100644 --- a/src/libtrace/Makefile.in +++ b/src/libtrace/Makefile.in @@ -2,13 +2,12 @@ PREFIX=@prefix@ VERSION=@PACKAGE_VERSION@ NAME=@PACKAGE_NAME@ HAVE_FATAL_WARNINGS=@HAVE_FATAL_WARNINGS@ -HAVE_MUSL_LIBC=@HAVE_MUSL_LIBC@ H_FILE_LIST = $(wildcard *.[h]) C_FILE_LIST = $(wildcard *.c) OBJS = $(C_FILE_LIST:.c=.o) BINOBJS = $(foreach file, $(OBJS), $file) -CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' $(HAVE_MUSL_LIBC) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security +CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now all: libtrace.so diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c index 2ce74d331..1eb1cf931 100644 --- a/src/libtrace/libtrace.c +++ b/src/libtrace/libtrace.c @@ -18,11 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _GNU_SOURCE -#ifdef HAVE_MUSL_LIBC -#include "musl_defs.h" -#else #include -#endif #include #include #include @@ -32,9 +28,7 @@ #include #include #include -#ifndef HAVE_MUSL_LIBC #include -#endif // break recursivity on fopen call typedef FILE *(*orig_fopen_t)(const char *pathname, const char *mode); @@ -420,17 +414,9 @@ int stat(const char *pathname, struct stat *buf) { return rv; } -#ifdef HAVE_MUSL_LIBC -typedef int (*orig_stat64_t)(const char *pathname, struct stat *buf); -#else typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf); -#endif static orig_stat64_t orig_stat64 = NULL; -#ifdef HAVE_MUSL_LIBC -int stat64(const char *pathname, struct stat *buf) { -#else int stat64(const char *pathname, struct stat64 *buf) { -#endif if (!orig_stat) orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat"); diff --git a/src/libtrace/musl_defs.h b/src/libtrace/musl_defs.h deleted file mode 100644 index 02eb65b83..000000000 --- a/src/libtrace/musl_defs.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2014, 2015 Firejail Authors - * - * This file is part of firejail project - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#ifndef _MUSL_DEFS_H -#define _MUSL_DEFS_H - -#include - -#define __NEED_FILE -#define __NEED_dev_t -#define __NEED_ino_t -#define __NEED_mode_t -#define __NEED_nlink_t -#define __NEED_uid_t -#define __NEED_gid_t -#define __NEED_off_t -#define __NEED_time_t -#define __NEED_blksize_t -#define __NEED_blkcnt_t -#define __NEED_struct_timespec - -#include -#include - -#ifdef __cplusplus -#define NULL 0L -#else -#define NULL ((void*)0) -#endif - -int printf(const char *format, ...); -int sprintf(char *buffer, const char *format, ...); -char *fgets(char *buffer, int size, FILE *fp); - -#endif -- cgit v1.2.3-54-g00ecf From 14b435a43ab54a718f1a899573fe1ce6bb06fe7a Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sun, 25 Oct 2015 15:30:09 +0100 Subject: libtrace: only include fopen64, freopen64 and stat64 if __GLIBC__ is defined --- src/libtrace/libtrace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) { return rv; } +#ifdef __GLIBC__ FILE *fopen64(const char *pathname, const char *mode) { if (!orig_fopen64) orig_fopen64 = (orig_fopen_t)dlsym(RTLD_NEXT, "fopen64"); @@ -320,6 +321,7 @@ FILE *fopen64(const char *pathname, const char *mode) { printf("%u:%s:fopen64 %s\n", pid(), name(), pathname); return rv; } +#endif /* __GLIBC__ */ // freopen @@ -334,6 +336,7 @@ FILE *freopen(const char *pathname, const char *mode, FILE *stream) { return rv; } +#ifdef __GLIBC__ typedef FILE *(*orig_freopen64_t)(const char *pathname, const char *mode, FILE *stream); static orig_freopen64_t orig_freopen64 = NULL; FILE *freopen64(const char *pathname, const char *mode, FILE *stream) { @@ -344,6 +347,7 @@ FILE *freopen64(const char *pathname, const char *mode, FILE *stream) { printf("%u:%s:freopen64 %s\n", pid(), name(), pathname); return rv; } +#endif /* __GLIBC__ */ // unlink typedef int (*orig_unlink_t)(const char *pathname); @@ -414,6 +418,7 @@ int stat(const char *pathname, struct stat *buf) { return rv; } +#ifdef __GLIBC__ typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf); static orig_stat64_t orig_stat64 = NULL; int stat64(const char *pathname, struct stat64 *buf) { @@ -424,6 +429,7 @@ int stat64(const char *pathname, struct stat64 *buf) { printf("%u:%s:stat %s\n", pid(), name(), pathname); return rv; } +#endif /* __GLIBC__ */ // access @@ -625,4 +631,4 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { printf("%u:%s:setresgid %d %d %d\n", pid(), name(), rgid, egid, sgid); return rv; -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf