From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#28875: 25.3.50; set-default-file-modes ignores execution bits Date: Fri, 20 Oct 2017 12:10:18 +0900 Message-ID: <878tg6ecpx.fsf@gmail.com> References: <87vajd2a1v.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1508469080 21221 195.159.176.226 (20 Oct 2017 03:11:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2017 03:11:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Andreas Schwab To: 28875@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 20 05:11:16 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5NiK-0004Zx-5t for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Oct 2017 05:11:12 +0200 Original-Received: from localhost ([::1]:52002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5NiR-0000SB-IT for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Oct 2017 23:11:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5NiF-0000Qz-TW for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 23:11:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5NiA-0006cX-Ux for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 23:11:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5NiA-0006cR-RB for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 23:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e5NiA-0002ra-Hz for bug-gnu-emacs@gnu.org; Thu, 19 Oct 2017 23:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Oct 2017 03:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28875 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28875-submit@debbugs.gnu.org id=B28875.150846903310964 (code B ref 28875); Fri, 20 Oct 2017 03:11:02 +0000 Original-Received: (at 28875) by debbugs.gnu.org; 20 Oct 2017 03:10:33 +0000 Original-Received: from localhost ([127.0.0.1]:50934 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5Nhg-0002qm-PQ for submit@debbugs.gnu.org; Thu, 19 Oct 2017 23:10:33 -0400 Original-Received: from mail-pf0-f180.google.com ([209.85.192.180]:51875) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5Nhf-0002qV-68 for 28875@debbugs.gnu.org; Thu, 19 Oct 2017 23:10:31 -0400 Original-Received: by mail-pf0-f180.google.com with SMTP id n14so8964046pfh.8 for <28875@debbugs.gnu.org>; Thu, 19 Oct 2017 20:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2FQx8+uotCIRPJaKw0wY2xgEOPy+IIEo2EQRpPd4Spo=; b=qr+l1YqSvKV3Bb9NaoSxxZSkXLGULTbqR7yEKmMMk+LkfDKVz+tSGuF5vTd4Eo3TaZ txeHJAMLzptfQzFEDg6jdLvx2VTMurMofQfoYHP+aSHZaEUZzApmW86X0RyA/QEHT/XI s0C9K2AU4FNHNtuLvkUg09MYypgrOBzCgNdemPT8OMjbjHApSrmonA1J10G+RCkgetQA SqXO0DhRvNOqo4ltJPlZGw6ywDE7j7hJAqlv7qa6P9oxRtRzKZNAlZVEaDUmEn3me5hH p8CiTBlZGAcZloslFUQGY6yXUMGXyfkf7DddNLiu2K6b6RYEd5/sh5rhsTZOnk1DoT6M g8sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=2FQx8+uotCIRPJaKw0wY2xgEOPy+IIEo2EQRpPd4Spo=; b=CpvFNSxwHppeu+gJeNsqtQ6TnW9yRKNGuFCAU7Eo4iTooI1Kuu+4txzRVt6USGkKoC YFk9p99zzI4LoJovuwU2D1FXX62yvURVvBKy3DwKwc8ZcyXrpxKizHDs+W7ozscnjw5E A+o4bGCk6TEa5C1HdDWLxrdZYHbVetXdGrYq3Ea8yEcWBsEfYOjUu3duXCQ3WAvCVqiV TUvgYbWd8kKRKThNtkSwzs1+cD7Me2ygmUvBr+hZg/O7GRy7EagJSvfixJ412nxk6eBl pkVT+H03C9X9OMB9Nop6iO1Zx5H32xgKZTzJWKv90BGXx+mEfq7WiFnxmmVBo1eqk7yf D3Dg== X-Gm-Message-State: AMCzsaWsbwzkt9uWOeZqIfA8jOsurd1q3vsutIXLaSe2TPqeoQgN6iti /Rl3HGpqIyrogCIP8X5/HLY= X-Google-Smtp-Source: ABhQp+R3rV+r7bAlt0hO9BBEC6KyfDfYBgwV8WwsF8IxDbmt4kdO6QYylZzbkO6OflqgFGp3vVYqhw== X-Received: by 10.84.241.207 with SMTP id t15mr3038543plm.158.1508469025222; Thu, 19 Oct 2017 20:10:25 -0700 (PDT) Original-Received: from calancha-pc (203.191.218.133.dy.bbexcite.jp. [133.218.191.203]) by smtp.gmail.com with ESMTPSA id s17sm22816504pgq.25.2017.10.19.20.10.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 20:10:24 -0700 (PDT) In-Reply-To: (Tino Calancha's message of "Tue, 17 Oct 2017 23:25:07 +0900 (JST)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138740 Archived-At: Tino Calancha writes: > On Tue, 17 Oct 2017, Andreas Schwab wrote: > >> On Okt 17 2017, Tino Calancha 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 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