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 Message-ID: <3CDDABBE.3020502@ece.gatech.edu> Date: Sat, 11 May 2002 19:39:42 -0400 From: Charles Wilson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 X-Accept-Language: en-us MIME-Version: 1.0 To: Charles Wilson CC: cygwin AT cygwin DOT com Subject: Re: cp.ese bug report -- possible fix? References: <3CD989CB DOT 4060806 AT ece DOT gatech DOT edu> <3CD98CF0 DOT 6050007 AT ece DOT gatech DOT edu> Content-Type: multipart/mixed; boundary="------------060908080501070605000202" --------------060908080501070605000202 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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. (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 --------------060908080501070605000202 Content-Type: text/plain; name="diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff" 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) --------------060908080501070605000202 Content-Type: text/plain; charset=us-ascii -- 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/ --------------060908080501070605000202--