Since a new version of Zabbix Agent 5 LTS was released before the previous patch-set was reviewed, I resubmit my patchset as a V2 updating current zabbix_agentd 4.2.6 to 5.0.10 as opposed to v5.0.9 in my previous submission. The other 3 patches in the set remain unchanged.
For reference I'll include the summary again:
This set of patches does not only update the binaries (well, the first patch only does that) but also fixes some things that I see as problematic in previous version: - /usr/lib/zabbix is created for users to drop custom agent modules in, however that dir was removed and recreated on update as it was not in the backup. I added it to the backup and prevented deletion of the directory if it is not empty upon uninstall, so user-added content would not disapear when the package is removed. - Sometimes a new version of the agent will introduce new configuration parameters. In general the Zabbix Agent config file(s) should remain compatible, but we never know what the future will bring us; and the user may miss out on new features introduced with new parameters in the config file. However we don't want to plain overwrite the configfile as the user may (probably has) have changed it. Currently on upgrade configfiles are backed up, removed, new are installed, then overwritten by the old ones from the backup. Ending with the old config and the new agent. I didn't find an example of another package doing something similar, so I chose to save the new configfile(s) as .ipfirenew-files like RPM-based distro's do with .rpmnew-files. If the original config file is absent the install script will automatically strip the .ipfirenew extension. And if the new config file does not differ from the currently installed one, the .ipfirenew-file is removed. The install-script will also issue warning messages if such .ipfirenew-files are left on the filesystem, requesting the user to manually investigate and possibly merge the configfile. I hope those warnings are visible in the pakfire output. A side effect is that the config files are also not removed when the package is uninstalled. I don't see a problem here for the zabbix own config-files. But it may pose a risk concerning the sudoers-file? - I added a few IPFire specific monitoring items to the agent config which can be used for more in-depth monitoring of the IPFire installation. The user is of course free to use my template available on share.zabbix.com or github to monitor those items, or create their own template.
Thanks for considering this patch-set. Please be honest but gentle commenting on it :-).
Regards Robin
- Update from 4.2.6 to latest LTS version 5.0.10 See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP=
-### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no + +### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*] + +### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no
### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem=
+### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface= + +### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem= + ### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. # @@ -265,7 +306,6 @@ ServerActive=127.0.0.1
Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
- ####### USER-DEFINED MONITORED PARAMETERS #######
### Option: UnsafeUserParameters @@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules
LoadModulePath=/usr/lib/zabbix
@@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile=
### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer=
### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile= + +####### For advanced users - TLS ciphersuite selection criteria ####### + +### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13= + +### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert= + +### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13= + +### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK= + +### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13= + +### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 4.2.6 +VER = 5.0.10
THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS =
############################################################################### @@ -43,7 +43,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212
install : $(TARGET)
@@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \ - --with-openssl + --with-openssl \ + --with-libcurl
cd $(DIR_APP) && make cd $(DIR_APP) && make install
Hi Robin,
I am not knowledgeable enough about zabbix to make any comment about the conf file changes other than that I could follow your explanations of why they were being done.
The lfs file changes look perfect to me.
A general comment I would make is that when you want to do a v2 version then if you enter
git patch-format -v2 -o ..... then the patches will be created automatically as [PATCH v2 1/3].
Note it is lower case v
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Update from 4.2.6 to latest LTS version 5.0.10 See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP=
-### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no
+### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*]
+### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no
### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem=
+### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface=
+### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem=
- ### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. #
@@ -265,7 +306,6 @@ ServerActive=127.0.0.1
Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS #######
### Option: UnsafeUserParameters
@@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules
LoadModulePath=/usr/lib/zabbix
@@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile=
### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer=
### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile=
+####### For advanced users - TLS ciphersuite selection criteria #######
+### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13=
+### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert=
+### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13=
+### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK=
+### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13=
+### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 4.2.6 +VER = 5.0.10
THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS =
############################################################################### @@ -43,7 +43,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212
install : $(TARGET)
@@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \
--with-openssl
--with-openssl \
--with-libcurl
cd $(DIR_APP) && make cd $(DIR_APP) && make install
Hi Adolf
Thanks for your review. I didn't know about the -v2 parameter. Will use that in the future.
The conf file changes in this patch actually only reflect the changes in the upstream source default zabbix_agentd.conf-file which I merged with the customizations previously introduced by Alex.
Robin
Adolf Belka schreef op vr 09-04-2021 om 21:25 [+0200]:
Hi Robin,
I am not knowledgeable enough about zabbix to make any comment about the conf file changes other than that I could follow your explanations of why they were being done.
The lfs file changes look perfect to me.
A general comment I would make is that when you want to do a v2 version then if you enter
git patch-format -v2 -o ..... then the patches will be created automatically as [PATCH v2 1/3].
Note it is lower case v
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Update from 4.2.6 to latest LTS version 5.0.10
See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP= -### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no
+### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*]
+### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no ### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem= +### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface=
+### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem=
### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. # @@ -265,7 +306,6 @@ ServerActive=127.0.0.1 Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS ####### ### Option: UnsafeUserParameters @@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules LoadModulePath=/usr/lib/zabbix @@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile= ### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer= ### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile=
+####### For advanced users - TLS ciphersuite selection criteria #######
+### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13=
+### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128- GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN- ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert=
+### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13=
+### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128- GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN- ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK=
+### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 :TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13=
+### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE- PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE- ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128: kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ################################################################### ############ # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@ include Config -VER = 4.2.6 +VER = 5.0.10 THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS = ################################################################### ############ @@ -43,7 +43,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212 install : $(TARGET) @@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \ - --with-openssl + --with-openssl \ + --with-libcurl cd $(DIR_APP) && make cd $(DIR_APP) && make install
Hello Adolf,
You can use the Reviewed-by: tag to mark a patch as reviewed by you:
https://wiki.ipfire.org/devel/git/tags
-Michael
On 9 Apr 2021, at 20:25, Adolf Belka adolf.belka@ipfire.org wrote:
Hi Robin,
I am not knowledgeable enough about zabbix to make any comment about the conf file changes other than that I could follow your explanations of why they were being done.
The lfs file changes look perfect to me.
A general comment I would make is that when you want to do a v2 version then if you enter
git patch-format -v2 -o ..... then the patches will be created automatically as [PATCH v2 1/3].
Note it is lower case v
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Update from 4.2.6 to latest LTS version 5.0.10 See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP= -### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no
+### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*]
+### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no ### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem= +### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface=
+### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem=
### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. # @@ -265,7 +306,6 @@ ServerActive=127.0.0.1 Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS ####### ### Option: UnsafeUserParameters @@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules LoadModulePath=/usr/lib/zabbix @@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile= ### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer= ### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile=
+####### For advanced users - TLS ciphersuite selection criteria #######
+### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13=
+### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert=
+### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13=
+### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK=
+### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13=
+### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@ include Config -VER = 4.2.6 +VER = 5.0.10 THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS = ############################################################################### @@ -43,7 +43,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212 install : $(TARGET) @@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \
--with-openssl
--with-openssl \
cd $(DIR_APP) && make cd $(DIR_APP) && make install--with-libcurl
Hi Michael,
On 12/04/2021 12:27, Michael Tremer wrote:
Hello Adolf,
You can use the Reviewed-by: tag to mark a patch as reviewed by you:
I wasn't sure if I was OK for me to use the reviewed tag or if it was limited to specific people. I will use it in future now when I do a review of a patch.
Regards, Adolf.
-Michael
On 9 Apr 2021, at 20:25, Adolf Belka adolf.belka@ipfire.org wrote:
Hi Robin,
I am not knowledgeable enough about zabbix to make any comment about the conf file changes other than that I could follow your explanations of why they were being done.
The lfs file changes look perfect to me.
A general comment I would make is that when you want to do a v2 version then if you enter
git patch-format -v2 -o ..... then the patches will be created automatically as [PATCH v2 1/3].
Note it is lower case v
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Update from 4.2.6 to latest LTS version 5.0.10 See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP= -### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no
+### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*]
+### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no ### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem= +### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface=
+### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem=
- ### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. #
@@ -265,7 +306,6 @@ ServerActive=127.0.0.1 Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS ####### ### Option: UnsafeUserParameters @@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules LoadModulePath=/usr/lib/zabbix @@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile= ### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer= ### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile=
+####### For advanced users - TLS ciphersuite selection criteria #######
+### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13=
+### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert=
+### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13=
+### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK=
+### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13=
+### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@ include Config -VER = 4.2.6 +VER = 5.0.10 THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS = ############################################################################### @@ -43,7 +43,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212 install : $(TARGET) @@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \
--with-openssl
--with-openssl \
cd $(DIR_APP) && make install--with-libcurl cd $(DIR_APP) && make
Hello,
No, if you have reviewed it you can add the tag. Just anywhere in an email and Patchwork will parse and add credit.
The reason why we are doing the tags is:
* To give credit (because it very often is not only one person who has worked on something, but Git only allows one author field)
* We know what has been reviewed
* And if something is broken, there is a list of people who have been working on this who can be shot… joking… who can be consulted about why something was solved in a certain way, etc.
You can also use Tested-by which is very helpful, too.
Best, -Michael
On 12 Apr 2021, at 12:23, Adolf Belka adolf.belka@ipfire.org wrote:
Hi Michael,
On 12/04/2021 12:27, Michael Tremer wrote:
Hello Adolf, You can use the Reviewed-by: tag to mark a patch as reviewed by you: https://wiki.ipfire.org/devel/git/tags
I wasn't sure if I was OK for me to use the reviewed tag or if it was limited to specific people. I will use it in future now when I do a review of a patch.
Regards, Adolf.
-Michael
On 9 Apr 2021, at 20:25, Adolf Belka adolf.belka@ipfire.org wrote:
Hi Robin,
I am not knowledgeable enough about zabbix to make any comment about the conf file changes other than that I could follow your explanations of why they were being done.
The lfs file changes look perfect to me.
A general comment I would make is that when you want to do a v2 version then if you enter
git patch-format -v2 -o ..... then the patches will be created automatically as [PATCH v2 1/3].
Note it is lower case v
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Update from 4.2.6 to latest LTS version 5.0.10 See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP= -### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no
+### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*]
+### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no ### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem= +### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface=
+### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem=
### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. # @@ -265,7 +306,6 @@ ServerActive=127.0.0.1 Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS ####### ### Option: UnsafeUserParameters @@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules LoadModulePath=/usr/lib/zabbix @@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile= ### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer= ### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile=
+####### For advanced users - TLS ciphersuite selection criteria #######
+### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13=
+### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert=
+### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13=
+### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK=
+### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13=
+### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@ include Config -VER = 4.2.6 +VER = 5.0.10 THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS = ############################################################################### @@ -43,7 +43,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212 install : $(TARGET) @@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \
--with-openssl
--with-openssl \
cd $(DIR_APP) && make cd $(DIR_APP) && make install--with-libcurl
Hello,
This looks all fine.
-Michael
On 7 Apr 2021, at 21:44, Robin Roevens robin.roevens@disroot.org wrote:
- Update from 4.2.6 to latest LTS version 5.0.10
See release notes: https://www.zabbix.com/rn/rn5.0.10
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/zabbix_agentd/zabbix_agentd.conf | 124 ++++++++++++++++++++++-- lfs/zabbix_agentd | 11 ++- 2 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/config/zabbix_agentd/zabbix_agentd.conf b/config/zabbix_agentd/zabbix_agentd.conf index 21b8e0122..4d6c4c154 100644 --- a/config/zabbix_agentd/zabbix_agentd.conf +++ b/config/zabbix_agentd/zabbix_agentd.conf @@ -63,14 +63,33 @@ LogFileSize=0 # Default: # SourceIP=
-### Option: EnableRemoteCommands -# Whether remote commands from Zabbix server are allowed. -# 0 - not allowed -# 1 - allowed +### Option: AllowKey +# Allow execution of item keys matching pattern. +# Multiple keys matching rules may be defined in combination with DenyKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# +# Mandatory: no
+### Option: DenyKey +# Deny execution of items keys matching pattern. +# Multiple keys matching rules may be defined in combination with AllowKey. +# Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. +# Parameters are processed one by one according their appearance order. +# If no AllowKey or DenyKey rules defined, all keys are allowed. +# Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: -# EnableRemoteCommands=0 +# DenyKey=system.run[*]
+### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead +# Internal alias for AllowKey/DenyKey parameters depending on value: +# 0 - DenyKey=system.run[*] +# 1 - AllowKey=system.run[*] +# +# Mandatory: no
### Option: LogRemoteCommands # Enable logging of executed shell commands as warnings. @@ -177,6 +196,28 @@ ServerActive=127.0.0.1 # Default: # HostMetadataItem=
+### Option: HostInterface +# Optional parameter that defines host interface. +# Host interface is used at host auto-registration process. +# An agent will issue an error and not start if the value is over limit of 255 characters. +# If not defined, value will be acquired from HostInterfaceItem. +# +# Mandatory: no +# Range: 0-255 characters +# Default: +# HostInterface=
+### Option: HostInterfaceItem +# Optional parameter that defines an item used for getting host interface. +# Host interface is used at host auto-registration process. +# During an auto-registration request an agent will log a warning message if +# the value returned by specified item is over limit of 255 characters. +# This option is only used when HostInterface is not defined. +# +# Mandatory: no +# Default: +# HostInterfaceItem=
### Option: RefreshActiveChecks # How often list of active checks is refreshed, in seconds. # @@ -265,7 +306,6 @@ ServerActive=127.0.0.1
Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf
####### USER-DEFINED MONITORED PARAMETERS #######
### Option: UnsafeUserParameters @@ -299,7 +339,7 @@ Include=/etc/zabbix_agentd/zabbix_agentd.d/*.conf # # Mandatory: no # Default: -# LoadModulePath=/usr/lib/modules +# LoadModulePath=${libdir}/modules
LoadModulePath=/usr/lib/zabbix
@@ -357,14 +397,14 @@ LoadModulePath=/usr/lib/zabbix # TLSCRLFile=
### Option: TLSServerCertIssuer -# Allowed server certificate issuer. +# Allowed server certificate issuer. # # Mandatory: no # Default: # TLSServerCertIssuer=
### Option: TLSServerCertSubject -# Allowed server certificate subject. +# Allowed server certificate subject. # # Mandatory: no # Default: @@ -397,3 +437,69 @@ LoadModulePath=/usr/lib/zabbix # Mandatory: no # Default: # TLSPSKFile=
+####### For advanced users - TLS ciphersuite selection criteria #######
+### Option: TLSCipherCert13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# +# Mandatory: no +# Default: +# TLSCipherCert13=
+### Option: TLSCipherCert +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128 +# +# Mandatory: no +# Default: +# TLSCipherCert=
+### Option: TLSCipherPSK13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example: +# TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherPSK13=
+### Option: TLSCipherPSK +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL +# Example for OpenSSL: +# kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherPSK=
+### Option: TLSCipherAll13 +# Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example: +# TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256 +# +# Mandatory: no +# Default: +# TLSCipherAll13=
+### Option: TLSCipherAll +# GnuTLS priority string or OpenSSL (TLS 1.2) cipher string. +# Override the default ciphersuite selection criteria for certificate- and PSK-based encryption. +# Example for GnuTLS: +# NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509 +# Example for OpenSSL: +# EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128 +# +# Mandatory: no +# Default: +# TLSCipherAll= diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index c69643a54..2d57b0dbe 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2019 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 4.2.6 +VER = 5.0.10
THISAPP = zabbix-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd -PAK_VER = 4 +PAK_VER = 5 DEPS =
############################################################################### @@ -43,7 +43,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 6cd55cd743d416d9ffbf2e6fdee680ee +$(DL_FILE)_MD5 = 17403cce60266019f25ff53c72f0e212
install : $(TARGET)
@@ -80,7 +80,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --prefix=/usr \ --enable-agent \ --sysconfdir=/etc/zabbix_agentd \
--with-openssl
--with-openssl \
--with-libcurl
cd $(DIR_APP) && make cd $(DIR_APP) && make install
-- 2.30.2
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
- Add agent modules-dir to backup - Remove original, not used agent modules dir from rootfile - Delete agent modules dir only when empty on uninstall thus keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix
restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files
+# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then + rmdir /usr/lib/zabbix +fi + # Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@ ############################################################################ # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Add agent modules-dir to backup
- Remove original, not used agent modules dir from rootfile
- Delete agent modules dir only when empty on uninstall thus keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix
restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files
+# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then
- rmdir /usr/lib/zabbix
+fi
- # Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd
diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@ ############################################################################ # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
Hi Adolf
Indeed, I should have explicitly mentioned the modules-dir; the original /usr/lib/modules which was removed from the rootfile and the custom one, introduced by Alex, but not backed up until now: /usr/lib/zabbix/. I have been digging in the mailinglist archives to find out why Alex was using /usr/lib/zabbix/ and thus I was 'deep' into the modules-dirs saga that I considered it 'common knowledge' at that point in time where I committed this change. But of course, it is no common knowledge for you guys :-) I will try to pay more attention to such things in the future.
Regards Robin
Adolf Belka schreef op vr 09-04-2021 om 21:36 [+0200]:
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Add agent modules-dir to backup
- Remove original, not used agent modules dir from rootfile
- Delete agent modules dir only when empty on uninstall thus
keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files +# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then + rmdir /usr/lib/zabbix +fi
# Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@ ################################################################### ######### # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
Hello,
So, this is slightly more complicated.
The usual way how we do things is to back up any kind of configuration, uninstall everything, install the new package and then restore the configuration.
Having custom files in a system directory is probably going to break this.
Is there any way to have custom scripts in /etc/zabbix/… or something similar?
-Michael
On 10 Apr 2021, at 22:13, Robin Roevens robin.roevens@disroot.org wrote:
Hi Adolf
Indeed, I should have explicitly mentioned the modules-dir; the original /usr/lib/modules which was removed from the rootfile and the custom one, introduced by Alex, but not backed up until now: /usr/lib/zabbix/. I have been digging in the mailinglist archives to find out why Alex was using /usr/lib/zabbix/ and thus I was 'deep' into the modules-dirs saga that I considered it 'common knowledge' at that point in time where I committed this change. But of course, it is no common knowledge for you guys :-) I will try to pay more attention to such things in the future.
Regards Robin
Adolf Belka schreef op vr 09-04-2021 om 21:36 [+0200]:
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Add agent modules-dir to backup
- Remove original, not used agent modules dir from rootfile
- Delete agent modules dir only when empty on uninstall thus
keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix
restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files
+# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then
rmdir /usr/lib/zabbix
+fi
- # Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd
diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@
################################################################### ######### # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
(forgot to reply to all :-))
Hi
In theory, I think I could move the modules dir from current /usr/lib/zabbix to /etc/zabbix_agentd/modules for example.
However modules are not planin text config files but rather binary (possibly user-created and compiled) libraries that plug into the agent to extend it's functionality. So I assume a user will probably have the source code of the binary library some place else and could probably easily re-deploy the compiled modules after the backup is restored in a recovery situation. But I figured, as it is in a way a configuration of the agent instance, it should also be backed up, not requiring users to re-deploy those after a recovery. But moving binary files into /etc/... feels a bit awkward.. but technically it could be done.
Robin
Michael Tremer schreef op ma 12-04-2021 om 11:26 [+0100]:
Hello,
So, this is slightly more complicated.
The usual way how we do things is to back up any kind of configuration, uninstall everything, install the new package and then restore the configuration.
Having custom files in a system directory is probably going to break this.
Is there any way to have custom scripts in /etc/zabbix/… or something similar?
-Michael
On 10 Apr 2021, at 22:13, Robin Roevens robin.roevens@disroot.org wrote:
Hi Adolf
Indeed, I should have explicitly mentioned the modules-dir; the original /usr/lib/modules which was removed from the rootfile and the custom one, introduced by Alex, but not backed up until now: /usr/lib/zabbix/. I have been digging in the mailinglist archives to find out why Alex was using /usr/lib/zabbix/ and thus I was 'deep' into the modules- dirs saga that I considered it 'common knowledge' at that point in time where I committed this change. But of course, it is no common knowledge for you guys :-) I will try to pay more attention to such things in the future.
Regards Robin
Adolf Belka schreef op vr 09-04-2021 om 21:36 [+0200]:
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Add agent modules-dir to backup
- Remove original, not used agent modules dir from rootfile
- Delete agent modules dir only when empty on uninstall thus
keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files +# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then + rmdir /usr/lib/zabbix +fi
# Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@ ############################################################### #### ######### # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hello,
I agree, /etc isn’t exactly the best place for it, but it comes with a couple of benefits:
* We will include those files in the backup (or at least should be doing so)
* We have control over /usr/lib/zabbix and can do whatever we need there (I was assuming that there are some system files in there - if that is wrong and there is nothing in this directory apart from user files, we can leave it as /usr/lib/zabbix)
-Michael
On 12 Apr 2021, at 11:50, Robin Roevens robin.roevens@disroot.org wrote:
(forgot to reply to all :-))
Hi
In theory, I think I could move the modules dir from current /usr/lib/zabbix to /etc/zabbix_agentd/modules for example.
However modules are not planin text config files but rather binary (possibly user-created and compiled) libraries that plug into the agent to extend it's functionality. So I assume a user will probably have the source code of the binary library some place else and could probably easily re-deploy the compiled modules after the backup is restored in a recovery situation. But I figured, as it is in a way a configuration of the agent instance, it should also be backed up, not requiring users to re-deploy those after a recovery. But moving binary files into /etc/... feels a bit awkward.. but technically it could be done.
Robin
Michael Tremer schreef op ma 12-04-2021 om 11:26 [+0100]:
Hello,
So, this is slightly more complicated.
The usual way how we do things is to back up any kind of configuration, uninstall everything, install the new package and then restore the configuration.
Having custom files in a system directory is probably going to break this.
Is there any way to have custom scripts in /etc/zabbix/… or something similar?
-Michael
On 10 Apr 2021, at 22:13, Robin Roevens robin.roevens@disroot.org wrote:
Hi Adolf
Indeed, I should have explicitly mentioned the modules-dir; the original /usr/lib/modules which was removed from the rootfile and the custom one, introduced by Alex, but not backed up until now: /usr/lib/zabbix/. I have been digging in the mailinglist archives to find out why Alex was using /usr/lib/zabbix/ and thus I was 'deep' into the modules- dirs saga that I considered it 'common knowledge' at that point in time where I committed this change. But of course, it is no common knowledge for you guys :-) I will try to pay more attention to such things in the future.
Regards Robin
Adolf Belka schreef op vr 09-04-2021 om 21:36 [+0200]:
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Add agent modules-dir to backup
- Remove original, not used agent modules dir from rootfile
- Delete agent modules dir only when empty on uninstall thus
keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix
restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files
+# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then
rmdir /usr/lib/zabbix
+fi
- # Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd
diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@
############################################################### #### ######### # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hi
That directory is purely meant for user-modules and by default is empty as nor we, nor Zabbix ship user-modules with the agent. And I don't see that changing in the near future. So currently indeed only user-files will be located there.
Robin
Michael Tremer schreef op ma 12-04-2021 om 11:52 [+0100]:
Hello,
I agree, /etc isn’t exactly the best place for it, but it comes with a couple of benefits:
- We will include those files in the backup (or at least should be
doing so)
- We have control over /usr/lib/zabbix and can do whatever we need
there (I was assuming that there are some system files in there - if that is wrong and there is nothing in this directory apart from user files, we can leave it as /usr/lib/zabbix)
-Michael
On 12 Apr 2021, at 11:50, Robin Roevens robin.roevens@disroot.org wrote:
(forgot to reply to all :-))
Hi
In theory, I think I could move the modules dir from current /usr/lib/zabbix to /etc/zabbix_agentd/modules for example.
However modules are not planin text config files but rather binary (possibly user-created and compiled) libraries that plug into the agent to extend it's functionality. So I assume a user will probably have the source code of the binary library some place else and could probably easily re-deploy the compiled modules after the backup is restored in a recovery situation. But I figured, as it is in a way a configuration of the agent instance, it should also be backed up, not requiring users to re-deploy those after a recovery. But moving binary files into /etc/... feels a bit awkward.. but technically it could be done.
Robin
Michael Tremer schreef op ma 12-04-2021 om 11:26 [+0100]:
Hello,
So, this is slightly more complicated.
The usual way how we do things is to back up any kind of configuration, uninstall everything, install the new package and then restore the configuration.
Having custom files in a system directory is probably going to break this.
Is there any way to have custom scripts in /etc/zabbix/… or something similar?
-Michael
On 10 Apr 2021, at 22:13, Robin Roevens robin.roevens@disroot.org wrote:
Hi Adolf
Indeed, I should have explicitly mentioned the modules-dir; the original /usr/lib/modules which was removed from the rootfile and the custom one, introduced by Alex, but not backed up until now: /usr/lib/zabbix/. I have been digging in the mailinglist archives to find out why Alex was using /usr/lib/zabbix/ and thus I was 'deep' into the modules- dirs saga that I considered it 'common knowledge' at that point in time where I committed this change. But of course, it is no common knowledge for you guys :-) I will try to pay more attention to such things in the future.
Regards Robin
Adolf Belka schreef op vr 09-04-2021 om 21:36 [+0200]:
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote:
- Add agent modules-dir to backup
- Remove original, not used agent modules dir from rootfile
- Delete agent modules dir only when empty on uninstall
thus keeping possible user deployed custom module files but removing it if unused.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/backup/includes/zabbix_agentd | 3 ++- config/rootfiles/packages/zabbix_agentd | 4 ++-- src/paks/zabbix_agentd/install.sh | 2 ++ src/paks/zabbix_agentd/uninstall.sh | 5 +++++ src/paks/zabbix_agentd/update.sh | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config/backup/includes/zabbix_agentd b/config/backup/includes/zabbix_agentd index cba18d772..d3305cb96 100644 --- a/config/backup/includes/zabbix_agentd +++ b/config/backup/includes/zabbix_agentd @@ -1,2 +1,3 @@ /etc/sudoers.d/zabbix -/etc/zabbix_agentd/* +/etc/zabbix_agentd/ +/usr/lib/zabbix/ diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 4420bda05..a938f2605 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.con f usr/bin/zabbix_get usr/bin/zabbix_sender -usr/lib/modules -usr/lib/zabbix +#usr/lib/modules +#usr/lib/zabbix usr/sbin/zabbix_agentd #usr/share/man/man1/zabbix_get.1 #usr/share/man/man1/zabbix_sender.1 diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index e1450a1d8..b98230ea1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd /etc/rc.d/rc6.d/K02zabbix_agentd # Create additonal directories and set permissions mkdir -pv /var/log/zabbix chown zabbix.zabbix /var/log/zabbix +mkdir -pv /usr/lib/zabbix +chown zabbix.zabbix /usr/lib/zabbix restore_backup ${NAME} start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index edff3b818..b771d1f63 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,5 +26,10 @@ stop_service ${NAME} make_backup ${NAME} remove_files +# Remove agent modules dir if empty +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then + rmdir /usr/lib/zabbix +fi
# Remove init-scripts and symlinks rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 7fc1c96fb..68bba4f80 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -22,6 +22,7 @@ ########################################################### #### #### ######### # . /opt/pakfire/lib/functions.sh +extract_backup_includes ./uninstall.sh ./install.sh
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hello,
In that case ignore what I have said.
It probably is sufficient if we create this directory and that is it.
If we add our own files, we will have to revisit then.
Thanks for clearing this up for me.
-Michael
On 12 Apr 2021, at 12:38, Robin Roevens robin.roevens@disroot.org wrote:
Hi
That directory is purely meant for user-modules and by default is empty as nor we, nor Zabbix ship user-modules with the agent. And I don't see that changing in the near future. So currently indeed only user-files will be located there.
Robin
Michael Tremer schreef op ma 12-04-2021 om 11:52 [+0100]:
Hello,
I agree, /etc isn’t exactly the best place for it, but it comes with a couple of benefits:
- We will include those files in the backup (or at least should be
doing so)
- We have control over /usr/lib/zabbix and can do whatever we need
there (I was assuming that there are some system files in there - if that is wrong and there is nothing in this directory apart from user files, we can leave it as /usr/lib/zabbix)
-Michael
On 12 Apr 2021, at 11:50, Robin Roevens robin.roevens@disroot.org wrote:
(forgot to reply to all :-))
Hi
In theory, I think I could move the modules dir from current /usr/lib/zabbix to /etc/zabbix_agentd/modules for example.
However modules are not planin text config files but rather binary (possibly user-created and compiled) libraries that plug into the agent to extend it's functionality. So I assume a user will probably have the source code of the binary library some place else and could probably easily re-deploy the compiled modules after the backup is restored in a recovery situation. But I figured, as it is in a way a configuration of the agent instance, it should also be backed up, not requiring users to re-deploy those after a recovery. But moving binary files into /etc/... feels a bit awkward.. but technically it could be done.
Robin
Michael Tremer schreef op ma 12-04-2021 om 11:26 [+0100]:
Hello,
So, this is slightly more complicated.
The usual way how we do things is to back up any kind of configuration, uninstall everything, install the new package and then restore the configuration.
Having custom files in a system directory is probably going to break this.
Is there any way to have custom scripts in /etc/zabbix/… or something similar?
-Michael
On 10 Apr 2021, at 22:13, Robin Roevens robin.roevens@disroot.org wrote:
Hi Adolf
Indeed, I should have explicitly mentioned the modules-dir; the original /usr/lib/modules which was removed from the rootfile and the custom one, introduced by Alex, but not backed up until now: /usr/lib/zabbix/. I have been digging in the mailinglist archives to find out why Alex was using /usr/lib/zabbix/ and thus I was 'deep' into the modules- dirs saga that I considered it 'common knowledge' at that point in time where I committed this change. But of course, it is no common knowledge for you guys :-) I will try to pay more attention to such things in the future.
Regards Robin
Adolf Belka schreef op vr 09-04-2021 om 21:36 [+0200]:
Hi Robin,
The patches seem fine to me, although again my lack of zabbix knowledge means I can't comment on specifics easily.
Only minor general point I had was that the commit message might have more clearly specified that the modules-dir is /usr/lib/zabbix. I had to read through the whole patch to come to that conclusion.
Overall these look good patches for your first input.
Regards,
Adolf
On 07/04/2021 22:44, Robin Roevens wrote: > - Add agent modules-dir to backup > - Remove original, not used agent modules dir from rootfile > - Delete agent modules dir only when empty on uninstall > thus > keeping > possible user deployed custom module files but removing > it > if > unused. > > Signed-off-by: Robin Roevens robin.roevens@disroot.org > --- > config/backup/includes/zabbix_agentd | 3 ++- > config/rootfiles/packages/zabbix_agentd | 4 ++-- > src/paks/zabbix_agentd/install.sh | 2 ++ > src/paks/zabbix_agentd/uninstall.sh | 5 +++++ > src/paks/zabbix_agentd/update.sh | 1 + > 5 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/config/backup/includes/zabbix_agentd > b/config/backup/includes/zabbix_agentd > index cba18d772..d3305cb96 100644 > --- a/config/backup/includes/zabbix_agentd > +++ b/config/backup/includes/zabbix_agentd > @@ -1,2 +1,3 @@ > /etc/sudoers.d/zabbix > -/etc/zabbix_agentd/* > +/etc/zabbix_agentd/ > +/usr/lib/zabbix/ > diff --git a/config/rootfiles/packages/zabbix_agentd > b/config/rootfiles/packages/zabbix_agentd > index 4420bda05..a938f2605 100644 > --- a/config/rootfiles/packages/zabbix_agentd > +++ b/config/rootfiles/packages/zabbix_agentd > @@ -8,8 +8,8 @@ etc/zabbix_agentd/zabbix_agentd.d > > etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.con > f > usr/bin/zabbix_get > usr/bin/zabbix_sender > -usr/lib/modules > -usr/lib/zabbix > +#usr/lib/modules > +#usr/lib/zabbix > usr/sbin/zabbix_agentd > #usr/share/man/man1/zabbix_get.1 > #usr/share/man/man1/zabbix_sender.1 > diff --git a/src/paks/zabbix_agentd/install.sh > b/src/paks/zabbix_agentd/install.sh > index e1450a1d8..b98230ea1 100644 > --- a/src/paks/zabbix_agentd/install.sh > +++ b/src/paks/zabbix_agentd/install.sh > @@ -41,6 +41,8 @@ ln -sf ../init.d/zabbix_agentd > /etc/rc.d/rc6.d/K02zabbix_agentd > # Create additonal directories and set permissions > mkdir -pv /var/log/zabbix > chown zabbix.zabbix /var/log/zabbix > +mkdir -pv /usr/lib/zabbix > +chown zabbix.zabbix /usr/lib/zabbix > > restore_backup ${NAME} > start_service --background ${NAME} > diff --git a/src/paks/zabbix_agentd/uninstall.sh > b/src/paks/zabbix_agentd/uninstall.sh > index edff3b818..b771d1f63 100644 > --- a/src/paks/zabbix_agentd/uninstall.sh > +++ b/src/paks/zabbix_agentd/uninstall.sh > @@ -26,5 +26,10 @@ stop_service ${NAME} > make_backup ${NAME} > remove_files > > +# Remove agent modules dir if empty > +if [ -z "$(ls -A /usr/lib/zabbix/)" ]; then > + rmdir /usr/lib/zabbix > +fi > + > # Remove init-scripts and symlinks > rm -rfv /etc/rc.d/rc*.d/*zabbix_agentd > diff --git a/src/paks/zabbix_agentd/update.sh > b/src/paks/zabbix_agentd/update.sh > index 7fc1c96fb..68bba4f80 100644 > --- a/src/paks/zabbix_agentd/update.sh > +++ b/src/paks/zabbix_agentd/update.sh > @@ -22,6 +22,7 @@ > > ########################################################### > #### > #### > ######### > # > . /opt/pakfire/lib/functions.sh > +extract_backup_includes > ./uninstall.sh > ./install.sh >
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
- Renamed userparameters_pakfire.conf to template_app_pakfire.conf following current Zabbix template naming conventions. - Install configfiles as .ipfirenew-files to prevent removing possible user changed files on uninstall. If the configfiles are not yet present, the .ipfirenew-files will be renamed to the actual configfiles. And if an existing configfile does not differ from the new one, the .ipfirenew-file will be removed. This allows the user to manually merge his existing config with the new config after update (warnings will be displayed during update when manual review is required).
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- config/rootfiles/packages/zabbix_agentd | 12 ++++---- ...pakfire.conf => template_app_pakfire.conf} | 0 lfs/zabbix_agentd | 11 ++++--- src/paks/zabbix_agentd/install.sh | 29 +++++++++++++++++++ src/paks/zabbix_agentd/uninstall.sh | 4 +++ src/paks/zabbix_agentd/update.sh | 14 +++++++-- 6 files changed, 57 insertions(+), 13 deletions(-) rename config/zabbix_agentd/{userparameter_pakfire.conf => template_app_pakfire.conf} (100%)
diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index a938f2605..6945c5ef7 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -1,11 +1,11 @@ etc/logrotate.d/zabbix_agentd etc/rc.d/init.d/zabbix_agentd -etc/sudoers.d/zabbix -etc/zabbix_agentd -etc/zabbix_agentd/scripts -etc/zabbix_agentd/zabbix_agentd.conf -etc/zabbix_agentd/zabbix_agentd.d -etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf +etc/sudoers.d/zabbix.ipfirenew +#etc/zabbix_agentd +#etc/zabbix_agentd/scripts +etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew +#etc/zabbix_agentd/zabbix_agentd.d +etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew usr/bin/zabbix_get usr/bin/zabbix_sender #usr/lib/modules diff --git a/config/zabbix_agentd/userparameter_pakfire.conf b/config/zabbix_agentd/template_app_pakfire.conf similarity index 100% rename from config/zabbix_agentd/userparameter_pakfire.conf rename to config/zabbix_agentd/template_app_pakfire.conf diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 2d57b0dbe..73e08d20a 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -90,10 +90,13 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) -rmdir /etc/zabbix_agentd/zabbix_agentd.conf.d -mkdir -pv /etc/zabbix_agentd/zabbix_agentd.d -mkdir -pv /etc/zabbix_agentd/scripts + # Remove original config + @rm -f /etc/zabbix_agentd/zabbix_agentd.conf + # And replace with our own config install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/zabbix_agentd.conf \ - /etc/zabbix_agentd/zabbix_agentd.conf - install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/userparameter_pakfire.conf \ - /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf + /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ + /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix @@ -111,7 +114,7 @@ $(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.ipfirenew
# Install include file for backup install -v -m 644 $(DIR_SRC)/config/backup/includes/zabbix_agentd \ diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index b98230ea1..4248a7ec1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -23,6 +23,23 @@ # . /opt/pakfire/lib/functions.sh
+review_required=false + +function setup_configfile() { + # Puts configfile in place if it does not already exist or + # remove the shipped version if it does not differ from existing file + configfile=$1 + + if [ ! -f $configfile ]; then + mv $configfile.ipfirenew $configfile + elif diff -q $configfile $configfile.ipfirenew >/dev/null; then + rm -f $configfile.ipfirenew + else + echo "WARNING: new $configfile saved as $configfile.ipfirenew for manual review" + review_required=true + fi +} + if ! getent group zabbix &>/dev/null; then groupadd -g 118 zabbix fi @@ -45,4 +62,16 @@ mkdir -pv /usr/lib/zabbix chown zabbix.zabbix /usr/lib/zabbix
restore_backup ${NAME} + +# Put zabbix configfiles in place +setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/sudoers.d/zabbix + +if $review_required; then + echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." + echo " They may need manual review in order to take advantage of new features" + echo " or even to make this version of ${NAME} work." +fi + start_service --background ${NAME} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index b771d1f63..7a13880c5 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -23,6 +23,10 @@ # . /opt/pakfire/lib/functions.sh stop_service ${NAME} + +# Remove .ipfirenew files in advance so they won't be included in backup +rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew + make_backup ${NAME} remove_files
diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 68bba4f80..91dd8f723 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -23,10 +23,18 @@ # . /opt/pakfire/lib/functions.sh extract_backup_includes -./uninstall.sh -./install.sh + +# Ensure /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf is +# renamed to /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +if [ -f /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf ]; then + mv -v /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf \ + /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +fi
# Ensure /etc/sudoers.d/zabbix.user is renamed to /etc/sudoers.d/zabbix -if [ -e /etc/sudoers.d/zabbix.user ]; then +if [ -f /etc/sudoers.d/zabbix.user ]; then mv -v /etc/sudoers.d/zabbix.user /etc/sudoers.d/zabbix fi + +./uninstall.sh +./install.sh \ No newline at end of file
Provide IPFire specific items for the Zabbix server to monitor: - Networking stats: - ipfire.net.gateway.pingtime: Internet Line Quality - ipfire.net.gateway.ping: Internet connection - ipfire.net.fw.hits[*]: Firewall hits - IPFire service states: - ipfire.services: JSON formatted state of all IPFire services using new ipfire_services.pl script.
Users can install the IPFire 2 Zabbix template-set provided here: https://share.zabbix.com/network-appliances/ipfire-2 to monitor these metrics. Or create their own template.
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- config/rootfiles/packages/zabbix_agentd | 3 + config/zabbix_agentd/ipfire_services.pl | 221 ++++++++++++++++++ config/zabbix_agentd/sudoers | 2 +- .../template_module_ipfire_network_stats.conf | 4 + .../template_module_ipfire_services.conf | 2 + lfs/zabbix_agentd | 8 +- src/paks/zabbix_agentd/install.sh | 5 + src/paks/zabbix_agentd/uninstall.sh | 2 + 8 files changed, 245 insertions(+), 2 deletions(-) create mode 100755 config/zabbix_agentd/ipfire_services.pl create mode 100644 config/zabbix_agentd/template_module_ipfire_network_stats.conf create mode 100644 config/zabbix_agentd/template_module_ipfire_services.conf
diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 6945c5ef7..aa3f1846b 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -3,9 +3,12 @@ etc/rc.d/init.d/zabbix_agentd etc/sudoers.d/zabbix.ipfirenew #etc/zabbix_agentd #etc/zabbix_agentd/scripts +etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew #etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew +etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_stats.conf.ipfirenew +etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.conf.ipfirenew usr/bin/zabbix_get usr/bin/zabbix_sender #usr/lib/modules diff --git a/config/zabbix_agentd/ipfire_services.pl b/config/zabbix_agentd/ipfire_services.pl new file mode 100755 index 000000000..dbf8aec56 --- /dev/null +++ b/config/zabbix_agentd/ipfire_services.pl @@ -0,0 +1,221 @@ +#!/usr/bin/perl +############################################################################### +# ipfire_services.pl - Retrieves available IPFire services information and +# return this as a JSON array suitable for easy processing +# by Zabbix server +# +# Author: robin.roevens (at) disroot.org +# Version: 1.0 +# +# Based on: services.cgi by IPFire Team +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################### + +use strict; + +# enable only the following on debugging purpose +# use warnings; + +# Maps a nice printable name to the changing part of the pid file, which +# is also the name of the program +my %servicenames =( + 'DHCP Server' => 'dhcpd', + 'Web Server' => 'httpd', + 'CRON Server' => 'fcron', + 'DNS Proxy Server' => 'unbound', + 'Logging Server' => 'syslogd', + 'Kernel Logging Server' => 'klogd', + 'NTP Server' => 'ntpd', + 'Secure Shell Server' => 'sshd', + 'VPN' => 'charon', + 'Web Proxy' => 'squid', + 'Intrusion Detection System' => 'suricata', + 'OpenVPN' => 'openvpn' +); + +# Hash to overwrite the process name of a process if it differs from the launch command. +my %overwrite_exename_hash = ( + "suricata" => "Suricata-Main" +); + +my $first = 1; + +print "["; + +# Built-in services +my $key = ''; +foreach $key (sort keys %servicenames){ + print "," if not $first; + $first = 0; + + print "{"; + print ""service":"$key","; + + my $shortname = $servicenames{$key}; + print &servicestats($shortname); + + print "}"; +} + +# Generate list of installed addon pak's +my @pak = `find /opt/pakfire/db/installed/meta-* 2>/dev/null | cut -d"-" -f2`; +foreach (@pak){ + chomp($_); + + # Check which of the paks are services + my @svc = `find /etc/init.d/$_ 2>/dev/null | cut -d"/" -f4`; + foreach (@svc){ + # blacklist some packages + # + # alsa has trouble with the volume saving and was not really stopped + # mdadm should not stopped with webif because this could crash the system + # + chomp($_); + if ( $_ eq 'squid' ) { + next; + } + if ( ($_ ne "alsa") && ($_ ne "mdadm") ) { + print ","; + print "{"; + + print ""service":"Addon: $_","; + print ""servicename":"$_","; + + my $onboot = isautorun($_); + print ""onboot":$onboot,"; + + print &addonservicestats($_); + + print "}"; + } + } +} + +print "]"; + +sub servicestats{ + my $cmd = $_[0]; + my $status = ""servicename":"$cmd","state":"0""; + my $pid = ''; + my $testcmd = ''; + my $exename; + my $memory; + + + $cmd =~ /(^[a-z]+)/; + + # Check if the exename needs to be overwritten. + # This happens if the expected process name string + # differs from the real one. This may happened if + # a service uses multiple processes or threads. + if (exists($overwrite_exename_hash{$cmd})) { + # Grab the string which will be reported by + # the process from the corresponding hash. + $exename = $overwrite_exename_hash{$1}; + } else { + # Directly expect the launched command as + # process name. + $exename = $1; + } + + if (open(FILE, "/var/run/${cmd}.pid")){ + $pid = <FILE>; chomp $pid; + close FILE; + if (open(FILE, "/proc/${pid}/status")){ + while (<FILE>){ + if (/^Name:\W+(.*)/) { + $testcmd = $1; + } + } + close FILE; + } + if (open(FILE, "/proc/${pid}/status")) { + while (<FILE>) { + my ($key, $val) = split(":", $_, 2); + if ($key eq 'VmRSS') { + $val =~ /\s*([0-9]*)\s+kB/; + # Convert kB to B + $memory = $1*1024; + last; + } + } + close(FILE); + } + if ($testcmd =~ /$exename/){ + $status = ""servicename":"$cmd","state":1,"pid":$pid,"memory":$memory"; + } + } + return $status; +} + +sub isautorun{ + my $cmd = $_[0]; + my $status = "0"; + my $init = `find /etc/rc.d/rc3.d/S??${cmd} 2>/dev/null`; + chomp ($init); + if ($init ne ''){ + $status = "1"; + } + $init = `find /etc/rc.d/rc3.d/off/S??${cmd} 2>/dev/null`; + chomp ($init); + if ($init ne ''){ + $status = "0"; + } + + return $status; +} + +sub addonservicestats{ + my $cmd = $_[0]; + my $status = "0"; + my $pid = ''; + my $testcmd = ''; + my $exename; + my @memory = (0); + + $testcmd = `sudo /usr/local/bin/addonctrl $_ status 2>/dev/null`; + + if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ + $status = ""state":1"; + + $testcmd =~ s/.* //gi; + $testcmd =~ s/[a-z_]//gi; + $testcmd =~ s/[[0-1];[0-9]+//gi; + $testcmd =~ s/[().]//gi; + $testcmd =~ s/ //gi; + $testcmd =~ s///gi; + + my @pid = split(/\s/,$testcmd); + $status .=","pid":"$pid[0]""; + + my $memory = 0; + + foreach (@pid){ + chomp($_); + if (open(FILE, "/proc/$_/statm")){ + my $temp = <FILE>; + @memory = split(/ /,$temp); + } + $memory+=$memory[0]; + } + $memory*=1024; + $status .=","memory":$memory"; + }else{ + $status = ""state":0"; + } + return $status; +} diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..340bb8e66 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -14,4 +14,4 @@ # Append / edit the following list of commands to fit your needs: # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/local/bin/addonctrl, /sbin/iptables, /usr/sbin/fping diff --git a/config/zabbix_agentd/template_module_ipfire_network_stats.conf b/config/zabbix_agentd/template_module_ipfire_network_stats.conf new file mode 100644 index 000000000..f1658ed07 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_network_stats.conf @@ -0,0 +1,4 @@ +### Parameters for monitoring IPFire network statistics +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? ]; echo $? +UserParameter=ipfire.net.fw.hits[*],sudo /sbin/iptables -vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }'; diff --git a/config/zabbix_agentd/template_module_ipfire_services.conf b/config/zabbix_agentd/template_module_ipfire_services.conf new file mode 100644 index 000000000..5f95218e3 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_services.conf @@ -0,0 +1,2 @@ +### Parameter for monitoring IPFire services +UserParameter=ipfire.services,/etc/zabbix_agentd/scripts/ipfire_services.pl diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 73e08d20a..c0d28d51f 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = +DEPS = "fping"
############################################################################### # Top-level Rules @@ -97,6 +97,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_network_stats.conf \ + /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_stats.conf.ipfirenew + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_services.conf \ + /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.conf.ipfirenew + install -v -m 755 $(DIR_SRC)/config/zabbix_agentd/ipfire_services.pl \ + /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index 4248a7ec1..ced915c81 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -66,8 +66,13 @@ restore_backup ${NAME} # Put zabbix configfiles in place setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_stats.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.conf setup_configfile /etc/sudoers.d/zabbix
+# Overwrite script if it exists as user should not modify it but it is included in backup +mv /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew /etc/zabbix_agentd/scripts/ipfire_services.pl + if $review_required; then echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." echo " They may need manual review in order to take advantage of new features" diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index 7a13880c5..ccbc8f7cf 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,6 +26,8 @@ stop_service ${NAME}
# Remove .ipfirenew files in advance so they won't be included in backup rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew +# Remove script-file as it should not have been modified by user +rm -fv /etc/zabbix_agentd/scripts/ipfire_services.pl
make_backup ${NAME} remove_files
Hello,
On 7 Apr 2021, at 21:44, Robin Roevens robin.roevens@disroot.org wrote:
Provide IPFire specific items for the Zabbix server to monitor:
- Networking stats:
- ipfire.net.gateway.pingtime: Internet Line Quality
- ipfire.net.gateway.ping: Internet connection
- ipfire.net.fw.hits[*]: Firewall hits
- IPFire service states:
- ipfire.services: JSON formatted state of all IPFire services using new ipfire_services.pl script.
Users can install the IPFire 2 Zabbix template-set provided here: https://share.zabbix.com/network-appliances/ipfire-2 to monitor these metrics. Or create their own template.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
config/rootfiles/packages/zabbix_agentd | 3 + config/zabbix_agentd/ipfire_services.pl | 221 ++++++++++++++++++ config/zabbix_agentd/sudoers | 2 +- .../template_module_ipfire_network_stats.conf | 4 + .../template_module_ipfire_services.conf | 2 + lfs/zabbix_agentd | 8 +- src/paks/zabbix_agentd/install.sh | 5 + src/paks/zabbix_agentd/uninstall.sh | 2 + 8 files changed, 245 insertions(+), 2 deletions(-) create mode 100755 config/zabbix_agentd/ipfire_services.pl create mode 100644 config/zabbix_agentd/template_module_ipfire_network_stats.conf create mode 100644 config/zabbix_agentd/template_module_ipfire_services.conf
diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index 6945c5ef7..aa3f1846b 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -3,9 +3,12 @@ etc/rc.d/init.d/zabbix_agentd etc/sudoers.d/zabbix.ipfirenew #etc/zabbix_agentd #etc/zabbix_agentd/scripts +etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew #etc/zabbix_agentd/zabbix_agentd.d etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew +etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_stats.conf.ipfirenew +etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.conf.ipfirenew usr/bin/zabbix_get usr/bin/zabbix_sender #usr/lib/modules diff --git a/config/zabbix_agentd/ipfire_services.pl b/config/zabbix_agentd/ipfire_services.pl new file mode 100755 index 000000000..dbf8aec56 --- /dev/null +++ b/config/zabbix_agentd/ipfire_services.pl @@ -0,0 +1,221 @@ +#!/usr/bin/perl +############################################################################### +# ipfire_services.pl - Retrieves available IPFire services information and +# return this as a JSON array suitable for easy processing +# by Zabbix server +# +# Author: robin.roevens (at) disroot.org +# Version: 1.0 +# +# Based on: services.cgi by IPFire Team +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +###############################################################################
+use strict;
+# enable only the following on debugging purpose +# use warnings;
+# Maps a nice printable name to the changing part of the pid file, which +# is also the name of the program +my %servicenames =(
'DHCP Server' => 'dhcpd',
'Web Server' => 'httpd',
'CRON Server' => 'fcron',
'DNS Proxy Server' => 'unbound',
'Logging Server' => 'syslogd',
'Kernel Logging Server' => 'klogd',
'NTP Server' => 'ntpd',
'Secure Shell Server' => 'sshd',
'VPN' => 'charon',
'Web Proxy' => 'squid',
'Intrusion Detection System' => 'suricata',
'OpenVPN' => 'openvpn'
+);
You have a hard-coded list with process names here. It technically is missing add-ons but including everything would make this list very long and a lot of work to maintain...
+# Hash to overwrite the process name of a process if it differs from the launch command. +my %overwrite_exename_hash = (
"suricata" => "Suricata-Main"
+);
+my $first = 1;
+print "[";
+# Built-in services +my $key = ''; +foreach $key (sort keys %servicenames){
- print "," if not $first;
- $first = 0;
- print "{";
- print ""service":"$key",";
- my $shortname = $servicenames{$key};
- print &servicestats($shortname);
- print "}";
+}
+# Generate list of installed addon pak's +my @pak = `find /opt/pakfire/db/installed/meta-* 2>/dev/null | cut -d"-" -f2`; +foreach (@pak){
- chomp($_);
- # Check which of the paks are services
- my @svc = `find /etc/init.d/$_ 2>/dev/null | cut -d"/" -f4`;
- foreach (@svc){
# blacklist some packages
#
# alsa has trouble with the volume saving and was not really stopped
# mdadm should not stopped with webif because this could crash the system
#
chomp($_);
if ( $_ eq 'squid' ) {
next;
}
if ( ($_ ne "alsa") && ($_ ne "mdadm") ) {
Another hardcoded list due to code duplication. Not your fault, but not pretty.
print ",";
print "{";
print "\"service\":\"Addon: $_\",";
print "\"servicename\":\"$_\",";
my $onboot = isautorun($_);
print "\"onboot\":$onboot,";
print &addonservicestats($_);
print "}";
}
- }
+}
+print "]";
+sub servicestats{
- my $cmd = $_[0];
- my $status = ""servicename":"$cmd","state":"0"";
- my $pid = '';
- my $testcmd = '';
my $exename;
my $memory;
- $cmd =~ /(^[a-z]+)/;
- # Check if the exename needs to be overwritten.
# This happens if the expected process name string
# differs from the real one. This may happened if
# a service uses multiple processes or threads.
if (exists($overwrite_exename_hash{$cmd})) {
# Grab the string which will be reported by
# the process from the corresponding hash.
$exename = $overwrite_exename_hash{$1};
} else {
# Directly expect the launched command as
# process name.
$exename = $1;
}
- if (open(FILE, "/var/run/${cmd}.pid")){
$pid = <FILE>; chomp $pid;
close FILE;
if (open(FILE, "/proc/${pid}/status")){
while (<FILE>){
if (/^Name:\W+(.*)/) {
$testcmd = $1;
}
}
close FILE;
}
if (open(FILE, "/proc/${pid}/status")) {
while (<FILE>) {
my ($key, $val) = split(":", $_, 2);
if ($key eq 'VmRSS') {
$val =~ /\s*([0-9]*)\s+kB/;
# Convert kB to B
$memory = $1*1024;
last;
}
}
close(FILE);
}
if ($testcmd =~ /$exename/){
$status = "\"servicename\":\"$cmd\",\"state\":1,\"pid\":$pid,\"memory\":$memory";
}
}
return $status;
+}
+sub isautorun{
my $cmd = $_[0];
my $status = "0";
my $init = `find /etc/rc.d/rc3.d/S??${cmd} 2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "1";
}
$init = `find /etc/rc.d/rc3.d/off/S??${cmd} 2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "0";
}
return $status;
+}
+sub addonservicestats{
my $cmd = $_[0];
my $status = "0";
my $pid = '';
my $testcmd = '';
my $exename;
my @memory = (0);
$testcmd = `sudo /usr/local/bin/addonctrl $_ status 2>/dev/null`;
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){
$status = "\"state\":1";
$testcmd =~ s/.* //gi;
$testcmd =~ s/[a-z_]//gi;
$testcmd =~ s/\[[0-1]\;[0-9]+//gi;
$testcmd =~ s/[\(\)\.]//gi;
$testcmd =~ s/ //gi;
$testcmd =~ s///gi;
my @pid = split(/\s/,$testcmd);
$status .=",\"pid\":\"$pid[0]\"";
my $memory = 0;
foreach (@pid){
chomp($_);
if (open(FILE, "/proc/$_/statm")){
my $temp = <FILE>;
@memory = split(/ /,$temp);
}
$memory+=$memory[0];
}
$memory*=1024;
$status .=",\"memory\":$memory";
}else{
$status = "\"state\":0";
}
return $status;
+} diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..340bb8e66 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -14,4 +14,4 @@ # Append / edit the following list of commands to fit your needs: # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/local/bin/addonctrl, /sbin/iptables, /usr/sbin/fping
This is absolutely impossible to give the zabbix user control to start/stop any add-on and to read and change the entire iptables ruleset.
Zabbix is listening on the network and does not have any kind of authentication. Any security vulnerabilities in Zabbix would allow to alter the firewall rules and DoS any add-ons. This is dangerous.
Are there any alternative ways to realise this functionality?
diff --git a/config/zabbix_agentd/template_module_ipfire_network_stats.conf b/config/zabbix_agentd/template_module_ipfire_network_stats.conf new file mode 100644 index 000000000..f1658ed07 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_network_stats.conf @@ -0,0 +1,4 @@ +### Parameters for monitoring IPFire network statistics +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? ]; echo $? +UserParameter=ipfire.net.fw.hits[*],sudo /sbin/iptables -vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }'; diff --git a/config/zabbix_agentd/template_module_ipfire_services.conf b/config/zabbix_agentd/template_module_ipfire_services.conf new file mode 100644 index 000000000..5f95218e3 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_services.conf @@ -0,0 +1,2 @@ +### Parameter for monitoring IPFire services +UserParameter=ipfire.services,/etc/zabbix_agentd/scripts/ipfire_services.pl diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 73e08d20a..c0d28d51f 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = +DEPS = "fping"
############################################################################### # Top-level Rules @@ -97,6 +97,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew
install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_network_stats.conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_stats.conf.ipfirenew
install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_services.conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.conf.ipfirenew
install -v -m 755 $(DIR_SRC)/config/zabbix_agentd/ipfire_services.pl \
/etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix
diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index 4248a7ec1..ced915c81 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -66,8 +66,13 @@ restore_backup ${NAME} # Put zabbix configfiles in place setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_stats.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.conf setup_configfile /etc/sudoers.d/zabbix
+# Overwrite script if it exists as user should not modify it but it is included in backup +mv /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew /etc/zabbix_agentd/scripts/ipfire_services.pl
if $review_required; then echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." echo " They may need manual review in order to take advantage of new features" diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index 7a13880c5..ccbc8f7cf 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,6 +26,8 @@ stop_service ${NAME}
# Remove .ipfirenew files in advance so they won't be included in backup rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew +# Remove script-file as it should not have been modified by user +rm -fv /etc/zabbix_agentd/scripts/ipfire_services.pl
make_backup ${NAME} remove_files -- 2.30.2
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-Michael
Hi Michael
Michael Tremer schreef op ma 12-04-2021 om 11:36 [+0100]:
Hello,
On 7 Apr 2021, at 21:44, Robin Roevens robin.roevens@disroot.org wrote: ... ... diff --git a/config/zabbix_agentd/ipfire_services.pl b/config/zabbix_agentd/ipfire_services.pl new file mode 100755 index 000000000..dbf8aec56 --- /dev/null +++ b/config/zabbix_agentd/ipfire_services.pl @@ -0,0 +1,221 @@ +#!/usr/bin/perl +#################################################################### ########### +# ipfire_services.pl - Retrieves available IPFire services information and +# return this as a JSON array suitable for easy processing +# by Zabbix server +# +# Author: robin.roevens (at) disroot.org +# Version: 1.0 +# +# Based on: services.cgi by IPFire Team +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see < http://www.gnu.org/licenses/%3E. +# +#################################################################### ###########
+use strict;
+# enable only the following on debugging purpose +# use warnings;
+# Maps a nice printable name to the changing part of the pid file, which +# is also the name of the program +my %servicenames =( + 'DHCP Server' => 'dhcpd', + 'Web Server' => 'httpd', + 'CRON Server' => 'fcron', + 'DNS Proxy Server' => 'unbound', + 'Logging Server' => 'syslogd', + 'Kernel Logging Server' => 'klogd', + 'NTP Server' => 'ntpd', + 'Secure Shell Server' => 'sshd', + 'VPN' => 'charon', + 'Web Proxy' => 'squid', + 'Intrusion Detection System' => 'suricata', + 'OpenVPN' => 'openvpn' +);
You have a hard-coded list with process names here. It technically is missing add-ons but including everything would make this list very long and a lot of work to maintain...
As explained in my previous mail, I don't currently know of a method to get a list of mandatory IPFire specific services. So this list is a straight copy out of services.cgi minus the translation. The add-on services are looked up below, exactly like it is done in services.cgi.
+# Hash to overwrite the process name of a process if it differs from the launch command. +my %overwrite_exename_hash = ( + "suricata" => "Suricata-Main" +);
+my $first = 1;
+print "[";
+# Built-in services +my $key = ''; +foreach $key (sort keys %servicenames){ + print "," if not $first; + $first = 0;
+ print "{"; + print ""service":"$key",";
+ my $shortname = $servicenames{$key}; + print &servicestats($shortname); + + print "}"; +}
+# Generate list of installed addon pak's +my @pak = `find /opt/pakfire/db/installed/meta-* 2>/dev/null | cut - d"-" -f2`; +foreach (@pak){ + chomp($_);
+ # Check which of the paks are services + my @svc = `find /etc/init.d/$_ 2>/dev/null | cut -d"/" -f4`; + foreach (@svc){ + # blacklist some packages + # + # alsa has trouble with the volume saving and was not really stopped + # mdadm should not stopped with webif because this could crash the system + # + chomp($_); + if ( $_ eq 'squid' ) { + next; + } + if ( ($_ ne "alsa") && ($_ ne "mdadm") ) {
Another hardcoded list due to code duplication. Not your fault, but not pretty.
Indeed, as is probably clear by now, I too would prefer a more clean way of generating a list of services.
Currently seeing this piece of code again.. I think this blacklist in services.cgi only exists so the user can't stop/start the service using the webgui.. But there is no such functionality in this script.. so I think I can skip this blacklist, and also provide service state of alsa and mdadm.. (not sure why squid is here, is there an addon that also provides squid, maybe squid-accounting?)
+ print ","; + print "{";
+ print ""service":"Addon: $_","; + print ""servicename":"$_",";
+ my $onboot = isautorun($_); + print ""onboot":$onboot,";
+ print &addonservicestats($_);
+ print "}"; + } + } +}
+print "]";
+sub servicestats{ + my $cmd = $_[0]; + my $status = ""servicename":"$cmd","state":"0""; + my $pid = ''; + my $testcmd = ''; + my $exename; + my $memory;
+ $cmd =~ /(^[a-z]+)/; + + # Check if the exename needs to be overwritten. + # This happens if the expected process name string + # differs from the real one. This may happened if + # a service uses multiple processes or threads. + if (exists($overwrite_exename_hash{$cmd})) { + # Grab the string which will be reported by + # the process from the corresponding hash. + $exename = $overwrite_exename_hash{$1}; + } else { + # Directly expect the launched command as + # process name. + $exename = $1; + } + + if (open(FILE, "/var/run/${cmd}.pid")){ + $pid = <FILE>; chomp $pid; + close FILE; + if (open(FILE, "/proc/${pid}/status")){ + while (<FILE>){ + if (/^Name:\W+(.*)/) { + $testcmd = $1; + } + } + close FILE; + } + if (open(FILE, "/proc/${pid}/status")) { + while (<FILE>) { + my ($key, $val) = split(":", $_, 2); + if ($key eq 'VmRSS') { + $val =~ /\s*([0-9]*)\s+kB/; + # Convert kB to B + $memory = $1*1024; + last; + } + } + close(FILE); + } + if ($testcmd =~ /$exename/){ + $status = ""servicename":"$cmd","state":1,"pid":$pid,"memory":$memory "; + } + } + return $status; +}
+sub isautorun{ + my $cmd = $_[0]; + my $status = "0"; + my $init = `find /etc/rc.d/rc3.d/S??${cmd} 2>/dev/null`; + chomp ($init); + if ($init ne ''){ + $status = "1"; + } + $init = `find /etc/rc.d/rc3.d/off/S??${cmd} 2>/dev/null`; + chomp ($init); + if ($init ne ''){ + $status = "0"; + }
+ return $status; +}
+sub addonservicestats{ + my $cmd = $_[0]; + my $status = "0"; + my $pid = ''; + my $testcmd = ''; + my $exename; + my @memory = (0);
+ $testcmd = `sudo /usr/local/bin/addonctrl $_ status 2>/dev/null`;
+ if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ + $status = ""state":1";
+ $testcmd =~ s/.* //gi; + $testcmd =~ s/[a-z_]//gi; + $testcmd =~ s/[[0-1];[0-9]+//gi; + $testcmd =~ s/[().]//gi; + $testcmd =~ s/ //gi; + $testcmd =~ s///gi;
+ my @pid = split(/\s/,$testcmd); + $status .=","pid":"$pid[0]"";
+ my $memory = 0;
+ foreach (@pid){ + chomp($_); + if (open(FILE, "/proc/$_/statm")){ + my $temp = <FILE>; + @memory = split(/ /,$temp); + } + $memory+=$memory[0]; + } + $memory*=1024; + $status .=","memory":$memory"; + }else{ + $status = ""state":0"; + } + return $status; +} diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..340bb8e66 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -14,4 +14,4 @@ # Append / edit the following list of commands to fit your needs: # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/local/bin/addonctrl, /sbin/iptables, /usr/sbin/fping
This is absolutely impossible to give the zabbix user control to start/stop any add-on and to read and change the entire iptables ruleset.
Zabbix is listening on the network and does not have any kind of authentication. Any security vulnerabilities in Zabbix would allow to alter the firewall rules and DoS any add-ons. This is dangerous.
There is some level of security: - the agent will only respond on requests from the configured Zabbix server (which the user has to configure in the zabbix agentd conf-file, and defaults to 127.0.0.1 as we can't possibly know the ip of the user's server, so by default the agent responds to no one) - By default remote commands (as in requests to the agent to execute any command given) are disabled so the only way to make the agent call those binaries is to request a predefined userparameter that in turn will execute such a command with predefined params (see the additional template_...conf-files) and on top of that, the user can add additional security by configuring encryption in the agent main configfile
But as you point out, a possible vulnerability of some sort may indeed still pose risks this way.
Are there any alternative ways to realise this functionality?
As sudo is not able to allow commands with variable parameters together with fixed parameters, a popular solution is using wrapper scripts, not writable by the user, denying the user direct access to the commands in question.
/usr/local/bin/addonctrl is only called from within the ipfire_services.pl script I provide, in the form of "addonctrl <service> status". So I could add /etc/zabbix_agentd/scripts/ipfire_services.pl to the sudo list instead so that the zabbix user won't be able to call addonctrl directly. (making sure zabbix user has no write permission on that script)
The same goes for iptables. This is only called by the predefined userparameter "ipfire.net.fw.hits[*]" defined in template_module_ipfire_network_stats.conf in the form "/sbin/iptables - vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }';" where $1 (chain) and $2 (rule) are parameters that have to be supplied to the agent when requesting that item. Here I can also supply a wrapper-script to be called by sudo /etc/zabbix_agentd/scripts/firewall_hits.sh that accepts those parameters, and checks them for validity and against abuse.
Regards Robin
diff --git a/config/zabbix_agentd/template_module_ipfire_network_stats.conf b/config/zabbix_agentd/template_module_ipfire_network_stats.conf new file mode 100644 index 000000000..f1658ed07 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_network_stats.conf @@ -0,0 +1,4 @@ +### Parameters for monitoring IPFire network statistics +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? ]; echo $? +UserParameter=ipfire.net.fw.hits[*],sudo /sbin/iptables -vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }'; diff --git a/config/zabbix_agentd/template_module_ipfire_services.conf b/config/zabbix_agentd/template_module_ipfire_services.conf new file mode 100644 index 000000000..5f95218e3 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_services.conf @@ -0,0 +1,2 @@ +### Parameter for monitoring IPFire services +UserParameter=ipfire.services,/etc/zabbix_agentd/scripts/ipfire_serv ices.pl diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 73e08d20a..c0d28d51f 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = +DEPS = "fping"
##################################################################### ########## # Top-level Rules @@ -97,6 +97,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfi re.conf.ipfirenew + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_network_stats. conf \ + /etc/zabbix_agentd/zabbix_agentd.d/template_module_ip fire_network_stats.conf.ipfirenew + install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_services.conf \ + /etc/zabbix_agentd/zabbix_agentd.d/template_module_ip fire_services.conf.ipfirenew + install -v -m 755 $(DIR_SRC)/config/zabbix_agentd/ipfire_services.pl \ + /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfiren ew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index 4248a7ec1..ced915c81 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -66,8 +66,13 @@ restore_backup ${NAME} # Put zabbix configfiles in place setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_sta ts.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.co nf setup_configfile /etc/sudoers.d/zabbix
+# Overwrite script if it exists as user should not modify it but it is included in backup +mv /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew /etc/zabbix_agentd/scripts/ipfire_services.pl
if $review_required; then echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." echo " They may need manual review in order to take advantage of new features" diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index 7a13880c5..ccbc8f7cf 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,6 +26,8 @@ stop_service ${NAME}
# Remove .ipfirenew files in advance so they won't be included in backup rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew +# Remove script-file as it should not have been modified by user +rm -fv /etc/zabbix_agentd/scripts/ipfire_services.pl
make_backup ${NAME} remove_files -- 2.30.2
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-Michael
Hello,
On 12 Apr 2021, at 23:16, Robin Roevens robin.roevens@disroot.org wrote:
Hi Michael
Michael Tremer schreef op ma 12-04-2021 om 11:36 [+0100]:
Hello,
On 7 Apr 2021, at 21:44, Robin Roevens robin.roevens@disroot.org wrote: ... ... diff --git a/config/zabbix_agentd/ipfire_services.pl b/config/zabbix_agentd/ipfire_services.pl new file mode 100755 index 000000000..dbf8aec56 --- /dev/null +++ b/config/zabbix_agentd/ipfire_services.pl @@ -0,0 +1,221 @@ +#!/usr/bin/perl +#################################################################### ########### +# ipfire_services.pl - Retrieves available IPFire services information and +# return this as a JSON array suitable for easy processing +# by Zabbix server +# +# Author: robin.roevens (at) disroot.org +# Version: 1.0 +# +# Based on: services.cgi by IPFire Team +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see < http://www.gnu.org/licenses/%3E. +# +#################################################################### ###########
+use strict;
+# enable only the following on debugging purpose +# use warnings;
+# Maps a nice printable name to the changing part of the pid file, which +# is also the name of the program +my %servicenames =(
'DHCP Server' => 'dhcpd',
'Web Server' => 'httpd',
'CRON Server' => 'fcron',
'DNS Proxy Server' => 'unbound',
'Logging Server' => 'syslogd',
'Kernel Logging Server' => 'klogd',
'NTP Server' => 'ntpd',
'Secure Shell Server' => 'sshd',
'VPN' => 'charon',
'Web Proxy' => 'squid',
'Intrusion Detection System' => 'suricata',
'OpenVPN' => 'openvpn'
+);
You have a hard-coded list with process names here. It technically is missing add-ons but including everything would make this list very long and a lot of work to maintain...
As explained in my previous mail, I don't currently know of a method to get a list of mandatory IPFire specific services. So this list is a straight copy out of services.cgi minus the translation. The add-on services are looked up below, exactly like it is done in services.cgi.
What list are you looking for? Just all processes that are running?
+# Hash to overwrite the process name of a process if it differs from the launch command. +my %overwrite_exename_hash = (
"suricata" => "Suricata-Main"
+);
+my $first = 1;
+print "[";
+# Built-in services +my $key = ''; +foreach $key (sort keys %servicenames){
print "," if not $first;
$first = 0;
print "{";
print "\"service\":\"$key\",";
my $shortname = $servicenames{$key};
print &servicestats($shortname);
print "}";
+}
+# Generate list of installed addon pak's +my @pak = `find /opt/pakfire/db/installed/meta-* 2>/dev/null | cut - d"-" -f2`; +foreach (@pak){
chomp($_);
# Check which of the paks are services
my @svc = `find /etc/init.d/$_ 2>/dev/null | cut -d"/" -f4`;
foreach (@svc){
# blacklist some packages
#
# alsa has trouble with the volume saving and was not
really stopped
# mdadm should not stopped with webif because this
could crash the system
#
chomp($_);
if ( $_ eq 'squid' ) {
next;
}
if ( ($_ ne "alsa") && ($_ ne "mdadm") ) {
Another hardcoded list due to code duplication. Not your fault, but not pretty.
Indeed, as is probably clear by now, I too would prefer a more clean way of generating a list of services.
Currently seeing this piece of code again.. I think this blacklist in services.cgi only exists so the user can't stop/start the service using the webgui.. But there is no such functionality in this script.. so I think I can skip this blacklist, and also provide service state of alsa and mdadm.. (not sure why squid is here, is there an addon that also provides squid, maybe squid-accounting?)
The code seemed to have some trouble with hyphenated package names, that is why those checks were introduced.
It is pretty bad code and we should rework it some time, but definitely not copy it if we can avoid it.
print ",";
print "{";
print "\"service\":\"Addon: $_\",";
print "\"servicename\":\"$_\",";
my $onboot = isautorun($_);
print "\"onboot\":$onboot,";
print &addonservicestats($_);
print "}";
}
}
+}
+print "]";
+sub servicestats{
my $cmd = $_[0];
my $status = "\"servicename\":\"$cmd\",\"state\":\"0\"";
my $pid = '';
my $testcmd = '';
my $exename;
my $memory;
$cmd =~ /(^[a-z]+)/;
# Check if the exename needs to be overwritten.
# This happens if the expected process name string
# differs from the real one. This may happened if
# a service uses multiple processes or threads.
if (exists($overwrite_exename_hash{$cmd})) {
# Grab the string which will be reported by
# the process from the corresponding hash.
$exename = $overwrite_exename_hash{$1};
} else {
# Directly expect the launched command as
# process name.
$exename = $1;
}
if (open(FILE, "/var/run/${cmd}.pid")){
$pid = <FILE>; chomp $pid;
close FILE;
if (open(FILE, "/proc/${pid}/status")){
while (<FILE>){
if (/^Name:\W+(.*)/) {
$testcmd = $1;
}
}
close FILE;
}
if (open(FILE, "/proc/${pid}/status")) {
while (<FILE>) {
my ($key, $val) = split(":", $_, 2);
if ($key eq 'VmRSS') {
$val =~ /\s*([0-9]*)\s+kB/;
# Convert kB to B
$memory = $1*1024;
last;
}
}
close(FILE);
}
if ($testcmd =~ /$exename/){
$status =
""servicename":"$cmd","state":1,"pid":$pid,"memory":$memory ";
}
}
return $status;
+}
+sub isautorun{
my $cmd = $_[0];
my $status = "0";
my $init = `find /etc/rc.d/rc3.d/S??${cmd} 2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "1";
}
$init = `find /etc/rc.d/rc3.d/off/S??${cmd} 2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "0";
}
return $status;
+}
+sub addonservicestats{
my $cmd = $_[0];
my $status = "0";
my $pid = '';
my $testcmd = '';
my $exename;
my @memory = (0);
$testcmd = `sudo /usr/local/bin/addonctrl $_ status
2>/dev/null`;
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\
running/){
$status = "\"state\":1";
$testcmd =~ s/.* //gi;
$testcmd =~ s/[a-z_]//gi;
$testcmd =~ s/\[[0-1]\;[0-9]+//gi;
$testcmd =~ s/[\(\)\.]//gi;
$testcmd =~ s/ //gi;
$testcmd =~ s///gi;
my @pid = split(/\s/,$testcmd);
$status .=",\"pid\":\"$pid[0]\"";
my $memory = 0;
foreach (@pid){
chomp($_);
if (open(FILE, "/proc/$_/statm")){
my $temp = <FILE>;
@memory = split(/ /,$temp);
}
$memory+=$memory[0];
}
$memory*=1024;
$status .=",\"memory\":$memory";
}else{
$status = "\"state\":0";
}
return $status;
+} diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..340bb8e66 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -14,4 +14,4 @@ # Append / edit the following list of commands to fit your needs: # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/local/bin/addonctrl, /sbin/iptables, /usr/sbin/fping
This is absolutely impossible to give the zabbix user control to start/stop any add-on and to read and change the entire iptables ruleset.
Zabbix is listening on the network and does not have any kind of authentication. Any security vulnerabilities in Zabbix would allow to alter the firewall rules and DoS any add-ons. This is dangerous.
There is some level of security:
I agree that it is *some*, but is it enough?
- the agent will only respond on requests from the configured Zabbix
server (which the user has to configure in the zabbix agentd conf-file, and defaults to 127.0.0.1 as we can't possibly know the ip of the user's server, so by default the agent responds to no one)
Host-based ACLs are not really a thing. On the local network faking a source IP address is one of the easiest jobs.
- By default remote commands (as in requests to the agent to execute
any command given) are disabled so the only way to make the agent call those binaries is to request a predefined userparameter that in turn will execute such a command with predefined params (see the additional template_...conf-files) and on top of that, the user can add additional security by configuring encryption in the agent main configfile
Encryption is not authentication.
And the predefined parameters might be a thing, but my view is that zabbix can execute quite serious commands if it is being exploited.
The Zabbix Agent had exactly one of these vulnerabilities in 2009 where an attacker could execute arbitrary commands:
https://www.cvedetails.com/cve/CVE-2009-4502/
But as you point out, a possible vulnerability of some sort may indeed still pose risks this way.
I just find this risk insanely large. I am not going to tell people what software they can use and what not, but I want to avoid that the default configuration is adding major security issues to the entire system. And adding those sudo rules by default does exactly this.
What would a monitoring tool do with a dump of the iptables ruleset? I do not even understand where the use of this is.
Are there any alternative ways to realise this functionality?
As sudo is not able to allow commands with variable parameters together with fixed parameters, a popular solution is using wrapper scripts, not writable by the user, denying the user direct access to the commands in question.
/usr/local/bin/addonctrl is only called from within the ipfire_services.pl script I provide, in the form of "addonctrl <service> status". So I could add /etc/zabbix_agentd/scripts/ipfire_services.pl to the sudo list instead so that the zabbix user won't be able to call addonctrl directly. (making sure zabbix user has no write permission on that script)
The same goes for iptables. This is only called by the predefined userparameter "ipfire.net.fw.hits[*]" defined in template_module_ipfire_network_stats.conf in the form "/sbin/iptables - vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }';" where $1 (chain) and $2 (rule) are parameters that have to be supplied to the agent when requesting that item. Here I can also supply a wrapper-script to be called by sudo /etc/zabbix_agentd/scripts/firewall_hits.sh that accepts those parameters, and checks them for validity and against abuse.
Regards Robin
-Michael
diff --git a/config/zabbix_agentd/template_module_ipfire_network_stats.conf b/config/zabbix_agentd/template_module_ipfire_network_stats.conf new file mode 100644 index 000000000..f1658ed07 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_network_stats.conf @@ -0,0 +1,4 @@ +### Parameters for monitoring IPFire network statistics +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? ]; echo $? +UserParameter=ipfire.net.fw.hits[*],sudo /sbin/iptables -vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }'; diff --git a/config/zabbix_agentd/template_module_ipfire_services.conf b/config/zabbix_agentd/template_module_ipfire_services.conf new file mode 100644 index 000000000..5f95218e3 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_services.conf @@ -0,0 +1,2 @@ +### Parameter for monitoring IPFire services +UserParameter=ipfire.services,/etc/zabbix_agentd/scripts/ipfire_serv ices.pl diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 73e08d20a..c0d28d51f 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = +DEPS = "fping"
##################################################################### ########## # Top-level Rules @@ -97,6 +97,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfi re.conf.ipfirenew
install -v -m 644
$(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_network_stats. conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_module_ip
fire_network_stats.conf.ipfirenew
install -v -m 644
$(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_services.conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_module_ip
fire_services.conf.ipfirenew
install -v -m 755
$(DIR_SRC)/config/zabbix_agentd/ipfire_services.pl \
/etc/zabbix_agentd/scripts/ipfire_services.pl.ipfiren
ew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix
diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index 4248a7ec1..ced915c81 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -66,8 +66,13 @@ restore_backup ${NAME} # Put zabbix configfiles in place setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_network_sta ts.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_services.co nf setup_configfile /etc/sudoers.d/zabbix
+# Overwrite script if it exists as user should not modify it but it is included in backup +mv /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew /etc/zabbix_agentd/scripts/ipfire_services.pl
if $review_required; then echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." echo " They may need manual review in order to take advantage of new features" diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index 7a13880c5..ccbc8f7cf 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,6 +26,8 @@ stop_service ${NAME}
# Remove .ipfirenew files in advance so they won't be included in backup rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew +# Remove script-file as it should not have been modified by user +rm -fv /etc/zabbix_agentd/scripts/ipfire_services.pl
make_backup ${NAME} remove_files -- 2.30.2
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-Michael
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hi Michael
Michael Tremer schreef op do 15-04-2021 om 12:21 [+0100]:
Hello,
On 12 Apr 2021, at 23:16, Robin Roevens < robin.roevens@disroot.org
wrote:
Hi Michael
Michael Tremer schreef op ma 12-04-2021 om 11:36 [+0100]:
Hello,
On 7 Apr 2021, at 21:44, Robin Roevens < robin.roevens@disroot.org
wrote: ... ... diff --git a/config/zabbix_agentd/ipfire_services.pl b/config/zabbix_agentd/ipfire_services.pl new file mode 100755 index 000000000..dbf8aec56 --- /dev/null +++ b/config/zabbix_agentd/ipfire_services.pl @@ -0,0 +1,221 @@ +#!/usr/bin/perl +############################################################## ###### ########### +# ipfire_services.pl - Retrieves available IPFire services information and +# return this as a JSON array suitable for easy processing +# by Zabbix server +# +# Author: robin.roevens (at) disroot.org +# Version: 1.0 +# +# Based on: services.cgi by IPFire Team +# Copyright (C) 2007-2021 IPFire Team < info@ipfire.org
+# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see < http://www.gnu.org/licenses/
.
+# +############################################################## ###### ###########
+use strict;
+# enable only the following on debugging purpose +# use warnings;
+# Maps a nice printable name to the changing part of the pid file, which +# is also the name of the program +my %servicenames =(
'DHCP Server' => 'dhcpd',
'Web Server' => 'httpd',
'CRON Server' => 'fcron',
'DNS Proxy Server' => 'unbound',
'Logging Server' => 'syslogd',
'Kernel Logging Server' => 'klogd',
'NTP Server' => 'ntpd',
'Secure Shell Server' => 'sshd',
'VPN' => 'charon',
'Web Proxy' => 'squid',
'Intrusion Detection System' => 'suricata',
'OpenVPN' => 'openvpn'
+);
You have a hard-coded list with process names here. It technically is missing add-ons but including everything would make this list very long and a lot of work to maintain...
As explained in my previous mail, I don't currently know of a method to get a list of mandatory IPFire specific services. So this list is a straight copy out of services.cgi minus the translation. The add-on services are looked up below, exactly like it is done in services.cgi.
What list are you looking for? Just all processes that are running?
The purpose of my extension to the default is that a user can easily configure Zabbix to monitor "IPFire"-specific functionalities. Generic Linux metrics can be monitored by default Zabbix templates and agent built-in functionality eventually extended with user-defined scripts or modules.
The IPFire webgui has a nice overview of all vital IPFire services and their state, as well as for addon-services. A user can browse the status pages of the WebGUI to have a view of how their IPFire machine is running This is exactly what I want to provide to the Zabbix user, hence my copy of services.cgi-code. Alternatively, I could 'parse' the output of the services-page of the webserver. But that is rather something one would do when trying to monitor a black-box.
+# Hash to overwrite the process name of a process if it differs from the launch command. +my %overwrite_exename_hash = (
"suricata" => "Suricata-Main"
+);
+my $first = 1;
+print "[";
+# Built-in services +my $key = ''; +foreach $key (sort keys %servicenames){
print "," if not $first;
$first = 0;
print "{";
print "\"service\":\"$key\",";
my $shortname = $servicenames{$key};
print &servicestats($shortname);
print "}";
+}
+# Generate list of installed addon pak's +my @pak = `find /opt/pakfire/db/installed/meta-* 2>/dev/null | cut - d"-" -f2`; +foreach (@pak){
chomp($_);
# Check which of the paks are services
my @svc = `find /etc/init.d/$_ 2>/dev/null | cut -d"/"
-f4`;
foreach (@svc){
# blacklist some packages
#
# alsa has trouble with the volume saving and
was not really stopped
# mdadm should not stopped with webif because
this could crash the system
#
chomp($_);
if ( $_ eq 'squid' ) {
next;
}
if ( ($_ ne "alsa") && ($_ ne "mdadm") ) {
Another hardcoded list due to code duplication. Not your fault, but not pretty.
Indeed, as is probably clear by now, I too would prefer a more clean way of generating a list of services.
Currently seeing this piece of code again.. I think this blacklist in services.cgi only exists so the user can't stop/start the service using the webgui.. But there is no such functionality in this script.. so I think I can skip this blacklist, and also provide service state of alsa and mdadm.. (not sure why squid is here, is there an addon that also provides squid, maybe squid-accounting?)
The code seemed to have some trouble with hyphenated package names, that is why those checks were introduced.
It is pretty bad code and we should rework it some time, but definitely not copy it if we can avoid it.
print ",";
print "{";
print "\"service\":\"Addon: $_\",";
print "\"servicename\":\"$_\",";
my $onboot = isautorun($_);
print "\"onboot\":$onboot,";
print &addonservicestats($_);
print "}";
}
}
+}
+print "]";
+sub servicestats{
my $cmd = $_[0];
my $status =
""servicename":"$cmd","state":"0"";
my $pid = '';
my $testcmd = '';
my $exename;
my $memory;
$cmd =~ /(^[a-z]+)/;
# Check if the exename needs to be overwritten.
# This happens if the expected process name string
# differs from the real one. This may happened if
# a service uses multiple processes or threads.
if (exists($overwrite_exename_hash{$cmd})) {
# Grab the string which will be reported by
# the process from the corresponding hash.
$exename = $overwrite_exename_hash{$1};
} else {
# Directly expect the launched command as
# process name.
$exename = $1;
}
if (open(FILE, "/var/run/${cmd}.pid")){
$pid = <FILE>; chomp $pid;
close FILE;
if (open(FILE, "/proc/${pid}/status")){
while (<FILE>){
if (/^Name:\W+(.*)/) {
$testcmd = $1;
}
}
close FILE;
}
if (open(FILE, "/proc/${pid}/status")) {
while (<FILE>) {
my ($key, $val) = split(":",
$_, 2);
if ($key eq 'VmRSS') {
$val =~ /\s*([0-
9]*)\s+kB/;
# Convert kB to B
$memory = $1*1024;
last;
}
}
close(FILE);
}
if ($testcmd =~ /$exename/){
$status =
""servicename":"$cmd","state":1,"pid":$pid,"memory":$ memory ";
}
}
return $status;
+}
+sub isautorun{
my $cmd = $_[0];
my $status = "0";
my $init = `find /etc/rc.d/rc3.d/S??${cmd}
2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "1";
}
$init = `find /etc/rc.d/rc3.d/off/S??${cmd}
2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "0";
}
return $status;
+}
+sub addonservicestats{
my $cmd = $_[0];
my $status = "0";
my $pid = '';
my $testcmd = '';
my $exename;
my @memory = (0);
$testcmd = `sudo /usr/local/bin/addonctrl $_ status
2>/dev/null`;
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\
not\ running/){
$status = "\"state\":1";
$testcmd =~ s/.* //gi;
$testcmd =~ s/[a-z_]//gi;
$testcmd =~ s/\[[0-1]\;[0-9]+//gi;
$testcmd =~ s/[\(\)\.]//gi;
$testcmd =~ s/ //gi;
$testcmd =~ s///gi;
my @pid = split(/\s/,$testcmd);
$status .=",\"pid\":\"$pid[0]\"";
my $memory = 0;
foreach (@pid){
chomp($_);
if (open(FILE, "/proc/$_/statm")){
my $temp = <FILE>;
@memory = split(/ /,$temp);
}
$memory+=$memory[0];
}
$memory*=1024;
$status .=",\"memory\":$memory";
}else{
$status = "\"state\":0";
}
return $status;
+} diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..340bb8e66 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -14,4 +14,4 @@ # Append / edit the following list of commands to fit your needs: # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/local/bin/addonctrl, /sbin/iptables, /usr/sbin/fping
This is absolutely impossible to give the zabbix user control to start/stop any add-on and to read and change the entire iptables ruleset.
Zabbix is listening on the network and does not have any kind of authentication. Any security vulnerabilities in Zabbix would allow to alter the firewall rules and DoS any add-ons. This is dangerous.
There is some level of security:
I agree that it is *some*, but is it enough?
- the agent will only respond on requests from the configured
Zabbix server (which the user has to configure in the zabbix agentd conf- file, and defaults to 127.0.0.1 as we can't possibly know the ip of the user's server, so by default the agent responds to no one)
Host-based ACLs are not really a thing. On the local network faking a source IP address is one of the easiest jobs.
- By default remote commands (as in requests to the agent to
execute any command given) are disabled so the only way to make the agent call those binaries is to request a predefined userparameter that in turn will execute such a command with predefined params (see the additional template_...conf-files) and on top of that, the user can add additional security by configuring encryption in the agent main configfile
Encryption is not authentication.
And the predefined parameters might be a thing, but my view is that zabbix can execute quite serious commands if it is being exploited.
The Zabbix Agent had exactly one of these vulnerabilities in 2009 where an attacker could execute arbitrary commands:
https://www.cvedetails.com/cve/CVE-2009-4502/
But as you point out, a possible vulnerability of some sort may indeed still pose risks this way.
I just find this risk insanely large. I am not going to tell people what software they can use and what not, but I want to avoid that the default configuration is adding major security issues to the entire system. And adding those sudo rules by default does exactly this.
I totally agree, I was only pointing out the *some* security there is, but that will indeed never be sufficient to allow full access to iptables or addonctrl by default. A user could, on his own risk, do that to maybe have the agent execute firewall-actions as a reaction to a detected network attack or so.. But that is not something we should provide by default.
What would a monitoring tool do with a dump of the iptables ruleset? I do not even understand where the use of this is.
The same as IPFire webgui currently does on netother.cgi?fwhits?day by calling /sbin/iptables -vnxL <chain> | grep "/* <rule> */" | awk '{ print $2 }';: keep history of and eventually react on the number of firewall-hits.
But you are completely right that access to iptables should be restricted to just that what we want to get from it, which can be achieved with a wrapper script as explained below in my previous mail.
Regards
Robin
Are there any alternative ways to realise this functionality?
As sudo is not able to allow commands with variable parameters together with fixed parameters, a popular solution is using wrapper scripts, not writable by the user, denying the user direct access to the commands in question.
/usr/local/bin/addonctrl is only called from within the ipfire_services.pl script I provide, in the form of "addonctrl <service> status". So I could add /etc/zabbix_agentd/scripts/ipfire_services.pl to the sudo list instead so that the zabbix user won't be able to call addonctrl directly. (making sure zabbix user has no write permission on that script) The same goes for iptables. This is only called by the predefined userparameter "ipfire.net.fw.hits[*]" defined in template_module_ipfire_network_stats.conf in the form "/sbin/iptables - vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }';" where $1 (chain) and $2 (rule) are parameters that have to be supplied to the agent when requesting that item. Here I can also supply a wrapper-script to be called by sudo /etc/zabbix_agentd/scripts/firewall_hits.sh that accepts those parameters, and checks them for validity and against abuse.
Regards Robin
-Michael
diff --git a/config/zabbix_agentd/template_module_ipfire_network_stats.con f b/config/zabbix_agentd/template_module_ipfire_network_stats.con f new file mode 100644 index 000000000..f1658ed07 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_network_stats.con f @@ -0,0 +1,4 @@ +### Parameters for monitoring IPFire network statistics +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? ]; echo $? +UserParameter=ipfire.net.fw.hits[*],sudo /sbin/iptables -vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }'; diff --git a/config/zabbix_agentd/template_module_ipfire_services.conf b/config/zabbix_agentd/template_module_ipfire_services.conf new file mode 100644 index 000000000..5f95218e3 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_services.conf @@ -0,0 +1,2 @@ +### Parameter for monitoring IPFire services +UserParameter=ipfire.services,/etc/zabbix_agentd/scripts/ipfir e_serv ices.pl diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 73e08d20a..c0d28d51f 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = +DEPS = "fping"
############################################################### ###### ########## # Top-level Rules @@ -97,6 +97,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ /etc/zabbix_agentd/zabbix_agentd.d/template_app _pakfi re.conf.ipfirenew
install -v -m 644
$(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_network_ stats. conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_mod
ule_ip fire_network_stats.conf.ipfirenew
install -v -m 644
$(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_services .conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_mod
ule_ip fire_services.conf.ipfirenew
install -v -m 755
$(DIR_SRC)/config/zabbix_agentd/ipfire_services.pl \
/etc/zabbix_agentd/scripts/ipfire_services.pl.i
pfiren ew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix
diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index 4248a7ec1..ced915c81 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -66,8 +66,13 @@ restore_backup ${NAME} # Put zabbix configfiles in place setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_netwo rk_sta ts.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_servi ces.co nf setup_configfile /etc/sudoers.d/zabbix
+# Overwrite script if it exists as user should not modify it but it is included in backup +mv /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew /etc/zabbix_agentd/scripts/ipfire_services.pl
if $review_required; then echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." echo " They may need manual review in order to take advantage of new features" diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index 7a13880c5..ccbc8f7cf 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,6 +26,8 @@ stop_service ${NAME}
# Remove .ipfirenew files in advance so they won't be included in backup rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew +# Remove script-file as it should not have been modified by user +rm -fv /etc/zabbix_agentd/scripts/ipfire_services.pl
make_backup ${NAME} remove_files -- 2.30.2
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-Michael
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hi Michael
I looked a bit deeper into this and was thinking, as IPfire already runs collectd, another possible solution to preventing zabbix agent from using iptables directly for getting metrics from the firewall, is to request them from collectd:
One way could be by enabling the collectd unixsock plugin (https://collectd.org/documentation/manpages/collectd-unixsock.5.shtml) and to make things 'easier' I could then call collectd-nagios (https://collectd.org/documentation/manpages/collectd-nagios.1.shtml) to collect live metrics from collectd as is explained in this example: https://docs.wallarm.com/admin-en/monitoring/collectd-zabbix/ However the collectd unixsock plugin is currently not enabled and collectd-nagios binary is not installed. So I'm not sure if all that is worth the effort for an optional addon as zabbix_agentd is. Since I assume this would require changes to a core component.
Another way could be by reading the last recorded value from the rrd- files generated by collectd using for example: # rrdtool lastupdate /var/log/rrd/collectd/localhost/iptables-filter- POLICYFWD/ipt_bytes-DROP_FORWARD.rrd which gives back the timestamp of the measurement and the metric. But this would require a different approach on how to send those values to the Zabbix server since we now also have to send a timestamp together with the metric and this can only be done by using zabbix_sender to actively send metrics to Zabbix. Hence I would have to create a script that collects all required last values from the RRD files, and then send them to Zabbix using zabbix_sender. The executing of that script can be triggered by a cron job or as a custom userparameter by the agent, but then the script needs to finish within the timeout configured in the zabbix agent config (default: 3s, max 10s).. And in de case of a cron job, we'd only want that enabled if the Zabbix server is set up to listen for those specific metric-items. This could possibly integrated in the webgui as a user-configurable setting somehow.. (Providing a webgui-addon for configuring zabbix_agentd is also something I can imagine myself submitting in the future, but I wasn't planning to do that in short terms :-))
So as you see, both have different challenges.. And of course, should collectd silently start to fail, Zabbix also will not get accurate data anymore. Or if the RRD file(s) would become corrupt (which I had once after migrating from i586 vm to x86_64 appliance).. Up to some level, additional checks by Zabbix on collectd and the rrd files could possibly detect such failures..
But I still prefer for zabbix agent (or any monitoring tool for that matter) to have the shortest and most trustworthy direct path to the metrics it wants, in this case iptables statistics, hence the iptables command. So those wrapper scripts I brought up before are still my preferred solution on this.
Your thoughts ?
Regards
Robin
Robin Roevens schreef op do 15-04-2021 om 15:12 [+0200]:
What would a monitoring tool do with a dump of the iptables ruleset? I do not even understand where the use of this is.
The same as IPFire webgui currently does on netother.cgi?fwhits?day by calling /sbin/iptables -vnxL <chain> | grep "/* <rule> */" | awk '{ print $2 }';: keep history of and eventually react on the number of firewall-hits.
But you are completely right that access to iptables should be restricted to just that what we want to get from it, which can be achieved with a wrapper script as explained below in my previous mail.
Regards
Robin
Hello,
On 15 Apr 2021, at 21:34, Robin Roevens robin.roevens@disroot.org wrote:
Hi Michael
I looked a bit deeper into this and was thinking, as IPfire already runs collectd, another possible solution to preventing zabbix agent from using iptables directly for getting metrics from the firewall, is to request them from collectd:
One way could be by enabling the collectd unixsock plugin (https://collectd.org/documentation/manpages/collectd-unixsock.5.shtml) and to make things 'easier' I could then call collectd-nagios (https://collectd.org/documentation/manpages/collectd-nagios.1.shtml) to collect live metrics from collectd as is explained in this example: https://docs.wallarm.com/admin-en/monitoring/collectd-zabbix/ However the collectd unixsock plugin is currently not enabled and collectd-nagios binary is not installed. So I'm not sure if all that is worth the effort for an optional addon as zabbix_agentd is. Since I assume this would require changes to a core component.
Hmm, it does not strike me as a very straight-forward solution to involve collectd. We have a replacement for collectd ready which we will roll out at some point and so it will go away eventually.
See my remarks about “getipstat” from my other email.
Another way could be by reading the last recorded value from the rrd- files generated by collectd using for example: # rrdtool lastupdate /var/log/rrd/collectd/localhost/iptables-filter- POLICYFWD/ipt_bytes-DROP_FORWARD.rrd
If we have to go this road, this would be a better solution in my view, but it still makes the Zabbix Agent dependant on collectd.
which gives back the timestamp of the measurement and the metric. But this would require a different approach on how to send those values to the Zabbix server since we now also have to send a timestamp together with the metric and this can only be done by using zabbix_sender to actively send metrics to Zabbix. Hence I would have to create a script that collects all required last values from the RRD files, and then send them to Zabbix using zabbix_sender. The executing of that script can be triggered by a cron job or as a custom userparameter by the agent, but then the script needs to finish within the timeout configured in the zabbix agent config (default: 3s, max 10s).. And in de case of a cron job, we'd only want that enabled if the Zabbix server is set up to listen for those specific metric-items. This could possibly integrated in the webgui as a user-configurable setting somehow.. (Providing a webgui-addon for configuring zabbix_agentd is also something I can imagine myself submitting in the future, but I wasn't planning to do that in short terms :-))
This sounds overly complicated to me and will require a lot of things being right (i.e. time).
You will end up with corner cases and bad metrics when the system is under load and the execution of the command is delayed.
So as you see, both have different challenges.. And of course, should collectd silently start to fail, Zabbix also will not get accurate data anymore. Or if the RRD file(s) would become corrupt (which I had once after migrating from i586 vm to x86_64 appliance)..
They are not corrupt, just incompatible between different architectures.
The result is the same :)
Up to some level, additional checks by Zabbix on collectd and the rrd files could possibly detect such failures..
But I still prefer for zabbix agent (or any monitoring tool for that matter) to have the shortest and most trustworthy direct path to the metrics it wants, in this case iptables statistics, hence the iptables command. So those wrapper scripts I brought up before are still my preferred solution on this.
Your thoughts ?
I agree :)
-Michael
Regards
Robin
Robin Roevens schreef op do 15-04-2021 om 15:12 [+0200]:
What would a monitoring tool do with a dump of the iptables ruleset? I do not even understand where the use of this is.
The same as IPFire webgui currently does on netother.cgi?fwhits?day by calling /sbin/iptables -vnxL <chain> | grep "/* <rule> */" | awk '{ print $2 }';: keep history of and eventually react on the number of firewall-hits.
But you are completely right that access to iptables should be restricted to just that what we want to get from it, which can be achieved with a wrapper script as explained below in my previous mail.
Regards
Robin
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hello,
On 15 Apr 2021, at 14:12, Robin Roevens robin.roevens@disroot.org wrote:
Hi Michael
Michael Tremer schreef op do 15-04-2021 om 12:21 [+0100]:
Hello,
On 12 Apr 2021, at 23:16, Robin Roevens < robin.roevens@disroot.org
wrote:
Hi Michael
Michael Tremer schreef op ma 12-04-2021 om 11:36 [+0100]:
Hello,
On 7 Apr 2021, at 21:44, Robin Roevens < robin.roevens@disroot.org
wrote: ... ... diff --git a/config/zabbix_agentd/ipfire_services.pl b/config/zabbix_agentd/ipfire_services.pl new file mode 100755 index 000000000..dbf8aec56 --- /dev/null +++ b/config/zabbix_agentd/ipfire_services.pl @@ -0,0 +1,221 @@ +#!/usr/bin/perl +############################################################## ###### ########### +# ipfire_services.pl - Retrieves available IPFire services information and +# return this as a JSON array suitable for easy processing +# by Zabbix server +# +# Author: robin.roevens (at) disroot.org +# Version: 1.0 +# +# Based on: services.cgi by IPFire Team +# Copyright (C) 2007-2021 IPFire Team < info@ipfire.org
+# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see < http://www.gnu.org/licenses/
.
+# +############################################################## ###### ###########
+use strict;
+# enable only the following on debugging purpose +# use warnings;
+# Maps a nice printable name to the changing part of the pid file, which +# is also the name of the program +my %servicenames =(
'DHCP Server' => 'dhcpd',
'Web Server' => 'httpd',
'CRON Server' => 'fcron',
'DNS Proxy Server' => 'unbound',
'Logging Server' => 'syslogd',
'Kernel Logging Server' => 'klogd',
'NTP Server' => 'ntpd',
'Secure Shell Server' => 'sshd',
'VPN' => 'charon',
'Web Proxy' => 'squid',
'Intrusion Detection System' => 'suricata',
'OpenVPN' => 'openvpn'
+);
You have a hard-coded list with process names here. It technically is missing add-ons but including everything would make this list very long and a lot of work to maintain...
As explained in my previous mail, I don't currently know of a method to get a list of mandatory IPFire specific services. So this list is a straight copy out of services.cgi minus the translation. The add-on services are looked up below, exactly like it is done in services.cgi.
What list are you looking for? Just all processes that are running?
The purpose of my extension to the default is that a user can easily configure Zabbix to monitor "IPFire"-specific functionalities. Generic Linux metrics can be monitored by default Zabbix templates and agent built-in functionality eventually extended with user-defined scripts or modules.
Yes, and I am absolutely for it. The Zabbix Agent alone is not very useful when it does not understand the special metrics that IPFire has and exports them in some way or another.
That said, there is obviously always the problem that if a third person gains access to the monitoring system, they would have a full map of the entire network and loads of other metrics that are helpful to see whether their attack is effective and/or detected. That is something that is out of scope of this project and a risk that people need to evaluate elsewhere. Obviously no monitoring at all is not a solution either.
The IPFire webgui has a nice overview of all vital IPFire services and their state, as well as for addon-services. A user can browse the status pages of the WebGUI to have a view of how their IPFire machine is running This is exactly what I want to provide to the Zabbix user, hence my copy of services.cgi-code.
Understood. Since the services.cgi code is a bit ugly, we might want to rethink how we solve this.
I would be in favour of a file that every add-on brings with it and that makes it show up on the services.cgi table as well as bringing some more meta information like the name of the initscript (if there is one) which you could then call by using addonctrl status.
Alternatively, I could 'parse' the output of the services-page of the webserver. But that is rather something one would do when trying to monitor a black-box.
That is going to break as soon as we touch any of the markup.
+# Hash to overwrite the process name of a process if it differs from the launch command. +my %overwrite_exename_hash = (
"suricata" => "Suricata-Main"
+);
+my $first = 1;
+print "[";
+# Built-in services +my $key = ''; +foreach $key (sort keys %servicenames){
print "," if not $first;
$first = 0;
print "{";
print "\"service\":\"$key\",";
my $shortname = $servicenames{$key};
print &servicestats($shortname);
print "}";
+}
+# Generate list of installed addon pak's +my @pak = `find /opt/pakfire/db/installed/meta-* 2>/dev/null | cut - d"-" -f2`; +foreach (@pak){
chomp($_);
# Check which of the paks are services
my @svc = `find /etc/init.d/$_ 2>/dev/null | cut -d"/"
-f4`;
foreach (@svc){
# blacklist some packages
#
# alsa has trouble with the volume saving and
was not really stopped
# mdadm should not stopped with webif because
this could crash the system
#
chomp($_);
if ( $_ eq 'squid' ) {
next;
}
if ( ($_ ne "alsa") && ($_ ne "mdadm") ) {
Another hardcoded list due to code duplication. Not your fault, but not pretty.
Indeed, as is probably clear by now, I too would prefer a more clean way of generating a list of services.
Currently seeing this piece of code again.. I think this blacklist in services.cgi only exists so the user can't stop/start the service using the webgui.. But there is no such functionality in this script.. so I think I can skip this blacklist, and also provide service state of alsa and mdadm.. (not sure why squid is here, is there an addon that also provides squid, maybe squid-accounting?)
The code seemed to have some trouble with hyphenated package names, that is why those checks were introduced.
It is pretty bad code and we should rework it some time, but definitely not copy it if we can avoid it.
print ",";
print "{";
print "\"service\":\"Addon: $_\",";
print "\"servicename\":\"$_\",";
my $onboot = isautorun($_);
print "\"onboot\":$onboot,";
print &addonservicestats($_);
print "}";
}
}
+}
+print "]";
+sub servicestats{
my $cmd = $_[0];
my $status =
""servicename":"$cmd","state":"0"";
my $pid = '';
my $testcmd = '';
my $exename;
my $memory;
$cmd =~ /(^[a-z]+)/;
# Check if the exename needs to be overwritten.
# This happens if the expected process name string
# differs from the real one. This may happened if
# a service uses multiple processes or threads.
if (exists($overwrite_exename_hash{$cmd})) {
# Grab the string which will be reported by
# the process from the corresponding hash.
$exename = $overwrite_exename_hash{$1};
} else {
# Directly expect the launched command as
# process name.
$exename = $1;
}
if (open(FILE, "/var/run/${cmd}.pid")){
$pid = <FILE>; chomp $pid;
close FILE;
if (open(FILE, "/proc/${pid}/status")){
while (<FILE>){
if (/^Name:\W+(.*)/) {
$testcmd = $1;
}
}
close FILE;
}
if (open(FILE, "/proc/${pid}/status")) {
while (<FILE>) {
my ($key, $val) = split(":",
$_, 2);
if ($key eq 'VmRSS') {
$val =~ /\s*([0-
9]*)\s+kB/;
# Convert kB to B
$memory = $1*1024;
last;
}
}
close(FILE);
}
if ($testcmd =~ /$exename/){
$status =
""servicename":"$cmd","state":1,"pid":$pid,"memory":$ memory ";
}
}
return $status;
+}
+sub isautorun{
my $cmd = $_[0];
my $status = "0";
my $init = `find /etc/rc.d/rc3.d/S??${cmd}
2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "1";
}
$init = `find /etc/rc.d/rc3.d/off/S??${cmd}
2>/dev/null`;
chomp ($init);
if ($init ne ''){
$status = "0";
}
return $status;
+}
+sub addonservicestats{
my $cmd = $_[0];
my $status = "0";
my $pid = '';
my $testcmd = '';
my $exename;
my @memory = (0);
$testcmd = `sudo /usr/local/bin/addonctrl $_ status
2>/dev/null`;
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\
not\ running/){
$status = "\"state\":1";
$testcmd =~ s/.* //gi;
$testcmd =~ s/[a-z_]//gi;
$testcmd =~ s/\[[0-1]\;[0-9]+//gi;
$testcmd =~ s/[\(\)\.]//gi;
$testcmd =~ s/ //gi;
$testcmd =~ s///gi;
my @pid = split(/\s/,$testcmd);
$status .=",\"pid\":\"$pid[0]\"";
my $memory = 0;
foreach (@pid){
chomp($_);
if (open(FILE, "/proc/$_/statm")){
my $temp = <FILE>;
@memory = split(/ /,$temp);
}
$memory+=$memory[0];
}
$memory*=1024;
$status .=",\"memory\":$memory";
}else{
$status = "\"state\":0";
}
return $status;
+} diff --git a/config/zabbix_agentd/sudoers b/config/zabbix_agentd/sudoers index 1b362a4fd..340bb8e66 100644 --- a/config/zabbix_agentd/sudoers +++ b/config/zabbix_agentd/sudoers @@ -14,4 +14,4 @@ # Append / edit the following list of commands to fit your needs: # Defaults:zabbix !requiretty -zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status +zabbix ALL=(ALL) NOPASSWD: /opt/pakfire/pakfire status, /usr/local/bin/addonctrl, /sbin/iptables, /usr/sbin/fping
This is absolutely impossible to give the zabbix user control to start/stop any add-on and to read and change the entire iptables ruleset.
Zabbix is listening on the network and does not have any kind of authentication. Any security vulnerabilities in Zabbix would allow to alter the firewall rules and DoS any add-ons. This is dangerous.
There is some level of security:
I agree that it is *some*, but is it enough?
- the agent will only respond on requests from the configured
Zabbix server (which the user has to configure in the zabbix agentd conf- file, and defaults to 127.0.0.1 as we can't possibly know the ip of the user's server, so by default the agent responds to no one)
Host-based ACLs are not really a thing. On the local network faking a source IP address is one of the easiest jobs.
- By default remote commands (as in requests to the agent to
execute any command given) are disabled so the only way to make the agent call those binaries is to request a predefined userparameter that in turn will execute such a command with predefined params (see the additional template_...conf-files) and on top of that, the user can add additional security by configuring encryption in the agent main configfile
Encryption is not authentication.
And the predefined parameters might be a thing, but my view is that zabbix can execute quite serious commands if it is being exploited.
The Zabbix Agent had exactly one of these vulnerabilities in 2009 where an attacker could execute arbitrary commands:
https://www.cvedetails.com/cve/CVE-2009-4502/
But as you point out, a possible vulnerability of some sort may indeed still pose risks this way.
I just find this risk insanely large. I am not going to tell people what software they can use and what not, but I want to avoid that the default configuration is adding major security issues to the entire system. And adding those sudo rules by default does exactly this.
I totally agree, I was only pointing out the *some* security there is, but that will indeed never be sufficient to allow full access to iptables or addonctrl by default.
I could live with the information leak (that is pretty much what Zabbix is designed for), but I cannot live with the possibility that breaking in the agent allows changing the iptables ruleset. Definitely not in the default configuration.
A user could, on his own risk, do that to maybe have the agent execute firewall-actions as a reaction to a detected network attack or so.. But that is not something we should provide by default.
What would a monitoring tool do with a dump of the iptables ruleset? I do not even understand where the use of this is.
The same as IPFire webgui currently does on netother.cgi?fwhits?day by calling /sbin/iptables -vnxL <chain> | grep "/* <rule> */" | awk '{ print $2 }';: keep history of and eventually react on the number of firewall-hits.
We have the following SUID binary:
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=src/misc-progs/getipstat.c...
It isn’t pretty, but dumps the entire iptables ruleset into files which you can then read.
This allows exposing the ruleset without giving the agent the option to run the iptables command as root.
But you are completely right that access to iptables should be restricted to just that what we want to get from it, which can be achieved with a wrapper script as explained below in my previous mail.
-Michael
Regards
Robin
Are there any alternative ways to realise this functionality?
As sudo is not able to allow commands with variable parameters together with fixed parameters, a popular solution is using wrapper scripts, not writable by the user, denying the user direct access to the commands in question.
/usr/local/bin/addonctrl is only called from within the ipfire_services.pl script I provide, in the form of "addonctrl <service> status". So I could add /etc/zabbix_agentd/scripts/ipfire_services.pl to the sudo list instead so that the zabbix user won't be able to call addonctrl directly. (making sure zabbix user has no write permission on that script) The same goes for iptables. This is only called by the predefined userparameter "ipfire.net.fw.hits[*]" defined in template_module_ipfire_network_stats.conf in the form "/sbin/iptables - vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }';" where $1 (chain) and $2 (rule) are parameters that have to be supplied to the agent when requesting that item. Here I can also supply a wrapper-script to be called by sudo /etc/zabbix_agentd/scripts/firewall_hits.sh that accepts those parameters, and checks them for validity and against abuse.
Regards Robin
-Michael
diff --git a/config/zabbix_agentd/template_module_ipfire_network_stats.con f b/config/zabbix_agentd/template_module_ipfire_network_stats.con f new file mode 100644 index 000000000..f1658ed07 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_network_stats.con f @@ -0,0 +1,4 @@ +### Parameters for monitoring IPFire network statistics +UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? ]; echo $? +UserParameter=ipfire.net.fw.hits[*],sudo /sbin/iptables -vnxL $1 | grep "/* $2 */" | awk '{ print $$2 }'; diff --git a/config/zabbix_agentd/template_module_ipfire_services.conf b/config/zabbix_agentd/template_module_ipfire_services.conf new file mode 100644 index 000000000..5f95218e3 --- /dev/null +++ b/config/zabbix_agentd/template_module_ipfire_services.conf @@ -0,0 +1,2 @@ +### Parameter for monitoring IPFire services +UserParameter=ipfire.services,/etc/zabbix_agentd/scripts/ipfir e_serv ices.pl diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 73e08d20a..c0d28d51f 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = zabbix_agentd PAK_VER = 5 -DEPS = +DEPS = "fping"
############################################################### ###### ########## # Top-level Rules @@ -97,6 +97,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \ /etc/zabbix_agentd/zabbix_agentd.d/template_app _pakfi re.conf.ipfirenew
install -v -m 644
$(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_network_ stats. conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_mod
ule_ip fire_network_stats.conf.ipfirenew
install -v -m 644
$(DIR_SRC)/config/zabbix_agentd/template_module_ipfire_services .conf \
/etc/zabbix_agentd/zabbix_agentd.d/template_mod
ule_ip fire_services.conf.ipfirenew
install -v -m 755
$(DIR_SRC)/config/zabbix_agentd/ipfire_services.pl \
/etc/zabbix_agentd/scripts/ipfire_services.pl.i
pfiren ew
# Create directory for additional agent modules -mkdir -pv /usr/lib/zabbix
diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index 4248a7ec1..ced915c81 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -66,8 +66,13 @@ restore_backup ${NAME} # Put zabbix configfiles in place setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_netwo rk_sta ts.conf +setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_module_ipfire_servi ces.co nf setup_configfile /etc/sudoers.d/zabbix
+# Overwrite script if it exists as user should not modify it but it is included in backup +mv /etc/zabbix_agentd/scripts/ipfire_services.pl.ipfirenew /etc/zabbix_agentd/scripts/ipfire_services.pl
if $review_required; then echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files." echo " They may need manual review in order to take advantage of new features" diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index 7a13880c5..ccbc8f7cf 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -26,6 +26,8 @@ stop_service ${NAME}
# Remove .ipfirenew files in advance so they won't be included in backup rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew +# Remove script-file as it should not have been modified by user +rm -fv /etc/zabbix_agentd/scripts/ipfire_services.pl
make_backup ${NAME} remove_files -- 2.30.2
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-Michael
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hi
Michael Tremer schreef op ma 19-04-2021 om 14:37 [+0100]:
Hello,
On 15 Apr 2021, at 14:12, Robin Roevens robin.roevens@disroot.org wrote:
Hi Michael
...
The purpose of my extension to the default is that a user can easily configure Zabbix to monitor "IPFire"-specific functionalities. Generic Linux metrics can be monitored by default Zabbix templates and agent built-in functionality eventually extended with user-defined scripts or modules.
Yes, and I am absolutely for it. The Zabbix Agent alone is not very useful when it does not understand the special metrics that IPFire has and exports them in some way or another.
That said, there is obviously always the problem that if a third person gains access to the monitoring system, they would have a full map of the entire network and loads of other metrics that are helpful to see whether their attack is effective and/or detected. That is something that is out of scope of this project and a risk that people need to evaluate elsewhere. Obviously no monitoring at all is not a solution either.
True that, a monitoring system an sich is a security risk and should be appropriately secured on its own. But is indeed not our scope here. What we can do to secure it a little bit more is adding a big remark to the wiki page for the user to seriously consider setting up encrypted agent communication so hackers on the network at least can't intercept the values coming from IPFire. But by default we can't set that up for the user as PSK's or certificates are required that only the user can provide.
The IPFire webgui has a nice overview of all vital IPFire services and their state, as well as for addon-services. A user can browse the status pages of the WebGUI to have a view of how their IPFire machine is running This is exactly what I want to provide to the Zabbix user, hence my copy of services.cgi-code.
Understood. Since the services.cgi code is a bit ugly, we might want to rethink how we solve this.
I would be in favour of a file that every add-on brings with it and that makes it show up on the services.cgi table as well as bringing some more meta information like the name of the initscript (if there is one) which you could then call by using addonctrl status.
For the add-on services at least, that sounds like a good idea. I see there is already a bit of metadata in /opt/pakfire/db/installed/meta-*. This could possibly be extended with an InitScript: entry? But I'm not sure how to do this as I'm not sure how and where this file is actually generated. A proper place to set the variable that would be used in the final meta-file if an initscript is present would be in the lfs call INSTALL_INITSCRIPT but also here I have no idea where this function INSTALL_INITSCRIPT is actually defined. So I'm just guessing that this is the ideal place.
Alternatively, I could 'parse' the output of the services-page of the webserver. But that is rather something one would do when trying to monitor a black-box.
That is going to break as soon as we touch any of the markup.
That's one of the reasons why I would like to avoid that. :-)
... I totally agree, I was only pointing out the *some* security there is, but that will indeed never be sufficient to allow full access to iptables or addonctrl by default.
I could live with the information leak (that is pretty much what Zabbix is designed for), but I cannot live with the possibility that breaking in the agent allows changing the iptables ruleset. Definitely not in the default configuration.
A user could, on his own risk, do that to maybe have the agent execute firewall-actions as a reaction to a detected network attack or so.. But that is not something we should provide by default.
What would a monitoring tool do with a dump of the iptables ruleset? I do not even understand where the use of this is.
The same as IPFire webgui currently does on netother.cgi?fwhits?day by calling /sbin/iptables -vnxL <chain> | grep "/* <rule> */" | awk '{ print $2 }';: keep history of and eventually react on the number of firewall-hits.
We have the following SUID binary:
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=src/misc-progs/getipstat.c...
It isn’t pretty, but dumps the entire iptables ruleset into files which you can then read.
This allows exposing the ruleset without giving the agent the option to run the iptables command as root.
At first, this sounded like the solution. But I found 2 problems with it:
- It generates a (few) fixed files with names that can't be customized. And it is called in guardian.cgi and iptables.cgi. So if it so happens that a user opens one of those 2 pages at the moment the zabbix agent is using that command; chances are that the file is removed again by the time the agent can parse it or incompletely (re)written. Resulting in the agent failing to collect the metrics accurately. (or one of those cgi's failing to give a correct output). A possible fix for this could be to have a command parameter on this tool that switches output to stdout, or that would let you define the output-filename.
- It doesn't call iptables with the -x parameter (to show the exact # of bytes in the output) which I really require. Rounded values up to K/M or even G are pretty useless for fine grained monitoring. Also here is a possible fix to accept a command line parameter to make the command call iptables with the -x parameter added. (as it is currently used by iptables, we probably don't want -x to be used by default, hence an optional parameter)
If you see no problem in these changes, I will try to submit a patch for it shortly.
About addonctrl where zabbix needs to call "addonctrl status" which requires root: I propose to add a wrapper script to the zabbix_agentd package that will call addonctrl status "$1" which then in turn can be added to the sudo list instead of addonctrl itself.
Regards
Robin
But you are completely right that access to iptables should be restricted to just that what we want to get from it, which can be achieved with a wrapper script as explained below in my previous mail.
-Michael
Regards
Robin
Hello Robin,
Welcome to the list and thank you for working on this.
Generally I am very happy for you to take on Zabbix which needs some more love in IPFire.
But I am not sure what to make with all the custom tooling that comes in this patch series. It is a lot of code that might not be suitable for all users and probably would be hard work to extend (a few more details below).
Could you go more into detail why this is required? Doesn’t zabbix have any builtin tools to show running services?
Maybe it is a better idea to add a configuration template to the wiki (minus the code)?!
-Michael
On 7 Apr 2021, at 21:44, Robin Roevens robin.roevens@disroot.org wrote:
Since a new version of Zabbix Agent 5 LTS was released before the previous patch-set was reviewed, I resubmit my patchset as a V2 updating current zabbix_agentd 4.2.6 to 5.0.10 as opposed to v5.0.9 in my previous submission. The other 3 patches in the set remain unchanged.
For reference I'll include the summary again:
This set of patches does not only update the binaries (well, the first patch only does that) but also fixes some things that I see as problematic in previous version:
- /usr/lib/zabbix is created for users to drop custom agent
modules in, however that dir was removed and recreated on update as it was not in the backup. I added it to the backup and prevented deletion of the directory if it is not empty upon uninstall, so user-added content would not disapear when the package is removed.
- Sometimes a new version of the agent will introduce
new configuration parameters. In general the Zabbix Agent config file(s) should remain compatible, but we never know what the future will bring us; and the user may miss out on new features introduced with new parameters in the config file. However we don't want to plain overwrite the configfile as the user may (probably has) have changed it. Currently on upgrade configfiles are backed up, removed, new are installed, then overwritten by the old ones from the backup. Ending with the old config and the new agent. I didn't find an example of another package doing something similar, so I chose to save the new configfile(s) as .ipfirenew-files like RPM-based distro's do with .rpmnew-files. If the original config file is absent the install script will automatically strip the .ipfirenew extension. And if the new config file does not differ from the currently installed one, the .ipfirenew-file is removed. The install-script will also issue warning messages if such .ipfirenew-files are left on the filesystem, requesting the user to manually investigate and possibly merge the configfile. I hope those warnings are visible in the pakfire output. A side effect is that the config files are also not removed when the package is uninstalled. I don't see a problem here for the zabbix own config-files. But it may pose a risk concerning the sudoers-file?
- I added a few IPFire specific monitoring items to the agent
config which can be used for more in-depth monitoring of the IPFire installation. The user is of course free to use my template available on share.zabbix.com or github to monitor those items, or create their own template.
Thanks for considering this patch-set. Please be honest but gentle commenting on it :-).
Regards Robin
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.
Hi Michael
Michael Tremer schreef op ma 12-04-2021 om 11:32 [+0100]:
Hello Robin,
Welcome to the list and thank you for working on this.
Generally I am very happy for you to take on Zabbix which needs some more love in IPFire.
Thanks! I will try to do my best :-)
But I am not sure what to make with all the custom tooling that comes in this patch series. It is a lot of code that might not be suitable for all users and probably would be hard work to extend (a few more details below).
Zabbix provides default templates for monitoring a generic Linux host where it checks cpu, memory, disk space and all that. But on a sysv init system, it has no built-in way to dynamically monitor services (see below). By providing this custom code as a default in IPFire's zabbix_agentd, it allows the user to easily monitor the services important specifically to IPFire- and addon functionality without the need for the user to find out which services he actually has to monitor manually (or look up in a wiki). So, I think this is a great addition in user experience, providing an easy method for monitoring IPFire specific metrics. As this is a firewall distro and not a general purpose generic distro, I'm only assuming a user installing the zabbix_agentd addon on it, will actually want to monitor these metrics. And if for some reason, they don't want that, then they just don't configure their Zabbix server to monitor those metrics, and in that case all that code will never even be called. If they would want to monitor extra services besides the ones the script provides, they can just configure those on their server (also more on this later).. or for more advanced checks add additional script(s) and/or config-files. Actually there is no need for a user to change anything I provided here to be able to monitor things differently or additionally; but they can, if they want to.. I'm just providing easily accessible metrics as seen on the webgui.
Could you go more into detail why this is required? Doesn’t zabbix have any builtin tools to show running services?
If IPFire would use systemd and we would deploy zabbix_agent2 (a Go version of the agent with a few different capabilities, which I currently didn't see much of a purpose for on IPFire), one could check service states more easily using built-in checks.
In the current case, there are only running processes that happen to be started on system startup due to the existence of an initscript. But initscripts are not all the starting of services. Zabbix (or the user for that matter) has to know which processes to monitor and for as far as I know, the only place to find a list of built-in services is in the services.cgi file of the webgui. Once Zabbix can retrieve a list of services to monitor, it can check if those process(es) are running and how much CPU/memory they consume using built-in agent functionality without the need of any script. So actually the checking if the service is up and retrieving the memory and/or cpu usage of the service could be done without the use of the script I added.
However, I currently opted for this script as I wanted to perform the checks on the available services exactly as the webgui does, to minimize the risk of possibly causing different values in zabbix than currently visible in the webgui due to different checking methods. Checking if a service is up in zabbix would be performed by counting the number of active processes with a certain name and/or cmdline params. And the case that this result would differ with the way the script (and the webgui) currently checks built-in services is probably minimal, but for addon-services the webgui and thus the script also, use 'addonctrl <addon> status' which I assume calls '<initscript> status', hence could theoretically perform any kind of custom checks beside the simple check to see if the pid exists to determine if the service is up and running. I have not checked up on all initscripts of all addons, so I don't know if there is such a case.. but if it is not, it still could be in the future, I figured.
And due to this I've put the whole services-status retrieval, both for built-in and addon-services to normalize retrieval of the list, in a script to be certain that all information about IPFire in Zabbix will match the information in the webgui exactly. Another benefit of this is that the services discovery and each of the metrics are all sent to the Zabbix server in one go, minimizing network traffic and load on the server which otherwise would have to retrieve each metric separately, possibly important in embedded systems, but for this amount of information maybe not making that much of a difference.
Maybe it is a better idea to add a configuration template to the wiki (minus the code)?!
We could ship a vanilla agent, if this is what you meant?, without my additional ipfire specific 'extension'; adding instructions to the wiki on how to configure the agent to be able to generate metrics like on the webgui but without an easy method to get at least a list of available services as displayed in the webgui, the user will have to manually configure each possible metric (currently state, pid, memory) for each possible service separately. And once again every time he installs a new addon with a service. (Or I have to maintain this in a Zabbix template the user can install on their server, but I can't do so for all possible addon-services). So either in the end the user will end up configuring a lot manually or still installing this or another script to provide this info to Zabbix but requesting a lot more effort and knowledge of the user.
If IPFire would have some easy generic method of obtaining this information instead of inside the webgui code. The webgui, zabbix_agentd or any other monitoring tool could check that instead without resorting to so much custom code.
But currently I don't see a way to retrieve the list of services (both built-in and addon, as displayed on the webgui) other than the current method. (Theoretically I could let the agent read out the services.cgi script as text and get the list from that code using some regex.. Or even scrape the page as it is returned by the webserver, but that would create an extra dependency on a correctly running webserver. And possibly break if services.cgi would change in the future. And then I still have to get a list of addon-services some way.. So that was not a feasible path for me)
Of course in the current case, I have to maintain the list in the script to have it in sync with services.cgi. But I'm assuming this list is not that regularly changing ? Until there is a more generic way available on IPFire to get this list.. And maybe I will think about submitting such a rework in the future, but it would require for me to be much more comfortable in Perl as I'm now; and it is a bit too much 'in the core' of IPFire for me at this moment.
But I'm open to suggestions on how to improve this. I may not have a complete view on the internals of IPfire yet.
Regards Robin
-Michael
On 7 Apr 2021, at 21:44, Robin Roevens robin.roevens@disroot.org wrote:
Since a new version of Zabbix Agent 5 LTS was released before the previous patch-set was reviewed, I resubmit my patchset as a V2 updating current zabbix_agentd 4.2.6 to 5.0.10 as opposed to v5.0.9 in my previous submission. The other 3 patches in the set remain unchanged.
For reference I'll include the summary again:
This set of patches does not only update the binaries (well, the first patch only does that) but also fixes some things that I see as problematic in previous version:
- /usr/lib/zabbix is created for users to drop custom agent
modules in, however that dir was removed and recreated on update as it was not in the backup. I added it to the backup and prevented deletion of the directory if it is not empty upon uninstall, so user-added content would not disapear when the package is removed.
- Sometimes a new version of the agent will introduce
new configuration parameters. In general the Zabbix Agent config file(s) should remain compatible, but we never know what the future will bring us; and the user may miss out on new features introduced with new parameters in the config file. However we don't want to plain overwrite the configfile as the user may (probably has) have changed it. Currently on upgrade configfiles are backed up, removed, new are installed, then overwritten by the old ones from the backup. Ending with the old config and the new agent. I didn't find an example of another package doing something similar, so I chose to save the new configfile(s) as .ipfirenew-files like RPM-based distro's do with .rpmnew-files. If the original config file is absent the install script will automatically strip the .ipfirenew extension. And if the new config file does not differ from the currently installed one, the .ipfirenew-file is removed. The install-script will also issue warning messages if such .ipfirenew-files are left on the filesystem, requesting the user to manually investigate and possibly merge the configfile. I hope those warnings are visible in the pakfire output. A side effect is that the config files are also not removed when the package is uninstalled. I don't see a problem here for the zabbix own config-files. But it may pose a risk concerning the sudoers-file?
- I added a few IPFire specific monitoring items to the agent
config which can be used for more in-depth monitoring of the IPFire installation. The user is of course free to use my template available on share.zabbix.com or github to monitor those items, or create their own template.
Thanks for considering this patch-set. Please be honest but gentle commenting on it :-).
Regards Robin
-- Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn.