From patchwork Sun Feb 12 15:20:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6514 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4PFB4C3NVzz3xGC for ; Sun, 12 Feb 2023 15:20:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4PFB482J0rztF; Sun, 12 Feb 2023 15:20:24 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4PFB475qPhz2xhb; Sun, 12 Feb 2023 15:20:23 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4PFB461v06z2xY8 for ; Sun, 12 Feb 2023 15:20:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4PFB451JDxzBV; Sun, 12 Feb 2023 15:20:21 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1676215221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1nmFxPFZ7/EETTYemRHucPmU9S0d4R0PTuu+miTdncY=; b=kIAx5ri/O8Z2tmw+O96B9wdeM7pYTc2PJCWuRnOXneuI9nFI2onpuk7xGIxvfEApsknoRV DXHYdF0ne8ueLxBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1676215221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1nmFxPFZ7/EETTYemRHucPmU9S0d4R0PTuu+miTdncY=; b=HK4X0Rv5Xnh2W6pAkB6kiig7L5qckfjrsEJ79mfklMHBjWwnQ19ACk+TrwxhvNhK/XPFNl LvAf8YvTsbAp4ebA+3CXk4mUPVcu/UrOLY89NRrT43BebqLmTcEznoLMHBQi2bnotp2GYM 1CWlAji7BYVRlYIQqzseKwq0QBZdE8Z+tp32xcYLSfEcJN3QsLj++DG67eG3/NNkTppdaD J3X2UD3a10fo11++b/U+ZpgWhOkQhljycKA/gvqKtdgGOSkUItVFNt0Mg/h1+HwNutdwEt 6tXw82TBukI3MVloftWIiieHQxMOz5YpS/owk0QCuO70Ou4Jr647EPMcvR7MYg== From: Stefan Schantl 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 Message-Id: <20230212152013.386417-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- 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 From patchwork Sun Feb 12 15:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6513 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4PFB4B3jNkz3ws7 for ; Sun, 12 Feb 2023 15:20:26 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4PFB4875Mgz1Dk; Sun, 12 Feb 2023 15:20:24 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4PFB480JZdz2xBD; Sun, 12 Feb 2023 15:20:24 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4PFB463xPQz2xY8 for ; Sun, 12 Feb 2023 15:20:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4PFB461TtMzdM; Sun, 12 Feb 2023 15:20:22 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1676215222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RKcZyHBFvCXVPaSLnsv+ADfrB4WuUjurZqv4OfI+PVg=; b=VmZ55N1V5/67oG4l6P0EQXEgfWCd+n6u/VN52aeH7QHz0sSTD7nBSvU4sS3+Brd+gB8oF3 ZYZL4divlmw5JTBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1676215222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RKcZyHBFvCXVPaSLnsv+ADfrB4WuUjurZqv4OfI+PVg=; b=jNLBdPQ+HbUTmIVk+ah7GfHu9FiJKyXxuy0sihDtYdB4RHBTAtxd7OURE9H6clUepwgNSC XhyphGDaUzobdxQZGctWoqup3Q2pJBtB71BHSowYlXl2NSTCXbM/uYM+d5MnVcOrjgS9TM yH7C0C+f8BXq5v1OuhPUkbyFy8lN0MJdSPYEoIrws7HBxdHaGRmhSEEChPqwpHYbkm1gp1 WZxyi01i1afGOaCUYv3xE3bLKVoHXApVStjsE8i7YQ27FaLJPb8PFqqFvRtGKs41LoMhqh 6tX5KlwbF9SlHu8bIrCpY9fd01GiXUWzK/fGBgotVxagCer9vNij4s+jnH4DSw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 2/2] clamav: Add scriptlets to handle systemd service files. Date: Sun, 12 Feb 2023 16:20:13 +0100 Message-Id: <20230212152013.386417-2-stefan.schantl@ipfire.org> In-Reply-To: <20230212152013.386417-1-stefan.schantl@ipfire.org> References: <20230212152013.386417-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Fixes #11603. Signed-off-by: Stefan Schantl --- clamav/clamav.nm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/clamav/clamav.nm b/clamav/clamav.nm index 14765e000..f941bc6b9 100644 --- a/clamav/clamav.nm +++ b/clamav/clamav.nm @@ -82,9 +82,42 @@ packages %{name}-libs = %{thisver} end + configfiles + %{sysconfdir}/clamd.conf + %{sysconfdir}/freshclam.conf + end + + prerequires + systemd-units + end + script prein %{create_users} end + + script postin + systemctl daemon-reload >/dev/null 2>&1 || : + systemctl enable clamav-freshclam.service >/dev/null 2>&1 || : + systemctl enable clamav-daemon.service >/dev/null 2>&1 || : + end + + script preun + systemctl --no-reload disable clamav-freshclam.service >/dev/null 2>&1 || : + systemctl --no-reload disable clamav-daemon.service >/dev/null 2>&1 ||: + + systemctl stop clamav-freshclam.service.service >/dev/null 2>&1 || : + systemctl stop clamav-daemon.service >/dev/null 2>&1 || : + end + + script postun + systemctl daemon-reload >/dev/null 2>&1 || : + end + + script postup + systemctl daemon-reload >/dev/null 2>&1 || : + systemctl try-restart clamav-freshclam.service >/dev/null 2>&1 || : + systemctl try-restart clamav-daemon.service >/dev/null 2>&1 || : + end end package %{name}-libs