bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28875: 25.3.50; set-default-file-modes ignores execution bits


From: Tino Calancha
Subject: bug#28875: 25.3.50; set-default-file-modes ignores execution bits
Date: Fri, 20 Oct 2017 12:10:18 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Tino Calancha <address@hidden> writes:

> On Tue, 17 Oct 2017, Andreas Schwab wrote:
>
>> On Okt 17 2017, Tino Calancha <address@hidden> wrote:
>>
>>> emacs -Q:
>>> (let ((foo (make-temp-file "foo")) mode)
>>>   (with-file-modes #o755 (write-region "" nil foo nil 0))
>>>   ;; (set-file-modes foo #o755)
>>>   (setq mode (nth 8 (file-attributes foo)))
>>>   (delete-file foo) mode)
>>> => "-rw-------"
>>>
>>> To set foo file permissions to "-rwxr-xr-x" I need uncomment
>>> (set-file-modes foo #o755) above.
>>> Why? Is for security reasons?
>>
>> make-temp-file already creates the file (with restrictive modes), so
>> with-file-modes has no effect (write-region does not change the mode of
>> existing files).  But write-region also never sets the x bits in the
>> first place, it uses #o666 as the base mode.
>>
> I think I was fooled by the docstring of `set-default-file-modes':
> "Set the file permission bits for newly created files..."
Besides the behavior is mentioned in the manual, that is relevant
for the correct use of the function, so IMO it's worth to include it
the docstring as well.

--8<-----------------------------cut here---------------start------------->8---
commit d749ad1ca0375a938c0283155b56e737cc120640
Author: Tino Calancha <address@hidden>
Date:   Fri Oct 20 11:58:17 2017 +0900

    * src/fileio.c (set-default-file-modes): Doc fix

diff --git a/src/fileio.c b/src/fileio.c
index b7df38c857..d707bfc1c6 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3125,7 +3125,11 @@ symbolic notation, like the `chmod' command from GNU 
Coreutils.  */)
 DEFUN ("set-default-file-modes", Fset_default_file_modes, 
Sset_default_file_modes, 1, 1, 0,
        doc: /* Set the file permission bits for newly created files.
 The argument MODE should be an integer; only the low 9 bits are used.
-This setting is inherited by subprocesses.  */)
+This setting is inherited by subprocesses.
+
+Note that some functions (e.g., `write-region') ignore the execution
+bits in MODE.  In that case you need first to create the file,
+and then set the permisions with `set-file-modes'.  */)
   (Lisp_Object mode)
 {
   mode_t oldrealmask, oldumask, newumask;

--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.90 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-10-20
Repository revision: ddd547fada112c603dae7a204fa0b141429f1927





reply via email to

[Prev in Thread] Current Thread [Next in Thread]