From: deraadt Date: Sun, 17 Jul 2022 03:12:20 +0000 (+0000) Subject: /var/run/ypbind.lock doesn't need to be created with an advisory lock anymore, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=95e50ed9e97f3d4aa5a3f30b642116c39a94e0a2;p=openbsd /var/run/ypbind.lock doesn't need to be created with an advisory lock anymore, because libc & pledge() doesn't care. libc now calls ypconnect(), which still cares about the advisory lock on /var/yp/bindings/$domain.2, so that code remains. ok jmatthew miod --- diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index fae94ff9570..fba44efc78f 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypbind.c,v 1.75 2022/07/15 16:59:49 deraadt Exp $ */ +/* $OpenBSD: ypbind.c,v 1.76 2022/07/17 03:12:20 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt @@ -58,7 +58,6 @@ #define SERVERSDIR "/etc/yp" #define BINDINGDIR "/var/yp/binding" -#define YPBINDLOCK "/var/run/ypbind.lock" struct _dom_binding { struct _dom_binding *dom_pnext; @@ -339,7 +338,7 @@ main(int argc, char *argv[]) char path[PATH_MAX]; struct sockaddr_in sin; struct pollfd *pfd = NULL; - int width = 0, nready, lockfd, lsock; + int width = 0, nready, lsock; socklen_t len; int evil = 0, one = 1; DIR *dirp; @@ -377,23 +376,6 @@ main(int argc, char *argv[]) (void)mkdir(BINDINGDIR, 0755); } -#ifdef O_SHLOCK - if ((lockfd = open(YPBINDLOCK, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, - 0644)) == -1) { - fprintf(stderr, "ypbind: cannot create %s\n", YPBINDLOCK); - exit(1); - } -#else - if ((lockfd = open(YPBINDLOCK, O_CREAT|O_RDWR|O_TRUNC, 0644)) == -1) { - fprintf(stderr, "ypbind: cannot create %s.\n", YPBINDLOCK); - exit(1); - } - flock(lockfd, LOCK_SH); -#endif - - if (fchmod(lockfd, 0644) == -1) - err(1, "fchmod"); - (void)pmap_unset(YPBINDPROG, YPBINDVERS); udptransp = svcudp_create(RPC_ANYSOCK); @@ -1036,24 +1018,12 @@ rpc_received(char *dom, struct sockaddr_in *raddrp, int force) snprintf(path, sizeof path, "%s/%s.%d", BINDINGDIR, ypdb->dom_domain, (int)ypdb->dom_vers); -#ifdef O_SHLOCK if ((fd = open(path, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, 0644)) == -1) { (void)mkdir(BINDINGDIR, 0755); if ((fd = open(path, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, 0644)) == -1) return; } -#else - if ((fd = open(path, O_CREAT|O_RDWR|O_TRUNC, 0644)) == -1) { - (void)mkdir(BINDINGDIR, 0755); - if ((fd = open(path, O_CREAT|O_RDWR|O_TRUNC, 0644)) == -1) - return; - } - flock(fd, LOCK_SH); -#endif - - if (fchmod(fd, 0644) == -1) - err(1, "fchmod"); /* * ok, if BINDINGDIR exists, and we can create the binding file,