From: deraadt Date: Mon, 22 Jan 2024 17:21:52 +0000 (+0000) Subject: getpwnam(3) uses dbopen(3), which pulls all 3 database backends into X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5f5ca73179e5fdfb1850b1c2693d82422f7e84ae;p=openbsd getpwnam(3) uses dbopen(3), which pulls all 3 database backends into static binaries. If we call libc-private __hash_open() instead, it results in a ~40K reduction in many static binaries. ok millert --- diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index a1cc31cfb46..9a6fe5e9ae9 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetgrent.c,v 1.31 2023/02/17 18:00:11 miod Exp $ */ +/* $OpenBSD: getnetgrent.c,v 1.32 2024/01/22 17:21:52 deraadt Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -630,7 +630,7 @@ setnetgrent(const char *ng) return; if (_ng_db == NULL) - _ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL); + _ng_db = __hash_open(_PATH_NETGROUP_DB, O_RDONLY, 0, NULL, 0); #ifdef YP /* @@ -682,7 +682,7 @@ innetgr(const char *grp, const char *host, const char *user, const char *domain) struct stringlist *sl; if (_ng_db == NULL) - _ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL); + _ng_db = __hash_open(_PATH_NETGROUP_DB, O_RDONLY, 0, NULL, 0); #ifdef YP /* diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 24ac8f96c3a..6bab12a0725 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getpwent.c,v 1.66 2022/08/02 17:00:15 deraadt Exp $ */ +/* $OpenBSD: getpwent.c,v 1.67 2024/01/22 17:21:52 deraadt Exp $ */ /* * Copyright (c) 2008 Theo de Raadt * Copyright (c) 1988, 1993 @@ -961,9 +961,9 @@ __initdb(int shadow) __getpwent_has_yppw = -1; #endif if (shadow) - _pw_db = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL); + _pw_db = __hash_open(_PATH_SMP_DB, O_RDONLY, 0, NULL, 0); if (!_pw_db) - _pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL); + _pw_db = __hash_open(_PATH_MP_DB, O_RDONLY, 0, NULL, 0); if (_pw_db) { errno = saved_errno; return (1);