Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Sat, 11 May 2002 21:10:00 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: cp.ese bug report -- possible fix? Message-ID: <20020512011000.GB29021@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <3CD989CB DOT 4060806 AT ece DOT gatech DOT edu> <3CD98CF0 DOT 6050007 AT ece DOT gatech DOT edu> <3CDDABBE DOT 3020502 AT ece DOT gatech DOT edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3CDDABBE.3020502@ece.gatech.edu> User-Agent: Mutt/1.3.23.1i On Sat, May 11, 2002 at 07:39:42PM -0400, Charles Wilson wrote: >Well, I've attached a patch for this bug. However, it uncovered another >problem with 'cp -p src dest', when src is not owned by the current user. If the system UID is 18 then maybe cygwin should be translating that to 0. Especially if 0 has no meaning to windows. cgf >(AROUND LINE 1170 in fileutils/src/copy.c): > > /* Permissions of newly-created regular files were set upon `open' in > copy_reg. But don't return early if there were any special bits and > we had to run chown, because the chown must have reset those bits. */ > if ((new_dst && copied_as_regular) > && !(ran_chown && (src_mode & ~S_IRWXUGO))) > return delayed_fail; > > if ((x->preserve_chmod_bits || new_dst) > && (x->copy_as_regular || S_ISREG (src_type) || S_ISDIR (src_type))) > { > if (chmod (dst_path, get_dest_mode (x, src_mode))) <<<<< HERE > { >#ifdef __CYGWIN__ > char *p; > >The chmod command returns with ENOENT. I have no idea why; the file has >already been created at this point... > >--Chuck >diff -ur fileutils-4.1-1/src/copy.c fileutils-4.1-1a/src/copy.c >--- fileutils-4.1-1/src/copy.c Fri Jun 15 15:20:08 2001 >+++ fileutils-4.1-1a/src/copy.c Sat May 11 17:50:11 2002 >@@ -37,12 +37,22 @@ > #include "quote.h" > #include "same.h" > >+#if defined(__CYGWIN__) >+#define DO_CHOWN(Chown, File, New_uid, New_gid) \ >+ (Chown (File, New_uid, New_gid) \ >+ /* On cygwin, SYSTEM has uid = 18 and we treat that as \ >+ root. Also, cygwin returns EACCES when non-"root" \ >+ attempts to chown ... */ \ >+ && ((errno != EPERM && errno != EINVAL && errno != EACCES) || \ >+ x->myeuid == 18)) >+#else > #define DO_CHOWN(Chown, File, New_uid, New_gid) \ > (Chown (File, New_uid, New_gid) \ > /* If non-root uses -p, it's ok if we can't preserve ownership. \ > But root probably wants to know, e.g. if NFS disallows it, \ > or if the target system doesn't support file ownership. */ \ > && ((errno != EPERM && errno != EINVAL) || x->myeuid == 0)) >+#endif > > #define SAME_OWNER(A, B) ((A).st_uid == (B).st_uid) > #define SAME_GROUP(A, B) ((A).st_gid == (B).st_gid) > >-- >Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >Bug reporting: http://cygwin.com/bugs.html >Documentation: http://cygwin.com/docs.html >FAQ: http://cygwin.com/faq/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/