[Fakeroot-commits] [SCM] fakeroot branch, master, updated. debian/1.14.2-3-g316e1ed

Clint Adams schizo at debian.org
Tue Oct 27 05:48:29 UTC 2009


The following commit has been merged in the master branch:
commit 316e1ed2a37d78a4314bc3d5a2e0634a1ec9214a
Author: Clint Adams <schizo at debian.org>
Date:   Tue Oct 27 01:47:40 2009 -0400

    Apply patch (guarded) from VMware: "Add debug support."

diff --git a/libfakeroot.c b/libfakeroot.c
index 4ae3af4..ac50a35 100644
--- a/libfakeroot.c
+++ b/libfakeroot.c
@@ -155,6 +155,9 @@ void *get_libc(){
 void load_library_symbols(void);
 
 int fakeroot_disabled = 0;
+#ifdef LIBFAKEROOT_DEBUGGING
+int fakeroot_debug = 0;
+#endif /* LIBFAKEROOT_DEBUGGING */
 
 #ifdef __APPLE__
 #include "patchattr.h"
@@ -182,6 +185,15 @@ void load_library_symbols(void){
   int i;
   const char *msg;
   
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (getenv("FAKEROOT_DEBUG")) {
+    fakeroot_debug=1;
+  }
+  if (fakeroot_debug) {
+    fprintf(stderr, "load_library_symbols\n");
+  }
+
+#endif /* LIBFAKEROOT_DEBUGGING */
   for(i=0; next_wrap[i].doit; i++){
     *(next_wrap[i].doit)=dlsym(get_libc(), next_wrap[i].name);
     if ( (msg = dlerror()) != NULL){
@@ -542,6 +554,11 @@ int WRAP_LSTAT LSTAT_ARG(int ver,
 
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "lstat file_name %s\n", file_name);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=NEXT_LSTAT(ver, file_name, statbuf);
   if(r)
     return -1;
@@ -555,6 +572,11 @@ int WRAP_STAT STAT_ARG(int ver,
 		       struct stat *st){
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "stat file_name %s\n", file_name);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=NEXT_STAT(ver, file_name, st);
   if(r)
     return -1;
@@ -570,6 +592,11 @@ int WRAP_FSTAT FSTAT_ARG(int ver,
 
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fstat fd %d\n", fd);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=NEXT_FSTAT(ver, fd, st);
   if(r)
     return -1;
@@ -603,6 +630,11 @@ int WRAP_LSTAT64 LSTAT64_ARG (int ver,
 
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "lstat64 file_name %s\n", file_name);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=NEXT_LSTAT64(ver, file_name, st);
 
   if(r)
@@ -618,6 +650,11 @@ int WRAP_STAT64 STAT64_ARG(int ver,
 			   struct stat64 *st){
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "stat64 file_name %s\n", file_name);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=NEXT_STAT64(ver,file_name,st);
   if(r)
     return -1;
@@ -631,6 +668,11 @@ int WRAP_FSTAT64 FSTAT64_ARG(int ver,
 			     struct stat64 *st){
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fstat64 fd %d\n", fd);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=NEXT_FSTAT64(ver, fd, st);
   if(r)
     return -1;
@@ -691,6 +733,11 @@ int chown(const char *path, uid_t owner, gid_t group){
   int r=0;
 
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "chown path %s owner %d group %d\n", path, owner, group);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
 #ifdef LCHOWN_SUPPORT
   /*chown(sym-link) works on the target of the symlink if lchown is
     present and enabled.*/
@@ -721,6 +768,11 @@ int lchown(const char *path, uid_t owner, gid_t group){
   INT_STRUCT_STAT st;
   int r=0;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "lchown path %s owner %d group %d\n", path, owner, group);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_LSTAT(path, &st);
   if(r)
     return r;
@@ -794,6 +846,11 @@ int chmod(const char *path, mode_t mode){
   INT_STRUCT_STAT st;
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "chmod path %s\n", path);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_STAT(path, &st);
   if(r)
     return r;
@@ -829,6 +886,11 @@ int fchmod(int fd, mode_t mode){
   INT_STRUCT_STAT st;
 
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fchmod fd %d\n", fd);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_FSTAT(fd, &st);
   
   if(r)
@@ -975,6 +1037,11 @@ int mkdir(const char *path, mode_t mode){
      to communicate with faked we need a struct stat, so we now
      do a stat of the new directory (just for the inode/dev) */
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "mkdir path %s\n", path);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_mkdir(path, mode|0700); 
   /* mode|0700: see comment in the chown() function above */
   if(r)
@@ -1313,12 +1380,22 @@ int setegid(uid_t id){
 }
 
 int setreuid(SETREUID_ARG ruid, SETREUID_ARG euid){
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "setreuid\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   if (fakeroot_disabled)
     return next_setreuid(ruid, euid);
   return set_faked_reuid(ruid, euid);
 }
 
 int setregid(SETREGID_ARG rgid, SETREGID_ARG egid){
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "setregid\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   if (fakeroot_disabled)
     return next_setregid(rgid, egid);
   return set_faked_regid(rgid, egid);
@@ -1398,6 +1475,11 @@ int acl_set_file(const char *path_p, acl_type_t type, acl_t acl) {
 FTSENT *fts_read(FTS *ftsp) {
   FTSENT *r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fts_read\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_fts_read(ftsp);
   if(r && r->fts_statp) {  /* Should we bother checking fts_info here? */
 # if defined(STAT64_SUPPORT) && !defined(__APPLE__)
@@ -1415,6 +1497,11 @@ FTSENT *fts_read(FTS *ftsp) {
 FTSENT *fts_children(FTS *ftsp, int options) {
   FTSENT *first, *r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fts_children\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   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? */
@@ -1444,6 +1531,11 @@ getattrlist(const char *path, void *attrList, void *attrBuf,
   int r;
   struct stat st;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "getattrlist path %s\n", path);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_getattrlist(path, attrList, attrBuf, attrBufSize, options);
   if (r) {
     return r;
@@ -1474,6 +1566,11 @@ fgetattrlist(int fd, void *attrList, void *attrBuf,
   int r;
   struct stat st;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fgetattrlist fd %d\n", fd);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_fgetattrlist(fd, attrList, attrBuf, attrBufSize, options);
   if (r) {
     return r;
diff --git a/libfakeroot_inode64.c b/libfakeroot_inode64.c
index d6c042e..87d36bf 100644
--- a/libfakeroot_inode64.c
+++ b/libfakeroot_inode64.c
@@ -25,11 +25,20 @@
 
 #include "wrapped.h"
 
+#ifdef LIBFAKEROOT_DEBUGGING
+extern int fakeroot_debug;
+
+#endif /* LIBFAKEROOT_DEBUGGING */
 int lstat(const char *file_name,
           struct stat *st){
 
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "lstat$INODE64 file_name %s\n", file_name);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_lstat$INODE64(file_name, st);
 
   if(r)
@@ -44,6 +53,11 @@ int stat(const char *file_name,
          struct stat *st){
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "stat$INODE64 file_name %s\n", file_name);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_stat$INODE64(file_name,st);
   if(r)
     return -1;
@@ -56,6 +70,11 @@ int fstat(int fd,
           struct stat *st){
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fstat$INODE64 fd %d\n", fd);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_fstat$INODE64(fd, st);
   if(r)
     return -1;
@@ -68,6 +87,11 @@ int fstat(int fd,
 FTSENT *fts_read(FTS *ftsp) {
   FTSENT *r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fts_read$INODE64\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   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);
@@ -81,6 +105,11 @@ FTSENT *fts_children(FTS *ftsp,
   FTSENT *first;
   FTSENT *r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fts_children$INODE64\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   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? */
diff --git a/libfakeroot_unix2003.c b/libfakeroot_unix2003.c
index a77deb6..812fc43 100644
--- a/libfakeroot_unix2003.c
+++ b/libfakeroot_unix2003.c
@@ -71,6 +71,11 @@ int lchown(const char *path, uid_t owner, gid_t group){
   INT_STRUCT_STAT st;
   int r=0;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "lchown$UNIX2003 path %s owner %d group %d\n", path, owner, group);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_LSTAT(path, &st);
   if(r)
     return r;
@@ -92,6 +97,11 @@ int chmod(const char *path, mode_t mode){
   INT_STRUCT_STAT st;
   int r;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "chmod$UNIX2003 path %s\n", path);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_STAT(path, &st);
   if(r)
     return r;
@@ -127,6 +137,11 @@ int fchmod(int fd, mode_t mode){
   INT_STRUCT_STAT st;
 
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "fchmod$UNIX2003 fd %d\n", fd);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=INT_NEXT_FSTAT(fd, &st);
   
   if(r)
@@ -151,12 +166,22 @@ int fchmod(int fd, mode_t mode){
 }
 
 int setreuid(SETREUID_ARG ruid, SETREUID_ARG euid){
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "setreuid$UNIX2003\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   if (fakeroot_disabled)
     return next_setreuid$UNIX2003(ruid, euid);
   return set_faked_reuid(ruid, euid);
 }
 
 int setregid(SETREGID_ARG rgid, SETREGID_ARG egid){
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "setregid$UNIX2003\n");
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   if (fakeroot_disabled)
     return next_setregid$UNIX2003(rgid, egid);
   return set_faked_regid(rgid, egid);
@@ -169,6 +194,11 @@ getattrlist(const char *path, void *attrList, void *attrBuf,
   int r;
   struct stat st;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "getattrlist$UNIX2003 path %s\n", path);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   r=next_getattrlist$UNIX2003(path, attrList, attrBuf, attrBufSize, options);
   if (r) {
     return r;
diff --git a/patchattr.h b/patchattr.h
index cad4693..15e2c91 100644
--- a/patchattr.h
+++ b/patchattr.h
@@ -6,6 +6,10 @@
 #include <sys/attr.h>
 #include <sys/mount.h>
 
+#ifdef LIBFAKEROOT_DEBUGGING
+extern int fakeroot_debug;
+
+#endif /* LIBFAKEROOT_DEBUGGING */
 static void
 patchattr(void *attrList, void *attrBuf, uid_t uid, gid_t gid)
 {
@@ -13,9 +17,16 @@ patchattr(void *attrList, void *attrBuf, uid_t uid, gid_t gid)
      the order they are described in the man page).
   */
   static const struct {
+#ifdef LIBFAKEROOT_DEBUGGING
+    const char *name;
+#endif /* LIBFAKEROOT_DEBUGGING */
     u_int32_t value;
     size_t size;
+#ifdef LIBFAKEROOT_DEBUGGING
+    int isRef;
+#endif /* LIBFAKEROOT_DEBUGGING */
   } attrs[] = {
+#ifndef LIBFAKEROOT_DEBUGGING
 #define PATCHATTR(a,b) { a, b, }
     PATCHATTR(ATTR_CMN_RETURNED_ATTRS, sizeof (attribute_set_t)),
     PATCHATTR(ATTR_CMN_NAME, sizeof (attrreference_t)),
@@ -46,22 +57,87 @@ patchattr(void *attrList, void *attrBuf, uid_t uid, gid_t gid)
     PATCHATTR(ATTR_CMN_FILEID, sizeof (u_int64_t)),
     PATCHATTR(ATTR_CMN_PARENTID, sizeof (u_int64_t)),
     PATCHATTR(ATTR_CMN_FULLPATH, sizeof (attrreference_t)),
+#else /* LIBFAKEROOT_DEBUGGING */
+#define PATCHATTR(a,b,c) { #a, a, b, c, }
+    PATCHATTR(ATTR_CMN_RETURNED_ATTRS, sizeof (attribute_set_t), 0),
+    PATCHATTR(ATTR_CMN_NAME, sizeof (attrreference_t), 1),
+    PATCHATTR(ATTR_CMN_DEVID, sizeof (dev_t), 0),
+    PATCHATTR(ATTR_CMN_FSID, sizeof (fsid_t), 0),
+    PATCHATTR(ATTR_CMN_OBJTYPE, sizeof (fsobj_type_t), 0),
+    PATCHATTR(ATTR_CMN_OBJTAG, sizeof (fsobj_tag_t), 0),
+    PATCHATTR(ATTR_CMN_OBJID, sizeof (fsobj_id_t), 0),
+    PATCHATTR(ATTR_CMN_OBJPERMANENTID, sizeof (fsobj_id_t), 0),
+    PATCHATTR(ATTR_CMN_PAROBJID, sizeof (fsobj_id_t), 0),
+    PATCHATTR(ATTR_CMN_SCRIPT, sizeof (text_encoding_t), 0),
+    PATCHATTR(ATTR_CMN_CRTIME, sizeof (struct timespec), 0),
+    PATCHATTR(ATTR_CMN_MODTIME, sizeof (struct timespec), 0),
+    PATCHATTR(ATTR_CMN_CHGTIME, sizeof (struct timespec), 0),
+    PATCHATTR(ATTR_CMN_ACCTIME, sizeof (struct timespec), 0),
+    PATCHATTR(ATTR_CMN_BKUPTIME, sizeof (struct timespec), 0),
+    PATCHATTR(ATTR_CMN_FNDRINFO, 32, 0),
+    PATCHATTR(ATTR_CMN_OWNERID, sizeof (uid_t), 0),
+    PATCHATTR(ATTR_CMN_GRPID, sizeof (gid_t), 0),
+    PATCHATTR(ATTR_CMN_ACCESSMASK, sizeof (u_int32_t), 0),
+    PATCHATTR(ATTR_CMN_NAMEDATTRCOUNT, sizeof (u_int32_t), 0),
+    PATCHATTR(ATTR_CMN_NAMEDATTRLIST, sizeof (attrreference_t), 1),
+    PATCHATTR(ATTR_CMN_FLAGS, sizeof (u_int32_t), 0),
+    PATCHATTR(ATTR_CMN_USERACCESS, sizeof (u_int32_t), 0),
+    PATCHATTR(ATTR_CMN_EXTENDED_SECURITY, sizeof (attrreference_t), 1),
+    PATCHATTR(ATTR_CMN_UUID, sizeof (guid_t), 0),
+    PATCHATTR(ATTR_CMN_GRPUUID, sizeof (guid_t), 0),
+    PATCHATTR(ATTR_CMN_FILEID, sizeof (u_int64_t), 0),
+    PATCHATTR(ATTR_CMN_PARENTID, sizeof (u_int64_t), 0),
+    PATCHATTR(ATTR_CMN_FULLPATH, sizeof (attrreference_t), 1),
+#endif /* LIBFAKEROOT_DEBUGGING */
 #undef PATCHATTR
   };
   struct attrlist *l = attrList;
   unsigned char *b = attrBuf;
   unsigned i;
 
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    fprintf(stderr, "patchattr actual attrBuf size %u\n", *(u_int32_t *)b);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
   b += sizeof (u_int32_t);
   for (i = 0; i < sizeof attrs / sizeof attrs[0]; i++) {
     if (l->commonattr & attrs[i].value) {
+#ifdef LIBFAKEROOT_DEBUGGING
+      if (fakeroot_debug) {
+        fprintf(stderr, "patchattr attr %s: yes\n", attrs[i].name);
+        if (attrs[i].isRef) {
+          size_t here = b - (unsigned char *)attrBuf;
+          size_t begin = here + ((attrreference_t *)b)->attr_dataoffset;
+          size_t size = ((attrreference_t *)b)->attr_length;
+          size_t alignedEnd = (begin + size + 3) & ~3;
+          fprintf(stderr, "patchattr reference begin %zu size %zu aligned end %zu\n", begin, size, alignedEnd);
+        }
+      }
+#endif /* LIBFAKEROOT_DEBUGGING */
       if (attrs[i].value == ATTR_CMN_OWNERID) {
+#ifdef LIBFAKEROOT_DEBUGGING
+        if (fakeroot_debug) {
+          fprintf(stderr, "patchattr owner %d\n", *(uid_t *)b);
+        }
+#endif /* LIBFAKEROOT_DEBUGGING */
         *(uid_t *)b = uid;
       }
       if (attrs[i].value == ATTR_CMN_GRPID) {
+#ifdef LIBFAKEROOT_DEBUGGING
+        if (fakeroot_debug) {
+          fprintf(stderr, "patchattr group %d\n", *(gid_t *)b);
+        }
+#endif /* LIBFAKEROOT_DEBUGGING */
         *(gid_t *)b = gid;
       }
       b += (attrs[i].size + 3) & ~3;
     }
   }
+#ifdef LIBFAKEROOT_DEBUGGING
+  if (fakeroot_debug) {
+    size_t here = b - (unsigned char *)attrBuf;
+    fprintf(stderr, "patchattr attrBuf fixed size %zu\n", here);
+  }
+#endif /* LIBFAKEROOT_DEBUGGING */
 }

-- 
fakeroot



More information about the Fakeroot-commits mailing list