samba-bugs@samba.org
2007-Oct-20 02:00 UTC
DO NOT REPLY [Bug 5027] New: Perms in do_mkstemp are not always valid
https://bugzilla.samba.org/show_bug.cgi?id=5027 Summary: Perms in do_mkstemp are not always valid Product: rsync Version: 2.6.9 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P3 Component: core AssignedTo: wayned@samba.org ReportedBy: cmadams@hiwaay.net QAContact: rsync-qa@samba.org I'm trying to rsync (with -a to preserve permissions) to a mount point on an NFS server, and it fails when copying a file that is read-only. The problem is that do_mkstemp creates the temp file with the desired user permissions (either with open() or with fchmod(). SUSv3 says that the affect of chmod()/fchmod() on existing open file descriptors is implemtation defined; it also says: Any file descriptors currently open by any process on the file could possibly become invalid if the mode of the file is changed to a value which would deny access to that process. One situation where this could occur is on a stateless file system. This behavior will not occur in a conforming environment. I guess I have a non-conforming environment (I'm talking to a unfs3 server). If I remove HAVE_FCHMOD, it still doesn't work, because the call to open() includes the read-only permissions as well (a case I don't really see referenced in SUSv3 right off). The following patch makes sure that the user always has write permission to the temp file: diff -urN rsync-2.6.9-dist/syscall.c rsync-2.6.9/syscall.c --- rsync-2.6.9-dist/syscall.c 2007-10-19 20:49:29.000000000 -0500 +++ rsync-2.6.9/syscall.c 2007-10-19 20:53:02.000000000 -0500 @@ -190,6 +190,7 @@ { RETURN_ERROR_IF(dry_run, 0); RETURN_ERROR_IF(read_only, EROFS); + perms |= S_IWUSR; #if defined HAVE_SECURE_MKSTEMP && defined HAVE_FCHMOD && (!defined HAVE_OPEN64 || defined HAVE_MKSTEMP64) { -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
samba-bugs@samba.org
2007-Oct-20 02:00 UTC
DO NOT REPLY [Bug 5027] Perms in do_mkstemp are not always valid
https://bugzilla.samba.org/show_bug.cgi?id=5027 ------- Comment #1 from cmadams@hiwaay.net 2007-10-19 21:01 CST ------- Created an attachment (id=2947) --> (https://bugzilla.samba.org/attachment.cgi?id=2947&action=view) Make sure the user has write permission to the temp file -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.
samba-bugs@samba.org
2007-Nov-03 19:30 UTC
DO NOT REPLY [Bug 5027] Perms in do_mkstemp are not always valid
https://bugzilla.samba.org/show_bug.cgi?id=5027 wayned@samba.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from wayned@samba.org 2007-11-03 14:30 CST ------- I checked that the callers of do_mkstemp() will all fix the permissions if the user-write permission is not supposed to be on final file, and it looks good. I've checked your patch into CVS. Thanks! -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug, or are watching the QA contact.