diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-03-10 22:15:04 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-03-10 22:15:04 +0000 |
commit | 23999f57b3d5d9f5d91406b4e96bffcd4f30abcc (patch) | |
tree | 47bfe61da6a6492d76a8e755a308810f624c4620 /usr.bin | |
parent | 1a24eb2e66a028692210e300e56697da3fe80a5b (diff) |
wrap AF_UNIX bind() call in umask() handling (as well as post-chmod)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/sock.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/cvs/sock.c b/usr.bin/cvs/sock.c index cdde5fe14af..fb75116fe83 100644 --- a/usr.bin/cvs/sock.c +++ b/usr.bin/cvs/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.12 2005/02/22 23:17:42 jfb Exp $ */ +/* $OpenBSD: sock.c,v 1.13 2005/03/10 22:15:03 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -67,6 +67,8 @@ static struct sockaddr_un cvs_sun; int cvsd_sock_open(void) { + mode_t old_umask; + if (cvsd_sock >= 0) cvsd_sock_close(); @@ -79,13 +81,16 @@ cvsd_sock_open(void) return (-1); } + old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); if (bind(cvsd_sock, (struct sockaddr *)&cvsd_sun, SUN_LEN(&cvsd_sun)) == -1) { cvs_log(LP_ERRNO, "failed to bind local socket to `%s'", cvsd_sock_path); (void)close(cvsd_sock); + umask(old_umask); return (-1); } + umask(old_umask); (void)listen(cvsd_sock, 10); |