From: ludo@gnu.org (Ludovic Courtès)
To: Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 1/2] dmd: Use ~/.dmd.d/ by default when not run as root.
Date: Tue, 04 Feb 2014 21:34:19 +0100 [thread overview]
Message-ID: <87d2j2d3ck.fsf@gnu.org> (raw)
In-Reply-To: <1391449065-19063-2-git-send-email-alex.sassmannshausen@gmail.com> (Alex Sassmannshausen's message of "Mon, 3 Feb 2014 18:37:44 +0100")
Alex Sassmannshausen <alex.sassmannshausen@gmail.com> skribis:
> * modules/dmd/support.scm: Add copyright.
> (user-dmddir): New variable.
> (default-logfile): Use it instead of user-homedir.
> (default-persistency-state-file): Use it instead of user-homedir.
> (default-configfile): Use it instead of user-homedir, use init.scm
> as default name for configfile, ensure .dmd.d exists.
> (default-socket-dir): Add check for root, if #f, use user-dmddir as
> base for socket.
Applied, thanks!
> ;; Configuration file.
> (define default-config-file
> (if (zero? (getuid))
> (string-append Prefix-dir "/etc/dmdconf.scm")
> - (string-append user-homedir "/.dmdconf.scm")))
> + (begin
> + (let ((config-file (string-append user-dmddir "/init.scm")))
> + (cond ((not (file-exists? user-dmddir))
> + (mkdir user-dmddir)
> + config-file)
> + (else config-file))))))
The file-exists?/mkdir pattern above introduces a TOCTTOU problem: when
running ‘make check -j’ the first time, one of the tests failed because
‘mkdir’ failed with EEXIST.
So I changed it to (catch-system-error (mkdir user-dmddir)).
Ludo’.
next prev parent reply other threads:[~2014-02-04 20:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-03 17:37 dmd: make user-mode easier to use Alex Sassmannshausen
2014-02-03 17:37 ` =?y?q?=5BPATCH=201/2=5D=20dmd=3A=20Use=20=7E/=2Edmd=2Ed/=20by=20default=20when=20not=20run=20as=20root=2E?= Alex Sassmannshausen
2014-02-04 20:34 ` Ludovic Courtès [this message]
2014-02-03 17:37 ` [PATCH 2/2] dmd: Make config file if necessary when not run as root Alex Sassmannshausen
2014-02-04 20:41 ` Ludovic Courtès
2014-02-05 18:27 ` Alex Sassmannshausen
2014-02-05 20:17 ` Ludovic Courtès
2014-02-04 20:34 ` dmd: make user-mode easier to use Ludovic Courtès
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://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d2j2d3ck.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=alex.sassmannshausen@gmail.com \
--cc=guix-devel@gnu.org \
/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/guix.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).