summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2011-09-05 03:52:24 +0000
committerguenther <guenther@openbsd.org>2011-09-05 03:52:24 +0000
commit3169a29e21a58969677812ccc7a605cebe8c5818 (patch)
tree108e691870e72bcf035963a816617ffe970e84c7 /lib/libc
parentSwitch sigreturn() to the normal syscall entry instead of int$80. (diff)
downloadwireguard-openbsd-3169a29e21a58969677812ccc7a605cebe8c5818.tar.xz
wireguard-openbsd-3169a29e21a58969677812ccc7a605cebe8c5818.zip
Preserve errno across calls to open the password database(s), so
that errno isn't changed when a normal user (who can't open spwd.db) does a lookup. Problem pointed out by Tim van der Molen (tbvdm at xs4all.nl)
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getpwent.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index e65ffdc488f..a9d4b8540c5 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getpwent.c,v 1.42 2009/11/21 10:24:59 chl Exp $ */
+/* $OpenBSD: getpwent.c,v 1.43 2011/09/05 03:52:24 guenther Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
* Copyright (c) 1988, 1993
@@ -844,14 +844,17 @@ static int
__initdb(void)
{
static int warned;
+ int saved_errno = errno;
#ifdef YP
__ypmode = YPMODE_NONE;
__getpwent_has_yppw = -1;
#endif
if ((_pw_db = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL)) ||
- (_pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL)))
+ (_pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL))) {
+ errno = saved_errno;
return (1);
+ }
if (!warned)
syslog(LOG_ERR, "%s: %m", _PATH_MP_DB);
warned = 1;