Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_update over nrpe #44

Closed
xxedgexx opened this issue Sep 11, 2021 · 47 comments · Fixed by #49
Closed

check_update over nrpe #44

xxedgexx opened this issue Sep 11, 2021 · 47 comments · Fixed by #49
Assignees
Labels
bug need more info Not enough information to reproduce or analyse the problem

Comments

@xxedgexx
Copy link

xxedgexx commented Sep 11, 2021

Describe the bug

/usr/lib64/nagios/plugins/check_nrpe -t 60 -H mx1.la1.blah.corp --key-file=mon.la1.blah.corp.key --client-cert=mon.la1.blah.corp.cer --ca-cert-file=/etc/pki/tls/certs/BlahCA-chain.pem -c check_updates
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually

NRPE server side:
[1631340898] CONN_CHECK_PEER: checking if host is allowed: 192.168.30.76 port 28316
[1631340898] Connection from 192.168.30.76 port 28316
[1631340898] is_an_allowed_host (AF_INET): is host >192.168.30.76< an allowed host >192.168.30.76<
[1631340898] is_an_allowed_host (AF_INET): host is in allowed host list!
[1631340898] Host address is in allowed_hosts
[1631340898] Host 192.168.30.76 is asking for command 'check_updates' to be run...
[1631340898] Running command: /usr/lib64/nagios/plugins/check_updates
[1631340898] WARNING: my_system() seteuid(0): Operation not permitted

System (please complete the following information):

  • OS: RockyLinux
  • OS Version: 8.4
  • check_updates Version: 1.8.4

Additional context/output

I'm able to run as the nrpe user. I'm assuming this is some kind of tty allocation permission thing? Maybe a sudo fix?

[nrpe@mx1 ~]$ /usr/lib64/nagios/plugins/check_updates -d -v
[DBG] check_updates version: 1.8.4
[DBG] system info: Linux mx1.la1.blah.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
Checking a linux system
Running on Rocky Linux release 8.4 (Green Obsidian)
[DBG] Updater: yum
Using Yum or DNF
running a Linux kernel: 5.13.12-1
kernel: running = 5.13.12-1, installed = 5.13.12-1
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
[DBG]
[DBG] bpftool.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
[DBG] cabextract.x86_64 1.9-7.epel8.playground epel-playground
[DBG] certbot.noarch 1.18.0-2.el8 epel-testing
[DBG] clamav.x86_64 0.103.3-5.epel8.playground epel-playground
[DBG] clamav-data.noarch 0.103.3-5.epel8.playground epel-playground
[DBG] clamav-filesystem.noarch 0.103.3-5.epel8.playground epel-playground
[DBG] clamav-lib.x86_64 0.103.3-5.epel8.playground epel-playground
[DBG] clamav-update.x86_64 0.103.3-5.epel8.playground epel-playground
[DBG] clamd.x86_64 0.103.3-5.epel8.playground epel-playground
[DBG] epel-release.noarch 8-13.el8 epel-testing
[DBG] kernel.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-core.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-ml.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
[DBG] kernel-ml-core.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
[DBG] kernel-ml-modules.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
[DBG] kernel-modules.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-tools.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-tools-libs.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] libprelude.x86_64 5.2.0-1.epel8.playground epel-playground
[DBG] p7zip.x86_64 16.02-20.epel8.playground epel-playground
[DBG] p7zip-plugins.x86_64 16.02-20.epel8.playground epel-playground
[DBG] php-common.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-fpm.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-gd.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-gmp.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-imap.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-intl.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-json.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-mbstring.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-mysqlnd.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-opcache.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-pdo.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-pecl-zip.x86_64 1.19.4-1.el8.remi.7.4 remi-modular
[DBG] php-pgsql.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] php-xml.x86_64 7.4.23-1.el8.remi remi-modular
[DBG] python3-acme.noarch 1.18.0-1.el8 epel
[DBG] python3-certbot.noarch 1.18.0-2.el8 epel-testing
[DBG] python3-perf.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
Security updates available
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q --security 2>&1 2>&1"
[DBG]
[DBG] bpftool.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
[DBG] kernel.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-core.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-modules.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-tools.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] kernel-tools-libs.x86_64 4.18.0-305.17.1.el8_4 baseos
[DBG] p7zip.x86_64 16.02-20.epel8.playground epel-playground
[DBG] p7zip-plugins.x86_64 16.02-20.epel8.playground epel-playground
[DBG] python3-perf.x86_64 5.14.2-1.el8.elrepo elrepo-kernel
Security updates available
no security plugin: every update could be a security problem
CHECK_UPDATES CRITICAL - 9 security updates and 29 non-security updates available | total_updates=38;0;0 security_updates=9;0;0
bpftool.x86_64 (security)
kernel.x86_64 (security)
kernel-core.x86_64 (security)
kernel-modules.x86_64 (security)
kernel-tools.x86_64 (security)
kernel-tools-libs.x86_64 (security)
p7zip.x86_64 (security)
p7zip-plugins.x86_64 (security)
python3-perf.x86_64 (security)
cabextract.x86_64
certbot.noarch
clamav.x86_64
clamav-data.noarch
clamav-filesystem.noarch
clamav-lib.x86_64
clamav-update.x86_64
clamd.x86_64
epel-release.noarch
kernel-ml.x86_64
kernel-ml-core.x86_64
kernel-ml-modules.x86_64
libprelude.x86_64
php-common.x86_64
php-fpm.x86_64
php-gd.x86_64
php-gmp.x86_64
php-imap.x86_64
php-intl.x86_64
php-json.x86_64
php-mbstring.x86_64
php-mysqlnd.x86_64
php-opcache.x86_64
php-pdo.x86_64
php-pecl-zip.x86_64
php-pgsql.x86_64
php-xml.x86_64
python3-acme.noarch
python3-certbot.noarch

@xxedgexx xxedgexx added the bug label Sep 11, 2021
@matteocorti matteocorti self-assigned this Sep 13, 2021
@matteocorti
Copy link
Owner

What happens if you run dnf check-update manually as "nrpe" and as "root"?

@xxedgexx
Copy link
Author

As nrpe:

[nrpe@mx1 ~]$ dnf check-update
Rocky Linux 8 - AppStream 11 kB/s | 4.8 kB 00:00
Rocky Linux 8 - AppStream 4.6 MB/s | 8.7 MB 00:01
Rocky Linux 8 - BaseOS 34 kB/s | 4.3 kB 00:00
Rocky Linux 8 - BaseOS 10 MB/s | 6.5 MB 00:00
Rocky Linux 8 - Extras 28 kB/s | 3.5 kB 00:00
Rocky Linux 8 - Extras 33 kB/s | 10 kB 00:00
Rocky Linux 8 - Plus 16 kB/s | 3.5 kB 00:00
Rocky Linux 8 - Plus 8.0 kB/s | 6.5 kB 00:00
Rocky Linux 8 - PowerTools 13 kB/s | 4.8 kB 00:00
Rocky Linux 8 - PowerTools 2.5 MB/s | 2.2 MB 00:00
ELRepo.org Community Enterprise Linux Repository - el8 5.8 kB/s | 3.0 kB 00:00
ELRepo.org Community Enterprise Linux Repository - el8 105 kB/s | 273 kB 00:02
ELRepo.org Community Enterprise Linux Testing Repository - el8 7.5 kB/s | 3.0 kB 00:00
ELRepo.org Community Enterprise Linux Testing Repository - el8 12 kB/s | 8.7 kB 00:00
ELRepo.org Community Enterprise Linux Kernel Repository - el8 6.7 kB/s | 3.0 kB 00:00
ELRepo.org Community Enterprise Linux Kernel Repository - el8 343 kB/s | 2.0 MB 00:06
ELRepo.org Community Enterprise Linux Extras Repository - el8 7.9 kB/s | 3.0 kB 00:00
ELRepo.org Community Enterprise Linux Extras Repository - el8 25 kB/s | 18 kB 00:00
Extra Packages for Enterprise Linux Modular 8 - x86_64 43 kB/s | 15 kB 00:00
Extra Packages for Enterprise Linux 8 - Playground - x86_64 46 kB/s | 12 kB 00:00
Extra Packages for Enterprise Linux 8 - Playground - x86_64 764 kB/s | 1.4 MB 00:01
Extra Packages for Enterprise Linux Modular 8 - Testing - x86_64 51 kB/s | 16 kB 00:00
Extra Packages for Enterprise Linux Modular 8 - Testing - x86_64 883 kB/s | 943 kB 00:01
Extra Packages for Enterprise Linux 8 - Testing - x86_64 40 kB/s | 13 kB 00:00
Extra Packages for Enterprise Linux 8 - Testing - x86_64 1.1 MB/s | 1.1 MB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 83 kB/s | 13 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 5.4 MB/s | 10 MB 00:01
Remi's Modular repository for Enterprise Linux 8 - x86_64 705 B/s | 858 B 00:01
Remi's Modular repository for Enterprise Linux 8 - x86_64 445 kB/s | 848 kB 00:01
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 930 B/s | 858 B 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 969 kB/s | 2.0 MB 00:02

bpftool.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
cabextract.x86_64 1.9-7.epel8.playground epel-playground
certbot.noarch 1.19.0-1.el8 epel-testing
clamav.x86_64 0.103.3-5.epel8.playground epel-playground
clamav-data.noarch 0.103.3-5.epel8.playground epel-playground
clamav-filesystem.noarch 0.103.3-5.epel8.playground epel-playground
clamav-lib.x86_64 0.103.3-5.epel8.playground epel-playground
clamav-update.x86_64 0.103.3-5.epel8.playground epel-playground
clamd.x86_64 0.103.3-5.epel8.playground epel-playground
epel-release.noarch 8-13.el8 epel
kernel.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-core.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-ml.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
kernel-ml-core.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
kernel-ml-modules.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
kernel-modules.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-tools.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-tools-libs.x86_64 4.18.0-305.17.1.el8_4 baseos
libprelude.x86_64 5.2.0-1.epel8.playground epel-playground
p7zip.x86_64 16.02-20.epel8.playground epel-playground
p7zip-plugins.x86_64 16.02-20.epel8.playground epel-playground
php-common.x86_64 7.4.23-1.el8.remi remi-modular
php-fpm.x86_64 7.4.23-1.el8.remi remi-modular
php-gd.x86_64 7.4.23-1.el8.remi remi-modular
php-gmp.x86_64 7.4.23-1.el8.remi remi-modular
php-imap.x86_64 7.4.23-1.el8.remi remi-modular
php-intl.x86_64 7.4.23-1.el8.remi remi-modular
php-json.x86_64 7.4.23-1.el8.remi remi-modular
php-mbstring.x86_64 7.4.23-1.el8.remi remi-modular
php-mysqlnd.x86_64 7.4.23-1.el8.remi remi-modular
php-opcache.x86_64 7.4.23-1.el8.remi remi-modular
php-pdo.x86_64 7.4.23-1.el8.remi remi-modular
php-pecl-zip.x86_64 1.19.4-1.el8.remi.7.4 remi-modular
php-pgsql.x86_64 7.4.23-1.el8.remi remi-modular
php-xml.x86_64 7.4.23-1.el8.remi remi-modular
python-josepy-doc.noarch 1.9.0-1.el8 epel-testing
python3-acme.noarch 1.19.0-1.el8 epel-testing
python3-certbot.noarch 1.19.0-1.el8 epel-testing
python3-josepy.noarch 1.9.0-1.el8 epel-testing
python3-perf.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
rocky-gpg-keys.noarch 8.4-34.el8 baseos
rocky-release.noarch 8.4-34.el8 baseos
rocky-repos.noarch 8.4-34.el8 baseos
systemtap-sdt-devel.x86_64 4.4-11.el8_4.0.1 appstream

As root:

[root@mx1 ~]# yum check-update
Last metadata expiration check: 1:48:39 ago on Wed 15 Sep 2021 02:14:46 AM PDT.

bpftool.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
cabextract.x86_64 1.9-7.epel8.playground epel-playground
certbot.noarch 1.19.0-1.el8 epel-testing
clamav.x86_64 0.103.3-5.epel8.playground epel-playground
clamav-data.noarch 0.103.3-5.epel8.playground epel-playground
clamav-filesystem.noarch 0.103.3-5.epel8.playground epel-playground
clamav-lib.x86_64 0.103.3-5.epel8.playground epel-playground
clamav-update.x86_64 0.103.3-5.epel8.playground epel-playground
clamd.x86_64 0.103.3-5.epel8.playground epel-playground
epel-release.noarch 8-13.el8 epel
kernel.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-core.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-ml.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
kernel-ml-core.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
kernel-ml-modules.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
kernel-modules.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-tools.x86_64 4.18.0-305.17.1.el8_4 baseos
kernel-tools-libs.x86_64 4.18.0-305.17.1.el8_4 baseos
libprelude.x86_64 5.2.0-1.epel8.playground epel-playground
p7zip.x86_64 16.02-20.epel8.playground epel-playground
p7zip-plugins.x86_64 16.02-20.epel8.playground epel-playground
php-common.x86_64 7.4.23-1.el8.remi remi-modular
php-fpm.x86_64 7.4.23-1.el8.remi remi-modular
php-gd.x86_64 7.4.23-1.el8.remi remi-modular
php-gmp.x86_64 7.4.23-1.el8.remi remi-modular
php-imap.x86_64 7.4.23-1.el8.remi remi-modular
php-intl.x86_64 7.4.23-1.el8.remi remi-modular
php-json.x86_64 7.4.23-1.el8.remi remi-modular
php-mbstring.x86_64 7.4.23-1.el8.remi remi-modular
php-mysqlnd.x86_64 7.4.23-1.el8.remi remi-modular
php-opcache.x86_64 7.4.23-1.el8.remi remi-modular
php-pdo.x86_64 7.4.23-1.el8.remi remi-modular
php-pecl-zip.x86_64 1.19.4-1.el8.remi.7.4 remi-modular
php-pgsql.x86_64 7.4.23-1.el8.remi remi-modular
php-xml.x86_64 7.4.23-1.el8.remi remi-modular
python-josepy-doc.noarch 1.9.0-1.el8 epel-testing
python3-acme.noarch 1.19.0-1.el8 epel-testing
python3-certbot.noarch 1.19.0-1.el8 epel-testing
python3-josepy.noarch 1.9.0-1.el8 epel-testing
python3-perf.x86_64 5.14.3-1.el8.elrepo elrepo-kernel
rocky-gpg-keys.noarch 8.4-34.el8 baseos
rocky-release.noarch 8.4-34.el8 baseos
rocky-repos.noarch 8.4-34.el8 baseos
systemtap-sdt-devel.x86_64 4.4-11.el8_4.0.1 appstream

@matteocorti
Copy link
Owner

I don't get it ... It seems that the process is not run as "nrpe" and not as "root" ... I don't use NRPE. What happens if you specify the -d option? Can the debugging output be seen in the logs?

@xxedgexx
Copy link
Author

xxedgexx commented Sep 15, 2021

Client side:

[root@mon ssl]# /usr/lib64/nagios/plugins/check_nrpe -t 60 -H mx1.la1.clx.corp --key-file=mon.la1.clx.corp.key --client-cert=mon.la1.clx.corp.cer --ca-cert-file=/etc/pki/tls/certs/blah-chain.pem -c check_updates
[DBG] check_updates version: 1.8.4
[DBG] system info: Linux mx1.la1.clx.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[DBG] Updater: yum
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
UPDATES UNKNOWN - plugin timed out (timeout 15s)
[root@mon ssl]# /usr/lib64/nagios/plugins/check_nrpe -t 60 -H mx1.la1.clx.corp --key-file=mon.la1.clx.corp.key --client-cert=mon.la1.clx.corp.cer --ca-cert-file=/etc/pki/tls/certs/blah-chain.pem -c check_updates
[DBG] check_updates version: 1.8.4
[DBG] system info: Linux mx1.la1.clx.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[DBG] Updater: yum
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
[DBG] Importing GPG key 0x5F11735A:
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually

NRPE Server side:

[1631704204] CONN_CHECK_PEER: checking if host is allowed: 192.168.30.76 port 48771
[1631704204] Connection from 192.168.30.76 port 48771
[1631704204] is_an_allowed_host (AF_INET): is host >192.168.30.76< an allowed host >192.168.30.76<
[1631704204] is_an_allowed_host (AF_INET): host is in allowed host list!
[1631704204] Host address is in allowed_hosts
[1631704204] Host 192.168.30.76 is asking for command 'check_updates' to be run...
[1631704204] Running command: /usr/lib64/nagios/plugins/check_updates -d
[1631704204] WARNING: my_system() seteuid(0): Operation not permitted
[1631704207] Command completed with return code 3 and output: [DBG] check_updates version: 1.8.4
[DBG] system info: Linux mx1.la1.clx.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[DBG] Updater: yum
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
[DBG] Importing GPG key 0x5F11735A:
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
[1631704207] Return Code: 3, Output: [DBG] check_updates version: 1.8.4
[DBG] system info: Linux mx1.la1.clx.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[DBG] Updater: yum
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
[DBG] Importing GPG key 0x5F11735A:
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
[1631704207] Connection from 192.168.30.76 closed.

@matteocorti
Copy link
Owner

I just committed a new version with some more debugging output. Would it be possible to test again?

@matteocorti matteocorti added the need more info Not enough information to reproduce or analyse the problem label Sep 15, 2021
@xxedgexx
Copy link
Author

xxedgexx commented Sep 15, 2021

[1631705217] CONN_CHECK_PEER: checking if host is allowed: 192.168.30.76 port 3204
[1631705217] Connection from 192.168.30.76 port 3204
[1631705217] is_an_allowed_host (AF_INET): is host >192.168.30.76< an allowed host >192.168.30.76<
[1631705217] is_an_allowed_host (AF_INET): host is in allowed host list!
[1631705217] Host address is in allowed_hosts
[1631705217] Host 192.168.30.76 is asking for command 'check_updates' to be run...
[1631705217] Running command: /usr/lib64/nagios/plugins/check_updates -d
[1631705217] WARNING: my_system() seteuid(0): Operation not permitted
[1631705221] Command completed with return code 3 and output: [DBG] check_updates version: 1.8.4
[DBG] running as: nrpe
[DBG] system info: Linux mx1.la1.blah.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[DBG] Updater: yum
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
[DBG] Importing GPG key 0x5F11735A:
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
[1631705221] Return Code: 3, Output: [DBG] check_updates version: 1.8.4
[DBG] running as: nrpe
[DBG] system info: Linux mx1.la1.blah.corp 5.13.12-1.el8.elrepo.x86_64 #1 SMP Tue Aug 17 10:51:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
[DBG] NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[DBG] Updater: yum
[DBG] Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q 2>&1"
[DBG] Importing GPG key 0x5F11735A:
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
[1631705221] Connection from 192.168.30.76 closed.

@jonmilby
Copy link

I am experiencing this bug as well. Worth noting that it only happens to my CentOS/RHEL 8 systems, those on 7.x work as expected.

check_updates works fine when run standalone, as root or the nrpe user. When run via check_nrpe from the local system or our monitoring server it bombs with the "CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually" error.

Also, while troubleshooting I saw exactly the same 'Importing GPG key' line from @xxedgexx 's output. When I disabled the third-party repos using this key (remi-safe and remi-modular), the check_nrpe command started working. Obviously that's not a viable long-term solution, though.

@matteocorti
Copy link
Owner

matteocorti commented Nov 19, 2021

Thanks for the feedback ... I'll try to take a look again

@matteocorti
Copy link
Owner

The warning about seteuid(0) seems that can be ignored: NagiosEnterprises/nrpe#237

@matteocorti
Copy link
Owner

What happens when running

/usr/bin/dnf check-update --assumeno 

as user nrpe?

@jonmilby
Copy link

It appears to work, as far as I can see. (This is the output via the nrpe user on RHEL 8.)

Not root, Subscription Management repositories not updated
Repository 'pbis-open' is missing name in configuration, using id.
Repository 'puppetlabs' is missing name in configuration, using id.
Extra Packages for Enterprise Linux 8 - x86_64 24 kB/s | 12 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 2.7 MB/s | 11 MB 00:04
Extra Packages for Enterprise Linux Modular 8 - x86_64 118 kB/s | 16 kB 00:00
pbis-open 38 kB/s | 2.5 kB 00:00
puppetlabs 11 kB/s | 2.5 kB 00:00
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 18 kB/s | 4.5 kB 00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 12 kB/s | 4.1 kB 00:00
Red Hat CodeReady Linux Builder for RHEL 8 x86_64 (RPMs) 22 kB/s | 4.5 kB 00:00
Remi's Modular repository for Enterprise Linux 8 - x86_64 926 B/s | 858 B 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 1.2 kB/s | 858 B 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 925 kB/s | 2.0 MB 00:02
Security: kernel-core-4.18.0-348.2.1.el8_5.x86_64 is an installed security update
Security: kernel-core-4.18.0-348.el8.x86_64 is the currently running version

@matteocorti
Copy link
Owner

I really why dnf is behaving differently when called via a Perl script.
What happens with perl -e 'system("/usr/bin/dnf check-update --assumeno");'?

@jonmilby
Copy link

I get the same output as running from a bash prompt.
In looking at the definitions for the repos that seem to be causing the issue, I found that both remi-safe and remi-modular had repo_gpgcheck=1 set. My other 3rd party repos either had this set to 0, or did not explicitly set it at all.
Setting repo_gpgcheck=0 for the remi-safe and remi-modular repos allowed check_updates to work via NRPE. Not sure why that should matter, maybe some difference in the NRPE execution environment?

@matteocorti
Copy link
Owner

Mmmm I really don't get why it's behaving differently when run through nrpe. I'll try to set it up with a server of mine (I usually check with ssh ...).

@matteocorti
Copy link
Owner

@jonmilby I installed NRPE on a CentOS 8 machine with the following command

command[check_updates]=/usr/lib64/nagios/plugins/check_updates -t 120

And got no issues ... Even by the first run. And I have the GPG check set to 1 globally

$ cat /etc/dnf/dnf.conf 
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False

@jonmilby
Copy link

@matteocorti I tried this as well, and it works as you said. The issue only occurs once I install the Remi repo RPM (dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm) to install other versions of PHP than those provided by the system repos. None of the other repos has repo_gpgcheck defined at all, but these do and that seems to be the trouble.

Here's one of the repo definitions (/etc/yum.repos.d/remi-safe.repo):

[remi-safe]
name=Safe Remi's RPM repository for Enterprise Linux 8 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/8/safe/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/8/safe/$basearch/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/8/safe/$basearch/mirror
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8

On this fresh install, running as the nrpe user, both running check_updates directly and via NRPE fail once the repo is added. If I run 'dnf check-update' as the nrpe user, it asks me to accept the GPG keys for the repos. Once I do that, running check_updates directly works as expected. However, running via check_nrpe still throws the GPG key error.

If I edit remi-safe.repo and remi-modular.repo to set repo_gpgcheck=0, the NRPE check works as it did with my other system.

@matteocorti
Copy link
Owner

Thanks

I installed the RPM and got the same error.

Then:

root@elhz ~> su -s /bin/sh - nrpe
Last login: Tue Nov 30 15:35:05 CET 2021 on pts/0
[nrpe@elhz ~]$ dnf check-update 
CentOS Linux 8 - AppStream                                                                                        19 MB/s | 8.1 MB     00:00    
CentOS Linux 8 - BaseOS                                                                                           14 MB/s | 3.5 MB     00:00    
CentOS Linux 8 - Extras                                                                                           83 kB/s |  10 kB     00:00    
CentOS Linux 8 - PowerTools                                                                                      7.0 MB/s | 2.3 MB     00:00    
Matteo Corti                                                                                                     233 kB/s |  29 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                                                                    23 MB/s |  11 MB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                           2.4 MB/s | 958 kB     00:00    
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        826  B/s | 858  B     00:01    
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <remi@remirepo.net>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        1.6 MB/s | 942 kB     00:00    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       2.2 kB/s | 858  B     00:00    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <remi@remirepo.net>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       3.5 MB/s | 2.0 MB     00:00    
[nrpe@elhz ~]$ 

If I run dnf check-updates again as nrpe I do not get any errors.

But I get the message in Nagios (as you do ...)

@matteocorti
Copy link
Owner

In /etc/nagios/nrpe.cfg:

command[check_updates]=/usr/lib64/nagios/plugins/check_updates -t 120

And executing the command:

[nrpe@elhz ~]$ /usr/lib64/nagios/plugins/check_updates -t 120
CHECK_UPDATES OK - no updates available | total_updates=0;0;0 security_updates=0;0;0

@matteocorti
Copy link
Owner

The plugin is not (?) running as user nrpe.
I added --debug-file=/var/run/nrpe/log and I get a permission error.

@matteocorti
Copy link
Owner

SELinux is not the problem:

root@elhz ~> sudo sestatus
SELinux status:                 disabled

@matteocorti
Copy link
Owner

Still puzzled: with

command[check_updates]=/usr/lib64/nagios/plugins/check_updates -t 120 --debug-file=/tmp/check_updates.log

No log file is generated...

@matteocorti
Copy link
Owner

By running dnf check-updates manually and importing the keys I solved the problem on the command line

$ whoami
nrpe
$ /usr/lib64/nagios/plugins/check_updates -t 120
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
$ dnf check-update
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        766  B/s | 858  B     00:01    
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <remi@remirepo.net>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                        1.9 MB/s | 956 kB     00:00    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       2.0 kB/s | 858  B     00:00    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <remi@remirepo.net>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                                       3.6 MB/s | 2.0 MB     00:00    
Last metadata expiration check: 0:00:01 ago on Mon 17 Jan 2022 03:08:41 PM CET.
$ /usr/lib64/nagios/plugins/check_updates -t 120
CHECK_UPDATES OK - no updates available | total_updates=0;0;0 security_updates=0;0;0

@matteocorti
Copy link
Owner

By manually removing a check in the plugin I was able to get

Error: Failed to download metadata for repo 'remi-modular': repomd.xml GPG signature verification error: Bad GPG signature

@matteocorti
Copy link
Owner

matteocorti commented Jan 17, 2022

Running "/usr/bin/dnf check-update --assumeno --errorlevel=0 -q  2>&1"
Importing GPG key 0x5F11735A:
Userid     : "Remi's RPM repository <remi@remirepo.net>"
Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Error: Failed to download metadata for repo 'remi-modular': repomd.xml GPG signature verification error: Bad GPG signature

@matteocorti
Copy link
Owner

As I really did not find out why the import has to be repeated when running with nrpe with this repository I added (fd4aa38
) an option --assumeyes to allow the import of the GPG key while running the plugin.

@tilghman
Copy link
Contributor

Possibly part of the problem is that when NRPE runs, because it runs as a daemon, the environment is empty, so PATH and HOME in particular are missing. This affects the use of the 'which' command line (i.e. get_path()), which won't find commands, and GPG won't find keys. Given that daemons are supposed to run without environment variables, it seems like either we simply can't run check_updates at all through NRPE, or we need a backup plan to set those environment variables if they're missing, and we expect there to be some.

I'm having the current problem of check_updates being unable to find dnf or yum due to this difference. (Replicate on command line by prefixing your invocation with "env -i".)

@xxedgexx
Copy link
Author

xxedgexx commented Jan 21, 2022

NRPE config:

command[check_updates]=/usr/lib64/nagios/plugins/check_updates -t 60 --assumeyes

On the Nagios server:

/usr/lib64/nagios/plugins/check_nrpe -t 60 -H mx1 --key-file=/etc/nagios/ssl/mon.key --client-cert=/etc/nagios/ssl/mon.cer --ca-cert-file=/etc/pki/tls/certs/chain.pem -c check_updates
CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually

On the client side:

[1642759033] CONN_CHECK_PEER: checking if host is allowed: 192.168.30.76 port 30914
[1642759033] Connection from 192.168.30.76 port 30914
[1642759033] is_an_allowed_host (AF_INET): is host >192.168.30.76< an allowed host >192.168.30.76<
[1642759033] is_an_allowed_host (AF_INET): host is in allowed host list!
[1642759033] Host address is in allowed_hosts
[1642759033] Host 192.168.30.76 is asking for command 'check_updates' to be run...
[1642759033] Running command: /usr/lib64/nagios/plugins/check_updates -t 60 --assumeyes
[1642759033] WARNING: my_system() seteuid(0): Operation not permitted
[1642759035] Command completed with return code 2 and output:
[1642759035] Return Code: 3, Output: NRPE: Command timed out after 60 seconds
[1642759035] Connection from 192.168.30.76 closed.
[1642759050] Command completed with return code 3 and output: CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
[1642759050] Return Code: 3, Output: CHECK_UPDATES UNKNOWN - Missing GPG key, run "dnf check-update" manually
[1642759050] Connection from 192.168.30.76 closed.

@xxedgexx
Copy link
Author

The only way I could get it to work is to run the command under sudo:

command[check_updates]=sudo /usr/lib64/nagios/plugins/check_updates -t 60 --assumeyes

Not ideal but maybe this lends to what the issue could be running it as the nrpe user?

@matteocorti matteocorti reopened this Jan 21, 2022
@matteocorti
Copy link
Owner

matteocorti commented Jan 21, 2022

Possibly part of the problem is that when NRPE runs, because it runs as a daemon, the environment is empty, so PATH and HOME in particular are missing. This affects the use of the 'which' command line (i.e. get_path()), which won't find commands, and GPG won't find keys. Given that daemons are supposed to run without environment variables, it seems like either we simply can't run check_updates at all through NRPE, or we need a backup plan to set those environment variables if they're missing, and we expect there to be some.

I'm having the current problem of check_updates being unable to find dnf or yum due to this difference. (Replicate on command line by prefixing your invocation with "env -i".)

I applied your patch, but this is most likely not the problem. When the script is executed with NRPE the PATH is not empty (at least in my case it is /usr/bin:/bin:/usr/sbin:/sbin)

HOME is set to /var/run/nrpe

@tilghman
Copy link
Contributor

I'm running RHEL 8, and the PATH is blank (RPM version 4.0.3 - nrpe-4.0.3-6.el8.x86_64)

@tilghman
Copy link
Contributor

The only way I could get it to work is to run the command under sudo:

command[check_updates]=sudo /usr/lib64/nagios/plugins/check_updates -t 60 --assumeyes

Not ideal but maybe this lends to what the issue could be running it as the nrpe user?

I'd recommend setting your timeout (both in nrpe.cfg and in the nagios client) to 120 or 150. That first time through can take quite a bit of time. Subsequent invocations are nicely quick. Also, make sure that your SElinux is either off or the context for the check_updates command is set to 'unconfined_u:object_r:nagios_unconfined_plugin_exec_t:s0' (the default on RHEL 8).

@matteocorti
Copy link
Owner

The only way I could get it to work is to run the command under sudo:
command[check_updates]=sudo /usr/lib64/nagios/plugins/check_updates -t 60 --assumeyes
Not ideal but maybe this lends to what the issue could be running it as the nrpe user?

I'd recommend setting your timeout (both in nrpe.cfg and in the nagios client) to 120 or 150. That first time through can take quite a bit of time. Subsequent invocations are nicely quick. Also, make sure that your SElinux is either off or the context for the check_updates command is set to 'unconfined_u:object_r:nagios_unconfined_plugin_exec_t:s0' (the default on RHEL 8).

Yes I implemented the standard 15s recommended as default for Nagios plugins. For check_updates it's too low.

@matteocorti
Copy link
Owner

Mmm I am on CentOS 8 ... I will try to get a RHEL 8 machine to test

@tilghman
Copy link
Contributor

Mmm I am on CentOS 8 ... I will try to get a RHEL 8 machine to test

Yes, unfortunately, Red Hat dropped continuing support for CentOS 8 at the end of 2021, which is why I've been working on getting this to work on RHEL 8 (Developer license).

@xxedgexx
Copy link
Author

xxedgexx commented Jan 22, 2022 via email

@matteocorti
Copy link
Owner

I am not sure if the issue should be followed up as nrpe is now deprecated (https://github.com/NagiosEnterprises/nrpe)

@xxedgexx
Copy link
Author

Initial tests with ncpa give me good results. I didn't have to do anything special outside of making the check_updates command available in NCPA's plugins directory. Still playing around but I get out of date package results.

@matteocorti
Copy link
Owner

No feedback. NRPE is deprecated.

@creshal
Copy link

creshal commented Apr 2, 2024

We see the same problem when running checks over SSH with Icinga, and generally when running the script under a separate user that isn't root (sudo -u icinga ./check_updates breaks too): If the cache is fresh, it works, but if yum decides it needs a cache update, it fails, as it wants to import keys (even though they're imported when running as root) but doesn't have write permissions.

@tilghman
Copy link
Contributor

tilghman commented Apr 2, 2024

The command needs --nogpgcheck added to the arguments. Once that's there, the command runs correctly and detects when new packages need to be installed, per the intended functionality.

@creshal
Copy link

creshal commented Apr 2, 2024

But then I can't check for real GPG key problems when a repository owner actually rotates a key. Broken GPG handling can't be intended behaviour.

@tilghman
Copy link
Contributor

tilghman commented Apr 2, 2024

Why does a changed key matter to you, unless there are packages to be updated? When there are new packages, it alerts you to the fact, and you'll see the GPG key conflict when you login to the affected machine and run the update command.

This is a check update command, not a run update command.

@creshal
Copy link

creshal commented Apr 2, 2024

It's a check update command that cannot properly check for authentic updates if it can't properly handle GPG keys. Why would I ever want to voluntarily disable that security check, even if it's "just" to check updates? If you disregard security that much I'll just replace your plugin with something safer.

@tilghman
Copy link
Contributor

tilghman commented Apr 2, 2024

Sure, go ahead, replace my plugin. I won't hold my breath.

@matteocorti
Copy link
Owner

We could compromise and add a command line option like --ignore-gpg-issues. The plugin would per default complain if there is a problem, but could be used with nrpr adding the optional parameter ...

@matteocorti matteocorti reopened this Apr 3, 2024
@tilghman
Copy link
Contributor

tilghman commented Apr 3, 2024

That works for me

@matteocorti
Copy link
Owner

I just remembered that YUM or DNF arguments can be specified with the --yum-arguments option.

The workaround would then be:

$ check_updates --yum-arguments='--nogpgcheck'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug need more info Not enough information to reproduce or analyse the problem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants