Now on revision 111263. ------------------------------------------------------------ revno: 111263 committer: Juanma Barranquero branch nick: trunk timestamp: Mon 2012-12-17 21:59:04 +0100 message: src/makefile.w32-in: Update depencencies. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-17 19:17:06 +0000 +++ src/ChangeLog 2012-12-17 20:59:04 +0000 @@ -1,3 +1,8 @@ +2012-12-17 Juanma Barranquero + + * makefile.w32-in ($(BLD)/editfns.$(O), $(BLD)/fileio.$(O)) + ($(BLD)/w32.$(O)): Update dependencies. + 2012-12-17 Stefan Monnier * xdisp.c (select_frame_for_redisplay): Use select_window_1 to === modified file 'src/makefile.w32-in' --- src/makefile.w32-in 2012-12-14 19:43:12 +0000 +++ src/makefile.w32-in 2012-12-17 20:59:04 +0000 @@ -781,7 +781,6 @@ $(SRC)/editfns.c \ $(SRC)/blockinput.h \ $(NT_INC)/pwd.h \ - $(NT_INC)/grp.h \ $(NT_INC)/unistd.h \ $(GNU_LIB)/intprops.h \ $(GNU_LIB)/strftime.h \ @@ -791,6 +790,7 @@ $(CODING_H) \ $(CONFIG_H) \ $(FRAME_H) \ + $(GRP_H) \ $(INTERVALS_H) \ $(LISP_H) \ $(SYSTIME_H) \ @@ -843,6 +843,7 @@ $(SRC)/commands.h \ $(SRC)/w32.h \ $(NT_INC)/pwd.h \ + $(NT_INC)/sys/acl.h \ $(NT_INC)/sys/file.h \ $(NT_INC)/sys/stat.h \ $(NT_INC)/unistd.h \ @@ -1185,6 +1186,7 @@ $(SRC)/w32select.h \ $(NT_INC)/dirent.h \ $(NT_INC)/pwd.h \ + $(NT_INC)/sys/acl.h \ $(NT_INC)/sys/file.h \ $(NT_INC)/sys/time.h \ $(GNU_LIB)/allocator.h \ ------------------------------------------------------------ revno: 111262 committer: Juanma Barranquero branch nick: trunk timestamp: Mon 2012-12-17 21:58:12 +0100 message: nt/config.nt: Sync with autogen/config.in. (BSD4_2): Remove. diff: === modified file 'nt/ChangeLog' --- nt/ChangeLog 2012-12-17 19:14:34 +0000 +++ nt/ChangeLog 2012-12-17 20:58:12 +0000 @@ -1,3 +1,8 @@ +2012-12-17 Juanma Barranquero + + * config.nt: Sync with autogen/config.in. + (BSD4_2): Remove. + 2012-12-17 Eli Zaretskii * inc/sys/acl.h: New file. === modified file 'nt/config.nt' --- nt/config.nt 2012-12-17 19:14:34 +0000 +++ nt/config.nt 2012-12-17 20:58:12 +0000 @@ -61,9 +61,6 @@ #undef BROKEN_PTY_READ_AFTER_EAGAIN /* Define if the system is compatible with BSD 4.2. */ -#undef BSD4_2 - -/* Define if the system is compatible with BSD 4.2. */ #undef BSD_SYSTEM /* Define if AH_BOTTOM should change BSD_SYSTEM. */ @@ -725,7 +722,7 @@ /* Define to 1 if you have the header file. */ #undef HAVE_PNG_H -/* Define to 1 if you have the POSIX ACL support. */ +/* Define to 1 if using POSIX ACL support. */ #define HAVE_POSIX_ACL 1 /* Define to 1 if you have the `posix_memalign' function. */ ------------------------------------------------------------ revno: 111261 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2012-12-17 14:43:55 -0500 message: * lisp/icomplete.el (icomplete-completions): Also use … to truncate prefix. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-17 15:51:49 +0000 +++ lisp/ChangeLog 2012-12-17 19:43:55 +0000 @@ -1,3 +1,7 @@ +2012-12-17 Stefan Monnier + + * icomplete.el (icomplete-completions): Also use … to truncate prefix. + 2012-12-17 Kevin Ryde * files.el (auto-save-file-name-p): Use \` and \' (bug#13186). === modified file 'lisp/icomplete.el' --- lisp/icomplete.el 2012-11-30 17:09:55 +0000 +++ lisp/icomplete.el 2012-12-17 19:43:55 +0000 @@ -337,8 +337,10 @@ ((= compare (length name)) ;; Typical case: name is a prefix. (substring most compare)) - ((< compare 5) most) - (t (concat "..." (substring most compare)))) + ;; Don't bother truncating if it doesn't gain + ;; us at least 2 columns. + ((< compare 3) most) + (t (concat "…" (substring most compare)))) close-bracket))) ;;"-prospects" - more than one candidate (prospects-len (+ (length determ) 6 ;; take {,...} into account ------------------------------------------------------------ revno: 111260 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2012-12-17 14:17:06 -0500 message: * src/xdisp.c (select_frame_for_redisplay): Use select_window_1 to propagate redisplay's scrolling (if any) to the right window. (redisplay_internal): Use ensure_selected_frame. (display_mode_lines): Complete last fix. * src/window.c (select_window_1): New func, extracted from select_window. (select_window): Use it. * src/window.h (select_window_1): Declare. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-17 19:14:34 +0000 +++ src/ChangeLog 2012-12-17 19:17:06 +0000 @@ -1,3 +1,13 @@ +2012-12-17 Stefan Monnier + + * xdisp.c (select_frame_for_redisplay): Use select_window_1 to + propagate redisplay's scrolling (if any) to the right window. + (redisplay_internal): Use ensure_selected_frame. + (display_mode_lines): Complete last fix. + * window.c (select_window_1): New func, extracted from select_window. + (select_window): Use it. + * window.h (select_window_1): Declare. + 2012-12-17 Eli Zaretskii Emulate Posix ACL APIs on MS-Windows. @@ -42,8 +52,7 @@ * fileio.c (Ffile_acl, Fset_file_acl): New functions. (Fcopy_file): Change last arg to `preserve_extended_attributes' - and copy ACL entries of file in addition to SELinux context if - set. + and copy ACL entries of file in addition to SELinux context if set. (syms_of_fileio): Add `file-acl' and `set-file-acl'. * Makefile.in (LIBACL_LIBS): New macro. @@ -166,7 +175,7 @@ 2012-12-12 Daniel Colascione - * unexcw.c (fixup_executable): use posix_fallocate to ensure that + * unexcw.c (fixup_executable): Use posix_fallocate to ensure that the dumped Emacs is not a sparse file, greatly improving Cygwin "make bootstrap" performance. @@ -235,8 +244,7 @@ * w32fns.c (cache_system_info): Initialize the global hinst variable here so various initialization calls DTRT. - * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused - variables. + * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused variables. (hinst): Remove unneeded extern declaration. (_start): Remove initialization of above variables; remove initialization of hinst, as cache_system_info now does that. @@ -308,8 +316,7 @@ * w32fns.c (w32_wnd_proc): Handle the WM_EMACS_FILENOTIFY message by posting it to the w32_read_socket queue. - * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support - FILE_NOTIFY_EVENT. + * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support FILE_NOTIFY_EVENT. * makefile.w32-in (OBJ2): Add $(BLD)/w32notify.$(O). (GLOBAL_SOURCES): Add w32notify.c @@ -317,8 +324,8 @@ * lisp.h (syms_of_w32notify) [WINDOWSNT]: Add prototype. - * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: Handle - FILE_NOTIFY_EVENT. + * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: + Handle FILE_NOTIFY_EVENT. (syms_of_keyboard) [HAVE_NTGUI] : New symbol. (keys_of_keyboard) [WINDOWSNT]: Bind file-notify to w32notify-handle-event by default. @@ -329,8 +336,7 @@ 2012-12-10 Rüdiger Sonderfeld Support for filesystem notifications on GNU/Linux via inotify. - * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add - FILE_NOTIFY_EVENT. + * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add FILE_NOTIFY_EVENT. * lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype. @@ -647,9 +653,9 @@ 2012-12-03 Fabrice Popineau * w32fns.c: Remove prototype of atof. - (syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit + (syspage_mask): Make it DWORD_PTR, for compatibility with 64-bit builds. - (file_dialog_callback): Declared UINT_PTR. + (file_dialog_callback): Make it UINT_PTR. * w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility with 64-bit builds. === modified file 'src/window.c' --- src/window.c 2012-12-12 15:33:30 +0000 +++ src/window.c 2012-12-17 19:17:06 +0000 @@ -487,7 +487,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) { register struct window *w; - register struct window *ow; struct frame *sf; CHECK_LIVE_WINDOW (window); @@ -523,12 +522,25 @@ else fset_selected_window (sf, window); + select_window_1 (window, inhibit_point_swap); + + bset_last_selected_window (XBUFFER (w->buffer), window); + windows_or_buffers_changed++; + return window; +} + +/* Select window with a minimum of fuss, i.e. don't record the change anywhere + (not even for rediaplay's benefit), and assume that the window's frame is + already selected. */ +void +select_window_1 (Lisp_Object window, bool inhibit_point_swap) +{ /* Store the old selected window's buffer's point in pointm of the old selected window. It belongs to that window, and when the window is not selected, must be in the window. */ if (!inhibit_point_swap) { - ow = XWINDOW (selected_window); + struct window *ow = XWINDOW (selected_window); if (! NILP (ow->buffer)) set_marker_both (ow->pointm, ow->buffer, BUF_PT (XBUFFER (ow->buffer)), @@ -536,7 +548,6 @@ } selected_window = window; - bset_last_selected_window (XBUFFER (w->buffer), window); /* Go to the point recorded in the window. This is important when the buffer is in more @@ -544,7 +555,7 @@ redisplay_window has altered point after scrolling, because it makes the change only in the window. */ { - register ptrdiff_t new_point = marker_position (w->pointm); + register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm); if (new_point < BEGV) SET_PT (BEGV); else if (new_point > ZV) @@ -552,9 +563,6 @@ else SET_PT (new_point); } - - windows_or_buffers_changed++; - return window; } DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, === modified file 'src/window.h' --- src/window.h 2012-12-10 17:34:47 +0000 +++ src/window.h 2012-12-17 19:17:06 +0000 @@ -261,7 +261,7 @@ EMACS_INT last_overlay_modified; /* Value of point at that time. Since this is a position in a buffer, - it should be positive. */ + it should be positive. */ ptrdiff_t last_point; /* Scaling factor for the glyph_matrix size calculation in this window. @@ -290,7 +290,7 @@ /* Non-zero if this window is a minibuffer window. */ unsigned mini : 1; - /* Non-zero means must regenerate mode line of this window */ + /* Non-zero means must regenerate mode line of this window. */ unsigned update_mode_line : 1; /* Non-nil if the buffer was "modified" when the window @@ -343,7 +343,7 @@ y-direction (smooth scrolling). */ int vscroll; - /* Z_BYTE - the buffer position of the last glyph in the current matrix of W. + /* Z_BYTE - Buffer position of the last glyph in the current matrix of W. Should be nonnegative, and only valid if window_end_valid is not nil. */ ptrdiff_t window_end_bytepos; }; @@ -934,7 +934,7 @@ extern int update_mode_lines; /* Nonzero if window sizes or contents have changed since last - redisplay that finished */ + redisplay that finished. */ extern int windows_or_buffers_changed; @@ -978,6 +978,7 @@ extern Lisp_Object Qwindowp, Qwindow_live_p; extern Lisp_Object Vwindow_list; +extern void select_window_1 (Lisp_Object window, bool inhibit_point_swap); extern struct window *decode_live_window (Lisp_Object); extern struct window *decode_any_window (Lisp_Object); extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); === modified file 'src/xdisp.c' --- src/xdisp.c 2012-12-14 15:52:43 +0000 +++ src/xdisp.c 2012-12-17 19:17:06 +0000 @@ -869,7 +869,6 @@ static void iterate_out_of_display_property (struct it *); static void pop_it (struct it *); static void sync_frame_with_window_matrix_rows (struct window *); -static void select_frame_for_redisplay (Lisp_Object); static void redisplay_internal (void); static int echo_area_display (int); static void redisplay_windows (Lisp_Object); @@ -1330,7 +1329,7 @@ BVAR (current_buffer, header_line_format)); start_display (&it, w, top); - move_it_to (&it, charpos, -1, it.last_visible_y-1, -1, + move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); if (charpos >= 0 @@ -1338,7 +1337,7 @@ && IT_CHARPOS (it) >= charpos) /* When scanning backwards under bidi iteration, move_it_to stops at or _before_ CHARPOS, because it stops at or to - the _right_ of the character at CHARPOS. */ + the _right_ of the character at CHARPOS. */ || (it.bidi_p && it.bidi_it.scan_dir == -1 && IT_CHARPOS (it) <= charpos))) { @@ -12966,7 +12965,9 @@ eassert (FRAMEP (frame) && FRAME_LIVE_P (XFRAME (frame))); selected_frame = frame; - selected_window = XFRAME (frame)->selected_window; + /* If redisplay causes scrolling, it sets point in the window, so we need to + be careful with the selected-window's point handling. */ + select_window_1 (XFRAME (frame)->selected_window, 0); do { for (tail = XFRAME (frame)->param_alist; @@ -13490,10 +13491,8 @@ if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) { - if (! EQ (frame, selected_frame)) - /* Select the frame, for the sake of frame-local - variables. */ - select_frame_for_redisplay (frame); + /* Select the frame, for the sake of frame-local variables. */ + ensure_selected_frame (frame); /* Mark all the scroll bars to be removed; we'll redeem the ones we want when we redisplay their windows. */ @@ -13790,8 +13789,8 @@ { struct buffer *b = XBUFFER (w->buffer); - w->last_modified = accurate_p ? BUF_MODIFF(b) : 0; - w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF(b) : 0; + w->last_modified = accurate_p ? BUF_MODIFF (b) : 0; + w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0; w->last_had_star = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b); @@ -20360,8 +20359,11 @@ Lisp_Object old_frame_selected_window = XFRAME (new_frame)->selected_window; int n = 0; - selected_frame = w->frame; + selected_frame = new_frame; + /* FIXME: If we were to allow the mode-line's computation changing the buffer + or window's point, then we'd need select_window_1 here as well. */ XSETWINDOW (selected_window, w); + XFRAME (new_frame)->selected_window = selected_window; /* These will be set while the mode line specs are processed. */ line_number_displayed = 0; ------------------------------------------------------------ revno: 111259 committer: Eli Zaretskii branch nick: trunk timestamp: Mon 2012-12-17 21:14:34 +0200 message: Support Posix ACL APIs on MS-Windows. src/w32.c: Include sddl.h and sys/acl.h. (SDDL_REVISION_1): Define if not already defined. (g_b_init_get_security_descriptor_dacl) (g_b_init_convert_sd_to_sddl, g_b_init_convert_sddl_to_sd) (g_b_init_is_valid_security_descriptor) (g_b_init_set_file_security): New static flags. (globals_of_w32): Initialize them to zero. (SetFileSecurity_Name): New string constant. (SetFileSecurity_Proc, GetSecurityDescriptorDacl_Proc) (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc) (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc) (IsValidSecurityDescriptor_Proc): New typedefs. (get_file_security, get_security_descriptor_owner) (get_security_descriptor_group): Set errno to ENOTSUP. (set_file_security, get_security_descriptor_dacl) (is_valid_security_descriptor, convert_sd_to_sddl) (convert_sddl_to_sd, acl_valid, acl_to_text, acl_from_text) (acl_free, acl_get_file, acl_set_file): New functions. src/fileio.c (Fcopy_file) [WINDOWSNT]: Support copying ACLs. nt/inc/sys/acl.h: New file. nt/inc/ms-w32.h (ENOTSUP): Define if undefined. nt/config.nt (HAVE_POSIX_ACL): Define. doc/lispref/files.texi (File Attributes, Changing Files): Update to include MS-Windows support for ACLs. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2012-12-16 18:22:27 +0000 +++ doc/lispref/ChangeLog 2012-12-17 19:14:34 +0000 @@ -1,3 +1,8 @@ +2012-12-17 Eli Zaretskii + + * files.texi (File Attributes, Changing Files): Update to include + MS-Windows support for ACLs. + 2012-12-16 Romain Francoise * files.texi (File Attributes): Document ACL support and new === modified file 'doc/lispref/files.texi' --- doc/lispref/files.texi 2012-12-16 18:22:27 +0000 +++ doc/lispref/files.texi 2012-12-17 19:14:34 +0000 @@ -1357,13 +1357,14 @@ If Emacs has been compiled with @dfn{ACL} (access control list) support, you can use the function @code{file-acl} to retrieve a file's ACL entries. The format is platform-specific; on GNU/Linux and BSD, -Emacs uses the POSIX ACL interface. For the function -@code{set-file-acl}, see @ref{Changing Files}. +Emacs uses the POSIX ACL interface, while on MS-Windows Emacs emulates +the POSIX ACL interface with native file security APIs. For the +function @code{set-file-acl}, see @ref{Changing Files}. @defun file-acl filename This function returns the ACL entries of the file @var{filename}. The return value is a string containing the textual representation of -the ACL entries, like the following: +the ACL entries. On Posix hosts, it looks like this: @example @group @@ -1375,6 +1376,12 @@ @end group @end example +@cindex security descriptor, file +@cindex SDDL, MS-Windows +On MS-Windows, the return value is a textual description of the file's +@dfn{security descriptor} in @acronym{SDDL}, the @dfn{Security +Descriptor Definition Language}. + If the file does not exist or is inaccessible, or if Emacs was unable to determine the ACL entries, then the return value is @code{nil}. The latter can happen for local files if Emacs was not compiled with ACL @@ -1719,7 +1726,8 @@ This function sets the ACL entries of the file @var{filename} to @var{acl-string}. @xref{File Attributes}, for a brief description of ACLs. The @var{acl-string} argument should be a string containing the -textual representation of the desired ACL entries. +textual representation of the desired ACL entries in the format +appropriate for the ACL interface being used. @end defun @node File Names === modified file 'etc/NEWS' --- etc/NEWS 2012-12-16 18:22:27 +0000 +++ etc/NEWS 2012-12-17 19:14:34 +0000 @@ -44,8 +44,9 @@ *** Emacs preserves the ACL entries of files when backing up. +++ *** New functions `file-acl' and `set-file-acl' get and set the ACL -entries of a file. On GNU/Linux the POSIX ACL interface is used via -libacl. +entries of a file. On GNU/Linux, the POSIX ACL interface is used via +libacl. On MS-Windows, the NT Security APIs are used to emulate the +POSIX ACL interfaces. * Editing Changes in Emacs 24.4 === modified file 'nt/ChangeLog' --- nt/ChangeLog 2012-12-15 13:42:33 +0000 +++ nt/ChangeLog 2012-12-17 19:14:34 +0000 @@ -1,3 +1,11 @@ +2012-12-17 Eli Zaretskii + + * inc/sys/acl.h: New file. + + * inc/ms-w32.h (ENOTSUP): Define if undefined. + + * config.nt (HAVE_POSIX_ACL): Define. + 2012-12-15 Eli Zaretskii * inc/ms-w32.h (sys_unlink): Provide prototype. === modified file 'nt/config.nt' --- nt/config.nt 2012-12-13 01:18:28 +0000 +++ nt/config.nt 2012-12-17 19:14:34 +0000 @@ -725,6 +725,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_PNG_H +/* Define to 1 if you have the POSIX ACL support. */ +#define HAVE_POSIX_ACL 1 + /* Define to 1 if you have the `posix_memalign' function. */ #undef HAVE_POSIX_MEMALIGN === modified file 'nt/inc/ms-w32.h' --- nt/inc/ms-w32.h 2012-12-15 13:38:21 +0000 +++ nt/inc/ms-w32.h 2012-12-17 19:14:34 +0000 @@ -293,6 +293,10 @@ #define NSIG 23 #endif +#ifndef ENOTSUP +#define ENOTSUP ENOSYS +#endif + #ifdef _MSC_VER typedef int sigset_t; typedef int ssize_t; === added file 'nt/inc/sys/acl.h' --- nt/inc/sys/acl.h 1970-01-01 00:00:00 +0000 +++ nt/inc/sys/acl.h 2012-12-17 19:14:34 +0000 @@ -0,0 +1,25 @@ +/* Emulation of Posix ACLs for Windows. */ + +#ifndef ACL_H +#define ACL_H + +#define NOMINMAX 1 /* don't define min and max */ +#include + +typedef PSECURITY_DESCRIPTOR acl_t; +typedef unsigned acl_type_t; + +/* Values of acl_type_t */ +#define ACL_TYPE_ACCESS 0 +#define ACL_TYPE_DEFAULT 1 + +typedef unsigned acl_perm_t; + +extern int acl_valid (acl_t); +extern acl_t acl_get_file (const char *, acl_type_t); +extern int acl_set_file (const char *, acl_type_t, acl_t); +extern char * acl_to_text (acl_t, ssize_t *); +extern acl_t acl_from_text (const char *); +extern int acl_free (void *); + +#endif /* ACL_H */ === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-17 17:51:25 +0000 +++ src/ChangeLog 2012-12-17 19:14:34 +0000 @@ -1,3 +1,27 @@ +2012-12-17 Eli Zaretskii + + Emulate Posix ACL APIs on MS-Windows. + * w32.c: Include sddl.h and sys/acl.h. + (SDDL_REVISION_1): Define if not already defined. + (g_b_init_get_security_descriptor_dacl) + (g_b_init_convert_sd_to_sddl, g_b_init_convert_sddl_to_sd) + (g_b_init_is_valid_security_descriptor) + (g_b_init_set_file_security): New static flags. + (globals_of_w32): Initialize them to zero. + (SetFileSecurity_Name): New string constant. + (SetFileSecurity_Proc, GetSecurityDescriptorDacl_Proc) + (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc) + (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc) + (IsValidSecurityDescriptor_Proc): New typedefs. + (get_file_security, get_security_descriptor_owner) + (get_security_descriptor_group): Set errno to ENOTSUP. + (set_file_security, get_security_descriptor_dacl) + (is_valid_security_descriptor, convert_sd_to_sddl) + (convert_sddl_to_sd, acl_valid, acl_to_text, acl_from_text) + (acl_free, acl_get_file, acl_set_file): New functions. + + * fileio.c (Fcopy_file) [WINDOWSNT]: Support copying ACLs. + 2012-12-17 Paul Eggert Don't reraise SIGCHLD, as that can now lose (Bug#13192). === modified file 'src/fileio.c' --- src/fileio.c 2012-12-16 18:22:27 +0000 +++ src/fileio.c 2012-12-17 19:14:34 +0000 @@ -1956,6 +1956,14 @@ out_st.st_mode = 0; #ifdef WINDOWSNT + if (!NILP (preserve_extended_attributes)) + { +#ifdef HAVE_POSIX_ACL + acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); + if (acl == NULL && errno != ENOTSUP) + report_file_error ("Getting ACL", Fcons (file, Qnil)); +#endif + } if (!CopyFile (SDATA (encoded_file), SDATA (encoded_newname), FALSE)) @@ -1983,6 +1991,17 @@ /* Restore original attributes. */ SetFileAttributes (filename, attributes); } +#ifdef HAVE_POSIX_ACL + if (acl != NULL) + { + bool fail = + acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; + if (fail && errno != ENOTSUP) + report_file_error ("Setting ACL", Fcons (newname, Qnil)); + + acl_free (acl); + } +#endif #else /* not WINDOWSNT */ immediate_quit = 1; ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); === modified file 'src/w32.c' --- src/w32.c 2012-12-15 11:04:14 +0000 +++ src/w32.c 2012-12-17 19:14:34 +0000 @@ -117,6 +117,15 @@ #include #include +#include + +#include + +/* This is not in MinGW's sddl.h (but they are in MSVC headers), so we + define them by hand if not already defined. */ +#ifndef SDDL_REVISION_1 +#define SDDL_REVISION_1 1 +#endif /* SDDL_REVISION_1 */ #ifdef _MSC_VER /* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the @@ -257,6 +266,11 @@ static BOOL g_b_init_get_native_system_info; static BOOL g_b_init_get_system_times; static BOOL g_b_init_create_symbolic_link; +static BOOL g_b_init_get_security_descriptor_dacl; +static BOOL g_b_init_convert_sd_to_sddl; +static BOOL g_b_init_convert_sddl_to_sd; +static BOOL g_b_init_is_valid_security_descriptor; +static BOOL g_b_init_set_file_security; /* BEGIN: Wrapper functions around OpenProcessToken @@ -286,9 +300,11 @@ #ifdef _UNICODE const char * const LookupAccountSid_Name = "LookupAccountSidW"; const char * const GetFileSecurity_Name = "GetFileSecurityW"; +const char * const SetFileSecurity_Name = "SetFileSecurityW"; #else const char * const LookupAccountSid_Name = "LookupAccountSidA"; const char * const GetFileSecurity_Name = "GetFileSecurityA"; +const char * const SetFileSecurity_Name = "SetFileSecurityA"; #endif typedef BOOL (WINAPI * LookupAccountSid_Proc) ( LPCTSTR lpSystemName, @@ -318,6 +334,10 @@ PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded); +typedef BOOL (WINAPI *SetFileSecurity_Proc) ( + LPCTSTR lpFileName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); typedef BOOL (WINAPI * GetSecurityDescriptorOwner_Proc) ( PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, @@ -326,6 +346,11 @@ PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pGroup, LPBOOL lpbGroupDefaulted); +typedef BOOL (WINAPI *GetSecurityDescriptorDacl_Proc) ( + PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPBOOL lpbDaclPresent, + PACL *pDacl, + LPBOOL lpbDaclDefaulted); typedef BOOL (WINAPI * IsValidSid_Proc) ( PSID sid); typedef HANDLE (WINAPI * CreateToolhelp32Snapshot_Proc) ( @@ -376,6 +401,18 @@ LPTSTR lpSymlinkFileName, LPTSTR lpTargetFileName, DWORD dwFlags); +typedef BOOL (WINAPI *ConvertStringSecurityDescriptorToSecurityDescriptor_Proc) ( + LPCTSTR StringSecurityDescriptor, + DWORD StringSDRevision, + PSECURITY_DESCRIPTOR *SecurityDescriptor, + PULONG SecurityDescriptorSize); +typedef BOOL (WINAPI *ConvertSecurityDescriptorToStringSecurityDescriptor_Proc) ( + PSECURITY_DESCRIPTOR SecurityDescriptor, + DWORD RequestedStringSDRevision, + SECURITY_INFORMATION SecurityInformation, + LPTSTR *StringSecurityDescriptor, + PULONG StringSecurityDescriptorLen); +typedef BOOL (WINAPI *IsValidSecurityDescriptor_Proc) (PSECURITY_DESCRIPTOR); /* ** A utility function ** */ static BOOL @@ -621,6 +658,7 @@ HMODULE hm_advapi32 = NULL; if (is_windows_9x () == TRUE) { + errno = ENOTSUP; return FALSE; } if (g_b_init_get_file_security == 0) @@ -633,6 +671,7 @@ } if (s_pfn_Get_File_Security == NULL) { + errno = ENOTSUP; return FALSE; } return (s_pfn_Get_File_Security (lpFileName, RequestedInformation, @@ -641,6 +680,35 @@ } static BOOL WINAPI +set_file_security (LPCTSTR lpFileName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor) +{ + static SetFileSecurity_Proc s_pfn_Set_File_Security = NULL; + HMODULE hm_advapi32 = NULL; + if (is_windows_9x () == TRUE) + { + errno = ENOTSUP; + return FALSE; + } + if (g_b_init_set_file_security == 0) + { + g_b_init_set_file_security = 1; + hm_advapi32 = LoadLibrary ("Advapi32.dll"); + s_pfn_Set_File_Security = + (SetFileSecurity_Proc) GetProcAddress ( + hm_advapi32, SetFileSecurity_Name); + } + if (s_pfn_Set_File_Security == NULL) + { + errno = ENOTSUP; + return FALSE; + } + return (s_pfn_Set_File_Security (lpFileName, SecurityInformation, + pSecurityDescriptor)); +} + +static BOOL WINAPI get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted) @@ -649,6 +717,7 @@ HMODULE hm_advapi32 = NULL; if (is_windows_9x () == TRUE) { + errno = ENOTSUP; return FALSE; } if (g_b_init_get_security_descriptor_owner == 0) @@ -661,6 +730,7 @@ } if (s_pfn_Get_Security_Descriptor_Owner == NULL) { + errno = ENOTSUP; return FALSE; } return (s_pfn_Get_Security_Descriptor_Owner (pSecurityDescriptor, pOwner, @@ -676,6 +746,7 @@ HMODULE hm_advapi32 = NULL; if (is_windows_9x () == TRUE) { + errno = ENOTSUP; return FALSE; } if (g_b_init_get_security_descriptor_group == 0) @@ -688,6 +759,7 @@ } if (s_pfn_Get_Security_Descriptor_Group == NULL) { + errno = ENOTSUP; return FALSE; } return (s_pfn_Get_Security_Descriptor_Group (pSecurityDescriptor, pGroup, @@ -695,6 +767,37 @@ } static BOOL WINAPI +get_security_descriptor_dacl (PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPBOOL lpbDaclPresent, + PACL *pDacl, + LPBOOL lpbDaclDefaulted) +{ + static GetSecurityDescriptorDacl_Proc s_pfn_Get_Security_Descriptor_Dacl = NULL; + HMODULE hm_advapi32 = NULL; + if (is_windows_9x () == TRUE) + { + errno = ENOTSUP; + return FALSE; + } + if (g_b_init_get_security_descriptor_dacl == 0) + { + g_b_init_get_security_descriptor_dacl = 1; + hm_advapi32 = LoadLibrary ("Advapi32.dll"); + s_pfn_Get_Security_Descriptor_Dacl = + (GetSecurityDescriptorDacl_Proc) GetProcAddress ( + hm_advapi32, "GetSecurityDescriptorDacl"); + } + if (s_pfn_Get_Security_Descriptor_Dacl == NULL) + { + errno = ENOTSUP; + return FALSE; + } + return (s_pfn_Get_Security_Descriptor_Dacl (pSecurityDescriptor, + lpbDaclPresent, pDacl, + lpbDaclDefaulted)); +} + +static BOOL WINAPI is_valid_sid (PSID sid) { static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL; @@ -888,6 +991,120 @@ } return retval; } + +static BOOL WINAPI +is_valid_security_descriptor (PSECURITY_DESCRIPTOR pSecurityDescriptor) +{ + static IsValidSecurityDescriptor_Proc s_pfn_Is_Valid_Security_Descriptor_Proc = NULL; + + if (is_windows_9x () == TRUE) + { + errno = ENOTSUP; + return FALSE; + } + + if (g_b_init_is_valid_security_descriptor == 0) + { + g_b_init_is_valid_security_descriptor = 1; + s_pfn_Is_Valid_Security_Descriptor_Proc = + (IsValidSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), + "IsValidSecurityDescriptor"); + } + if (s_pfn_Is_Valid_Security_Descriptor_Proc == NULL) + { + errno = ENOTSUP; + return FALSE; + } + + return s_pfn_Is_Valid_Security_Descriptor_Proc (pSecurityDescriptor); +} + +static BOOL WINAPI +convert_sd_to_sddl (PSECURITY_DESCRIPTOR SecurityDescriptor, + DWORD RequestedStringSDRevision, + SECURITY_INFORMATION SecurityInformation, + LPTSTR *StringSecurityDescriptor, + PULONG StringSecurityDescriptorLen) +{ + static ConvertSecurityDescriptorToStringSecurityDescriptor_Proc s_pfn_Convert_SD_To_SDDL = NULL; + BOOL retval; + + if (is_windows_9x () == TRUE) + { + errno = ENOTSUP; + return FALSE; + } + + if (g_b_init_convert_sd_to_sddl == 0) + { + g_b_init_convert_sd_to_sddl = 1; +#ifdef _UNICODE + s_pfn_Convert_SD_To_SDDL = + (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), + "ConvertSecurityDescriptorToStringSecurityDescriptorW"); +#else + s_pfn_Convert_SD_To_SDDL = + (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), + "ConvertSecurityDescriptorToStringSecurityDescriptorA"); +#endif + } + if (s_pfn_Convert_SD_To_SDDL == NULL) + { + errno = ENOTSUP; + return FALSE; + } + + retval = s_pfn_Convert_SD_To_SDDL (SecurityDescriptor, + RequestedStringSDRevision, + SecurityInformation, + StringSecurityDescriptor, + StringSecurityDescriptorLen); + + return retval; +} + +static BOOL WINAPI +convert_sddl_to_sd (LPCTSTR StringSecurityDescriptor, + DWORD StringSDRevision, + PSECURITY_DESCRIPTOR *SecurityDescriptor, + PULONG SecurityDescriptorSize) +{ + static ConvertStringSecurityDescriptorToSecurityDescriptor_Proc s_pfn_Convert_SDDL_To_SD = NULL; + BOOL retval; + + if (is_windows_9x () == TRUE) + { + errno = ENOTSUP; + return FALSE; + } + + if (g_b_init_convert_sddl_to_sd == 0) + { + g_b_init_convert_sddl_to_sd = 1; +#ifdef _UNICODE + s_pfn_Convert_SDDL_To_SD = + (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), + "ConvertStringSecurityDescriptorToSecurityDescriptorW"); +#else + s_pfn_Convert_SDDL_To_SD = + (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"), + "ConvertStringSecurityDescriptorToSecurityDescriptorA"); +#endif + } + if (s_pfn_Convert_SDDL_To_SD == NULL) + { + errno = ENOTSUP; + return FALSE; + } + + retval = s_pfn_Convert_SDDL_To_SD (StringSecurityDescriptor, + StringSDRevision, + SecurityDescriptor, + SecurityDescriptorSize); + + return retval; +} + /* Return 1 if P is a valid pointer to an object of size SIZE. Return @@ -4477,6 +4694,199 @@ return target; } + +/* Posix ACL emulation. */ + +int +acl_valid (acl_t acl) +{ + return is_valid_security_descriptor ((PSECURITY_DESCRIPTOR)acl) ? 0 : -1; +} + +char * +acl_to_text (acl_t acl, ssize_t *size) +{ + LPTSTR str_acl; + SECURITY_INFORMATION flags = + OWNER_SECURITY_INFORMATION | + GROUP_SECURITY_INFORMATION | + DACL_SECURITY_INFORMATION; + char *retval = NULL; + ssize_t local_size; + int e = errno; + + errno = 0; + + if (convert_sd_to_sddl ((PSECURITY_DESCRIPTOR)acl, SDDL_REVISION_1, flags, &str_acl, &local_size)) + { + errno = e; + /* We don't want to mix heaps, so we duplicate the string in our + heap and free the one allocated by the API. */ + retval = xstrdup (str_acl); + if (size) + *size = local_size; + LocalFree (str_acl); + } + else if (errno != ENOTSUP) + errno = EINVAL; + + return retval; +} + +acl_t +acl_from_text (const char *acl_str) +{ + PSECURITY_DESCRIPTOR psd, retval = NULL; + ULONG sd_size; + int e = errno; + + errno = 0; + + if (convert_sddl_to_sd (acl_str, SDDL_REVISION_1, &psd, &sd_size)) + { + errno = e; + retval = xmalloc (sd_size); + memcpy (retval, psd, sd_size); + LocalFree (psd); + } + else if (errno != ENOTSUP) + errno = EINVAL; + + return retval; +} + +int +acl_free (void *ptr) +{ + xfree (ptr); + return 0; +} + +acl_t +acl_get_file (const char *fname, acl_type_t type) +{ + PSECURITY_DESCRIPTOR psd = NULL; + + if (type == ACL_TYPE_ACCESS) + { + DWORD sd_len, err; + SECURITY_INFORMATION si = + OWNER_SECURITY_INFORMATION | + GROUP_SECURITY_INFORMATION | + DACL_SECURITY_INFORMATION ; + int e = errno; + + errno = 0; + if (!get_file_security (fname, si, psd, 0, &sd_len) + && errno != ENOTSUP) + { + err = GetLastError (); + if (err == ERROR_INSUFFICIENT_BUFFER) + { + psd = xmalloc (sd_len); + if (!get_file_security (fname, si, psd, sd_len, &sd_len)) + { + xfree (psd); + errno = EIO; + psd = NULL; + } + } + else if (err == ERROR_FILE_NOT_FOUND + || err == ERROR_PATH_NOT_FOUND) + errno = ENOENT; + else + errno = EIO; + } + else if (!errno) + errno = e; + } + else if (type != ACL_TYPE_DEFAULT) + errno = EINVAL; + + return psd; +} + +int +acl_set_file (const char *fname, acl_type_t type, acl_t acl) +{ + TOKEN_PRIVILEGES old1, old2; + DWORD err; + BOOL res; + int st = 0, retval = -1; + SECURITY_INFORMATION flags = 0; + PSID psid; + PACL pacl; + BOOL dflt; + BOOL dacl_present; + int e; + + if (acl_valid (acl) != 0 + || (type != ACL_TYPE_DEFAULT && type != ACL_TYPE_ACCESS)) + { + errno = EINVAL; + return -1; + } + + if (type == ACL_TYPE_DEFAULT) + { + errno = ENOSYS; + return -1; + } + + if (get_security_descriptor_owner ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt) + && psid) + flags |= OWNER_SECURITY_INFORMATION; + if (get_security_descriptor_group ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt) + && psid) + flags |= GROUP_SECURITY_INFORMATION; + if (get_security_descriptor_dacl ((PSECURITY_DESCRIPTOR)acl, &dacl_present, + &pacl, &dflt) + && dacl_present) + flags |= DACL_SECURITY_INFORMATION; + if (!flags) + return 0; + + /* According to KB-245153, setting the owner will succeed if either: + (1) the caller is the user who will be the new owner, and has the + SE_TAKE_OWNERSHIP privilege, or + (2) the caller has the SE_RESTORE privilege, in which case she can + set any valid user or group as the owner + + We request below both SE_TAKE_OWNERSHIP and SE_RESTORE + privileges, and disregard any failures in obtaining them. If + these privileges cannot be obtained, and do not already exist in + the calling thread's security token, this function could fail + with EPERM. */ + if (enable_privilege (SE_TAKE_OWNERSHIP_NAME, TRUE, &old1)) + st++; + if (enable_privilege (SE_RESTORE_NAME, TRUE, &old2)) + st++; + + e = errno; + errno = 0; + set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl); + err = GetLastError (); + if (st >= 2) + restore_privilege (&old2); + if (st >= 1) + restore_privilege (&old1); + + if (errno == ENOTSUP) + ; + else if (err == ERROR_SUCCESS) + { + retval = 0; + errno = e; + } + else if (err == ERROR_INVALID_OWNER) + errno = EPERM; + else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) + errno = ENOENT; + + return retval; +} + + /* MS-Windows version of careadlinkat (cf. ../lib/careadlinkat.c). We have a fixed max size for file names, so we don't need the kind of alloc/malloc/realloc dance the gnulib version does. We also don't @@ -6848,6 +7258,11 @@ g_b_init_get_native_system_info = 0; g_b_init_get_system_times = 0; g_b_init_create_symbolic_link = 0; + g_b_init_get_security_descriptor_dacl = 0; + g_b_init_convert_sd_to_sddl = 0; + g_b_init_convert_sddl_to_sd = 0; + g_b_init_is_valid_security_descriptor = 0; + g_b_init_set_file_security = 0; num_of_processors = 0; /* The following sets a handler for shutdown notifications for console apps. This actually applies to Emacs in both console and ------------------------------------------------------------ revno: 111258 fixes bug: http://debbugs.gnu.org/13192 committer: Paul Eggert branch nick: trunk timestamp: Mon 2012-12-17 09:51:25 -0800 message: Don't reraise SIGCHLD, as that can now lose. With the 2012-12-03 fix for Bug#12980 in place, an old workaround for some of that bug's symptoms can now cause Emacs to abort. Remove the workaround. * process.c (wait_reading_process_output): Don't reraise SIGCHLD. The bug that caused SIGCHLD to get lost has been fixed, and the workaround for it can now cause Emacs to abort. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-12-16 22:53:28 +0000 +++ src/ChangeLog 2012-12-17 17:51:25 +0000 @@ -1,3 +1,13 @@ +2012-12-17 Paul Eggert + + Don't reraise SIGCHLD, as that can now lose (Bug#13192). + With the 2012-12-03 fix for Bug#12980 in place, an old workaround + for some of that bug's symptoms can now cause Emacs to abort. + Remove the workaround. + * process.c (wait_reading_process_output): Don't reraise SIGCHLD. + The bug that caused SIGCHLD to get lost has been fixed, and the + workaround for it can now cause Emacs to abort. + 2012-12-16 Paul Eggert * sysdep.c (emacs_abort): Bump backtrace size to 40. === modified file 'src/process.c' --- src/process.c 2012-12-08 02:30:51 +0000 +++ src/process.c 2012-12-17 17:51:25 +0000 @@ -4773,11 +4773,7 @@ Therefore, if we get an error reading and errno = EIO, just continue, because the child process has exited and should clean itself up soon (e.g. when we - get a SIGCHLD). - - However, it has been known to happen that the SIGCHLD - got lost. So raise the signal again just in case. - It can't hurt. */ + get a SIGCHLD). */ else if (nread == -1 && errno == EIO) { struct Lisp_Process *p = XPROCESS (proc); @@ -4795,8 +4791,6 @@ p->tick = ++process_tick; pset_status (p, Qfailed); } - else - handle_child_signal (SIGCHLD); } #endif /* HAVE_PTYS */ /* If we can detect process termination, don't consider the ------------------------------------------------------------ revno: 111257 fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13186 author: Kevin Ryde committer: Stefan Monnier branch nick: trunk timestamp: Mon 2012-12-17 10:51:49 -0500 message: * lisp/files.el (auto-save-file-name-p): Use \` and \'. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-17 14:38:07 +0000 +++ lisp/ChangeLog 2012-12-17 15:51:49 +0000 @@ -1,3 +1,7 @@ +2012-12-17 Kevin Ryde + + * files.el (auto-save-file-name-p): Use \` and \' (bug#13186). + 2012-12-17 Michael Albinus Add support for preserving ACL entries of files. @@ -5,34 +9,34 @@ * net/tramp.el (tramp-file-name-for-operation): Add `file-acl' and `set-file-acl' handlers. - * net/tramp-adb.el (tramp-adb-handle-copy-file): Handle - PRESERVE-EXTENDED-ATTRIBUTES. - - * net/tramp-compat.el (tramp-compat-copy-file): Handle - PRESERVE-EXTENDED-ATTRIBUTES. - - * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Add - `file-acl' and `set-file-acl' handlers. - (tramp-gvfs-handle-copy-file): Handle - PRESERVE-EXTENDED-ATTRIBUTES. - (tramp-gvfs-handle-file-acl, tramp-gvfs-handle-set-file-acl): New - defuns. - - * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add - `file-acl' and `set-file-acl' handlers. + * net/tramp-adb.el (tramp-adb-handle-copy-file): + Handle PRESERVE-EXTENDED-ATTRIBUTES. + + * net/tramp-compat.el (tramp-compat-copy-file): + Handle PRESERVE-EXTENDED-ATTRIBUTES. + + * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): + Add `file-acl' and `set-file-acl' handlers. + (tramp-gvfs-handle-copy-file): + Handle PRESERVE-EXTENDED-ATTRIBUTES. + (tramp-gvfs-handle-file-acl, tramp-gvfs-handle-set-file-acl): + New defuns. + + * net/tramp-sh.el (tramp-sh-file-name-handler-alist): + Add `file-acl' and `set-file-acl' handlers. (tramp-remote-acl-p, tramp-sh-handle-file-acl) (tramp-sh-handle-set-file-acl): New defuns. - (tramp-sh-handle-copy-file, tramp-do-copy-or-rename-file): Handle - PRESERVE-EXTENDED-ATTRIBUTES. + (tramp-sh-handle-copy-file, tramp-do-copy-or-rename-file): + Handle PRESERVE-EXTENDED-ATTRIBUTES. - * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add - `file-acl' and `set-file-acl' handlers. + * net/tramp-smb.el (tramp-smb-file-name-handler-alist): + Add `file-acl' and `set-file-acl' handlers. (tramp-smb-handle-copy-file): Handle PRESERVE-EXTENDED-ATTRIBUTES. 2012-12-17 Kelly Dean (tiny change) * help-macro.el (make-help-screen): Instead of switch-to-buffer - use pop-to-buffer with NORECORD argument t. As buffer name use + use pop-to-buffer with NORECORD argument t. As buffer name, use *Metahelp* with a leading space (Bug#13190). 2012-12-16 Romain Francoise @@ -101,8 +105,8 @@ 2012-12-14 Julien Danjou - * progmodes/sql.el (sql-mode-postgres-font-lock-keywords): Update - keywords list, data type and PL/pgSQL. + * progmodes/sql.el (sql-mode-postgres-font-lock-keywords): + Update keywords list, data type and PL/pgSQL. 2012-12-14 Dave Abrahams === modified file 'lisp/files.el' --- lisp/files.el 2012-12-16 18:22:27 +0000 +++ lisp/files.el 2012-12-17 15:51:49 +0000 @@ -5717,7 +5717,7 @@ (defun auto-save-file-name-p (filename) "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. FILENAME should lack slashes. You can redefine this for customization." - (string-match "^#.*#$" filename)) + (string-match "\\`#.*#\\'" filename)) (defun wildcard-to-regexp (wildcard) "Given a shell file name pattern WILDCARD, return an equivalent regexp. ------------------------------------------------------------ revno: 111256 committer: Michael Albinus + + Add support for preserving ACL entries of files. + + * net/tramp.el (tramp-file-name-for-operation): Add `file-acl' and + `set-file-acl' handlers. + + * net/tramp-adb.el (tramp-adb-handle-copy-file): Handle + PRESERVE-EXTENDED-ATTRIBUTES. + + * net/tramp-compat.el (tramp-compat-copy-file): Handle + PRESERVE-EXTENDED-ATTRIBUTES. + + * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Add + `file-acl' and `set-file-acl' handlers. + (tramp-gvfs-handle-copy-file): Handle + PRESERVE-EXTENDED-ATTRIBUTES. + (tramp-gvfs-handle-file-acl, tramp-gvfs-handle-set-file-acl): New + defuns. + + * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add + `file-acl' and `set-file-acl' handlers. + (tramp-remote-acl-p, tramp-sh-handle-file-acl) + (tramp-sh-handle-set-file-acl): New defuns. + (tramp-sh-handle-copy-file, tramp-do-copy-or-rename-file): Handle + PRESERVE-EXTENDED-ATTRIBUTES. + + * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add + `file-acl' and `set-file-acl' handlers. + (tramp-smb-handle-copy-file): Handle PRESERVE-EXTENDED-ATTRIBUTES. + 2012-12-17 Kelly Dean (tiny change) * help-macro.el (make-help-screen): Instead of switch-to-buffer === modified file 'lisp/net/tramp-adb.el' --- lisp/net/tramp-adb.el 2012-12-14 09:02:34 +0000 +++ lisp/net/tramp-adb.el 2012-12-17 14:38:07 +0000 @@ -526,9 +526,9 @@ (defun tramp-adb-handle-copy-file (filename newname &optional ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context) + preserve-uid-gid preserve-extended-attributes) "Like `copy-file' for Tramp files. -PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored." +PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (setq filename (expand-file-name filename) newname (expand-file-name newname)) === modified file 'lisp/net/tramp-compat.el' --- lisp/net/tramp-compat.el 2012-12-06 09:15:27 +0000 +++ lisp/net/tramp-compat.el 2012-12-17 14:38:07 +0000 @@ -304,16 +304,17 @@ (wrong-number-of-arguments (file-attributes filename)))))) ;; PRESERVE-UID-GID does not exist in XEmacs. -;; PRESERVE-SELINUX-CONTEXT has been introduced with Emacs 24.1. +;; PRESERVE-EXTENDED-ATTRIBUTES has been introduced with Emacs 24.1 +;; (as PRESERVE-SELINUX-CONTEXT), and renamed in Emacs 24.3. (defun tramp-compat-copy-file (filename newname &optional ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context) + preserve-uid-gid preserve-extended-attributes) "Like `copy-file' for Tramp files (compat function)." (cond - (preserve-selinux-context + (preserve-extended-attributes (tramp-compat-funcall 'copy-file filename newname ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context)) + preserve-uid-gid preserve-extended-attributes)) (preserve-uid-gid (tramp-compat-funcall 'copy-file filename newname ok-if-already-exists keep-date === modified file 'lisp/net/tramp-gvfs.el' --- lisp/net/tramp-gvfs.el 2012-12-14 09:02:34 +0000 +++ lisp/net/tramp-gvfs.el 2012-12-17 14:38:07 +0000 @@ -385,6 +385,7 @@ ;; `executable-find' is not official yet. performed by default handler. (expand-file-name . tramp-gvfs-handle-expand-file-name) ;; `file-accessible-directory-p' performed by default handler. + (file-acl . tramp-gvfs-handle-file-acl) (file-attributes . tramp-gvfs-handle-file-attributes) (file-directory-p . tramp-gvfs-handle-file-directory-p) (file-executable-p . tramp-gvfs-handle-file-executable-p) @@ -417,6 +418,7 @@ (make-symbolic-link . ignore) (process-file . tramp-gvfs-handle-process-file) (rename-file . tramp-gvfs-handle-rename-file) + (set-file-acl . tramp-gvfs-handle-set-file-acl) (set-file-modes . tramp-gvfs-handle-set-file-modes) (set-file-selinux-context . tramp-gvfs-handle-set-file-selinux-context) (set-visited-file-modtime . tramp-gvfs-handle-set-visited-file-modtime) @@ -539,7 +541,7 @@ (defun tramp-gvfs-handle-copy-file (filename newname &optional ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context) + preserve-uid-gid preserve-extended-attributes) "Like `copy-file' for Tramp files." (with-parsed-tramp-file-name (if (tramp-tramp-file-p filename) filename newname) nil @@ -555,8 +557,8 @@ (tramp-gvfs-fuse-file-name newname) newname) ok-if-already-exists keep-date preserve-uid-gid))) - (when preserve-selinux-context - (setq args (append args (list preserve-selinux-context)))) + (when preserve-extended-attributes + (setq args (append args (list preserve-extended-attributes)))) (apply 'copy-file args)) ;; Error case. Let's try it with the GVFS utilities. @@ -655,6 +657,10 @@ (tramp-run-real-handler 'expand-file-name (list localname)))))) +(defun tramp-gvfs-handle-file-acl (filename) + "Like `file-acl' for Tramp files." + (tramp-compat-funcall 'file-acl (tramp-gvfs-fuse-file-name filename))) + (defun tramp-gvfs-handle-file-attributes (filename &optional id-format) "Like `file-attributes' for Tramp files." (file-attributes (tramp-gvfs-fuse-file-name filename) id-format)) @@ -781,6 +787,11 @@ (tramp-flush-file-property v (file-name-directory localname)) (tramp-flush-file-property v localname)))) +(defun tramp-gvfs-handle-set-file-acl (filename acl-string) + "Like `set-file-acl' for Tramp files." + (with-tramp-gvfs-error-message filename 'set-file-acl + (tramp-gvfs-fuse-file-name filename) acl-string)) + (defun tramp-gvfs-handle-set-file-modes (filename mode) "Like `set-file-modes' for Tramp files." (with-tramp-gvfs-error-message filename 'set-file-modes === modified file 'lisp/net/tramp-sh.el' --- lisp/net/tramp-sh.el 2012-12-14 18:59:00 +0000 +++ lisp/net/tramp-sh.el 2012-12-17 14:38:07 +0000 @@ -985,6 +985,8 @@ (verify-visited-file-modtime . tramp-sh-handle-verify-visited-file-modtime) (file-selinux-context . tramp-sh-handle-file-selinux-context) (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context) + (file-acl . tramp-sh-handle-file-acl) + (set-file-acl . tramp-sh-handle-set-file-acl) (vc-registered . tramp-sh-handle-vc-registered)) "Alist of handler functions. Operations not mentioned here will be handled by the normal Emacs functions.") @@ -1532,6 +1534,39 @@ ;; We always return nil. nil) +(defun tramp-remote-acl-p (vec) + "Check, whether ACL is enabled on the remote host." + (with-tramp-connection-property (tramp-get-connection-process vec) "acl-p" + (tramp-send-command-and-check vec "getfacl /"))) + +(defun tramp-sh-handle-file-acl (filename) + "Like `file-acl' for Tramp files." + (with-parsed-tramp-file-name filename nil + (with-tramp-file-property v localname "file-acl" + (when (and (tramp-remote-acl-p v) + (tramp-send-command-and-check + v (format + "getfacl -ac %s 2>/dev/null" + (tramp-shell-quote-argument localname)))) + (with-current-buffer (tramp-get-connection-buffer v) + (buffer-string)))))) + +(defun tramp-sh-handle-set-file-acl (filename acl-string) + "Like `set-file-acl' for Tramp files." + (with-parsed-tramp-file-name filename nil + (if (and (stringp acl-string) + (tramp-remote-acl-p v) + (tramp-send-command-and-check + v + (format "setfacl --set-file=- %s <<'EOF'\n%s\nEOF\n" + (tramp-shell-quote-argument localname) + acl-string) + t)) + (tramp-set-file-property v localname "file-acl" acl-string) + (tramp-set-file-property v localname "file-acl-string" 'undef))) + ;; We always return nil. + nil) + ;; Simple functions using the `test' command. (defun tramp-sh-handle-file-executable-p (filename) @@ -1883,7 +1918,7 @@ (defun tramp-sh-handle-copy-file (filename newname &optional ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context) + preserve-uid-gid preserve-extended-attributes) "Like `copy-file' for Tramp files." (setq filename (expand-file-name filename)) (setq newname (expand-file-name newname)) @@ -1893,13 +1928,13 @@ (tramp-tramp-file-p newname)) (tramp-do-copy-or-rename-file 'copy filename newname ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context)) + preserve-uid-gid preserve-extended-attributes)) ;; Compat section. - (preserve-selinux-context + (preserve-extended-attributes (tramp-run-real-handler 'copy-file (list filename newname ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context))) + preserve-uid-gid preserve-extended-attributes))) (preserve-uid-gid (tramp-run-real-handler 'copy-file @@ -1962,7 +1997,7 @@ (defun tramp-do-copy-or-rename-file (op filename newname &optional ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context) + preserve-uid-gid preserve-extended-attributes) "Copy or rename a remote file. OP must be `copy' or `rename' and indicates the operation to perform. FILENAME specifies the file to copy or rename, NEWNAME is the name of @@ -1971,7 +2006,7 @@ KEEP-DATE means to make sure that NEWNAME has the same timestamp as FILENAME. PRESERVE-UID-GID, when non-nil, instructs to keep the uid and gid if both files are on the same host. -PRESERVE-SELINUX-CONTEXT activates selinux commands. +PRESERVE-EXTENDED-ATTRIBUTES activates selinux and acl commands. This function is invoked by `tramp-sh-handle-copy-file' and `tramp-sh-handle-rename-file'. It is an error if OP is neither @@ -1982,8 +2017,8 @@ (let ((t1 (tramp-tramp-file-p filename)) (t2 (tramp-tramp-file-p newname)) (length (nth 7 (file-attributes (file-truename filename)))) - (context (and preserve-selinux-context - (apply 'file-selinux-context (list filename)))) + (attributes (and preserve-extended-attributes + (apply 'file-extended-attributes (list filename)))) pr tm) (with-parsed-tramp-file-name (if t1 filename newname) nil @@ -2053,8 +2088,9 @@ ;; One of them must be a Tramp file. (error "Tramp implementation says this cannot happen"))) - ;; Handle `preserve-selinux-context'. - (when context (apply 'set-file-selinux-context (list newname context))) + ;; Handle `preserve-extended-attributes'. + (when attributes + (apply 'set-file-extended-attributes (list newname attributes))) ;; In case of `rename', we must flush the cache of the source file. (when (and t1 (eq op 'rename)) === modified file 'lisp/net/tramp-smb.el' --- lisp/net/tramp-smb.el 2012-12-14 09:02:34 +0000 +++ lisp/net/tramp-smb.el 2012-12-17 14:38:07 +0000 @@ -195,6 +195,7 @@ (dired-uncache . tramp-handle-dired-uncache) (expand-file-name . tramp-smb-handle-expand-file-name) (file-accessible-directory-p . tramp-smb-handle-file-directory-p) + (file-acl . ignore) (file-attributes . tramp-smb-handle-file-attributes) (file-directory-p . tramp-smb-handle-file-directory-p) (file-executable-p . tramp-handle-file-exists-p) @@ -227,6 +228,7 @@ (make-symbolic-link . tramp-smb-handle-make-symbolic-link) (process-file . tramp-smb-handle-process-file) (rename-file . tramp-smb-handle-rename-file) + (set-file-acl . ignore) (set-file-modes . tramp-smb-handle-set-file-modes) ;; `set-file-selinux-context' performed by default handler. (set-file-times . ignore) @@ -487,10 +489,10 @@ (defun tramp-smb-handle-copy-file (filename newname &optional ok-if-already-exists keep-date - preserve-uid-gid preserve-selinux-context) + preserve-uid-gid preserve-extended-attributes) "Like `copy-file' for Tramp files. KEEP-DATE has no effect in case NEWNAME resides on an SMB server. -PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored." +PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (setq filename (expand-file-name filename) newname (expand-file-name newname)) (with-tramp-progress-reporter @@ -1813,5 +1815,6 @@ ;; * Try to remove the inclusion of dummy "" directory. Seems to be at ;; several places, especially in `tramp-smb-handle-insert-directory'. ;; * Ignore case in file names. +;; * Implement `tramp-smb-handle-file-acl' for proper Samba versions. ;;; tramp-smb.el ends here === modified file 'lisp/net/tramp.el' --- lisp/net/tramp.el 2012-12-06 09:15:27 +0000 +++ lisp/net/tramp.el 2012-12-17 14:38:07 +0000 @@ -1879,7 +1879,8 @@ ;; Emacs 22+ only. 'set-file-times ;; Emacs 24+ only. - 'file-selinux-context 'set-file-selinux-context + 'file-acl 'file-selinux-context + 'set-file-acl 'set-file-selinux-context ;; XEmacs only. 'abbreviate-file-name 'create-file-buffer 'dired-file-modtime 'dired-make-compressed-filename ------------------------------------------------------------ revno: 111255 committer: Glenn Morris branch nick: trunk timestamp: Mon 2012-12-17 06:17:34 -0500 message: Auto-commit of generated files. diff: === modified file 'autogen/Makefile.in' --- autogen/Makefile.in 2012-12-13 05:29:15 +0000 +++ autogen/Makefile.in 2012-12-17 11:17:34 +0000 @@ -543,6 +543,7 @@ LD_SWITCH_SYSTEM_TEMACS = @LD_SWITCH_SYSTEM_TEMACS@ LD_SWITCH_X_SITE = @LD_SWITCH_X_SITE@ LD_SWITCH_X_SITE_RPATH = @LD_SWITCH_X_SITE_RPATH@ +LIBACL_LIBS = @LIBACL_LIBS@ LIBGIF = @LIBGIF@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ === modified file 'autogen/config.in' --- autogen/config.in 2012-12-15 11:17:30 +0000 +++ autogen/config.in 2012-12-17 11:17:34 +0000 @@ -716,6 +716,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_PNG_H +/* Define to 1 if using POSIX ACL support. */ +#undef HAVE_POSIX_ACL + /* Define to 1 if you have the `posix_memalign' function. */ #undef HAVE_POSIX_MEMALIGN === modified file 'autogen/configure' --- autogen/configure 2012-12-15 11:17:30 +0000 +++ autogen/configure 2012-12-17 11:17:34 +0000 @@ -1201,6 +1201,7 @@ FONTCONFIG_CFLAGS LIBXMU LIBXTR6 +LIBACL_LIBS LIBGNUTLS_LIBS LIBGNUTLS_CFLAGS LIBSELINUX_LIBS @@ -1395,6 +1396,7 @@ with_gconf with_gsettings with_selinux +with_acl with_gnutls with_inotify with_makeinfo @@ -2118,6 +2120,7 @@ --without-gconf don't compile with GConf support --without-gsettings don't compile with GSettings support --without-selinux don't compile with SELinux support + --without-acl don't compile with ACL support --without-gnutls don't use -lgnutls for SSL/TLS support --without-inotify don't compile with inotify (file-watch) support --without-makeinfo don't require makeinfo for building manuals @@ -4174,6 +4177,14 @@ fi +# Check whether --with-acl was given. +if test "${with_acl+set}" = set; then : + withval=$with_acl; +else + with_acl=$with_features +fi + + # Check whether --with-gnutls was given. if test "${with_gnutls+set}" = set; then : withval=$with_gnutls; @@ -11489,6 +11500,73 @@ fi +HAVE_POSIX_ACL=no +LIBACL_LIBS= +if test "${with_acl}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for acl_set_file in -lacl" >&5 +$as_echo_n "checking for acl_set_file in -lacl... " >&6; } +if test "${ac_cv_lib_acl_acl_set_file+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lacl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char acl_set_file (); +int +main () +{ +return acl_set_file (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_acl_acl_set_file=yes +else + ac_cv_lib_acl_acl_set_file=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_acl_acl_set_file" >&5 +$as_echo "$ac_cv_lib_acl_acl_set_file" >&6; } +if test "x$ac_cv_lib_acl_acl_set_file" = x""yes; then : + HAVE_POSIX_ACL=yes +else + HAVE_POSIX_ACL=no +fi + + if test "$HAVE_POSIX_ACL" = yes; then + +$as_echo "#define HAVE_POSIX_ACL 1" >>confdefs.h + + LIBACL_LIBS=-lacl + else + ac_fn_c_check_func "$LINENO" "acl_set_file" "ac_cv_func_acl_set_file" +if test "x$ac_cv_func_acl_set_file" = x""yes; then : + HAVE_POSIX_ACL=yes +else + HAVE_POSIX_ACL=no +fi + + if test "$HAVE_POSIX_ACL" = yes; then + +$as_echo "#define HAVE_POSIX_ACL 1" >>confdefs.h + + fi + fi +fi + + HAVE_XAW3D=no LUCID_LIBW= if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then ------------------------------------------------------------ revno: 111254 author: Kelly Dean committer: martin rudalics branch nick: trunk timestamp: Mon 2012-12-17 08:54:57 +0100 message: Fix some interactions of make-help-screen and other Help forms (Bug#13190). * help-macro.el (make-help-screen): Instead of switch-to-buffer use pop-to-buffer with NORECORD argument t. As buffer name use *Metahelp* with a leading space (Bug#13190). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-12-16 18:22:27 +0000 +++ lisp/ChangeLog 2012-12-17 07:54:57 +0000 @@ -1,3 +1,9 @@ +2012-12-17 Kelly Dean (tiny change) + + * help-macro.el (make-help-screen): Instead of switch-to-buffer + use pop-to-buffer with NORECORD argument t. As buffer name use + *Metahelp* with a leading space (Bug#13190). + 2012-12-16 Romain Francoise * files.el (file-extended-attributes) === modified file 'lisp/help-macro.el' --- lisp/help-macro.el 2012-10-03 16:15:04 +0000 +++ lisp/help-macro.el 2012-12-17 07:54:57 +0000 @@ -134,7 +134,7 @@ (when (or (eq char ??) (eq char help-char) (memq char help-event-list)) (setq config (current-window-configuration)) - (switch-to-buffer-other-window "*Help*") + (pop-to-buffer " *Metahelp*" nil t) (and (fboundp 'make-frame) (not (eq (window-frame (selected-window)) prev-frame))