summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-12-01 15:08:26 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-12-01 15:08:26 +0000
commit016b19f970b5b6f73068d5863dd35da9618c29b8 (patch)
tree4e3d101c927d613e398a0318bc560ac068362abc /lib/libc
parent80c6da5e833f55eb6c028eb199d5def447f0b3b2 (diff)
modify getpw*(), getgr*(), and getgrouplist() functions to access the
YP lock file unconditionally. This hints to the kernel that a "getpw" operation is happening, even in the non-YP case. This looks like a gruesome hack, but helps refine the ways these functions are called and mandates the right pledge requests. Once the tree is fully annotated we will know better how to improve the backing store management. ok semarie espie beck
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getgrent.c11
-rw-r--r--lib/libc/gen/getgrouplist.c9
-rw-r--r--lib/libc/gen/getpwent.c8
3 files changed, 24 insertions, 4 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 624a9c06110..348e7dd6883 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getgrent.c,v 1.45 2015/11/24 22:03:33 millert Exp $ */
+/* $OpenBSD: getgrent.c,v 1.46 2015/12/01 15:08:25 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
+#include <unistd.h>
#include <grp.h>
#include <errno.h>
#ifdef YP
@@ -207,6 +208,14 @@ start_gr(void)
#endif
return(1);
}
+
+#ifdef YP
+ /*
+ * Hint to the kernel that a passwd database operation is happening.
+ */
+ (void)access("/var/run/ypbind.lock", R_OK);
+#endif
+
return((_gr_fp = fopen(_PATH_GROUP, "re")) ? 1 : 0);
}
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index 7a904a2fd9a..e347ffcec90 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getgrouplist.c,v 1.26 2015/09/12 14:56:50 guenther Exp $ */
+/* $OpenBSD: getgrouplist.c,v 1.27 2015/12/01 15:08:25 deraadt Exp $ */
/*
* Copyright (c) 2008 Ingo Schwarze <schwarze@usta.de>
* Copyright (c) 1991, 1993
@@ -158,6 +158,13 @@ getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
}
groups[ngroups++] = agroup;
+#ifdef YP
+ /*
+ * Hint to the kernel that a passwd database operation is happening.
+ */
+ (void)access("/var/run/ypbind.lock", R_OK);
+#endif
+
/*
* Scan the group file to find additional groups.
*/
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index b09107b15d4..81a834d6fe6 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getpwent.c,v 1.58 2015/11/24 22:03:33 millert Exp $ */
+/* $OpenBSD: getpwent.c,v 1.59 2015/12/01 15:08:25 deraadt Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
* Copyright (c) 1988, 1993
@@ -924,6 +924,11 @@ __initdb(int shadow)
int saved_errno = errno;
#ifdef YP
+ /*
+ * Hint to the kernel that a passwd database operation is happening.
+ */
+ (void)access("/var/run/ypbind.lock", R_OK);
+
__ypmode = YPMODE_NONE;
__getpwent_has_yppw = -1;
#endif
@@ -937,7 +942,6 @@ __initdb(int shadow)
}
if (!warned) {
saved_errno = errno;
- syslog(LOG_ERR, "%s: %m", _PATH_MP_DB);
errno = saved_errno;
warned = 1;
}