unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Ihor Radchenko <yantar92@posteo.net>
Subject: Re: [elpa] externals-release/org e2366ac283: * lisp/org-persist.el: Do not litter /tmp when native compiling
Date: Wed, 21 Dec 2022 14:07:48 -0500	[thread overview]
Message-ID: <jwv3598r38i.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20221221185757.74391C00613@vcs2.savannah.gnu.org> (ELPA Syncer's message of "Wed, 21 Dec 2022 13:57:57 -0500 (EST)")

> +(when (and org-persist--disable-when-emacs-Q
> +           ;; FIXME: This is relying on undocumented fact that
> +           ;; Emacs sets `user-init-file' to nil when loaded with
> +           ;; "-Q" argument.
> +           (not user-init-file))
> +  (setq org-persist-directory
> +        (make-temp-file "org-persist-" 'dir))
> +  ;; We don't need the temp directory to exist.
> +  ;; `org-persist-write-all' will refrain from creating and writing to the dir if
> +  ;; none exists yet.
> +  (delete-directory org-persist-directory))

Could we skip the "create dir" so we can skip the `delete-directory`
part as well?

Also, this smells like a security hole: after `delete-directory`, with
the /tmp setup as mode #o1777, some other user can come and create
a directory at that location, so that our `org-persist-directory` will
then point to their directory (where they may be able to read the
things we write) or they can replace it with a link to a directory of
our own tricking us into overwriting some of our own files.

IOW, I suggest we use something like

    (setq org-persist-directory "/non-existing")
or
    (setq org-persist-directory (make-temp-name "/non-existing"))

[ Not sure if there is a standard such name that's "guaranteed" not to
  exist.  ]


        Stefan




       reply	other threads:[~2022-12-21 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <167164907706.9937.9724677162932540750@vcs2.savannah.gnu.org>
     [not found] ` <20221221185757.74391C00613@vcs2.savannah.gnu.org>
2022-12-21 19:07   ` Stefan Monnier [this message]
2022-12-21 19:15     ` [elpa] externals-release/org e2366ac283: * lisp/org-persist.el: Do not litter /tmp when native compiling Ihor Radchenko
2022-12-21 19:54       ` Stefan Monnier
2022-12-25  9:22         ` Ihor Radchenko

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://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwv3598r38i.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=yantar92@posteo.net \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).