[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [elpa] externals-release/org e2366ac283: * lisp/org-persist.el: Do n
From: |
Ihor Radchenko |
Subject: |
Re: [elpa] externals-release/org e2366ac283: * lisp/org-persist.el: Do not litter /tmp when native compiling |
Date: |
Wed, 21 Dec 2022 19:15:48 +0000 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> + (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?
It would be wonderful, but
There is a race condition between calling make-temp-name and
later creating the file, which opens all kinds of security holes.
For that reason, you should normally use make-temp-file instead.
which scared me.
> 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.
This also means that other user has access to Elisp machine state (the
value of org-persist-directory). If we are in that situation, your
scenario is the least of our concerns. Also, do note that this branch of
code is only executed with emacs -Q.
> 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. ]
If you confirm that it is safe to use `make-temp-name' here, I will go
with your suggestion.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>