opendoas

my fork of doas with custom prompt
git clone git://git.kocotian.pl/opendoas.git
Log | Files | Refs | README | LICENSE

commit 6cf64c20542022569d468403b951065eea99b20b
parent 5054c7a52d950e0f66a088689a36ca5999987c97
Author: Duncaen <mail@duncano.de>
Date:   Tue, 12 Dec 2017 16:42:11 +0100

persist_timestamp: create timestamp file with O_NOFOLLOW and don't leak the name

Diffstat:
Mpersist_timestamp.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/persist_timestamp.c b/persist_timestamp.c @@ -262,11 +262,12 @@ persist_open(int *valid, int secs) if ((fd = openat(dirfd, name, (O_RDWR), (S_IRUSR|S_IWUSR))) == -1) if (errno != ENOENT) - err(1, "open: %s", name); + err(1, "open timestamp file"); if (fd == -1) { - if ((fd = openat(dirfd, name, (O_RDWR|O_CREAT|O_EXCL), (S_IRUSR|S_IWUSR))) == -1) - err(1, "open: %s", name); + if ((fd = openat(dirfd, name, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), + (S_IRUSR|S_IWUSR))) == -1) + err(1, "open timestamp file"); } size_t tssize;