Commit dc1bd1a2cbead8a75febae0514904674bbfbf1ed

Guillem Jover 2023-04-23T02:00:10

build: Conditionalize only id-from-name functions not the entire pwcache On macOS the name-from-id functions are present, but not the id-from-name ones, so we want to provide those instead of suppressing the entire file.

diff --git a/configure.ac b/configure.ac
index 624494e..9b2c277 100644
--- a/configure.ac
+++ b/configure.ac
@@ -325,7 +325,7 @@ need_md5=yes
 need_nlist=yes
 need_strl=yes
 need_strmode=yes
-need_pwcache=yes
+need_id_from_name=yes
 need_fpurge=yes
 need_funopen=yes
 AS_CASE([$host_os],
@@ -355,7 +355,7 @@ AS_CASE([$host_os],
     need_nlist=no
     need_strl=no
     need_strmode=no
-    need_pwcache=no
+    need_id_from_name=no
     need_fpurge=no
     # On macOS we do not have fopencookie(), and cannot implement it.
     need_funopen=no
@@ -372,7 +372,7 @@ AM_CONDITIONAL([NEED_MD5], [test "x$need_md5" = "xyes"])
 AM_CONDITIONAL([NEED_NLIST], [test "x$need_nlist" = "xyes"])
 AM_CONDITIONAL([NEED_STRL], [test "x$need_strl" = "xyes"])
 AM_CONDITIONAL([NEED_STRMODE], [test "x$need_strmode" = "xyes"])
-AM_CONDITIONAL([NEED_PWCACHE], [test "x$need_pwcache" = "xyes"])
+AM_CONDITIONAL([NEED_ID_FROM_NAME], [test "x$need_id_from_name" = "xyes"])
 AM_CONDITIONAL([NEED_FPURGE], [test "x$need_fpurge" = "xyes"])
 AM_CONDITIONAL([NEED_FUNOPEN], [test "x$need_funopen" = "xyes"])
 AS_IF([test "x$need_funopen" = "xno" && \
diff --git a/man/Makefile.am b/man/Makefile.am
index 91499e1..118ab2d 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -180,6 +180,7 @@ dist_man_MANS = \
 	getbsize.3bsd \
 	getmode.3bsd \
 	getpeereid.3bsd \
+	group_from_gid.3bsd \
 	heapsort.3bsd \
 	humanize_number.3bsd \
 	le16dec.3bsd \
@@ -195,6 +196,7 @@ dist_man_MANS = \
 	pidfile_open.3bsd \
 	pidfile_remove.3bsd \
 	pidfile_write.3bsd \
+	pwcache.3bsd \
 	queue.3bsd \
 	radixsort.3bsd \
 	readpassphrase.3bsd \
@@ -234,6 +236,7 @@ dist_man_MANS = \
 	timeval.3bsd \
 	tree.3bsd \
 	unvis.3bsd \
+	user_from_uid.3bsd \
 	vis.3bsd \
 	wcslcat.3bsd \
 	wcslcpy.3bsd \
@@ -271,13 +274,10 @@ dist_man_MANS += \
 	# EOL
 endif
 
-if NEED_PWCACHE
+if NEED_ID_FROM_NAME
 dist_man_MANS += \
-	pwcache.3bsd \
 	uid_from_user.3bsd \
-	user_from_uid.3bsd \
 	gid_from_group.3bsd \
-	group_from_gid.3bsd \
 	# EOL
 endif
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 3e26159..0648b03 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -96,6 +96,7 @@ libbsd_la_SOURCES = \
 	merge.c \
 	pidfile.c \
 	progname.c \
+	pwcache.c \
 	radixsort.c \
 	readpassphrase.c \
 	reallocarray.c \
@@ -163,12 +164,6 @@ libbsd_la_SOURCES += \
 	# EOL
 endif
 
-if NEED_PWCACHE
-libbsd_la_SOURCES += \
-	pwcache.c \
-	# EOL
-endif
-
 if NEED_FPURGE
 libbsd_la_SOURCES += \
 	fpurge.c \
diff --git a/test/Makefile.am b/test/Makefile.am
index 13c2ae1..459012c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -41,6 +41,7 @@ check_PROGRAMS = \
 	fgetln \
 	fparseln \
 	proctitle-init \
+	pwcache \
 	setmode \
 	strnstr \
 	strtonum \
@@ -64,10 +65,6 @@ if NEED_STRMODE
 check_PROGRAMS += strmode
 endif
 
-if NEED_PWCACHE
-check_PROGRAMS += pwcache
-endif
-
 if NEED_FPURGE
 check_PROGRAMS += fpurge
 endif