GNU bug report logs -
#10257
23.3.1 Cygwin: network drives - file is write protected (false positive)
Previous Next
Reported by: Jari Aalto <jari.aalto <at> cante.net>
Date: Fri, 9 Dec 2011 18:25:02 UTC
Severity: normal
Found in version 23.3+1-4
Fixed in version 24.0.93
Done: Ken Brown <kbrown <at> cornell.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 12/14/2011 9:43 PM, Ken Brown wrote:
> On 12/14/2011 12:57 PM, Ken Brown wrote:
>> On 12/14/2011 12:30 PM, Eli Zaretskii wrote:
>>> "Such cases" are those where UID and GID are returned as -1 (I think),
>>> see the original report where Jari shows the result of
>>> file-attributes.
>>
>> OK, I could certainly change check_writable to return success if
>> euidaccess returns failure and UID and GID are both -1. I'll make a
>> patch when I get a chance and let Jari test it.
>
> How does the following patch look?
>
> === modified file 'src/fileio.c'
> --- src/fileio.c 2011-12-05 08:55:25 +0000
> +++ src/fileio.c 2011-12-15 02:17:01 +0000
> @@ -2416,15 +2416,27 @@
> return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
> #else /* not MSDOS */
> #ifdef HAVE_EUIDACCESS
> - return (euidaccess (filename, 2) >= 0);
> -#else
> + int res = (euidaccess (filename, 2) >= 0);
> +#ifdef CYGWIN
> + /* euidaccess may have returned failure because Cygwin couldn't
> + determine the file's UID and GID; if so, we return success. */
> + if (!res)
> + {
> + struct stat st;
> + if (stat (filename, &st) < 0)
> + return 0;
> + res = (st.st_uid == -1 && st.st_gid == -1);
> + }
> +#endif /* CYGWIN */
> + return res;
> +#else /* not HAVE_EUIDACCESS */
> /* Access isn't quite right because it uses the real uid
> and we really want to test with the effective uid.
> But Unix doesn't give us a right way to do it.
> Opening with O_WRONLY could work for an ordinary file,
> but would lose for directories. */
> return (access (filename, 2) >= 0);
> -#endif
> +#endif /* not HAVE_EUIDACCESS */
> #endif /* not MSDOS */
> }
Sorry, this isn't quite right. I think it's too lenient. As long as
I've called stat, I should at least check that stat shows the file to be
writable, as in the MSDOS port.
I'll send a revised patch.
Ken
This bug report was last modified 13 years and 222 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.