[Fakeroot-commits] [SCM] fakeroot branch, upstream, updated. 08ed00124d8b6b445d3b91a9aa15eec638b02f05
Clint Adams
schizo at debian.org
Sun Nov 15 03:17:49 UTC 2009
The following commit has been merged in the upstream branch:
commit 389eb86944c7e1db595a617a218fba5c88ba0c6a
Author: Clint Adams <schizo at debian.org>
Date: Tue Oct 27 01:28:53 2009 -0400
Apply patch (tweaked) from VMware: "Make sure STAT64_SUPPORT is defined on Mac OS, and wrap versioned symbols."
diff --git a/communicate.c b/communicate.c
index 2651e0d..74547ff 100644
--- a/communicate.c
+++ b/communicate.c
@@ -10,6 +10,14 @@
*/
+#ifdef __APPLE__
+/*
+ In this file, we want 'struct stat' to have a 32-bit 'ino_t'.
+ We use 'struct stat64' when we need a 64-bit 'ino_t'.
+*/
+#define _DARWIN_NO_64_BIT_INODE
+#endif
+
#include "communicate.h"
#include <dlfcn.h>
#include <stdio.h>
diff --git a/communicate.h b/communicate.h
index 378fff6..0a34c4a 100644
--- a/communicate.h
+++ b/communicate.h
@@ -35,7 +35,7 @@
#endif
/* Then decide whether we do or do not use the stat64 support */
-#if (defined(sun) && !defined(__SunOS_5_5_1) && !defined(_LP64)) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
+#if defined __APPLE__ || (defined(sun) && !defined(__SunOS_5_5_1) && !defined(_LP64)) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
# define STAT64_SUPPORT
#else
# warning Not using stat64 support
diff --git a/faked.c b/faked.c
index 1e38853..0b4e3ce 100644
--- a/faked.c
+++ b/faked.c
@@ -68,6 +68,14 @@
(def in ./linux/msg.h, couldn't find other def in /usr/include/
*/
+#ifdef __APPLE__
+/*
+ In this file, we want 'struct stat' to have a 32-bit 'ino_t'.
+ We use 'struct stat64' when we need a 64-bit 'ino_t'.
+*/
+#define _DARWIN_NO_64_BIT_INODE
+#endif
+
#include "config.h"
#include "communicate.h"
#ifndef FAKEROOT_FAKENET
diff --git a/libfakeroot.c b/libfakeroot.c
index b748db8..e10fa30 100644
--- a/libfakeroot.c
+++ b/libfakeroot.c
@@ -21,6 +21,21 @@
#define FAKEROOT_LIBFAKEROOT
+#ifdef __APPLE__
+/*
+ In this file, we want 'struct stat' to have a 32-bit 'ino_t'.
+ We use 'struct stat64' when we need a 64-bit 'ino_t'.
+*/
+#define _DARWIN_NO_64_BIT_INODE
+
+#ifndef __LP64__
+/*
+ This file is for 32-bit symbols which do not have the "$UNIX2003" version.
+*/
+#define _NONSTD_SOURCE
+#endif
+#endif
+
#include "config.h"
#include "communicate.h"
@@ -1382,7 +1397,7 @@ FTSENT *fts_read(FTS *ftsp) {
r=next_fts_read(ftsp);
if(r && r->fts_statp) { /* Should we bother checking fts_info here? */
-# ifdef STAT64_SUPPORT
+# if defined(STAT64_SUPPORT) && !defined(__APPLE__)
SEND_GET_STAT64(r->fts_statp, _STAT_VER);
# else
SEND_GET_STAT(r->fts_statp, _STAT_VER);
@@ -1400,7 +1415,7 @@ FTSENT *fts_children(FTS *ftsp, int options) {
first=next_fts_children(ftsp, options);
for(r = first; r; r = r->fts_link) {
if(r && r->fts_statp) { /* Should we bother checking fts_info here? */
-# ifdef STAT64_SUPPORT
+# if defined(STAT64_SUPPORT) && !defined(__APPLE__)
SEND_GET_STAT64(r->fts_statp, _STAT_VER);
# else
SEND_GET_STAT(r->fts_statp, _STAT_VER);
diff --git a/libfakeroot_inode64.c b/libfakeroot_inode64.c
new file mode 100644
index 0000000..d6c042e
--- /dev/null
+++ b/libfakeroot_inode64.c
@@ -0,0 +1,94 @@
+/*
+ Copyright: GPL.
+ Author: regis duchesne (hpreg at vmware.com)
+*/
+
+#ifdef __APPLE__
+/*
+ This file is for symbols which have the "$INODE64" version, i.e. symbols
+ which use a 64-bit ino_t.
+
+ In this file, 'struct stat' is an alias for 'struct stat64'.
+*/
+#define _DARWIN_USE_64_BIT_INODE
+
+#include "config.h"
+#include "communicate.h"
+
+#include <stdio.h>
+#ifdef HAVE_SYS_ACL_H
+#include <sys/acl.h>
+#endif /* HAVE_SYS_ACL_H */
+#if HAVE_FTS_H
+#include <fts.h>
+#endif /* HAVE_FTS_H */
+
+#include "wrapped.h"
+
+int lstat(const char *file_name,
+ struct stat *st){
+
+ int r;
+
+ r=next_lstat$INODE64(file_name, st);
+
+ if(r)
+ return -1;
+
+ send_get_stat64((struct stat64 *)st);
+ return 0;
+}
+
+
+int stat(const char *file_name,
+ struct stat *st){
+ int r;
+
+ r=next_stat$INODE64(file_name,st);
+ if(r)
+ return -1;
+ send_get_stat64((struct stat64 *)st);
+ return 0;
+}
+
+
+int fstat(int fd,
+ struct stat *st){
+ int r;
+
+ r=next_fstat$INODE64(fd, st);
+ if(r)
+ return -1;
+ send_get_stat64((struct stat64 *)st);
+
+ return 0;
+}
+
+#ifdef HAVE_FTS_READ
+FTSENT *fts_read(FTS *ftsp) {
+ FTSENT *r;
+
+ r=next_fts_read$INODE64(ftsp);
+ if(r && r->fts_statp) { /* Should we bother checking fts_info here? */
+ send_get_stat64((struct stat64 *)r->fts_statp);
+ }
+
+ return r;
+}
+
+FTSENT *fts_children(FTS *ftsp,
+ int options) {
+ FTSENT *first;
+ FTSENT *r;
+
+ first=next_fts_children$INODE64(ftsp, options);
+ for(r = first; r; r = r->fts_link) {
+ if(r->fts_statp) { /* Should we bother checking fts_info here? */
+ send_get_stat64((struct stat64 *)r->fts_statp);
+ }
+ }
+
+ return first;
+}
+#endif /* HAVE_FTS_READ */
+#endif /* ifdef __APPLE__ */
diff --git a/libfakeroot_unix2003.c b/libfakeroot_unix2003.c
new file mode 100644
index 0000000..f8d0884
--- /dev/null
+++ b/libfakeroot_unix2003.c
@@ -0,0 +1,163 @@
+/*
+ Copyright: GPL.
+ Author: regis duchesne (hpreg at vmware.com)
+*/
+
+#if defined __APPLE__ && !defined __LP64__
+/*
+ In this file, we want 'struct stat' to have a 32-bit 'ino_t'.
+ We use 'struct stat64' when we need a 64-bit 'ino_t'.
+*/
+#define _DARWIN_NO_64_BIT_INODE
+
+/*
+ This file is for 32-bit symbols which have the "$UNIX2003" version, i.e.
+ 32-bit symbols whose semantics adhere to the SUSv3 standard.
+*/
+#define _DARWIN_C_SOURCE
+
+#include "config.h"
+#include "communicate.h"
+
+#ifdef STUPID_ALPHA_HACK
+#define SEND_STAT(a,b,c) send_stat(a,b,c)
+#define SEND_STAT64(a,b,c) send_stat64(a,b,c)
+#define SEND_GET_STAT(a,b) send_get_stat(a,b)
+#define SEND_GET_STAT64(a,b) send_get_stat64(a,b)
+#else
+#define SEND_STAT(a,b,c) send_stat(a,b)
+#define SEND_STAT64(a,b,c) send_stat64(a,b)
+#define SEND_GET_STAT(a,b) send_get_stat(a)
+#define SEND_GET_STAT64(a,b) send_get_stat64(a)
+#endif
+
+/*
+ These INT_* (which stands for internal) macros should always be used when
+ the fakeroot library owns the storage of the stat variable.
+*/
+#ifdef STAT64_SUPPORT
+#define INT_STRUCT_STAT struct stat64
+#define INT_NEXT_STAT(a,b) NEXT_STAT64(_STAT_VER,a,b)
+#define INT_NEXT_LSTAT(a,b) NEXT_LSTAT64(_STAT_VER,a,b)
+#define INT_NEXT_FSTAT(a,b) NEXT_FSTAT64(_STAT_VER,a,b)
+#define INT_NEXT_FSTATAT(a,b,c,d) NEXT_FSTATAT64(_STAT_VER,a,b,c,d)
+#define INT_SEND_STAT(a,b) SEND_STAT64(a,b,_STAT_VER)
+#else
+#define INT_STRUCT_STAT struct stat
+#define INT_NEXT_STAT(a,b) NEXT_STAT(_STAT_VER,a,b)
+#define INT_NEXT_LSTAT(a,b) NEXT_LSTAT(_STAT_VER,a,b)
+#define INT_NEXT_FSTAT(a,b) NEXT_FSTAT(_STAT_VER,a,b)
+#define INT_NEXT_FSTATAT(a,b,c,d) NEXT_FSTATAT(_STAT_VER,a,b,c,d)
+#define INT_SEND_STAT(a,b) SEND_STAT(a,b,_STAT_VER)
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#ifdef HAVE_SYS_ACL_H
+#include <sys/acl.h>
+#endif /* HAVE_SYS_ACL_H */
+#if HAVE_FTS_H
+#include <fts.h>
+#endif /* HAVE_FTS_H */
+
+#include "wrapped.h"
+
+extern int fakeroot_disabled;
+
+#ifdef LCHOWN_SUPPORT
+int lchown(const char *path, uid_t owner, gid_t group){
+ INT_STRUCT_STAT st;
+ int r=0;
+
+ r=INT_NEXT_LSTAT(path, &st);
+ if(r)
+ return r;
+ st.st_uid=owner;
+ st.st_gid=group;
+ INT_SEND_STAT(&st,chown_func);
+ if(!dont_try_chown())
+ r=next_lchown$UNIX2003(path,owner,group);
+ else
+ r=0;
+ if(r&&(errno==EPERM))
+ r=0;
+
+ return r;
+}
+#endif
+
+int chmod(const char *path, mode_t mode){
+ INT_STRUCT_STAT st;
+ int r;
+
+ r=INT_NEXT_STAT(path, &st);
+ if(r)
+ return r;
+
+ st.st_mode=(mode&ALLPERMS)|(st.st_mode&~ALLPERMS);
+
+ INT_SEND_STAT(&st, chmod_func);
+
+ /* if a file is unwritable, then root can still write to it
+ (no matter who owns the file). If we are fakeroot, the only
+ way to fake this is to always make the file writable, readable
+ etc for the real user (who started fakeroot). Also holds for
+ the exec bit of directories.
+ Yes, packages requering that are broken. But we have lintian
+ to get rid of broken packages, not fakeroot.
+ */
+ mode |= 0600;
+ if(S_ISDIR(st.st_mode))
+ mode |= 0100;
+
+ r=next_chmod$UNIX2003(path, mode);
+ if(r&&(errno==EPERM))
+ r=0;
+#ifdef EFTYPE /* available under FreeBSD kernel */
+ if(r&&(errno==EFTYPE))
+ r=0;
+#endif
+ return r;
+}
+
+int fchmod(int fd, mode_t mode){
+ int r;
+ INT_STRUCT_STAT st;
+
+
+ r=INT_NEXT_FSTAT(fd, &st);
+
+ if(r)
+ return(r);
+
+ st.st_mode=(mode&ALLPERMS)|(st.st_mode&~ALLPERMS);
+ INT_SEND_STAT(&st,chmod_func);
+
+ /* see chmod() for comment */
+ mode |= 0600;
+ if(S_ISDIR(st.st_mode))
+ mode |= 0100;
+
+ r=next_fchmod$UNIX2003(fd, mode);
+ if(r&&(errno==EPERM))
+ r=0;
+#ifdef EFTYPE /* available under FreeBSD kernel */
+ if(r&&(errno==EFTYPE))
+ r=0;
+#endif
+ return r;
+}
+
+int setreuid(SETREUID_ARG ruid, SETREUID_ARG euid){
+ if (fakeroot_disabled)
+ return next_setreuid$UNIX2003(ruid, euid);
+ return set_faked_reuid(ruid, euid);
+}
+
+int setregid(SETREGID_ARG rgid, SETREGID_ARG egid){
+ if (fakeroot_disabled)
+ return next_setregid$UNIX2003(rgid, egid);
+ return set_faked_regid(rgid, egid);
+}
+#endif /* if defined __APPLE__ && !defined __LP64__ */
diff --git a/wrapfunc.inp b/wrapfunc.inp
index 717914b..e04a458 100644
--- a/wrapfunc.inp
+++ b/wrapfunc.inp
@@ -32,6 +32,12 @@ WRAP_FSTATAT64;int;FSTATAT64_ARG(int ver, int dir_fd, const char *path, struct s
#endif /* HAVE_FSTATAT */
#endif /* STAT64_SUPPORT */
+#ifdef __APPLE__
+lstat$INODE64;int;(const char *file_name, struct stat *buf);(file_name, buf)
+stat$INODE64;int;(const char *file_name, struct stat *buf);(file_name, buf)
+fstat$INODE64;int;(int fd, struct stat *buf);(fd, buf)
+#endif /* ifdef __APPLE__ */
+
WRAP_MKNOD;int;MKNOD_ARG(int ver, const char *pathname, mode_t mode, dev_t XMKNOD_FRTH_ARG dev);MKNOD_ARG(ver, pathname, mode, dev);MKNOD
#ifdef HAVE_FSTATAT
@@ -51,6 +57,11 @@ lchown;int;(const char *path, uid_t owner, gid_t group);(path, owner, group)
fchown;int;(int fd, uid_t owner, gid_t group);(fd, owner, group)
chmod;int;(const char *path, mode_t mode);(path, mode)
fchmod;int;(int fd, mode_t mode);(fd, mode)
+#if defined __APPLE__ && !defined __LP64__
+lchown$UNIX2003;int;(const char *path, uid_t owner, gid_t group);(path, owner, group)
+chmod$UNIX2003;int;(const char *path, mode_t mode);(path, mode)
+fchmod$UNIX2003;int;(int fd, mode_t mode);(fd, mode)
+#endif /* if defined __APPLE__ && !defined __LP64__ */
mkdir;int;(const char *path, mode_t mode);(path, mode)
unlink;int;(const char *pathname);(pathname)
rmdir;int;(const char *pathname);(pathname)
@@ -78,6 +89,10 @@ seteuid;int;(uid_t id);(id)
setegid;int;(gid_t id);(id)
setreuid;int;(SETREUID_ARG ruid, SETREUID_ARG euid);(ruid, euid)
setregid;int;(SETREGID_ARG rgid, SETREGID_ARG egid);(rgid, egid)
+#if defined __APPLE__ && !defined __LP64__
+setreuid$UNIX2003;int;(SETREUID_ARG ruid, SETREUID_ARG euid);(ruid, euid)
+setregid$UNIX2003;int;(SETREGID_ARG rgid, SETREGID_ARG egid);(rgid, egid)
+#endif /* if defined __APPLE__ && !defined __LP64__ */
#ifdef HAVE_GETRESUID
getresuid;int;(uid_t *ruid, uid_t *euid, uid_t *suid);(ruid, euid, suid)
#endif /* HAVE_GETRESUID */
@@ -127,6 +142,11 @@ acl_set_file;int;(const char *path_p, acl_type_t type, acl_t acl);(path_p, type,
#ifdef HAVE_FTS_READ
fts_read;FTSENT *;(FTS *ftsp);(ftsp)
+fts_children;FTSENT *;(FTS *ftsp, int options);(ftsp, options)
+#ifdef __APPLE__
+fts_read$INODE64;FTSENT *;(FTS *ftsp);(ftsp)
+fts_children$INODE64;FTSENT *;(FTS *ftsp, int options);(ftsp, options)
+#endif /* ifdef __APPLE__ */
#endif /* HAVE_FTS_READ */
#ifdef HAVE_FTS_CHILDREN
fts_children;FTSENT *;(FTS *ftsp, int options);(ftsp, options)
--
fakeroot
More information about the Fakeroot-commits
mailing list