diff options
| author | Paul Eggert | 2012-12-14 10:59:00 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-12-14 10:59:00 -0800 |
| commit | 97976f9f3fcf588535bf4afad71de92860bb2f8e (patch) | |
| tree | 48af44cc93624fd119f59ceb94fbb5c5f3eaaf7c /src/dired.c | |
| parent | ad966fe7542070b5c9aa34ed019d586e7c3adae6 (diff) | |
| download | emacs-97976f9f3fcf588535bf4afad71de92860bb2f8e.tar.gz emacs-97976f9f3fcf588535bf4afad71de92860bb2f8e.zip | |
Fix permissions bugs with setgid directories etc.
* configure.ac (BSD4_2): Remove; no longer needed.
* admin/CPP-DEFINES (BSD4_2): Remove.
* doc/lispintro/emacs-lisp-intro.texi (Files List):
directory-files-and-attributes now outputs t for attribute that's
now a placeholder.
* doc/lispref/files.texi (Testing Accessibility): Document GROUP arg
of file-ownership-preserved-p.
(File Attributes): Document that 9th element is now
just a placeholder.
* doc/lispref/os.texi (User Identification): Document new functions group-gid,
group-real-gid.
* etc/NEWS: Document changes to file-attributes,
file-ownership-preserved-p.
Mention new functions group-gid, group-real-gid.
* lisp/files.el (backup-buffer): Don't rely on 9th output of
file-attributes, as it's now a placeholder. Instead, use the new
optional arg of file-ownership-preserved-p.
(file-ownership-preserved-p): New optional arg GROUP.
Fix mishandling of setuid directories that would cause this
function to return t when it should have returned nil.
Document what happens if the file does not exist, and when
it's not known whether the ownership will be preserved.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-ownership-preserved-p):
Likewise.
(tramp-get-local-gid): Use group-gid for integer, as that's
faster and more reliable.
* src/dired.c (Ffile_attributes): Return t as the 9th attribute,
to mark it as a placeholder. The old value was often wrong.
The only user of this attribute has been changed to use
file-ownership-preserved-p instead, with its new group arg.
* src/editfns.c (Fgroup_gid, Fgroup_real_gid): New functions.
Fixes: debbugs:13125
Diffstat (limited to 'src/dired.c')
| -rw-r--r-- | src/dired.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/dired.c b/src/dired.c index 85af906c1da..1fda9e8b371 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -869,7 +869,7 @@ Elements of the attribute list are: | |||
| 869 | 7. Size in bytes. | 869 | 7. Size in bytes. |
| 870 | This is a floating point number if the size is too large for an integer. | 870 | This is a floating point number if the size is too large for an integer. |
| 871 | 8. File modes, as a string of ten letters or dashes as in ls -l. | 871 | 8. File modes, as a string of ten letters or dashes as in ls -l. |
| 872 | 9. t if file's gid would change if file were deleted and recreated. | 872 | 9. An unspecified value, present only for backward compatibility. |
| 873 | 10. inode number. If it is larger than what an Emacs integer can hold, | 873 | 10. inode number. If it is larger than what an Emacs integer can hold, |
| 874 | this is of the form (HIGH . LOW): first the high bits, then the low 16 bits. | 874 | this is of the form (HIGH . LOW): first the high bits, then the low 16 bits. |
| 875 | If even HIGH is too large for an Emacs integer, this is instead of the form | 875 | If even HIGH is too large for an Emacs integer, this is instead of the form |
| @@ -891,10 +891,6 @@ so last access time will always be midnight of that day. */) | |||
| 891 | Lisp_Object values[12]; | 891 | Lisp_Object values[12]; |
| 892 | Lisp_Object encoded; | 892 | Lisp_Object encoded; |
| 893 | struct stat s; | 893 | struct stat s; |
| 894 | #ifdef BSD4_2 | ||
| 895 | Lisp_Object dirname; | ||
| 896 | struct stat sdir; | ||
| 897 | #endif /* BSD4_2 */ | ||
| 898 | int lstat_result; | 894 | int lstat_result; |
| 899 | 895 | ||
| 900 | /* An array to hold the mode string generated by filemodestring, | 896 | /* An array to hold the mode string generated by filemodestring, |
| @@ -974,17 +970,7 @@ so last access time will always be midnight of that day. */) | |||
| 974 | 970 | ||
| 975 | filemodestring (&s, modes); | 971 | filemodestring (&s, modes); |
| 976 | values[8] = make_string (modes, 10); | 972 | values[8] = make_string (modes, 10); |
| 977 | #ifdef BSD4_2 /* file gid will be dir gid */ | 973 | values[9] = Qt; |
| 978 | dirname = Ffile_name_directory (filename); | ||
| 979 | if (! NILP (dirname)) | ||
| 980 | encoded = ENCODE_FILE (dirname); | ||
| 981 | if (! NILP (dirname) && stat (SDATA (encoded), &sdir) == 0) | ||
| 982 | values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; | ||
| 983 | else /* if we can't tell, assume worst */ | ||
| 984 | values[9] = Qt; | ||
| 985 | #else /* file gid will be egid */ | ||
| 986 | values[9] = (s.st_gid != getegid ()) ? Qt : Qnil; | ||
| 987 | #endif /* not BSD4_2 */ | ||
| 988 | values[10] = INTEGER_TO_CONS (s.st_ino); | 974 | values[10] = INTEGER_TO_CONS (s.st_ino); |
| 989 | values[11] = INTEGER_TO_CONS (s.st_dev); | 975 | values[11] = INTEGER_TO_CONS (s.st_dev); |
| 990 | 976 | ||