I forgot that chpass(1) and passwd(1) reach-around into libc for
authorderaadt <deraadt@openbsd.org>
Mon, 22 Jan 2024 21:07:09 +0000 (21:07 +0000)
committerderaadt <deraadt@openbsd.org>
Mon, 22 Jan 2024 21:07:09 +0000 (21:07 +0000)
getpwent.c (isn't it horrible), and therefore lack visibility of
the the libc-internal __hash_open() function.  Use -DFORCE_DBOPEN
in chpass/Makefile and passwd/Makefile and adjust getpwent.c to
use the external visible interface.  Is there a better way?

lib/libc/gen/getpwent.c
usr.bin/chpass/Makefile
usr.bin/passwd/Makefile

index 6bab12a..0a959e7 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: getpwent.c,v 1.67 2024/01/22 17:21:52 deraadt Exp $ */
+/*     $OpenBSD: getpwent.c,v 1.68 2024/01/22 21:07:09 deraadt Exp $ */
 /*
  * Copyright (c) 2008 Theo de Raadt
  * Copyright (c) 1988, 1993
@@ -960,10 +960,20 @@ __initdb(int shadow)
        __ypmode = YPMODE_NONE;
        __getpwent_has_yppw = -1;
 #endif
-       if (shadow)
+       if (shadow) {
+#ifdef FORCE_DBOPEN
+               _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);
-       if (!_pw_db)
+#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, O_RDONLY, 0, NULL, 0);
+#endif
+       }
        if (_pw_db) {
                errno = saved_errno;
                return (1);
index b3a4053..6af5e84 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.15 2016/03/30 06:38:45 jmc Exp $
+#      $OpenBSD: Makefile,v 1.16 2024/01/22 21:07:10 deraadt Exp $
 
 .include <bsd.own.mk>
 
@@ -8,7 +8,7 @@ BINOWN= root
 BINMODE=4555
 .PATH: ${.CURDIR}/../../lib/libc/gen
 LINKS= ${BINDIR}/chpass ${BINDIR}/chfn ${BINDIR}/chpass ${BINDIR}/chsh
-CFLAGS+=-I${.CURDIR}/../../lib/libc/include
+CFLAGS+=-I${.CURDIR}/../../lib/libc/include -DFORCE_DBOPEN
 DPADD+= ${LIBUTIL}
 LDADD+= -lutil
 
index e1168b7..c671a88 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.41 2015/11/26 19:01:47 deraadt Exp $
+#      $OpenBSD: Makefile,v 1.42 2024/01/22 21:07:10 deraadt Exp $
 
 .include <bsd.own.mk>
 
@@ -8,7 +8,7 @@ SRCS=   local_passwd.c passwd.c getpwent.c \
 .PATH:  ${.CURDIR}/../../lib/libc/gen
 DPADD+= ${LIBRPCSVC} ${LIBUTIL}
 LDADD+= -lrpcsvc -lutil
-CFLAGS+= -I${.CURDIR}
+CFLAGS+= -I${.CURDIR} -DFORCE_DBOPEN
 
 CFLAGS+=-I${.CURDIR}/../../lib/libc/include