From patchwork Thu Mar 3 21:02:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 5309 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 4K8k3h6Xy4z3xK1 for ; Thu, 3 Mar 2022 21:03:28 +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 4K8k3f2Nhfz4Ws; Thu, 3 Mar 2022 21:03:26 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4K8k3f1lJNz2yXK; Thu, 3 Mar 2022 21:03:26 +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 4K8k3c2GKcz2yDF for ; Thu, 3 Mar 2022 21:03:24 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4K8k3c0QJvz5Wr for ; Thu, 3 Mar 2022 21:03:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C320A8EBD3 for ; Thu, 3 Mar 2022 22:03:23 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id beh8APmjoyi7 for ; Thu, 3 Mar 2022 22:03:22 +0100 (CET) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 6E093184D1; Thu, 3 Mar 2022 22:03:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1646341401; bh=UhgoIbXVdjfz/R0RsRfiYU84bvhSxexMTO1aPIfNC/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D7Ra8BkkQ4CKf4wpLqf7iGPtLgJQBvg1cV6AT7y+bLmTJ7Pn9hrBcBbKMU3Y5GZeu ZTRWTFJAJFsVu+wju/k09SwlkRmE04sriB3+qVG4GLvkXL+Ju4UognyHOwARcUENxW F5M90Sh0VwmhC+lfDEqduoAHnJHumSu5es0XyWGI+DS9qfCOp8wjT9nnBthtV/FQEZ vnWWCIdLO8YQI854WGx9q8jdWSU0lJBWA4GA2sjRzQHGksWhAOMfCgWgl+DXKq5T21 lu8CSKc2iHXd19wT+SOeXTjurl9V4F1zA/Gc9UdNmvNGXWQJnqPbPJIDYUENYpnrV7 PO50gZaqQ4e1g== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v4 4/6] zabbix_agentd: Sudoers file reorganization Date: Thu, 3 Mar 2022 22:02:52 +0100 Message-Id: <20220303210254.3116-5-robin.roevens@disroot.org> In-Reply-To: <20220303210254.3116-1-robin.roevens@disroot.org> References: <20220303210254.3116-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 6E093184D1.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1646946187.53049@5HMIWfHLqgW+cRJNi6ZtlA ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1646341404; a=rsa-sha256; cv=none; b=e4peJiTVw7nRkCziOr545p1BG/rETIzi9PbzkDLxchM0ouWi8Y5nfXgy65+dphGpz+Oa9a rcwYmI76vvJPXkGj2Cwk1+AcGocp/QrZmxS7XwLZBLWDP6Bdu+JXosBeOVZe0aSsSBdr+G mTQ04QG4ZzGi9Tqv221ZrYUXxeZkIrKWEi7t5SOrx8+XSF2ZE5j1Tv4Qg5IFyErpt5hpF+ O5aXinuJHKJVC3E/Rg/KWzxsQX8pzGG3h5ftQGzf/YFKastx6081KcfgZiqzCHGMY7RTru jVXB8p4HZkbcFLkh3Kt+KO9b+8C+wnLZUc3ykwHhkcPCYieMgfHIkgvFN2wK1A== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=D7Ra8Bkk; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1646341404; 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:dkim-signature; bh=yRuv9f4KHGVi+j3IJX+OTh7cAofOHSe08SG9Q+IrHHo=; b=x2YMU41NWDUIZwNu3y8EIXAmOA873RuphfgbjxzZdVq18ST62FjDuDi/U6W3ZbOM4M4QKV C+9Oj7y5ImY+3b4D3vULCTgMG2OLFLXPLv7Wgl6Vpjh8IAQ7cHu0s0B5QVtVtrsyj7DCYo 0bCXxyzMXhgUc2+0INGtSHQymAGNZB+Mf80buXJTZeSDOTVGgJfuiEmr2iNLT58PoNhstA wun+T1BuwQ0VQEy9fvFDI+xwW2rwC8URhk93sYGHzdqDOb/+Y5zCW+2FX0Vg8lV8My1/ra JCXvmWiw/efKA5bp/SkMWHq+VaHMeAbXM+MQNn83g8eVRk4Yu4C1vvNAI4z9yA== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=D7Ra8Bkk; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-4.80 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.16)[asn: 50673(-0.33), country: NL(-0.01), ip: 178.21.23.139(-0.82)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-0.98)[-0.984]; SPF_REPUTATION_HAM(-0.65)[-0.6536605255241]; MV_CASE(0.50)[]; R_MISSING_CHARSET(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_SPF_ALLOW(-0.20)[+a:c]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[disroot.org:+]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4K8k3c0QJvz5Wr 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" - Remove sudoers file 'zabbix' in favour of new IPFire managed 'zabbix_agentd' and user managed 'zabbix_agentd_user' which is included in the backup - Provide migration of old sudoers file 'zabbix' or 'zabbix.user' to new zabbix_agentd_user sudoers file if it was modified by user. Signed-off-by: Robin Roevens --- config/backup/includes/zabbix_agentd | 4 ++-- config/rootfiles/packages/zabbix_agentd | 3 ++- config/zabbix_agentd/sudoers | 14 ++++---------- config/zabbix_agentd/sudoers_user | 16 ++++++++++++++++ lfs/zabbix_agentd | 4 +++- src/paks/zabbix_agentd/update.sh | 22 ++++++++++++++++++---- 6 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 config/zabbix_agentd/sudoers_user diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index 4be365297..834766992 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,5 +1,5 @@ -/etc/sudoers.d/zabbix +/etc/sudoers.d/zabbix_agentd_user /etc/zabbix_agentd/zabbix_agentd.conf /etc/zabbix_agentd/scripts/ /etc/zabbix_agentd/zabbix_agentd.d/ -/usr/lib/zabbix/ +/usr/lib/zabbix/ \ No newline at end of file diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 66a1087cf..2ea98fc21 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -1,6 +1,7 @@ etc/logrotate.d/zabbix_agentd etc/rc.d/init.d/zabbix_agentd -etc/sudoers.d/zabbix +etc/sudoers.d/zabbix_agentd +etc/sudoers.d/zabbix_agentd_user etc/zabbix_agentd etc/zabbix_agentd/scripts etc/zabbix_agentd/zabbix_agentd.conf diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..cb4263ff6 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -1,17 +1,11 @@ # Include file for sudoers file # -# This is needed for some userparameters to be able to execute commands that only run as root (using sudo) -# e.g. /usr/bin/openssl or /usr/sbin/smartctl +# This is needed for some IPFire specific userparameters to be able to execute commands that only run as root (using sudo) # -# USE AT YOU'RE OWN RISK. USING THIS WRONG CAN RESULT IN A SECURITY BREACH! +# DO NOT CHANGE THIS FILE. This file is managed by IPFire, will be overwritten on next addon upgrade and is not +# included in the backup. # -# Some hints: -# - It is strongly recommended to edit this file only using the visudo -f command. If you mess up this file, -# you might end up locking yourself out of your system! -# - Append the full path incl. parameters to each command, using "," as separator. -# - Only add commands you really need. Zabbix should not have more rights than it has to. -# -# Append / edit the following list of commands to fit your needs: +# To add more sudo rights to zabbix agent, you should modify the sudoers file zabbix_agentd_user # Defaults:zabbix !requiretty zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status diff --git a/config/zabbix_agentd/sudoers_user b/config/zabbix_agentd/sudoers_user new file mode 100644 index 000000000..61cbc417b --- /dev/null +++ b/config/zabbix_agentd/sudoers_user @@ -0,0 +1,16 @@ +# Include file for sudoers file +# +# This is needed for some userparameters to be able to execute commands that only run as root (using sudo) +# e.g. /usr/bin/openssl or /usr/sbin/smartctl +# +# USE AT YOU'RE OWN RISK. USING THIS WRONG CAN RESULT IN A SECURITY BREACH! +# +# Some hints: +# - It is strongly recommended to edit this file only using the visudo -f command. If you mess up this file, +# you might end up locking yourself out of your system! +# - Append the full path incl. parameters to each command, using "," as separator. +# - Only add commands you really need. Zabbix should not have more rights than it has to. +# +# Uncomment the following line and edit the example of commands to fit your needs: + +#zabbix ALL=(ALL) NOPASSWD: , , ... diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 6e995f40b..929d36628 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -124,7 +124,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) # Install sudoers include file install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/sudoers \ - /etc/sudoers.d/zabbix + /etc/sudoers.d/zabbix_agentd + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/sudoers_user \ + /etc/sudoers.d/zabbix_agentd_user # Install include file for backup install -v -m 644 $(DIR_SRC)/config/backup/includes/zabbix_agentd \ diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 68bba4f80..74a47aa66 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,11 +22,25 @@ ############################################################################ # . /opt/pakfire/lib/functions.sh + +# Check if old sudoers file exists and remove if it was not modified +# or rename to the new zabbix_agentd_user file if it was. +if [ -f /etc/sudoers.d/zabbix.user ]; then + mv -v /etc/sudoers.d/zabbix.user /etc/sudoers.d/zabbix +fi + +if [ -f /etc/sudoers.d/zabbix ]; then + md5=$(md5sum /etc/sudoers.d/zabbix | cut -f1 -d" ") + # from commits 5737a22 & 06fc617 + if [ "$md5" == "dae8daa1bb7cb3d9959d1438ebe84c71" ] || \ + [ "$md5" == "9bc24158734f0bf7c8697d62bf4c952a" ]; then + rm -vf /etc/sudoers.d/zabbix + else + mv -v /etc/sudoers.d/zabbix /etc/sudoers.d/zabbix_agentd_user + fi +fi + extract_backup_includes ./uninstall.sh ./install.sh -# Ensure /etc/sudoers.d/zabbix.user is renamed to /etc/sudoers.d/zabbix -if [ -e /etc/sudoers.d/zabbix.user ]; then - mv -v /etc/sudoers.d/zabbix.user /etc/sudoers.d/zabbix -fi