[Fakeroot-commits] [SCM] fakeroot branch, master, updated. debian/1.14.3-200-gb232f8a

Kyle J. McKay mackyle at gmail.com
Tue Aug 23 13:03:43 UTC 2011


The following commit has been merged in the master branch:
commit d4eaf68fccb2162aa4943d30e5fe08c73d6d96d4
Author: Kyle J. McKay <mackyle at gmail.com>
Date:   Thu May 26 16:09:36 2011 -0700

    Mac OS X support without using DYLD_FORCE_FLAT_NAMESPACE=1 so that all executables are supported

diff --git a/Makefile.am b/Makefile.am
index ae1b6f2..aa31694 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,7 @@ noinst_PROGRAMS=simple
 CLEANFILES= wrapdef.h wrapstruct.h wrapped.h wraptmpf.h
 DISTCLEANFILES = fakerootconfig.h
 
-EXTRA_DIST=wrapawk wrapfunc.inp                        \
+EXTRA_DIST=wrapawk wrapawk_macosx wrapfunc.inp           \
            debian/rules debian/changelog debian/control  \
 	   message.h \
 	   DEBUG BUGS \
@@ -37,8 +37,13 @@ EXTRA_DIST=wrapawk wrapfunc.inp                        \
 
 CLEAN_FILES=fakerootconfig.h
 
+if MACOSX
+wrapped.h wrapdef.h wrapstruct.h wraptmpf.h:wrapawk_macosx wrapfunc.inp
+	awk -f $(srcdir)/wrapawk_macosx < $(srcdir)/wrapfunc.inp
+else !MACOSX
 wrapped.h wrapdef.h wrapstruct.h wraptmpf.h:wrapawk wrapfunc.inp
 	awk -f $(srcdir)/wrapawk < $(srcdir)/wrapfunc.inp
+endif !MACOSX
 
 libfakeroot.lo:libfakeroot.c wrapdef.h wrapstruct.h wraptmpf.h
 
diff --git a/README b/README
index da74364..21451ee 100644
--- a/README
+++ b/README
@@ -10,4 +10,5 @@ listed below.
 
 Portability Notes
 
-On OS X, only binaries that do NOT REQUIRE two-level namespace will work.
+On OS X, only binaries that do NOT rely on Mach-based [e]uid/[e]gid/mode
+APIs will correctly use fakeroot altered ownership/permissions.
diff --git a/configure.ac b/configure.ac
index db1d01c..6054ede 100644
--- a/configure.ac
+++ b/configure.ac
@@ -303,6 +303,7 @@ dnl    FOUND=$WRAPPED
       DEFINE_NEXT=[`echo wrap_${FOUND}| tr '[a-z]' '[A-Z]'`]
       DEFINE_ARG=[`echo wrap_${FOUND}| tr '[a-z]' '[A-Z]'`]
       AC_DEFINE_UNQUOTED(WRAP_${PF}, $FOUND)
+      AC_DEFINE_UNQUOTED(WRAP_${PF}_RAW, $FOUND)
       AC_DEFINE_UNQUOTED(WRAP_${PF}_QUOTE, "$FOUND")
       AC_DEFINE_UNQUOTED(TMP_${PF}, tmp_$FOUND)
       AC_DEFINE_UNQUOTED(NEXT_${PF}_NOARG, next_$FOUND)
@@ -405,7 +406,6 @@ case $target_cpu:$target_os in
 		LDLIBPATHVAR="DYLD_LIBRARY_PATH"
 		LDPRELOADVAR="DYLD_INSERT_LIBRARIES"
 		LDPRELOADABS=1
-		LDEXTRAVAR="DYLD_FORCE_FLAT_NAMESPACE=1"
 		;;
 	(*)
 		AC_MSG_WARN([don't know where libc is for $target_os on
@@ -437,51 +437,61 @@ AH_VERBATIM([WRAP_STAT],
 [/* Stuff.  */
 #define WRAP_STAT  __astat
 #define WRAP_STAT_QUOTE  __astat
+#define WRAP_STAT_RAW  __astat
 #define TMP_STAT  __astat
 #define NEXT_STAT_NOARG  next___astat
 
 #define WRAP_LSTAT_QUOTE  __astat
 #define WRAP_LSTAT  __astat
+#define WRAP_LSTAT_RAW  __astat
 #define TMP_LSTAT  __astat
 #define NEXT_LSTAT_NOARG  next___astat
 
 #define WRAP_FSTAT_QUOTE  __astat
 #define WRAP_FSTAT  __astat
+#define WRAP_FSTAT_RAW  __astat
 #define TMP_FSTAT  __astat
 #define NEXT_FSTAT_NOARG  next___astat
 
 #define WRAP_FSTATAT_QUOTE  __astatat
 #define WRAP_FSTATAT  __astatat
+#define WRAP_FSTATAT_RAW  __astatat
 #define TMP_FSTATAT  __astatat
 #define NEXT_FSTATAT_NOARG  next___astatat
 
 #define WRAP_STAT64_QUOTE  __astat64
 #define WRAP_STAT64  __astat64
+#define WRAP_STAT64_RAW  __astat64
 #define TMP_STAT64  __astat64
 #define NEXT_STAT64_NOARG  next___astat64
 
 #define WRAP_LSTAT64_QUOTE  __astat64
 #define WRAP_LSTAT64  __astat64
+#define WRAP_LSTAT64_RAW  __astat64
 #define TMP_LSTAT64  __astat64
 #define NEXT_LSTAT64_NOARG  next___astat64
 
 #define WRAP_FSTAT64_QUOTE  __astat64
 #define WRAP_FSTAT64  __astat64
+#define WRAP_FSTAT64_RAW  __astat64
 #define TMP_FSTAT64  __astat64
 #define NEXT_FSTAT64_NOARG  next___astat64
 
 #define WRAP_FSTATAT64_QUOTE  __astatat64
 #define WRAP_FSTATAT64  __astatat64
+#define WRAP_FSTATAT64_RAW  __astatat64
 #define TMP_FSTATAT64  __astatat64
 #define NEXT_FSTATAT64_NOARG  next___astatat64
 
 #define WRAP_MKNOD_QUOTE  __amknod
 #define WRAP_MKNOD  __amknod
+#define WRAP_MKNOD_RAW  __amknod
 #define TMP_MKNOD  __amknod
 #define NEXT_MKNOD_NOARG  next___amknod
 
 #define WRAP_MKNODAT_QUOTE  __amknodat
 #define WRAP_MKNODAT  __amknodat
+#define WRAP_MKNODAT_RAW  __amknodat
 #define TMP_MKNODAT  __amknodat
 #define NEXT_MKNODAT_NOARG  next___amknodat
 ])
diff --git a/libfakeroot_inode64.c b/libfakeroot_inode64.c
index 023db58..9de18f1 100644
--- a/libfakeroot_inode64.c
+++ b/libfakeroot_inode64.c
@@ -34,12 +34,14 @@
 #endif /* HAVE_FTS_H */
 
 #include "wrapped.h"
+#include "wraptmpf.h"
+#include "wrapdef.h"
 
 #ifdef LIBFAKEROOT_DEBUGGING
 extern int fakeroot_debug;
 
 #endif /* LIBFAKEROOT_DEBUGGING */
-int lstat(const char *file_name,
+int lstat$INODE64(const char *file_name,
           struct stat *st){
 
   int r;
@@ -59,7 +61,7 @@ int lstat(const char *file_name,
 }
 
 
-int stat(const char *file_name,
+int stat$INODE64(const char *file_name,
          struct stat *st){
   int r;
 
@@ -76,7 +78,7 @@ int stat(const char *file_name,
 }
 
 
-int fstat(int fd,
+int fstat$INODE64(int fd,
           struct stat *st){
   int r;
 
@@ -94,7 +96,7 @@ int fstat(int fd,
 }
 
 #ifdef HAVE_FTS_READ
-FTSENT *fts_read(FTS *ftsp) {
+FTSENT *fts_read$INODE64(FTS *ftsp) {
   FTSENT *r;
 
 #ifdef LIBFAKEROOT_DEBUGGING
@@ -110,7 +112,7 @@ FTSENT *fts_read(FTS *ftsp) {
   return r;
 }
 
-FTSENT *fts_children(FTS *ftsp,
+FTSENT *fts_children$INODE64(FTS *ftsp,
                      int options) {
   FTSENT *first;
   FTSENT *r;
diff --git a/libfakeroot_unix2003.c b/libfakeroot_unix2003.c
index af4dbbe..7a7e76b 100644
--- a/libfakeroot_unix2003.c
+++ b/libfakeroot_unix2003.c
@@ -73,11 +73,13 @@
 
 #include "patchattr.h"
 #include "wrapped.h"
+#include "wraptmpf.h"
+#include "wrapdef.h"
 
 extern int fakeroot_disabled;
 
 #ifdef LCHOWN_SUPPORT
-int lchown(const char *path, uid_t owner, gid_t group){
+int lchown$UNIX2003(const char *path, uid_t owner, gid_t group){
   INT_STRUCT_STAT st;
   int r=0;
 
@@ -103,7 +105,7 @@ int lchown(const char *path, uid_t owner, gid_t group){
 }
 #endif
 
-int chmod(const char *path, mode_t mode){
+int chmod$UNIX2003(const char *path, mode_t mode){
   INT_STRUCT_STAT st;
   int r;
 
@@ -142,7 +144,7 @@ int chmod(const char *path, mode_t mode){
   return r;
 }
 
-int fchmod(int fd, mode_t mode){
+int fchmod$UNIX2003(int fd, mode_t mode){
   int r;
   INT_STRUCT_STAT st;
 
@@ -175,7 +177,7 @@ int fchmod(int fd, mode_t mode){
   return r;
 }
 
-int setreuid(SETREUID_ARG ruid, SETREUID_ARG euid){
+int setreuid$UNIX2003(SETREUID_ARG ruid, SETREUID_ARG euid){
 #ifdef LIBFAKEROOT_DEBUGGING
   if (fakeroot_debug) {
     fprintf(stderr, "setreuid$UNIX2003\n");
@@ -186,7 +188,7 @@ int setreuid(SETREUID_ARG ruid, SETREUID_ARG euid){
   return set_faked_reuid(ruid, euid);
 }
 
-int setregid(SETREGID_ARG rgid, SETREGID_ARG egid){
+int setregid$UNIX2003(SETREGID_ARG rgid, SETREGID_ARG egid){
 #ifdef LIBFAKEROOT_DEBUGGING
   if (fakeroot_debug) {
     fprintf(stderr, "setregid$UNIX2003\n");
@@ -198,7 +200,7 @@ int setregid(SETREGID_ARG rgid, SETREGID_ARG egid){
 }
 
 int
-getattrlist(const char *path, void *attrList, void *attrBuf,
+getattrlist$UNIX2003(const char *path, void *attrList, void *attrBuf,
             size_t attrBufSize, unsigned long options)
 {
   int r;
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index c895e12..cd4065b 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -2,6 +2,15 @@ AUTOMAKE_OPTIONS=foreign
 bin_SCRIPTS=fakeroot
 EXTRA_DIST = fakeroot.in
 CLEANFILES=fakeroot
+if MACOSX
+define macosx_false
+#
+endef
+else !MACOSX
+define macosx_true
+#
+endef
+endif !MACOSX
 
 do_subst = sed -e 's,[@]prefix[@],$(prefix),g' \
 	   -e 's,[@]bindir[@],$(bindir),g' \
@@ -15,7 +24,9 @@ do_subst = sed -e 's,[@]prefix[@],$(prefix),g' \
 	   -e 's,[@]LDLIBPATHVAR[@],$(LDLIBPATHVAR),g' \
 	   -e 's,[@]LDPRELOADVAR[@],$(LDPRELOADVAR),g' \
 	   -e 's,[@]LDPRELOADABS[@],$(LDPRELOADABS),g' \
-	   -e 's,[@]LDEXTRAVAR[@],$(LDEXTRAVAR),g'
+	   -e 's,[@]LDEXTRAVAR[@],$(LDEXTRAVAR),g' \
+	   -e 's,[@]MACOSX_FALSE[@],$(macosx_false),g' \
+	   -e 's,[@]MACOSX_TRUE[@],$(macosx_true),g'
 
 fakeroot: $(srcdir)/fakeroot.in Makefile
 	$(do_subst) < $(srcdir)/fakeroot.in > fakeroot
diff --git a/scripts/fakeroot.in b/scripts/fakeroot.in
index 114956f..324a9dc 100755
--- a/scripts/fakeroot.in
+++ b/scripts/fakeroot.in
@@ -148,7 +148,8 @@ PID=`echo $KEY_PID|cut -d: -f2`
 if [ "$WAITINTRAP" -eq 0 ]; then
   trap "kill -s @signal@ $PID" EXIT INT
 else
-  trap 'FAKEROOTKEY=$FAKEROOTKEY @LDLIBPATHVAR@="$PATHS" @LDPRELOADVAR@="$LIB" /bin/ls -l / >/dev/null 2>&1; while kill -s @signal@ $PID 2>/dev/null; do sleep 0.1; done' EXIT INT
+  @MACOSX_FALSE at trap 'FAKEROOTKEY=$FAKEROOTKEY @LDLIBPATHVAR@="$PATHS" @LDPRELOADVAR@="$LIB" /bin/ls -l / >/dev/null 2>&1; while kill -s @signal@ $PID 2>/dev/null; do sleep 0.1; done' EXIT INT
+  @MACOSX_TRUE at trap 'FAKEROOTKEY=$FAKEROOTKEY @LDPRELOADVAR@="$LIB" /bin/ls -l / >/dev/null 2>&1; while kill -s @signal@ $PID 2>/dev/null; do sleep 0.1; done' EXIT INT
 fi
 
 if test -z "$FAKEROOTKEY" || test -z "$PID"; then
@@ -170,10 +171,12 @@ fi
 export FAKEROOT_FD_BASE
 
 if test -z "$*"; then
-  FAKEROOTKEY=$FAKEROOTKEY @LDLIBPATHVAR@="$PATHS" @LDEXTRAVAR@ @LDPRELOADVAR@="$LIB" ${SHELL:-/bin/sh}
+  @MACOSX_FALSE at FAKEROOTKEY=$FAKEROOTKEY @LDLIBPATHVAR@="$PATHS" @LDEXTRAVAR@ @LDPRELOADVAR@="$LIB" ${SHELL:-/bin/sh}
+  @MACOSX_TRUE at FAKEROOTKEY=$FAKEROOTKEY @LDEXTRAVAR@ @LDPRELOADVAR@="$LIB" ${SHELL:-/bin/sh}
   RESULT=$?
 else
-  FAKEROOTKEY=$FAKEROOTKEY @LDLIBPATHVAR@="$PATHS" @LDEXTRAVAR@ @LDPRELOADVAR@="$LIB" "$@"
+  @MACOSX_FALSE at FAKEROOTKEY=$FAKEROOTKEY @LDLIBPATHVAR@="$PATHS" @LDEXTRAVAR@ @LDPRELOADVAR@="$LIB" "$@"
+  @MACOSX_TRUE at FAKEROOTKEY=$FAKEROOTKEY @LDEXTRAVAR@ @LDPRELOADVAR@="$LIB" "$@"
   RESULT=$?
 fi
 
diff --git a/wrapawk_macosx b/wrapawk_macosx
new file mode 100644
index 0000000..159e764
--- /dev/null
+++ b/wrapawk_macosx
@@ -0,0 +1,93 @@
+#Saluton Emacson! Bonvolu elekti -*- mode: awk; -*-. Dankon.
+
+BEGIN{
+  headerfile="wrapped.h";
+  deffile="wrapdef.h";
+  structfile="wrapstruct.h";
+  tmpffile="wraptmpf.h";
+  FS=";";
+  WARNING="/* Automatically generated file. Do not edit. Edit wrapawk_macosx/wrapfunc.inp. */";
+  print WARNING > headerfile;
+  print "#ifndef WRAPPED_H" > headerfile;
+  print "#define WRAPPED_H" > headerfile;
+  print "#define MY_GLUE2(a,b) a ## b"      > headerfile;
+  print "#define MY_DEF(a) MY_GLUE2(my_,a)" > headerfile;
+  print WARNING > deffile;
+  print "#ifndef WRAPDEF_H" > deffile;
+  print "#define WRAPDEF_H" > deffile;
+  print WARNING > tmpffile;
+  print "#ifndef WRAPTMPF_H" > tmpffile;
+  print "#define WRAPTMPF_H" > tmpffile;
+  print WARNING > structfile;
+  print "#ifndef WRAPSTRUCT_H" > structfile;
+  print "#define WRAPSTRUCT_H" > structfile;
+  print "typedef struct interpose_s {"      > structfile;
+  print "  void *new_func;"                 > structfile;
+  print "  void *orig_func;"                > structfile;
+  print "} interpose_t;"                    > structfile;
+  print "#define INTERPOSE(newf,oldf) \\"   > structfile;
+  print "  __attribute__((used)) static const interpose_t MY_GLUE2(_interpose_,oldf) \\" > structfile;
+  print "    __attribute__((section(\"__DATA,__interpose\"))) = {(void *)newf, (void *)oldf}" > structfile;
+  print ""                                  > structfile;
+}
+
+/\/\*/{
+}
+/^(\#)/{
+  print $0 > structfile;
+  print $0 > tmpffile;
+  print $0 > deffile;
+  print $0 > headerfile;
+
+}
+/^[^\/].*;.*;.*;/{
+  name=$1;
+  ret=$2;
+  argtype=$3;
+  argname=$4;
+  MACRO=$5;
+  if(MACRO){
+    print "extern " ret " MY_DEF(" name ")" argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
+    print "INTERPOSE(MY_DEF(" name "_RAW)," name "_RAW);"   > structfile;
+    print "#undef " name                      > deffile
+    print "#define " name " MY_DEF(" name "_RAW)" > deffile
+
+    print "extern " ret, name, argtype ";"              > tmpffile;
+    print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " __attribute__((always_inline));" > tmpffile;
+    print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " {" > tmpffile;
+    print "  return " name, argname ";"                 > tmpffile;
+    print "}"                                           > tmpffile;
+    print ""                                            > tmpffile;
+  } else {
+    print "extern " ret " my_" name, argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
+    print "#undef " name                                > structfile;
+    print "INTERPOSE(my_" name "," name ");"            > structfile;
+    print "#define " name " my_" name                   > structfile
+    print "#define " name " my_" name                   > deffile
+
+    print "extern " ret, name, argtype ";"              > tmpffile;
+    print "static __inline__ " ret " next_" name, argtype " __attribute__((always_inline));" > tmpffile;
+    print "static __inline__ " ret " next_" name, argtype " {" > tmpffile;
+    print "  return " name, argname ";"                 > tmpffile;
+    print "}"                                           > tmpffile;
+    print ""                                            > tmpffile;
+  }
+}
+
+/^ *$/{
+  print > structfile;
+  print > headerfile;
+  print > deffile;
+  print > tmpffile;
+}
+
+END{
+  print ""                > structfile;
+  print "struct next_wrap_st next_wrap[]= {" > structfile;
+  print "  {NULL, NULL}," > structfile;
+  print "};"              > structfile;
+  print "#endif"          > structfile;
+  print "#endif"          > tmpffile;
+  print "#endif"          > deffile;
+  print "#endif"          > headerfile;
+}

-- 
fakeroot



More information about the Fakeroot-commits mailing list