summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2015-11-23 12:01:05 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2015-11-23 12:01:05 +0000
commitdad59a13f1e4ca290e80404f76fba5ce8fc88df9 (patch)
tree95b8297fcaef77778f4003ee930e558363241e49 /usr.bin
parentf369b55f5e9f72c41d679e6a3eae6691e5b71b0d (diff)
Save and restore umask when creating /tmp/aucat/ to ensure the
directory gets the right permissions, as we do in other places.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sndiod/sndiod.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/sndiod/sndiod.c b/usr.bin/sndiod/sndiod.c
index 1d0602df20f..06f07f5b080 100644
--- a/usr.bin/sndiod/sndiod.c
+++ b/usr.bin/sndiod/sndiod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndiod.c,v 1.13 2015/11/22 16:52:06 ratchov Exp $ */
+/* $OpenBSD: sndiod.c,v 1.14 2015/11/23 12:01:04 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -255,7 +255,7 @@ getbasepath(char *base, size_t size)
{
uid_t uid;
struct stat sb;
- mode_t mask;
+ mode_t mask, omask;
uid = geteuid();
if (uid == 0) {
@@ -265,10 +265,12 @@ getbasepath(char *base, size_t size)
mask = 077;
snprintf(base, SOCKPATH_MAX, SOCKPATH_DIR "-%u", uid);
}
- if (mkdir(base, 0777 & ~mask) < 0) {
+ omask = umask(mask);
+ if (mkdir(base, 0777) < 0) {
if (errno != EEXIST)
err(1, "mkdir(\"%s\")", base);
}
+ umask(omask);
if (stat(base, &sb) < 0)
err(1, "stat(\"%s\")", base);
if (sb.st_uid != uid || (sb.st_mode & mask) != 0)