diff options
| author | Ken Brown | 2011-12-17 12:00:49 -0500 |
|---|---|---|
| committer | Ken Brown | 2011-12-17 12:00:49 -0500 |
| commit | e1b01a3a530809a1e84ecddff31faf85b94e79e7 (patch) | |
| tree | 117972154609c49f6e99505423ed82f3cddfae45 /src | |
| parent | e1fefc61a4b0c59007b9375b62e889dd1e70bfdc (diff) | |
| download | emacs-e1b01a3a530809a1e84ecddff31faf85b94e79e7.tar.gz emacs-e1b01a3a530809a1e84ecddff31faf85b94e79e7.zip | |
* src/fileio.c (check_writable) [CYGWIN]: Return non-zero if UID or
GID is unknown (Bug#10257).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/fileio.c | 18 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 98e87ef4306..e25f0c68ce0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-12-17 Ken Brown <kbrown@cornell.edu> | ||
| 2 | |||
| 3 | * fileio.c (check_writable) [CYGWIN]: Return non-zero if UID or | ||
| 4 | GID is unknown (Bug#10257). | ||
| 5 | |||
| 1 | 2011-12-17 Paul Eggert <eggert@cs.ucla.edu> | 6 | 2011-12-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 7 | ||
| 3 | * s/gnu-linux.h: Fix mark_memory typo (Bug#10286). | 8 | * s/gnu-linux.h: Fix mark_memory typo (Bug#10286). |
diff --git a/src/fileio.c b/src/fileio.c index fb021cee5a4..3306085491e 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2416,15 +2416,27 @@ check_writable (const char *filename) | |||
| 2416 | return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); | 2416 | return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); |
| 2417 | #else /* not MSDOS */ | 2417 | #else /* not MSDOS */ |
| 2418 | #ifdef HAVE_EUIDACCESS | 2418 | #ifdef HAVE_EUIDACCESS |
| 2419 | return (euidaccess (filename, 2) >= 0); | 2419 | int res = (euidaccess (filename, 2) >= 0); |
| 2420 | #else | 2420 | #ifdef CYGWIN |
| 2421 | /* euidaccess may have returned failure because Cygwin couldn't | ||
| 2422 | determine the file's UID or GID; if so, we return success. */ | ||
| 2423 | if (!res) | ||
| 2424 | { | ||
| 2425 | struct stat st; | ||
| 2426 | if (stat (filename, &st) < 0) | ||
| 2427 | return 0; | ||
| 2428 | res = (st.st_uid == -1 || st.st_gid == -1); | ||
| 2429 | } | ||
| 2430 | #endif /* CYGWIN */ | ||
| 2431 | return res; | ||
| 2432 | #else /* not HAVE_EUIDACCESS */ | ||
| 2421 | /* Access isn't quite right because it uses the real uid | 2433 | /* Access isn't quite right because it uses the real uid |
| 2422 | and we really want to test with the effective uid. | 2434 | and we really want to test with the effective uid. |
| 2423 | But Unix doesn't give us a right way to do it. | 2435 | But Unix doesn't give us a right way to do it. |
| 2424 | Opening with O_WRONLY could work for an ordinary file, | 2436 | Opening with O_WRONLY could work for an ordinary file, |
| 2425 | but would lose for directories. */ | 2437 | but would lose for directories. */ |
| 2426 | return (access (filename, 2) >= 0); | 2438 | return (access (filename, 2) >= 0); |
| 2427 | #endif | 2439 | #endif /* not HAVE_EUIDACCESS */ |
| 2428 | #endif /* not MSDOS */ | 2440 | #endif /* not MSDOS */ |
| 2429 | } | 2441 | } |
| 2430 | 2442 | ||