readdir() and read() errors ignored

jw schultz jw at pegasys.ws
Tue Sep 16 14:44:01 EST 2003


Committed.

On Mon, Aug 25, 2003 at 03:48:32PM -0700, jw schultz wrote:
> On Sun, Aug 24, 2003 at 10:51:20AM +0100, Michael Brown wrote:
> > > > A similar error can occur when open() succeeds but subsequent calls to 
> > > > read() fail: under these circumstances rsync will transfer zeroes instead 
> > > > of the actual file data and will again report no errors to the user.
> > > > The attached patch fixes both of these problems.
> > > There is a patch on-list for the read error.   Your fix is
> > > incorrect because it causes rsync to exit if a file is
> > > truncated during read.
> > 
> > I think it will only exit if an error occurs, not just if EOF is reached 
> > unexpectedly (it checks for read() returning <0, not !=expected), but no 
> > matter since there is already a patch.  Is your patch going to be 
> > integrated into HEAD CVS?
> 
> Shortly.  I want to review the other callers of file_unmap
> first.
> 
> > > I'll look closer at the readir error when i get a chance.
> > 
> > I've attached a new patch that only addresses the readdir() issue.  This 
> > patch has been tested and does solve the problem:
> > 
> > Before the patch:
> > 
> > [root at angel root]# ls /mnt/nfs/rsync-test/
> > ls: reading directory /mnt/nfs/rsync-test/: Permission denied
> > [root at angel root]# rsync -avP /mnt/nfs/rsync-test/ rsync-test/
> > building file list ...
> > 1 file to consider
> > wrote 70 bytes  read 20 bytes  180.00 bytes/sec
> > total size is 0  speedup is 0.00
> > [root at angel root]# ls rsync-test/
> > [root at angel root]#
> > 
> > Here you can see rsync silently failing on an NFS-mounted directory for 
> > which opendir() succeeds but readdir() fails.
> > 
> > After the patch:
> > 
> > [root at angel root]# ls /mnt/nfs/rsync-test/
> > ls: reading directory /mnt/nfs/rsync-test/: Permission denied
> > [root at angel root]# ~/fixed-rsync -avP /mnt/nfs/rsync-test/ rsync-test/
> > building file list ...
> > readdir(.): Permission denied
> > 1 file to consider
> > 
> > wrote 70 bytes  read 20 bytes  180.00 bytes/sec
> > total size is 0  speedup is 0.00
> > rsync error: some files could not be transferred (code 23) at main.c(628)
> > [root at angel root]#
> > 
> > Now rsync acts correctly and reports a partial transfer error to the user.
> > 
> > 
> > You can easily reproduce this situation: create an NFS export with the
> > default flag of "root_squash", create a directory on the NFS server with
> > permissions of e.g. 750 and try to rsync it as root.  opendir() succeeds
> > because Linux just looks at the directory permissions and doesn't bother
> > contacting the NFS server but readdir() fails because the NFS server maps 
> > requests from root to the anonymous user, who doesn't have access to the 
> > directory.
> > 
> > (Please Cc me on replies)
> 
> Very good.  Accepted.
> I'll commit it with the read fix.
> -- 
> To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
> 

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt



More information about the rsync mailing list