summaryrefslogtreecommitdiff
path: root/usr.sbin/ypbind/ypbind.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2022-07-17 03:12:21 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2022-07-17 03:12:21 +0000
commit3c3c1e74f1f19522580f5c51c4224ac86655233c (patch)
tree4bd14d511e24d9b96d6e6b1527fb4304c04f2e14 /usr.sbin/ypbind/ypbind.c
parent9152589afab3d46fdf031ff1f38216dec13c6fb0 (diff)
/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
Diffstat (limited to 'usr.sbin/ypbind/ypbind.c')
-rw-r--r--usr.sbin/ypbind/ypbind.c34
1 files changed, 2 insertions, 32 deletions
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 <deraadt@openbsd.org>
@@ -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,