From c1317b35bde66c954be99e1eb6563fd5935fa7db Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 9 Mar 2026 12:56:12 +0000 Subject: [PATCH] Inside libc, getpwent.c does not use dbopen() and instead uses unexported db functions. The copy of the code outside libc, must use dbopen(). -DFORCE_DBOPEN was used with #ifdef, but now that the file is an edited copy that is no longer neccessary. --- lib/libc/gen/getpwent.c | 19 +++++-------------- usr.bin/chpass/Makefile | 3 +-- usr.bin/chpass/getpwent.c | 16 +++------------- usr.bin/passwd/Makefile | 4 ++-- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 41492a90a90..ab5879eeb26 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getpwent.c,v 1.69 2026/03/09 12:22:44 deraadt Exp $ */ +/* $OpenBSD: getpwent.c,v 1.70 2026/03/09 12:56:12 deraadt Exp $ */ /* * Copyright (c) 2008 Theo de Raadt * Copyright (c) 1988, 1993 @@ -960,20 +960,11 @@ __initdb(int shadow) __ypmode = YPMODE_NONE; __getpwent_has_yppw = -1; #endif - if (shadow) { -#ifdef FORCE_DBOPEN - _pw_db = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL); -#else + if (shadow) _pw_db = __hash_open(_PATH_SMP_DB, -1, O_RDONLY, 0, NULL, 0); -#endif - } - if (!_pw_db) { -#ifdef FORCE_DBOPEN - _pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL); -#else - _pw_db = __hash_open(_PATH_MP_DB, -1, O_RDONLY, 0, NULL, 0); -#endif - } + if (!_pw_db) + _pw_db = __hash_open(_PATH_MP_DB, -1, O_RDONLY, 0, NULL, 0); + if (_pw_db) { errno = saved_errno; return (1); diff --git a/usr.bin/chpass/Makefile b/usr.bin/chpass/Makefile index f99ff49e4cf..07873c370d1 100644 --- a/usr.bin/chpass/Makefile +++ b/usr.bin/chpass/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.17 2026/03/07 18:20:25 deraadt Exp $ +# $OpenBSD: Makefile,v 1.18 2026/03/09 12:56:12 deraadt Exp $ .include @@ -7,7 +7,6 @@ SRCS= chpass.c edit.c field.c table.c util.c getpwent.c BINOWN= root BINMODE=4555 LINKS= ${BINDIR}/chpass ${BINDIR}/chfn ${BINDIR}/chpass ${BINDIR}/chsh -CFLAGS+=-DFORCE_DBOPEN DPADD+= ${LIBUTIL} LDADD+= -lutil diff --git a/usr.bin/chpass/getpwent.c b/usr.bin/chpass/getpwent.c index a9b7a2e0099..57eeafd35eb 100644 --- a/usr.bin/chpass/getpwent.c +++ b/usr.bin/chpass/getpwent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getpwent.c,v 1.2 2026/03/07 18:15:49 deraadt Exp $ */ +/* $OpenBSD: getpwent.c,v 1.3 2026/03/09 12:56:12 deraadt Exp $ */ /* * Copyright (c) 2008 Theo de Raadt * Copyright (c) 1988, 1993 @@ -370,20 +370,10 @@ __initdb(int shadow) static int warned; int saved_errno = errno; - if (shadow) { -#ifdef FORCE_DBOPEN + if (shadow) _pw_db = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL); -#else - _pw_db = __hash_open(_PATH_SMP_DB, O_RDONLY, 0, NULL, 0); -#endif - } - if (!_pw_db) { -#ifdef FORCE_DBOPEN + if (!_pw_db) _pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL); -#else - _pw_db = __hash_open(_PATH_MP_DB, O_RDONLY, 0, NULL, 0); -#endif - } if (_pw_db) { errno = saved_errno; diff --git a/usr.bin/passwd/Makefile b/usr.bin/passwd/Makefile index e4f8bb782ba..6aab5ec0780 100644 --- a/usr.bin/passwd/Makefile +++ b/usr.bin/passwd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.43 2026/03/07 18:20:26 deraadt Exp $ +# $OpenBSD: Makefile,v 1.44 2026/03/09 12:56:12 deraadt Exp $ .include @@ -8,7 +8,7 @@ SRCS= local_passwd.c passwd.c getpwent.c \ .PATH: ${.CURDIR}/../chpass DPADD+= ${LIBRPCSVC} ${LIBUTIL} LDADD+= -lrpcsvc -lutil -CFLAGS+= -I${.CURDIR} -DFORCE_DBOPEN +CFLAGS+= -I${.CURDIR} BINMODE=4555 BINOWN=root