summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-03-10 22:22:20 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-03-10 22:22:20 +0000
commitec9757fc487d3cd2323f230c4affd9054ff75463 (patch)
tree0b3b033ff51bfb255fb366dc1d7a546f15e9324c /bin
parent23999f57b3d5d9f5d91406b4e96bffcd4f30abcc (diff)
wrap bind() to AF_UNIX with umask() to avoid race
Diffstat (limited to 'bin')
-rw-r--r--bin/systrace/cradle.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/systrace/cradle.c b/bin/systrace/cradle.c
index 3d38b8d586a..645f425584d 100644
--- a/bin/systrace/cradle.c
+++ b/bin/systrace/cradle.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cradle.c,v 1.1 2004/01/23 20:51:18 sturm Exp $ */
+/* $OpenBSD: cradle.c,v 1.2 2005/03/10 22:22:19 deraadt Exp $ */
/*
* Copyright (c) 2003 Marius Aamodt Eriksen <marius@monkey.org>
@@ -105,6 +105,7 @@ static int
mkunserv(char *path)
{
int s;
+ mode_t old_umask;
struct sockaddr_un sun;
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
@@ -117,8 +118,10 @@ mkunserv(char *path)
sizeof (sun.sun_path))
errx(1, "Path too long: %s", path);
+ old_umask = umask(S_IRUSR | S_IWUSR);
if (bind(s, (struct sockaddr *)&sun, sizeof(sun)) == -1)
err(1, "bind()");
+ umask(old_umask);
if (chmod(path, S_IRUSR | S_IWUSR) == -1)
err(1, "chmod()");