aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-05-07 14:34:03 -0700
committerPaul Eggert2013-05-07 14:34:03 -0700
commitffdc270a762ee93261f133632a9f82ea6ace9424 (patch)
treec1eacab0759fb3725a6fc99a089cc8f3f78644ac /src
parentad64371062c05222227d7d573075c81b1f046630 (diff)
downloademacs-ffdc270a762ee93261f133632a9f82ea6ace9424.tar.gz
emacs-ffdc270a762ee93261f133632a9f82ea6ace9424.zip
Use Gnulib ACL implementation, for benefit of Solaris etc.
* configure.ac: Remove -with-acl option, since Gnulib does that for us now. (LIBACL_LIBS): Remove; no longer needed. * lib/Makefile.am (CLEANFILES, SUFFIXES): New (empty) macros, for the benefit of the new ACL implementation. * lib/makefile.w32-in (GNULIBOBJS): Add $(BLD)/acl-errno-valid.$(O). ($(BLD)/acl-errno-valid.$(O)): New rule. * lib/acl-errno-valid.c, lib/acl-internal.h, lib/acl.h: * lib/acl_entries.c, lib/errno.in.h, lib/file-has-acl.c: * lib/qcopy-acl.c, lib/qset-acl.c, m4/acl.m4, m4/errno_h.m4: New files, taken from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * admin/merge-gnulib (GNULIB_MODULES): Add qacl. (GNULIB_TOOL_FLAGS): Do not avoid errno. * etc/NEWS: Emacs is no longer limited to POSIX ACLs. --disable-acl, not --without-acl, since we're now using Gnulib's implementation. * nt/config.nt (HAVE_ACL_SET_FILE): Rename from HAVE_POSIX_ACL. * nt/inc/ms-w32.h (EOPNOTSUPP): New macro. * src/Makefile.in (LIB_ACL): New macro. (LIBACL_LIBS): Remove. (LIBES): Use LIB_ACL, not LIBACL_LIBS. * src/fileio.c: Include <acl.h>. Use HAVE_ACL_SET_FILE rather than HAVE_POSIX_ACL. (ACL_NOT_WELL_SUPPORTED): Remove. All uses replaced by !acl_errno_valid. (Fcopy_file) [!WINDOWSNT]: Use qcopy_acl instead of rolling it ourselves. Fixes: debbugs:14295
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/Makefile.in7
-rw-r--r--src/fileio.c73
3 files changed, 35 insertions, 56 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 55b71844144..1085bc0b870 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,16 @@
12013-05-07 Paul Eggert <eggert@cs.ucla.edu> 12013-05-07 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Use Gnulib ACL implementation, for benefit of Solaris etc. (Bug#14295)
4 * Makefile.in (LIB_ACL): New macro.
5 (LIBACL_LIBS): Remove.
6 (LIBES): Use LIB_ACL, not LIBACL_LIBS.
7 * fileio.c: Include <acl.h>.
8 Use HAVE_ACL_SET_FILE rather than HAVE_POSIX_ACL.
9 (ACL_NOT_WELL_SUPPORTED): Remove. All uses replaced by
10 !acl_errno_valid.
11 (Fcopy_file) [!WINDOWSNT]: Use qcopy_acl instead of rolling
12 it ourselves.
13
3 * unexelf.c: Don't assume ElfW (Half) fits in int. 14 * unexelf.c: Don't assume ElfW (Half) fits in int.
4 (entry_address, find_section, unexec): Use ptrdiff_t, not int, 15 (entry_address, find_section, unexec): Use ptrdiff_t, not int,
5 when dealing with ElfW (Half) values, since they can exceed 2**31 16 when dealing with ElfW (Half) values, since they can exceed 2**31
diff --git a/src/Makefile.in b/src/Makefile.in
index 1222b5a5f98..ad81a8d6592 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -137,6 +137,7 @@ LIBOTF_LIBS = @LIBOTF_LIBS@
137M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@ 137M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@
138M17N_FLT_LIBS = @M17N_FLT_LIBS@ 138M17N_FLT_LIBS = @M17N_FLT_LIBS@
139 139
140LIB_ACL=@LIB_ACL@
140LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@ 141LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@
141LIB_EACCESS=@LIB_EACCESS@ 142LIB_EACCESS=@LIB_EACCESS@
142LIB_FDATASYNC=@LIB_FDATASYNC@ 143LIB_FDATASYNC=@LIB_FDATASYNC@
@@ -288,8 +289,6 @@ LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
288LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ 289LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
289LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ 290LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
290 291
291LIBACL_LIBS = @LIBACL_LIBS@
292
293LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ 292LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
294 293
295INTERVALS_H = dispextern.h intervals.h composite.h 294INTERVALS_H = dispextern.h intervals.h composite.h
@@ -397,13 +396,13 @@ ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj)
397## Construct full set of libraries to be linked. 396## Construct full set of libraries to be linked.
398LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ 397LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
399 $(LIBX_OTHER) $(LIBSOUND) \ 398 $(LIBX_OTHER) $(LIBSOUND) \
400 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \ 399 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \
401 $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ 400 $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
402 $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) \ 401 $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) \
403 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 402 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
404 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 403 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
405 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 404 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
406 $(LIBACL_LIBS) $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \ 405 $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
407 $(LIB_MATH) 406 $(LIB_MATH)
408 407
409all: emacs$(EXEEXT) $(OTHER_FILES) 408all: emacs$(EXEEXT) $(OTHER_FILES)
diff --git a/src/fileio.c b/src/fileio.c
index 4a792d43a97..fe1bce16ca0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -36,7 +36,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#include <selinux/context.h> 36#include <selinux/context.h>
37#endif 37#endif
38 38
39#ifdef HAVE_POSIX_ACL 39#ifdef HAVE_ACL_SET_FILE
40#include <sys/acl.h> 40#include <sys/acl.h>
41#endif 41#endif
42 42
@@ -81,26 +81,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
81#define DRIVE_LETTER(x) c_tolower (x) 81#define DRIVE_LETTER(x) c_tolower (x)
82#endif 82#endif
83 83
84#ifdef HAVE_POSIX_ACL
85/* FIXME: this macro was copied from gnulib's private acl-internal.h
86 header file. */
87/* Recognize some common errors such as from an NFS mount that does
88 not support ACLs, even when local drives do. */
89#if defined __APPLE__ && defined __MACH__ /* Mac OS X */
90#define ACL_NOT_WELL_SUPPORTED(Err) \
91 ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY || (Err) == ENOENT)
92#elif defined EOPNOTSUPP /* Tru64 NFS */
93#define ACL_NOT_WELL_SUPPORTED(Err) \
94 ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY || (Err) == EOPNOTSUPP)
95#elif defined WINDOWSNT
96#define ACL_NOT_WELL_SUPPORTED(Err) ((Err) == ENOTSUP)
97#else
98#define ACL_NOT_WELL_SUPPORTED(Err) \
99 ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY)
100#endif
101#endif /* HAVE_POSIX_ACL */
102
103#include "systime.h" 84#include "systime.h"
85#include <acl.h>
104#include <allocator.h> 86#include <allocator.h>
105#include <careadlinkat.h> 87#include <careadlinkat.h>
106#include <stat-time.h> 88#include <stat-time.h>
@@ -1988,7 +1970,7 @@ entries (depending on how Emacs was built). */)
1988 security_context_t con; 1970 security_context_t con;
1989 int conlength = 0; 1971 int conlength = 0;
1990#endif 1972#endif
1991#ifdef HAVE_POSIX_ACL 1973#ifdef WINDOWSNT
1992 acl_t acl = NULL; 1974 acl_t acl = NULL;
1993#endif 1975#endif
1994 1976
@@ -2028,11 +2010,9 @@ entries (depending on how Emacs was built). */)
2028#ifdef WINDOWSNT 2010#ifdef WINDOWSNT
2029 if (!NILP (preserve_extended_attributes)) 2011 if (!NILP (preserve_extended_attributes))
2030 { 2012 {
2031#ifdef HAVE_POSIX_ACL
2032 acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); 2013 acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS);
2033 if (acl == NULL && !ACL_NOT_WELL_SUPPORTED (errno)) 2014 if (acl == NULL && acl_errno_valid (errno))
2034 report_file_error ("Getting ACL", Fcons (file, Qnil)); 2015 report_file_error ("Getting ACL", Fcons (file, Qnil));
2035#endif
2036 } 2016 }
2037 if (!CopyFile (SDATA (encoded_file), 2017 if (!CopyFile (SDATA (encoded_file),
2038 SDATA (encoded_newname), 2018 SDATA (encoded_newname),
@@ -2069,17 +2049,15 @@ entries (depending on how Emacs was built). */)
2069 /* Restore original attributes. */ 2049 /* Restore original attributes. */
2070 SetFileAttributes (filename, attributes); 2050 SetFileAttributes (filename, attributes);
2071 } 2051 }
2072#ifdef HAVE_POSIX_ACL
2073 if (acl != NULL) 2052 if (acl != NULL)
2074 { 2053 {
2075 bool fail = 2054 bool fail =
2076 acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; 2055 acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0;
2077 if (fail && !ACL_NOT_WELL_SUPPORTED (errno)) 2056 if (fail && acl_errno_valid (errno))
2078 report_file_error ("Setting ACL", Fcons (newname, Qnil)); 2057 report_file_error ("Setting ACL", Fcons (newname, Qnil));
2079 2058
2080 acl_free (acl); 2059 acl_free (acl);
2081 } 2060 }
2082#endif
2083#else /* not WINDOWSNT */ 2061#else /* not WINDOWSNT */
2084 immediate_quit = 1; 2062 immediate_quit = 1;
2085 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); 2063 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
@@ -2103,12 +2081,6 @@ entries (depending on how Emacs was built). */)
2103 report_file_error ("Doing fgetfilecon", Fcons (file, Qnil)); 2081 report_file_error ("Doing fgetfilecon", Fcons (file, Qnil));
2104 } 2082 }
2105#endif 2083#endif
2106
2107#ifdef HAVE_POSIX_ACL
2108 acl = acl_get_fd (ifd);
2109 if (acl == NULL && !ACL_NOT_WELL_SUPPORTED (errno))
2110 report_file_error ("Getting ACL", Fcons (file, Qnil));
2111#endif
2112 } 2084 }
2113 2085
2114 if (out_st.st_mode != 0 2086 if (out_st.st_mode != 0
@@ -2156,7 +2128,7 @@ entries (depending on how Emacs was built). */)
2156 immediate_quit = 0; 2128 immediate_quit = 0;
2157 2129
2158#ifndef MSDOS 2130#ifndef MSDOS
2159 /* Preserve the original file modes, and if requested, also its 2131 /* Preserve the original file permissions, and if requested, also its
2160 owner and group. */ 2132 owner and group. */
2161 { 2133 {
2162 mode_t mode_mask = 07777; 2134 mode_t mode_mask = 07777;
@@ -2173,8 +2145,16 @@ entries (depending on how Emacs was built). */)
2173 mode_mask |= 02000; 2145 mode_mask |= 02000;
2174 } 2146 }
2175 } 2147 }
2176 if (fchmod (ofd, st.st_mode & mode_mask) != 0) 2148
2177 report_file_error ("Doing chmod", Fcons (newname, Qnil)); 2149 switch (!NILP (preserve_extended_attributes)
2150 ? qcopy_acl (SSDATA (encoded_file), ifd,
2151 SSDATA (encoded_newname), ofd,
2152 st.st_mode & mode_mask)
2153 : fchmod (ofd, st.st_mode & mode_mask))
2154 {
2155 case -2: report_file_error ("Copying permissions from", list1 (file));
2156 case -1: report_file_error ("Copying permissions to", list1 (newname));
2157 }
2178 } 2158 }
2179#endif /* not MSDOS */ 2159#endif /* not MSDOS */
2180 2160
@@ -2191,17 +2171,6 @@ entries (depending on how Emacs was built). */)
2191 } 2171 }
2192#endif 2172#endif
2193 2173
2194#ifdef HAVE_POSIX_ACL
2195 if (acl != NULL)
2196 {
2197 bool fail = acl_set_fd (ofd, acl) != 0;
2198 if (fail && !ACL_NOT_WELL_SUPPORTED (errno))
2199 report_file_error ("Setting ACL", Fcons (newname, Qnil));
2200
2201 acl_free (acl);
2202 }
2203#endif
2204
2205 if (!NILP (keep_time)) 2174 if (!NILP (keep_time))
2206 { 2175 {
2207 EMACS_TIME atime = get_stat_atime (&st); 2176 EMACS_TIME atime = get_stat_atime (&st);
@@ -3111,7 +3080,7 @@ was unable to determine the ACL entries. */)
3111{ 3080{
3112 Lisp_Object absname; 3081 Lisp_Object absname;
3113 Lisp_Object handler; 3082 Lisp_Object handler;
3114#ifdef HAVE_POSIX_ACL 3083#ifdef HAVE_ACL_SET_FILE
3115 acl_t acl; 3084 acl_t acl;
3116 Lisp_Object acl_string; 3085 Lisp_Object acl_string;
3117 char *str; 3086 char *str;
@@ -3126,7 +3095,7 @@ was unable to determine the ACL entries. */)
3126 if (!NILP (handler)) 3095 if (!NILP (handler))
3127 return call2 (handler, Qfile_acl, absname); 3096 return call2 (handler, Qfile_acl, absname);
3128 3097
3129#ifdef HAVE_POSIX_ACL 3098#ifdef HAVE_ACL_SET_FILE
3130 absname = ENCODE_FILE (absname); 3099 absname = ENCODE_FILE (absname);
3131 3100
3132 acl = acl_get_file (SSDATA (absname), ACL_TYPE_ACCESS); 3101 acl = acl_get_file (SSDATA (absname), ACL_TYPE_ACCESS);
@@ -3164,7 +3133,7 @@ support. */)
3164{ 3133{
3165 Lisp_Object absname; 3134 Lisp_Object absname;
3166 Lisp_Object handler; 3135 Lisp_Object handler;
3167#ifdef HAVE_POSIX_ACL 3136#ifdef HAVE_ACL_SET_FILE
3168 Lisp_Object encoded_absname; 3137 Lisp_Object encoded_absname;
3169 acl_t acl; 3138 acl_t acl;
3170 bool fail; 3139 bool fail;
@@ -3178,7 +3147,7 @@ support. */)
3178 if (!NILP (handler)) 3147 if (!NILP (handler))
3179 return call3 (handler, Qset_file_acl, absname, acl_string); 3148 return call3 (handler, Qset_file_acl, absname, acl_string);
3180 3149
3181#ifdef HAVE_POSIX_ACL 3150#ifdef HAVE_ACL_SET_FILE
3182 if (STRINGP (acl_string)) 3151 if (STRINGP (acl_string))
3183 { 3152 {
3184 acl = acl_from_text (SSDATA (acl_string)); 3153 acl = acl_from_text (SSDATA (acl_string));
@@ -3193,7 +3162,7 @@ support. */)
3193 fail = (acl_set_file (SSDATA (encoded_absname), ACL_TYPE_ACCESS, 3162 fail = (acl_set_file (SSDATA (encoded_absname), ACL_TYPE_ACCESS,
3194 acl) 3163 acl)
3195 != 0); 3164 != 0);
3196 if (fail && !ACL_NOT_WELL_SUPPORTED (errno)) 3165 if (fail && acl_errno_valid (errno))
3197 report_file_error ("Setting ACL", Fcons (absname, Qnil)); 3166 report_file_error ("Setting ACL", Fcons (absname, Qnil));
3198 3167
3199 acl_free (acl); 3168 acl_free (acl);