diff options
author | guenther <guenther@openbsd.org> | 2014-10-26 22:16:16 +0000 |
---|---|---|
committer | guenther <guenther@openbsd.org> | 2014-10-26 22:16:16 +0000 |
commit | b3a5c146ab99b77cd17260d7fcc74dfbee5c7bd5 (patch) | |
tree | 3fcb962a2fa3f188de35ccc2899a7dfba1f6fbb3 /usr.sbin/apmd | |
parent | Fix a possibly infinite recursion in Perl Data::Dumper. (diff) | |
download | wireguard-openbsd-b3a5c146ab99b77cd17260d7fcc74dfbee5c7bd5.tar.xz wireguard-openbsd-b3a5c146ab99b77cd17260d7fcc74dfbee5c7bd5.zip |
Use socket(SOCK_CLOEXEC), open(O_CLOEXEC), and fcntl(F_DUPFD_CLOEXEC)
instead of calling fcntl(F_SETFD) later.
ok otto@ millert@
Diffstat (limited to 'usr.sbin/apmd')
-rw-r--r-- | usr.sbin/apmd/apmd.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 46bf47f6cba..be67d71b103 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.71 2014/10/17 07:41:40 jmc Exp $ */ +/* $OpenBSD: apmd.c,v 1.72 2014/10/26 22:16:16 guenther Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -211,7 +211,7 @@ bind_socket(const char *sockname) mode_t old_umask; int sock; - sock = socket(AF_UNIX, SOCK_STREAM, 0); + sock = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sock == -1) error("cannot create local socket", NULL); @@ -441,9 +441,6 @@ main(int argc, char *argv[]) sock_fd = bind_socket(sockname); - if (fcntl(sock_fd, F_SETFD, FD_CLOEXEC) == -1) - error("cannot set close-on-exec for the socket", NULL); - power_status(ctl_fd, 1, &pinfo); if (statonly) |