man-db: Use sysusers mechanism for user/group creation

Message ID 20230329142943.2485040-1-stefan.schantl@ipfire.org
State New
Headers
Series man-db: Use sysusers mechanism for user/group creation |

Commit Message

Stefan Schantl March 29, 2023, 2:29 p.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 man-db/man-db.nm       | 20 ++++++++------------
 man-db/man-db.sysusers |  6 ++++++
 2 files changed, 14 insertions(+), 12 deletions(-)
 create mode 100644 man-db/man-db.sysusers
  

Patch

diff --git a/man-db/man-db.nm b/man-db/man-db.nm
index 5d3240537..1f46ca8f0 100644
--- a/man-db/man-db.nm
+++ b/man-db/man-db.nm
@@ -5,7 +5,7 @@ 
 
 name       = man-db
 version    = 2.11.2
-release    = 1
+release    = 2
 
 groups     = Documentation
 url        = http://savannah.nongnu.org/projects/man-db
@@ -13,9 +13,9 @@  license    = GPL
 summary    = man-db is an on-line manual database.
 
 description
-	man-db is an implementation of the standard Unix documentation \
-	system accessed using the man command. It uses a Berkeley DB database \
-	in place of the traditional flat-text whatis databases. man-db is \
+	man-db is an implementation of the standard Unix documentation
+	system accessed using the man command. It uses a Berkeley DB database
+	in place of the traditional flat-text whatis databases. man-db is
 	used by several popular GNU/Linux distributions.
 end
 
@@ -28,6 +28,7 @@  build
 		groff
 		less
 		libpipeline-devel >= 1.5.0
+		systemd-basetools
 		systemd-devel
 		zlib-devel
 	end
@@ -54,14 +55,13 @@  build
 		mkdir -pv %{BUILDROOT}/var/cache/man
 
 		# Own the cache directory to the man user/group.
-		chown man:man %{BUILDROOT}/var/cache/man
+		chown -v man:man %{BUILDROOT}/var/cache/man
 	end
 end
 
 create_user
-	getent group man >/dev/null || groupadd -r -g 15 man
-	getent passwd man >/dev/null || useradd -r -g 15 \
-		-c "Manpage cache user" -d /var/cache/man -s /sbin/nologin man
+	cat %{DIR_SOURCE}/%{name}.sysusers |
+		systemd-sysusers --replace=%{sysusersdir}/%{name}.conf -
 end
 
 packages
@@ -83,10 +83,6 @@  packages
 			man
 		end
 
-		script prein
-			%{create_user}
-		end
-
 		script posttransin
 			# Update the database right now.
 			rm -rf /var/cache/man/*
diff --git a/man-db/man-db.sysusers b/man-db/man-db.sysusers
new file mode 100644
index 000000000..3783bed2c
--- /dev/null
+++ b/man-db/man-db.sysusers
@@ -0,0 +1,6 @@ 
+# Create the man group with GID 15
+g man 15
+
+# Create the man user with UID 15, member of the man group
+# with a remark, /var/cache/man as homedir and no login shell.
+u man 15:15 "Manpage cache user" /var/cache/man /sbin/nologin