public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Stefan Schantl <stefan.schantl@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 1/2] clamav: Proper create users and groups during package installation.
Date: Sun, 12 Feb 2023 16:20:12 +0100	[thread overview]
Message-ID: <20230212152013.386417-1-stefan.schantl@ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
 clamav/clamav.nm | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/clamav/clamav.nm b/clamav/clamav.nm
index d4548a94a..14765e000 100644
--- a/clamav/clamav.nm
+++ b/clamav/clamav.nm
@@ -5,7 +5,7 @@
 
 name       = clamav
 version    = 0.103.7
-release    = 1
+release    = 2
 
 groups     = System Environment/Daemons
 url        = https://www.clamav.net
@@ -55,13 +55,7 @@ build
 	# User and group have to exist to compile the source code,
 	# so we have to create them
 	prepare_cmds
-		groupadd -g 497 -r clamupdate
-		useradd	-u 497 -r -s /sbin/nologin -d /var/lib/clamav -M \
-			-c 'Clamav database update user' -g clamupdate clamupdate
-
-		groupadd -g 496 -r clamscan
-		useradd -u 496 -r -s /sbin/nologin -d / -M \
-			-g clamscan clamscan
+		%{create_users}
 	end
 
 	test
@@ -69,11 +63,28 @@ build
 	end
 end
 
+create_users
+	# Create user and group for clamupdate.
+	getent group clamupdate || groupadd -g 497 -r clamupdate || :
+	getent passwd clamupdate || useradd -u 497 -r -s /sbin/nologin \
+		-d /var/lib/clamav -M -c 'Clamav database update user' \
+		-g clamupdate clamupdate || :
+
+	# Create user and group for clamscan.
+	getent group clamscan || groupadd -g 496 -r clamscan || :
+	getent passwd clamscan || useradd -u 496 -r -s /sbin/nologin \
+		-d / -M -g clamscan clamscan || :
+end
+
 packages
 	package %{name}
 		requires
 			%{name}-libs = %{thisver}
 		end
+
+		script prein
+			%{create_users}
+		end
 	end
 
 	package %{name}-libs
-- 
2.30.2


             reply	other threads:[~2023-02-12 15:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12 15:20 Stefan Schantl [this message]
2023-02-12 15:20 ` [PATCH 2/2] clamav: Add scriptlets to handle systemd service files Stefan Schantl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230212152013.386417-1-stefan.schantl@ipfire.org \
    --to=stefan.schantl@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox