aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2012-12-14 10:59:00 -0800
committerPaul Eggert2012-12-14 10:59:00 -0800
commit97976f9f3fcf588535bf4afad71de92860bb2f8e (patch)
tree48af44cc93624fd119f59ceb94fbb5c5f3eaaf7c
parentad966fe7542070b5c9aa34ed019d586e7c3adae6 (diff)
downloademacs-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
-rw-r--r--ChangeLog5
-rw-r--r--admin/CPP-DEFINES1
-rw-r--r--admin/ChangeLog5
-rw-r--r--configure.ac4
-rw-r--r--doc/lispintro/ChangeLog7
-rw-r--r--doc/lispintro/emacs-lisp-intro.texi2
-rw-r--r--doc/lispref/ChangeLog10
-rw-r--r--doc/lispref/files.texi14
-rw-r--r--doc/lispref/os.texi10
-rw-r--r--etc/ChangeLog7
-rw-r--r--etc/NEWS11
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/files.el46
-rw-r--r--lisp/net/tramp-sh.el11
-rw-r--r--src/ChangeLog9
-rw-r--r--src/dired.c18
-rw-r--r--src/editfns.c20
17 files changed, 153 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 498bc328714..f60ac180f6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * configure.ac (BSD4_2): Remove; no longer needed.
5
12012-12-13 Glenn Morris <rgm@gnu.org> 62012-12-13 Glenn Morris <rgm@gnu.org>
2 7
3 * info/dir: Add bovine, srecode, wisent. 8 * info/dir: Add bovine, srecode, wisent.
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index 13c3da1745a..393cf56e993 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -9,7 +9,6 @@ documented in config.in, and this file would not be necessary.
9 9
10AIX 10AIX
11_AIX 11_AIX
12BSD4_2
13BSD_SYSTEM 12BSD_SYSTEM
14CYGWIN Compiling the Cygwin port. 13CYGWIN Compiling the Cygwin port.
15__CYGWIN__ Ditto 14__CYGWIN__ Ditto
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 9c6413aa14f..6a6b1bd8da6 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,8 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * CPP-DEFINES (BSD4_2): Remove.
5
12012-12-08 Paul Eggert <eggert@cs.ucla.edu> 62012-12-08 Paul Eggert <eggert@cs.ucla.edu>
2 7
3 Use putenv+unsetenv instead of modifying environ directly (Bug#13070). 8 Use putenv+unsetenv instead of modifying environ directly (Bug#13070).
diff --git a/configure.ac b/configure.ac
index f721c02f71f..1a7f78326eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3841,7 +3841,6 @@ esac
3841 3841
3842dnl Define symbols to identify the version of Unix this is. 3842dnl Define symbols to identify the version of Unix this is.
3843dnl Define all the symbols that apply correctly. 3843dnl Define all the symbols that apply correctly.
3844AH_TEMPLATE(BSD4_2, [Define if the system is compatible with BSD 4.2.])
3845AH_TEMPLATE(BSD_SYSTEM, [Define if the system is compatible with BSD 4.2.]) 3844AH_TEMPLATE(BSD_SYSTEM, [Define if the system is compatible with BSD 4.2.])
3846AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.]) 3845AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
3847AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.]) 3846AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
@@ -3867,7 +3866,6 @@ case $opsys in
3867 3866
3868 darwin) 3867 darwin)
3869 dnl BSD4_3 and BSD4_4 are already defined in sys/param.h. 3868 dnl BSD4_3 and BSD4_4 are already defined in sys/param.h.
3870 AC_DEFINE(BSD4_2, [])
3871 AC_DEFINE(BSD_SYSTEM, []) 3869 AC_DEFINE(BSD_SYSTEM, [])
3872 dnl More specific than the above two. We cannot use __APPLE__ as this 3870 dnl More specific than the above two. We cannot use __APPLE__ as this
3873 dnl may not be defined on non-OSX Darwin, and we cannot define DARWIN 3871 dnl may not be defined on non-OSX Darwin, and we cannot define DARWIN
@@ -3877,7 +3875,6 @@ case $opsys in
3877 ;; 3875 ;;
3878 3876
3879 freebsd) 3877 freebsd)
3880 AC_DEFINE(BSD4_2, [])
3881 dnl Hack to avoid calling AC_PREPROC_IFELSE multiple times. 3878 dnl Hack to avoid calling AC_PREPROC_IFELSE multiple times.
3882 dnl Would not be needed with autoconf >= 2.67, where the 3879 dnl Would not be needed with autoconf >= 2.67, where the
3883 dnl preprocessed output is accessible in "conftest.i". 3880 dnl preprocessed output is accessible in "conftest.i".
@@ -3885,7 +3882,6 @@ case $opsys in
3885 ;; 3882 ;;
3886 3883
3887 gnu | netbsd | openbsd ) 3884 gnu | netbsd | openbsd )
3888 AC_DEFINE(BSD4_2, [])
3889 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ 3885 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
3890#ifndef BSD_SYSTEM 3886#ifndef BSD_SYSTEM
3891# error "BSD_SYSTEM not defined" 3887# error "BSD_SYSTEM not defined"
diff --git a/doc/lispintro/ChangeLog b/doc/lispintro/ChangeLog
index 51c6a53fcd8..8e7278ee2ee 100644
--- a/doc/lispintro/ChangeLog
+++ b/doc/lispintro/ChangeLog
@@ -1,3 +1,10 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * emacs-lisp-intro.texi (Files List):
5 directory-files-and-attributes now outputs t for attribute that's
6 now a placeholder.
7
12012-12-06 Paul Eggert <eggert@cs.ucla.edu> 82012-12-06 Paul Eggert <eggert@cs.ucla.edu>
2 9
3 * doclicense.texi: Update to latest version from FSF. 10 * doclicense.texi: Update to latest version from FSF.
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi
index 34ef7cc093c..5111ee116a3 100644
--- a/doc/lispintro/emacs-lisp-intro.texi
+++ b/doc/lispintro/emacs-lisp-intro.texi
@@ -15687,7 +15687,7 @@ nil
15687"-rw-r--r--" 15687"-rw-r--r--"
15688@end group 15688@end group
15689@group 15689@group
15690nil 15690t
156912971624 156912971624
15692773) 15692773)
15693@end group 15693@end group
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index b0727694b3d..8a99f8c9c40 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,13 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * files.texi (Testing Accessibility): Document GROUP arg
5 of file-ownership-preserved-p.
6 (File Attributes): Document that 9th element is now
7 just a placeholder.
8 * os.texi (User Identification): Document new functions group-gid,
9 group-real-gid.
10
12012-12-11 Paul Eggert <eggert@cs.ucla.edu> 112012-12-11 Paul Eggert <eggert@cs.ucla.edu>
2 12
3 * internals.texi (C Integer Types): New section. 13 * internals.texi (C Integer Types): New section.
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 863acbe3949..c0c2221a394 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -895,11 +895,14 @@ returns @code{nil}. However, if the open fails, it signals an error
895using @var{string} as the error message text. 895using @var{string} as the error message text.
896@end defun 896@end defun
897 897
898@defun file-ownership-preserved-p filename 898@defun file-ownership-preserved-p filename &optional group
899This function returns @code{t} if deleting the file @var{filename} and 899This function returns @code{t} if deleting the file @var{filename} and
900then creating it anew would keep the file's owner unchanged. It also 900then creating it anew would keep the file's owner unchanged. It also
901returns @code{t} for nonexistent files. 901returns @code{t} for nonexistent files.
902 902
903If the optional argument @var{group} is non-@code{nil}, this function
904also checks that the file's group would be unchanged.
905
903If @var{filename} is a symbolic link, then, unlike the other functions 906If @var{filename} is a symbolic link, then, unlike the other functions
904discussed here, @code{file-ownership-preserved-p} does @emph{not} 907discussed here, @code{file-ownership-preserved-p} does @emph{not}
905replace @var{filename} with its target. However, it does recursively 908replace @var{filename} with its target. However, it does recursively
@@ -1246,8 +1249,7 @@ The file's modes, as a string of ten letters or dashes,
1246as in @samp{ls -l}. 1249as in @samp{ls -l}.
1247 1250
1248@item 1251@item
1249@code{t} if the file's @acronym{GID} would change if file were 1252An unspecified value, present for backward compatibility.
1250deleted and recreated; @code{nil} otherwise.
1251 1253
1252@item 1254@item
1253The file's inode number. If possible, this is an integer. If the 1255The file's inode number. If possible, this is an integer. If the
@@ -1279,7 +1281,7 @@ For example, here are the file attributes for @file{files.texi}:
1279 (20000 23 0 0) 1281 (20000 23 0 0)
1280 (20614 64555 902289 872000) 1282 (20614 64555 902289 872000)
1281 122295 "-rw-rw-rw-" 1283 122295 "-rw-rw-rw-"
1282 nil (5888 2 . 43978) 1284 t (5888 2 . 43978)
1283 (15479 . 46724)) 1285 (15479 . 46724))
1284@end group 1286@end group
1285@end example 1287@end example
@@ -1318,8 +1320,8 @@ end-of-line format is CR-LF.)
1318@item "-rw-rw-rw-" 1320@item "-rw-rw-rw-"
1319has a mode of read and write access for the owner, group, and world. 1321has a mode of read and write access for the owner, group, and world.
1320 1322
1321@item nil 1323@item t
1322would retain the same @acronym{GID} if it were recreated. 1324is merely a placeholder; it carries no information.
1323 1325
1324@item (5888 2 . 43978) 1326@item (5888 2 . 43978)
1325has an inode number of 6473924464520138. 1327has an inode number of 6473924464520138.
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index e2161f51489..4b9cdfaae9e 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1157,6 +1157,16 @@ This function returns the effective @acronym{UID} of the user.
1157The value may be a floating point number. 1157The value may be a floating point number.
1158@end defun 1158@end defun
1159 1159
1160@defun group-gid
1161This function returns the effective @acronym{GID} of the Emacs process.
1162The value may be a floating point number.
1163@end defun
1164
1165@defun group-real-gid
1166This function returns the real @acronym{GID} of the Emacs process.
1167The value may be a floating point number.
1168@end defun
1169
1160@defun system-users 1170@defun system-users
1161This function returns a list of strings, listing the user names on the 1171This function returns a list of strings, listing the user names on the
1162system. If Emacs cannot retrieve this information, the return value 1172system. If Emacs cannot retrieve this information, the return value
diff --git a/etc/ChangeLog b/etc/ChangeLog
index ad0f9e9c7e8..7d58a670f80 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,10 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * NEWS: Document changes to file-attributes,
5 file-ownership-preserved-p.
6 Mention new functions group-gid, group-real-gid.
7
12012-12-06 Andreas Schwab <schwab@linux-m68k.org> 82012-12-06 Andreas Schwab <schwab@linux-m68k.org>
2 9
3 * themes/leuven-theme.el: Convert to Unix format. 10 * themes/leuven-theme.el: Convert to Unix format.
diff --git a/etc/NEWS b/etc/NEWS
index 9f61cff7342..d2a85507034 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -166,6 +166,17 @@ text-property on the first char.
166** The `defalias-fset-function' property lets you catch calls to defalias 166** The `defalias-fset-function' property lets you catch calls to defalias
167and redirect them to your own function instead of `fset'. 167and redirect them to your own function instead of `fset'.
168 168
169** The 9th element returned by `file-attributes' is now unspecified.
170Formerly, it was t if the file's gid would change if file were deleted
171and recreated. This value has been inaccurate for years on many
172platforms, and nobody seems to have noticed or cared.
173
174** The function `file-ownership-preserved-p' now has an optional
175argument GROUP which causes it check for file group too. This can be
176used in place of the 9th element of `file-attributes'.
177
178** New functions `group-gid' and `group-real-gid'.
179
169* Changes in Emacs 24.4 on non-free operating systems 180* Changes in Emacs 24.4 on non-free operating systems
170 181
171+++ 182+++
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 75387673f76..15cdb5cb879 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,19 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * files.el (backup-buffer): Don't rely on 9th output of
5 file-attributes, as it's now a placeholder. Instead, use the new
6 optional arg of file-ownership-preserved-p.
7 (file-ownership-preserved-p): New optional arg GROUP.
8 Fix mishandling of setuid directories that would cause this
9 function to return t when it should have returned nil.
10 Document what happens if the file does not exist, and when
11 it's not known whether the ownership will be preserved.
12 * net/tramp-sh.el (tramp-sh-handle-file-ownership-preserved-p):
13 Likewise.
14 (tramp-get-local-gid): Use group-gid for integer, as that's
15 faster and more reliable.
16
12012-12-14 Julien Danjou <julien@danjou.info> 172012-12-14 Julien Danjou <julien@danjou.info>
2 18
3 * progmodes/sql.el (sql-mode-postgres-font-lock-keywords): Update 19 * progmodes/sql.el (sql-mode-postgres-font-lock-keywords): Update
diff --git a/lisp/files.el b/lisp/files.el
index c8a75f67820..7974f73a248 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3941,8 +3941,8 @@ BACKUPNAME is the backup file name, which is the old file renamed."
3941 (and (integerp (nth 2 attr)) 3941 (and (integerp (nth 2 attr))
3942 (integerp backup-by-copying-when-privileged-mismatch) 3942 (integerp backup-by-copying-when-privileged-mismatch)
3943 (<= (nth 2 attr) backup-by-copying-when-privileged-mismatch))) 3943 (<= (nth 2 attr) backup-by-copying-when-privileged-mismatch)))
3944 (or (nth 9 attr) 3944 (not (file-ownership-preserved-p
3945 (not (file-ownership-preserved-p real-file-name))))))) 3945 real-file-name t))))))
3946 (backup-buffer-copy real-file-name backupname modes context) 3946 (backup-buffer-copy real-file-name backupname modes context)
3947 ;; rename-file should delete old backup. 3947 ;; rename-file should delete old backup.
3948 (rename-file real-file-name backupname t) 3948 (rename-file real-file-name backupname t)
@@ -4019,22 +4019,44 @@ See also `file-name-version-regexp'."
4019 (string-match (concat file-name-version-regexp "\\'") 4019 (string-match (concat file-name-version-regexp "\\'")
4020 name)))))) 4020 name))))))
4021 4021
4022(defun file-ownership-preserved-p (file) 4022(defun file-ownership-preserved-p (file &optional group)
4023 "Return t if deleting FILE and rewriting it would preserve the owner." 4023 "Return t if deleting FILE and rewriting it would preserve the owner.
4024Return nil if FILE does not exist, or if deleting and recreating it
4025might not preserve the owner. If GROUP is non-nil, check whether
4026the group would be preserved too."
4024 (let ((handler (find-file-name-handler file 'file-ownership-preserved-p))) 4027 (let ((handler (find-file-name-handler file 'file-ownership-preserved-p)))
4025 (if handler 4028 (if handler
4026 (funcall handler 'file-ownership-preserved-p file) 4029 (funcall handler 'file-ownership-preserved-p file group)
4027 (let ((attributes (file-attributes file 'integer))) 4030 (let ((attributes (file-attributes file 'integer)))
4028 ;; Return t if the file doesn't exist, since it's true that no 4031 ;; Return t if the file doesn't exist, since it's true that no
4029 ;; information would be lost by an (attempted) delete and create. 4032 ;; information would be lost by an (attempted) delete and create.
4030 (or (null attributes) 4033 (or (null attributes)
4031 (= (nth 2 attributes) (user-uid)) 4034 (and (or (= (nth 2 attributes) (user-uid))
4032 ;; Files created on Windows by Administrator (RID=500) 4035 ;; Files created on Windows by Administrator (RID=500)
4033 ;; have the Administrators group (RID=544) recorded as 4036 ;; have the Administrators group (RID=544) recorded as
4034 ;; their owner. Rewriting them will still preserve the 4037 ;; their owner. Rewriting them will still preserve the
4035 ;; owner. 4038 ;; owner.
4036 (and (eq system-type 'windows-nt) 4039 (and (eq system-type 'windows-nt)
4037 (= (user-uid) 500) (= (nth 2 attributes) 544))))))) 4040 (= (user-uid) 500) (= (nth 2 attributes) 544)))
4041 (or (not group)
4042 ;; On BSD-derived systems files always inherit the parent
4043 ;; directory's group, so skip the group-gid test.
4044 (memq system-type '(berkeley-unix darwin gnu/kfreebsd))
4045 (= (nth 3 attributes) (group-gid)))
4046 (let* ((parent (or (file-name-directory file) "."))
4047 (parent-attributes (file-attributes parent 'integer)))
4048 (and parent-attributes
4049 ;; On some systems, a file created in a setuid directory
4050 ;; inherits that directory's owner.
4051 (or
4052 (= (nth 2 parent-attributes) (user-uid))
4053 (string-match "^...[^sS]" (nth 8 parent-attributes)))
4054 ;; On many systems, a file created in a setgid directory
4055 ;; inherits that directory's group. On some systems
4056 ;; this happens even if the setgid bit is not set.
4057 (or (not group)
4058 (= (nth 3 parent-attributes)
4059 (nth 3 attributes)))))))))))
4038 4060
4039(defun file-name-sans-extension (filename) 4061(defun file-name-sans-extension (filename)
4040 "Return FILENAME sans final \"extension\". 4062 "Return FILENAME sans final \"extension\".
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 55af0f0d96b..3008601d9ca 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1616,7 +1616,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1616 (and (tramp-run-test "-d" (file-name-directory filename)) 1616 (and (tramp-run-test "-d" (file-name-directory filename))
1617 (tramp-run-test "-w" (file-name-directory filename))))))) 1617 (tramp-run-test "-w" (file-name-directory filename)))))))
1618 1618
1619(defun tramp-sh-handle-file-ownership-preserved-p (filename) 1619(defun tramp-sh-handle-file-ownership-preserved-p (filename &optional group)
1620 "Like `file-ownership-preserved-p' for Tramp files." 1620 "Like `file-ownership-preserved-p' for Tramp files."
1621 (with-parsed-tramp-file-name filename nil 1621 (with-parsed-tramp-file-name filename nil
1622 (with-tramp-file-property v localname "file-ownership-preserved-p" 1622 (with-tramp-file-property v localname "file-ownership-preserved-p"
@@ -1624,7 +1624,10 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1624 ;; Return t if the file doesn't exist, since it's true that no 1624 ;; Return t if the file doesn't exist, since it's true that no
1625 ;; information would be lost by an (attempted) delete and create. 1625 ;; information would be lost by an (attempted) delete and create.
1626 (or (null attributes) 1626 (or (null attributes)
1627 (= (nth 2 attributes) (tramp-get-remote-uid v 'integer))))))) 1627 (and
1628 (= (nth 2 attributes) (tramp-get-remote-uid v 'integer))
1629 (or (not group)
1630 (= (nth 3 attributes) (tramp-get-remote-gid v 'integer)))))))))
1628 1631
1629;; Directory listings. 1632;; Directory listings.
1630 1633
@@ -5021,7 +5024,9 @@ This is used internally by `tramp-file-mode-from-int'."
5021 (if (equal id-format 'integer) (user-uid) (user-login-name))) 5024 (if (equal id-format 'integer) (user-uid) (user-login-name)))
5022 5025
5023(defun tramp-get-local-gid (id-format) 5026(defun tramp-get-local-gid (id-format)
5024 (nth 3 (tramp-compat-file-attributes "~/" id-format))) 5027 (if (and (fboundp 'group-gid) (equal id-format 'integer))
5028 (tramp-compat-funcall 'group-gid)
5029 (nth 3 (tramp-compat-file-attributes "~/" id-format))))
5025 5030
5026;; Some predefined connection properties. 5031;; Some predefined connection properties.
5027(defun tramp-get-inline-compress (vec prop size) 5032(defun tramp-get-inline-compress (vec prop size)
diff --git a/src/ChangeLog b/src/ChangeLog
index a35c51b8555..ff80763f351 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12012-12-14 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix permissions bugs with setgid directories etc. (Bug#13125)
4 * dired.c (Ffile_attributes): Return t as the 9th attribute,
5 to mark it as a placeholder. The old value was often wrong.
6 The only user of this attribute has been changed to use
7 file-ownership-preserved-p instead, with its new group arg.
8 * editfns.c (Fgroup_gid, Fgroup_real_gid): New functions.
9
12012-12-14 Stefan Monnier <monnier@iro.umontreal.ca> 102012-12-14 Stefan Monnier <monnier@iro.umontreal.ca>
2 11
3 * xdisp.c (select_frame_for_redisplay, display_mode_lines): 12 * xdisp.c (select_frame_for_redisplay, display_mode_lines):
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.
87310. inode number. If it is larger than what an Emacs integer can hold, 87310. 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
diff --git a/src/editfns.c b/src/editfns.c
index eb909f73697..108c8b27187 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1272,6 +1272,24 @@ Value is an integer or a float, depending on the value. */)
1272 return make_fixnum_or_float (uid); 1272 return make_fixnum_or_float (uid);
1273} 1273}
1274 1274
1275DEFUN ("group-gid", Fgroup_gid, Sgroup_gid, 0, 0, 0,
1276 doc: /* Return the effective gid of Emacs.
1277Value is an integer or a float, depending on the value. */)
1278 (void)
1279{
1280 gid_t egid = getegid ();
1281 return make_fixnum_or_float (egid);
1282}
1283
1284DEFUN ("group-real-gid", Fgroup_real_gid, Sgroup_real_gid, 0, 0, 0,
1285 doc: /* Return the real gid of Emacs.
1286Value is an integer or a float, depending on the value. */)
1287 (void)
1288{
1289 gid_t gid = getgid ();
1290 return make_fixnum_or_float (gid);
1291}
1292
1275DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0, 1293DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0,
1276 doc: /* Return the full name of the user logged in, as a string. 1294 doc: /* Return the full name of the user logged in, as a string.
1277If the full name corresponding to Emacs's userid is not known, 1295If the full name corresponding to Emacs's userid is not known,
@@ -4899,6 +4917,8 @@ functions if all the text being accessed has this property. */);
4899 defsubr (&Suser_real_login_name); 4917 defsubr (&Suser_real_login_name);
4900 defsubr (&Suser_uid); 4918 defsubr (&Suser_uid);
4901 defsubr (&Suser_real_uid); 4919 defsubr (&Suser_real_uid);
4920 defsubr (&Sgroup_gid);
4921 defsubr (&Sgroup_real_gid);
4902 defsubr (&Suser_full_name); 4922 defsubr (&Suser_full_name);
4903 defsubr (&Semacs_pid); 4923 defsubr (&Semacs_pid);
4904 defsubr (&Scurrent_time); 4924 defsubr (&Scurrent_time);