----- "Clint Adams" <[EMAIL PROTECTED]> wrote:

> On Fri, Oct 03, 2008 at 07:11:08PM -0400, Joe Malicki wrote:
> > faked.diff was thoroughly tested.  When I posted I noticed that it
> didn't cover
> > all of the cases and added faked-link.diff, and meant to mention
> that I hadn't
> > tried it yet (I am testing it now, with the {).
> 
> Okay, I've uploaded the faked.diff-patched version for now. Let me
> know
> how it goes.

This faked-link2.diff (patch to fakeroot 1.5.10) passes tests and holds up 
through
reasonable testing.

It should fix all cases noted in this bug, which were probably all caused by 
ldconfig.
Index: faked.c
===================================================================
--- faked.c	(revision 86350)
+++ faked.c	(working copy)
@@ -633,7 +633,33 @@
   i = data_find(&buf->st, buf->remote);
   if (i != data_end()) {
     st = data_node_get(i);
-    st->mode = (buf->st.mode&~S_IFMT) | (st->mode&S_IFMT);
+    /* Statically linked binaries can remove inodes without us knowing.
+       ldconfig is a prime offender.  Also, some packages run tests without
+       LD_PRELOAD.
+
+       While those cases can be fixed in other ways, we shouldn't continue to
+       cache stale file information.
+
+       mknod() creates a regular file, everything else should have the same
+       file type on disk and in our database.  Therefore, we check the file's
+       type first.  If we have something in our database as a device node and
+       we get a request to change it to regular file, it might be a chmod of
+       a device node that was created from within fakeroot, which is a device
+       file on disk - there's no way to distinguish.   For anything else, we
+       trust the new type and assume the inode got unlinked from something that
+       wasn't using the LD_PRELOAD library.
+    */
+       
+    if ((buf->st.mode&S_IFMT) != (st->mode&S_IFMT) &&
+        ((buf->st.mode&S_IFMT) != S_IFREG || (!st->mode&(S_IFBLK|S_IFCHR)))) {
+        
+      fprintf(stderr,"FAKEROOT: chmod mode=%lo incompatible with "
+              "existing mode=%lo\n", buf->st.mode, st->mode);
+      st->mode = buf->st.mode;
+    }
+    else{
+      st->mode = (buf->st.mode&~S_IFMT) | (st->mode&S_IFMT);
+    }
   }
   else{
     st=&buf->st;
Index: test/t.no_ld_preload_link
===================================================================
--- test/t.no_ld_preload_link	(revision 0)
+++ test/t.no_ld_preload_link	(revision 86357)
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+mkdir tmp
+../scripts/fakeroot${tcp} -f ../faked${tcp} -l ../.libs/${libfakeroot} -- \
+ ${posixshell} -c 'touch tmp/justafile && ln -s justafile tmp/alink && LD_PRELOAD= rm tmp/alink && touch tmp/alink && ls -ld tmp/alink' | grep "^-"
+TEMP=$?
+rm -rf tmp
+exit $TEMP

Property changes on: test/t.no_ld_preload_link
___________________________________________________________________
Added: svn:executable
   + *

Index: test/Makefile.in
===================================================================
--- test/Makefile.in	(revision 86350)
+++ test/Makefile.in	(working copy)
@@ -156,7 +156,7 @@
 target_vendor = @target_vendor@
 AUTOMAKE_OPTIONS = foreign
 TESTS = t.echoarg t.mknod t.tar t.truereturn t.falsereturn t.option \
-	t.touchinstall
+	t.touchinstall t.no_ld_preload t.no_ld_preload_link t.chmod_dev
 
 suffix = 
 TESTS_ENVIRONMENT = libfakeroot=libfakeroot-0.so suffix=$(suffix) posixshell=$(SHELL)
Index: test/t.chmod_dev
===================================================================
--- test/t.chmod_dev	(revision 0)
+++ test/t.chmod_dev	(revision 86357)
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+mkdir tmp
+../scripts/fakeroot${tcp} -f ../faked${tcp} -l ../.libs/${libfakeroot} -- \
+ ${posixshell} -c 'mknod tmp/hda3 b 3 0 && chmod 644 tmp/hda3 && ls -ld tmp/hda3' | grep "^b"
+TEMP=$?
+rm -rf tmp
+exit $TEMP

Property changes on: test/t.chmod_dev
___________________________________________________________________
Added: svn:executable
   + *

Index: test/t.no_ld_preload
===================================================================
--- test/t.no_ld_preload	(revision 0)
+++ test/t.no_ld_preload	(revision 86357)
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+mkdir tmp
+../scripts/fakeroot${tcp} -f ../faked${tcp} -l ../.libs/${libfakeroot} -- \
+ ${posixshell} -c 'touch tmp/justafile && LD_PRELOAD= rm tmp/justafile && mkdir tmp/justafile && ls -ld tmp/justafile' | grep "^d"
+TEMP=$?
+rm -rf tmp
+exit $TEMP

Property changes on: test/t.no_ld_preload
___________________________________________________________________
Added: svn:executable
   + *

Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 86350)
+++ test/Makefile.am	(working copy)
@@ -1,7 +1,7 @@
 AUTOMAKE_OPTIONS=foreign
 
 TESTS = t.echoarg t.mknod t.tar t.truereturn t.falsereturn t.option \
-	t.touchinstall
+	t.touchinstall t.no_ld_preload t.no_ld_preload_link t.chmod_dev
 
 suffix =
 TESTS_ENVIRONMENT = libfakeroot=libfakeroot-0.so suffix=$(suffix) posixshell=$(SHELL)

Reply via email to