diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-03-11 15:48:59 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-03-11 15:48:59 +0000 |
commit | 63111a6b17f34af7953fda7154b7fa35985109e2 (patch) | |
tree | 717fda4bcf638cd64466deca4c830e46a6fe8e8d | |
parent | d73d54912b38dd893acc75a215f67fa04706b03e (diff) |
move umask() song and dance closer around the bind, being more careful about errors; ok claudio
-rw-r--r-- | usr.sbin/bgpd/control.c | 9 | ||||
-rw-r--r-- | usr.sbin/ospfd/control.c | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 7553fe8c474..c277867224d 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.42 2005/02/25 23:00:23 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.43 2005/03/11 15:48:58 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -50,7 +50,6 @@ control_init(void) return (-1); } - old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; strlcpy(sun.sun_path, SOCKET_NAME, sizeof(sun.sun_path)); @@ -62,12 +61,16 @@ control_init(void) return (-1); } + old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { log_warn("control_init: bind: %s", SOCKET_NAME); close(fd); + umask(old_umask); return (-1); } + umask(old_umask); + if (chmod(SOCKET_NAME, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) { log_warn("control_init chmod"); close(fd); @@ -75,8 +78,6 @@ control_init(void) return (-1); } - umask(old_umask); - session_socket_blockmode(fd, BM_NONBLOCK); control_state.fd = fd; diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c index c426d270a98..20fec1d3ed7 100644 --- a/usr.sbin/ospfd/control.c +++ b/usr.sbin/ospfd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.1 2005/01/28 14:05:40 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.2 2005/03/11 15:48:58 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -52,7 +52,6 @@ control_init(void) return (-1); } - old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; strlcpy(sun.sun_path, OSPFD_SOCKET, sizeof(sun.sun_path)); @@ -64,11 +63,14 @@ control_init(void) return (-1); } + old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { log_warn("control_init: bind: %s", OSPFD_SOCKET); close(fd); + umask(old_umask); return (-1); } + umask(old_umask); if (chmod(OSPFD_SOCKET, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) { log_warn("control_init: chmod"); @@ -76,8 +78,6 @@ control_init(void) return (-1); } - umask(old_umask); - session_socket_blockmode(fd, BM_NONBLOCK); control_state.fd = fd; |