Org-mode mailing list
 help / color / mirror / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: No Wayman <iarchivedmywholelife@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: org-babel-tangle: persmission denied when tangling [9.4.5 (9.4.5-gbc2659 @ /home/n/.emacs.d/straight/build/org/)]
Date: Tue,  4 May 2021 20:27:11 +0000
Message-ID: <bdc8b055-623b-06d5-74a9-b342b3ef321b@posteo.eu> (raw)
In-Reply-To: <8735v2706t.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

No Wayman writes:
> Subsequent tangles did not fail for me.
Ah yes, I understand, it is possible to delete a file without write
permission.

I'll see if I can fix this bug and keep the security improvements. In
the meantime, you can apply the attached patch that should fix
your issue.

Thank you for the report.

-- 
Sébastien Miquel


[-- Attachment #2: 0001-fix-readonly-tangle.patch --]
[-- Type: text/x-patch, Size: 794 bytes --]

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 36144d6ae..c041ff4b3 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -270,9 +270,10 @@ matching a regular expression."
 		     (make-directory fnd 'parents))
                    ;; erase previous file and set permissions on empty
                    ;; file before writing
-                   (write-region "" nil file-name nil 0)
-		   (mapc (lambda (mode) (set-file-modes file-name mode)) modes)
+                   (when (file-exists-p file-name)
+                     (delete-file file-name))
 		   (write-region nil nil file-name)
+		   (mapc (lambda (mode) (set-file-modes file-name mode)) modes)
                    (push file-name path-collector))))))
 	 (if (equal arg '(4))
 	     (org-babel-tangle-single-block 1 t)

  reply	other threads:[~2021-05-04 20:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04 18:26 No Wayman
2021-05-04 19:25 ` Sébastien Miquel
2021-05-04 19:33   ` No Wayman
2021-05-04 20:27     ` Sébastien Miquel [this message]
2021-05-04 20:32       ` Bastien
2021-05-04 21:19         ` Sébastien Miquel
2021-05-05  3:15           ` No Wayman
2021-05-05  6:49             ` Bug: [PATCH] " Sébastien Miquel
2021-05-05  7:03               ` Bastien
2021-05-05 13:53               ` No Wayman
2021-05-05  6:43           ` Bug: " Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bdc8b055-623b-06d5-74a9-b342b3ef321b@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=iarchivedmywholelife@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git