Now on revision 106821. ------------------------------------------------------------ revno: 106821 [merge] fixes bug(s): http://debbugs.gnu.org/10400 http://debbugs.gnu.org/10401 committer: Paul Eggert branch nick: trunk timestamp: Sat 2012-01-07 12:03:28 -0800 message: Fix two security races with file permissions. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-01-07 06:00:56 +0000 +++ lisp/ChangeLog 2012-01-07 20:00:56 +0000 @@ -1,3 +1,8 @@ +2012-01-07 Paul Eggert + + * files.el (move-file-to-trash): Preserve default file modes on error. + (Bug#10401) + 2012-01-07 Lars Magne Ingebrigtsen * faces.el (set-face-attribute): Clarify the meaning of the nil === modified file 'lisp/files.el' --- lisp/files.el 2012-01-06 10:53:41 +0000 +++ lisp/files.el 2012-01-07 19:51:13 +0000 @@ -6461,12 +6461,14 @@ ;; Ensure that the trash directory exists; otherwise, create it. (let ((saved-default-file-modes (default-file-modes))) - (set-default-file-modes ?\700) - (unless (file-exists-p trash-files-dir) - (make-directory trash-files-dir t)) - (unless (file-exists-p trash-info-dir) - (make-directory trash-info-dir t)) - (set-default-file-modes saved-default-file-modes)) + (unwind-protect + (progn + (set-default-file-modes #o700) + (unless (file-exists-p trash-files-dir) + (make-directory trash-files-dir t)) + (unless (file-exists-p trash-info-dir) + (make-directory trash-info-dir t))) + (set-default-file-modes saved-default-file-modes))) ;; Try to move to trash with .trashinfo undo information (save-excursion === modified file 'src/ChangeLog' --- src/ChangeLog 2012-01-07 11:57:48 +0000 +++ src/ChangeLog 2012-01-07 19:51:13 +0000 @@ -1,3 +1,15 @@ +2012-01-07 Paul Eggert + + emacs: fix an auto-save permissions race condition (Bug#10400) + * fileio.c (auto_saving_dir_umask): New static var. + (Fmake_directory_internal): Use it. + (do_auto_save_make_dir): Set it, instead of invoking chmod after + creating the directory. The old code temporarily assigns + too-generous permissions to the directory. + (do_auto_save_eh): Clear it. + (Fdo_auto_save): Catch all errors, not just file errors, so + that the var is always cleared. + 2012-01-07 Eli Zaretskii * search.c (scan_buffer): Pass character positions to === modified file 'src/fileio.c' --- src/fileio.c 2012-01-05 09:46:05 +0000 +++ src/fileio.c 2012-01-07 19:51:13 +0000 @@ -90,6 +90,9 @@ /* Nonzero during writing of auto-save files */ static int auto_saving; +/* Nonzero umask during creation of auto-save directories */ +static int auto_saving_dir_umask; + /* Set by auto_save_1 to mode of original file so Fwrite_region will create a new file with the same mode as the original */ static int auto_save_mode_bits; @@ -2062,7 +2065,7 @@ #ifdef WINDOWSNT if (mkdir (dir) != 0) #else - if (mkdir (dir, 0777) != 0) + if (mkdir (dir, 0777 & ~auto_saving_dir_umask) != 0) #endif report_file_error ("Creating directory", list1 (directory)); @@ -5205,16 +5208,18 @@ static Lisp_Object do_auto_save_make_dir (Lisp_Object dir) { - Lisp_Object mode; + Lisp_Object result; - call2 (Qmake_directory, dir, Qt); - XSETFASTINT (mode, 0700); - return Fset_file_modes (dir, mode); + auto_saving_dir_umask = 077; + result = call2 (Qmake_directory, dir, Qt); + auto_saving_dir_umask = 0; + return result; } static Lisp_Object do_auto_save_eh (Lisp_Object ignore) { + auto_saving_dir_umask = 0; return Qnil; } @@ -5282,7 +5287,7 @@ dir = Ffile_name_directory (listfile); if (NILP (Ffile_directory_p (dir))) internal_condition_case_1 (do_auto_save_make_dir, - dir, Fcons (Fcons (Qfile_error, Qnil), Qnil), + dir, Qt, do_auto_save_eh); UNGCPRO; } ------------------------------------------------------------ revno: 106820 fixes bug(s): http://debbugs.gnu.org/6540 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2012-01-07 13:57:48 +0200 message: Fix bug #6540 with a crash while inserting non-ASCII text under cache-long-line-scans. src/search.c (scan_buffer): Pass character positions to know_region_cache, not byte positions. (Bug#6540) diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-01-07 09:50:57 +0000 +++ src/ChangeLog 2012-01-07 11:57:48 +0000 @@ -1,3 +1,8 @@ +2012-01-07 Eli Zaretskii + + * search.c (scan_buffer): Pass character positions to + know_region_cache, not byte positions. (Bug#6540) + 2012-01-07 LynX <_LynX@bk.ru> (tiny change) * w32.c (sys_rename): Report EXDEV when rename of a directory === modified file 'src/search.c' --- src/search.c 2012-01-05 09:46:05 +0000 +++ src/search.c 2012-01-07 11:57:48 +0000 @@ -725,8 +725,8 @@ the region from start to cursor is free of them. */ if (target == '\n' && newline_cache) know_region_cache (current_buffer, newline_cache, - start_byte + scan_start - base, - start_byte + cursor - base); + BYTE_TO_CHAR (start_byte + scan_start - base), + BYTE_TO_CHAR (start_byte + cursor - base)); /* Did we find the target character? */ if (cursor < ceiling_addr) @@ -791,8 +791,8 @@ the region from after the cursor to start is free of them. */ if (target == '\n' && newline_cache) know_region_cache (current_buffer, newline_cache, - start_byte + cursor - base, - start_byte + scan_start - base); + BYTE_TO_CHAR (start_byte + cursor - base), + BYTE_TO_CHAR (start_byte + scan_start - base)); /* Did we find the target character? */ if (cursor >= ceiling_addr) ------------------------------------------------------------ revno: 106819 author: Lars Magne Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Sat 2012-01-07 11:46:47 +0000 message: shr.el (shr-visit-file): Move point to the beginning of the buffer after rendering. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2012-01-07 04:52:56 +0000 +++ lisp/gnus/ChangeLog 2012-01-07 11:46:47 +0000 @@ -1,5 +1,10 @@ 2012-01-07 Lars Magne Ingebrigtsen + * shr.el (shr-visit-file): Move point to the beginning of the buffer + after rendering. + +2012-01-07 Lars Magne Ingebrigtsen + * gnus-sum.el (gnus-summary-read-group): Document more parameters (bug#9693). (gnus-summary-setup-buffer): Document return value (bug#9697). === modified file 'lisp/gnus/shr.el' --- lisp/gnus/shr.el 2012-01-04 10:49:38 +0000 +++ lisp/gnus/shr.el 2012-01-07 11:46:47 +0000 @@ -134,7 +134,8 @@ (shr-insert-document (with-temp-buffer (insert-file-contents file) - (libxml-parse-html-region (point-min) (point-max))))) + (libxml-parse-html-region (point-min) (point-max)))) + (goto-char (point-min))) ;;;###autoload (defun shr-insert-document (dom) ------------------------------------------------------------ revno: 106818 fixes bug(s): http://debbugs.gnu.org/10284 author: LynX <_LynX@bk.ru> committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2012-01-07 11:50:57 +0200 message: Fix bug #10284 with renaming a directory on MS-Windows. src/w32.c (sys_rename): Report EXDEV when rename of a directory fails because the target is on another logical disk. (Bug#10284) diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-01-07 07:02:06 +0000 +++ src/ChangeLog 2012-01-07 09:50:57 +0000 @@ -1,3 +1,8 @@ +2012-01-07 LynX <_LynX@bk.ru> (tiny change) + + * w32.c (sys_rename): Report EXDEV when rename of a directory + fails because the target is on another logical disk. (Bug#10284) + 2012-01-07 David Benjamin (tiny change) * xterm.c (x_embed_request_focus): New function. === modified file 'src/w32.c' --- src/w32.c 2012-01-05 09:46:05 +0000 +++ src/w32.c 2012-01-07 09:50:57 +0000 @@ -2894,6 +2894,8 @@ { BOOL result; char temp[MAX_PATH]; + int newname_dev; + int oldname_dev; /* MoveFile on Windows 95 doesn't correctly change the short file name alias in a number of circumstances (it is not easy to predict when @@ -2910,6 +2912,9 @@ strcpy (temp, map_w32_filename (oldname, NULL)); + /* volume_info is set indirectly by map_w32_filename. */ + oldname_dev = volume_info.serialnum; + if (os_subtype == OS_WIN95) { char * o; @@ -2953,13 +2958,38 @@ all the permutations of shared or subst'd drives, etc.) */ newname = map_w32_filename (newname, NULL); + + /* volume_info is set indirectly by map_w32_filename. */ + newname_dev = volume_info.serialnum; + result = rename (temp, newname); - if (result < 0 - && errno == EEXIST - && _chmod (newname, 0666) == 0 - && _unlink (newname) == 0) - result = rename (temp, newname); + if (result < 0) + { + + if (errno == EACCES + && newname_dev != oldname_dev) + { + /* The implementation of `rename' on Windows does not return + errno = EXDEV when you are moving a directory to a + different storage device (ex. logical disk). It returns + EACCES instead. So here we handle such situations and + return EXDEV. */ + DWORD attributes; + + if ((attributes = GetFileAttributes (temp)) != -1 + && attributes & FILE_ATTRIBUTE_DIRECTORY) + errno = EXDEV; + } + else if (errno == EEXIST) + { + if (_chmod (newname, 0666) != 0) + return result; + if (_unlink (newname) != 0) + return result; + result = rename (temp, newname); + } + } return result; } ------------------------------------------------------------ revno: 106817 fixes bug(s): http://debbugs.gnu.org/10300 committer: Chong Yidong branch nick: trunk timestamp: Sat 2012-01-07 16:55:43 +0800 message: Document Whitespace mode in manual, plus its use in Diff mode. * doc/emacs/display.texi (Useless Whitespace): Add Whitespace mode. * doc/emacs/files.texi (Diff Mode): Discuss use of Whitespace mode. diff: === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2012-01-07 08:12:27 +0000 +++ doc/emacs/ChangeLog 2012-01-07 08:55:43 +0000 @@ -1,9 +1,11 @@ 2012-01-07 Chong Yidong + * display.texi (Useless Whitespace): Add Whitespace mode. + * custom.texi (Hooks): Discuss how to disable minor modes. * files.texi (Diff Mode): Discuss diff-auto-refine-mode - (Bug#10309). + (Bug#10309). Discuss use of Whitespace mode (Bug#10300). * trouble.texi (Lossage): Refer to Bugs node for problems. (DEL Does Not Delete): Don't use "usual erasure key" teminology. === modified file 'doc/emacs/display.texi' --- doc/emacs/display.texi 2012-01-05 09:46:05 +0000 +++ doc/emacs/display.texi 2012-01-07 08:55:43 +0000 @@ -1062,6 +1062,56 @@ default value of this variable, e.g.@: @code{(setq-default indicate-empty-lines t)}. +@cindex Whitespace mode +@cindex mode, Whitespace +@findex whitespace-mode +@vindex whitespace-style + Whitespace mode is a buffer-local minor mode that lets you +``visualize'' many kinds of whitespace in the buffer, by either +drawing the whitespace characters with a special face or displaying +them as special glyphs. To toggle this mode, type @kbd{M-x +whitespace-mode}. The kinds of whitespace visualized are determined +by the list variable @code{whitespace-style}. Here is a partial list +of possible elements (see the variable's documentation for the full +list): + +@table @code +@item face +Enable all visualizations which use special faces. This element has a +special meaing: if it is absent from the list, none of the other +visualizations take effect except @code{space-mark}, @code{tab-mark}, +and @code{newline-mark}. + +@item trailing +Highlight trailing whitespace. + +@item tabs +Highlight tab characters. + +@item spaces +Highlight space and non-breaking space characters. + +@item lines +@vindex whitespace-line-column +Highlight lines longer than 80 lines. To change the column limit, +customize the variable @code{whitespace-line-column}. + +@item newline +Highlight newlines. + +@item empty +Highlight empty lines. + +@item space-mark +Draw space and non-breaking characters with a special glyph. + +@item tab-mark +Draw tab characters with a special glyph. + +@item newline-mark +Draw newline characters with a special glyph. +@end table + @node Selective Display @section Selective Display @cindex selective display === modified file 'doc/emacs/files.texi' --- doc/emacs/files.texi 2012-01-07 08:14:45 +0000 +++ doc/emacs/files.texi 2012-01-07 08:55:43 +0000 @@ -1463,13 +1463,14 @@ operates on behalf of the current hunk's file, but gets the function name from the patch itself. This is useful for making log entries for functions that are deleted by the patch. - -@item M-x diff-show-trailing-whitespaces RET -@findex diff-show-trailing-whitespaces -Highlight trailing whitespace characters, except for those used by the -patch syntax (@pxref{Useless Whitespace}). @end table + By default, Diff mode highlights trailing whitespace on modified +lines, so that they are more obvious. This is done by enabling +Whitespace mode in the Diff buffer (@pxref{Useless Whitespace}). Diff +mode buffers are set up so that Whitespace mode avoids highlighting +trailing whitespace occurring in the diff context. + @node Misc File Ops @section Miscellaneous File Operations ------------------------------------------------------------ revno: 106816 committer: Chong Yidong branch nick: trunk timestamp: Sat 2012-01-07 16:14:45 +0800 message: Fix last change. diff: === modified file 'doc/emacs/files.texi' --- doc/emacs/files.texi 2012-01-07 08:12:27 +0000 +++ doc/emacs/files.texi 2012-01-07 08:14:45 +0000 @@ -1363,7 +1363,7 @@ @example (add-hook 'diff-mode-hook - (lambda () (diff-auto-refine-hook -1))) + (lambda () (diff-auto-refine-mode -1))) @end example @item M-p ------------------------------------------------------------ revno: 106815 fixes bug(s): http://debbugs.gnu.org/10309 committer: Chong Yidong branch nick: trunk timestamp: Sat 2012-01-07 16:12:27 +0800 message: * doc/emacs/files.texi (Diff Mode): Discuss diff-auto-refine-mode. * doc/emacs/custom.texi (Hooks): Discuss how to disable minor modes. diff: === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2012-01-07 03:15:48 +0000 +++ doc/emacs/ChangeLog 2012-01-07 08:12:27 +0000 @@ -1,5 +1,10 @@ 2012-01-07 Chong Yidong + * custom.texi (Hooks): Discuss how to disable minor modes. + + * files.texi (Diff Mode): Discuss diff-auto-refine-mode + (Bug#10309). + * trouble.texi (Lossage): Refer to Bugs node for problems. (DEL Does Not Delete): Don't use "usual erasure key" teminology. (Screen Garbled): Don't refer to terminal "manufacturers". === modified file 'doc/emacs/custom.texi' --- doc/emacs/custom.texi 2012-01-06 10:53:41 +0000 +++ doc/emacs/custom.texi 2012-01-07 08:12:27 +0000 @@ -857,17 +857,34 @@ Most major modes run one or more @dfn{mode hooks} as the last step of initialization. Mode hooks are a convenient way to customize the behavior of individual modes; they are always normal. For example, -here's how to set up a hook to turn on Auto Fill mode when entering -Text mode and other modes based on Text mode: +here's how to set up a hook to turn on Auto Fill mode in Text mode and +other modes based on Text mode: @example (add-hook 'text-mode-hook 'auto-fill-mode) @end example - Here is another example, showing how to use a hook to customize the -indentation of C code. The hook function uses an anonymous lambda -expression (@pxref{Lambda Expressions,,, elisp, The Emacs Lisp -Reference Manual}). +@noindent +This works by calling @code{auto-fill-mode}, which enables the minor +mode when no argument is supplied (@pxref{Minor Modes}). Next, +suppose you don't want Auto Fill mode turned on in La@TeX{} mode, +which is one of the modes based on Text mode. You can do this with +the following additional line: + +@example +(add-hook 'latex-mode-hook (lambda () (auto-fill-mode -1))) +@end example + +@noindent +Here we have used the special macro @code{lambda} to construct an +anonymous function (@pxref{Lambda Expressions,,, elisp, The Emacs Lisp +Reference Manual}), which calls @code{auto-fill-mode} with an argument +of @code{-1} to disable the minor mode. Because La@TeX{} mode runs +@code{latex-mode-hook} after running @code{text-mode-hook}, the result +leaves Auto Fill mode disabled. + + Here is a more complex example, showing how to use a hook to +customize the indentation of C code: @example @group === modified file 'doc/emacs/files.texi' --- doc/emacs/files.texi 2012-01-05 09:46:05 +0000 +++ doc/emacs/files.texi 2012-01-07 08:12:27 +0000 @@ -1352,9 +1352,25 @@ @findex diff-hunk-next Move to the next hunk-start (@code{diff-hunk-next}). +@findex diff-auto-refine-mode +@cindex mode, Diff Auto-Refine +@cindex Diff Auto-Refine mode +This command has a side effect: it @dfn{refines} the hunk you move to, +highlighting its changes with better granularity. To disable this +feature, type @kbd{M-x diff-auto-refine-mode} to toggle off the minor +mode Diff Auto-Refine mode. To disable Diff Auto Refine mode by +default, add this to your init file (@pxref{Hooks}): + +@example +(add-hook 'diff-mode-hook + (lambda () (diff-auto-refine-hook -1))) +@end example + @item M-p @findex diff-hunk-prev -Move to the previous hunk-start (@code{diff-hunk-prev}). +Move to the previous hunk-start (@code{diff-hunk-prev}). Like +@kbd{M-n}, this has the side-effect of refining the hunk you move to, +unless you disable Diff Auto-Refine mode. @item M-@} @findex diff-file-next @@ -1454,7 +1470,6 @@ patch syntax (@pxref{Useless Whitespace}). @end table - @node Misc File Ops @section Miscellaneous File Operations ------------------------------------------------------------ revno: 106814 fixes bug(s): http://debbugs.gnu.org/9977 author: David Benjamin committer: Chong Yidong branch nick: trunk timestamp: Sat 2012-01-07 15:02:06 +0800 message: Fix focus handling for embedded frames. * xfns.c (Fx_focus_frame): Use it for embedded frames. * xterm.c (x_embed_request_focus): New function. * xterm.h: Add prototype. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-01-05 09:46:05 +0000 +++ src/ChangeLog 2012-01-07 07:02:06 +0000 @@ -1,3 +1,11 @@ +2012-01-07 David Benjamin (tiny change) + + * xterm.c (x_embed_request_focus): New function. + + * xterm.h: Add prototype. + + * xfns.c (Fx_focus_frame): Use it for embedded frames (Bug#9977). + 2012-01-05 Glenn Morris * emacs.c (emacs_copyright): Update short copyright year to 2012. === modified file 'src/xfns.c' --- src/xfns.c 2012-01-05 09:46:05 +0000 +++ src/xfns.c 2012-01-07 07:02:06 +0000 @@ -3519,9 +3519,21 @@ BLOCK_INPUT; x_catch_errors (dpy); - XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - RevertToParent, CurrentTime); - x_ewmh_activate_frame (f); + + if (FRAME_X_EMBEDDED_P (f)) + { + /* For Xembedded frames, normally the embedder forwards key + events. See XEmbed Protocol Specification at + http://freedesktop.org/wiki/Specifications/xembed-spec */ + xembed_request_focus (f); + } + else + { + XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), + RevertToParent, CurrentTime); + x_ewmh_activate_frame (f); + } + x_uncatch_errors (); UNBLOCK_INPUT; === modified file 'src/xterm.c' --- src/xterm.c 2012-01-05 09:46:05 +0000 +++ src/xterm.c 2012-01-07 07:02:06 +0000 @@ -8981,6 +8981,18 @@ } } +/* Request focus with XEmbed */ + +void +xembed_request_focus (FRAME_PTR f) +{ + /* See XEmbed Protocol Specification at + http://freedesktop.org/wiki/Specifications/xembed-spec */ + if (f->async_visible) + xembed_send_message (f, CurrentTime, + XEMBED_REQUEST_FOCUS, 0, 0, 0); +} + /* Activate frame with Extended Window Manager Hints */ void === modified file 'src/xterm.h' --- src/xterm.h 2012-01-05 09:46:05 +0000 +++ src/xterm.h 2012-01-07 07:02:06 +0000 @@ -967,6 +967,7 @@ extern void x_set_window_size (struct frame *, int, int, int); extern void x_set_mouse_position (struct frame *, int, int); extern void x_set_mouse_pixel_position (struct frame *, int, int); +extern void xembed_request_focus (struct frame *); extern void x_ewmh_activate_frame (struct frame *); extern void x_make_frame_visible (struct frame *); extern void x_make_frame_invisible (struct frame *); ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.