Bug 1731468 - check_ntp has too strict regexp for hostnames
Summary: check_ntp has too strict regexp for hostnames
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: nagios-plugins
Version: epel7
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
Assignee: Stephen John Smoogen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-19 13:24 UTC by Kjetil T. Homme
Modified: 2019-09-14 04:05 UTC (History)
7 users (show)

Fixed In Version: nagios-plugins-2.2.1-17.20190829gitfb792ff.fc29 nagios-plugins-2.2.1-17.20190829gitfb792ff.el7 nagios-plugins-2.2.1-17.20190829gitfb792ff.el6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-09-11 21:18:41 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Kjetil T. Homme 2019-07-19 13:24:54 UTC
Description of problem:
The hostname parameter -H is matched against [a-z][a-z0-9]+ for each domain component (actual regexp is a little more complex), so single character domain components fail.

Version-Release number of selected component (if applicable):
nagios-plugins-ntp-2.2.1-16.20180725git3429dad.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. check_ntp -H ntp.i.bitbit.net

Actual results:
you get error message "No target host specified" (very misleading in itself, it should say "Invalid hostname" or similar instead IMHO)

Expected results:
use ntp.i.bitbit.net as reference clock.


Additional info:
bonus issue: the same regexp will also disallow literal IPv6 literal addresses

Comment 1 Kjetil T. Homme 2019-07-19 15:15:28 UTC
another example of a hostname which is disallowed is "0.pool.ntp.org".

here is a suggested regexp which handles the domain names and IPv6 as a bonus (does not accept IPv4-in-IPv6 literals, only pure v6 literals)

my $host = $opt_H if ($opt_H &&
                      ($opt_H =~ m/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ ||      # IPv4
                       $opt_H =~ m/^([0-9a-f]{1,4}:){7}([0-9a-f]{1,4})$/i || # IPv6 without ::
                       $opt_H =~ m/^:(:[0-9a-f]{1,4})+$/i ||                 # IPv6 with leading ::
                       $opt_H =~ m/^([0-9a-f]{1,4}:)+:$/i ||                 # IPv6 with trailing ::
                       $opt_H =~ m/^([0-9a-f]{1,4}:)+(:[0-9a-f]{1,4})+$/i || # IPv6 with middle ::
                       $opt_H =~ m/^[a-z0-9][-a-z0-9]*(\.[a-z0-9][-a-z0-9]*)*$/)); # hostnames

Comment 2 Stephen John Smoogen 2019-07-19 17:16:19 UTC
Thanks for both the bug and the patch. I would ask that you open this upstream, but that was rather 'dead' when I looked earlier this year. However I do recommend it in case it starts up so others can get this fix.

Comment 3 Fedora Update System 2019-08-29 21:51:22 UTC
FEDORA-EPEL-2019-9b63c08c0f has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2019-9b63c08c0f

Comment 4 Fedora Update System 2019-08-29 22:04:16 UTC
FEDORA-EPEL-2019-22c97df420 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2019-22c97df420

Comment 5 Fedora Update System 2019-08-30 16:07:46 UTC
nagios-plugins-2.2.1-17.20190829gitfb792ff.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2019-22c97df420

Comment 6 Fedora Update System 2019-08-30 16:07:49 UTC
nagios-plugins-2.2.1-17.20190829gitfb792ff.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2019-9b63c08c0f

Comment 7 Fedora Update System 2019-09-03 13:46:12 UTC
FEDORA-2019-fef2650216 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-fef2650216

Comment 8 Fedora Update System 2019-09-04 05:02:40 UTC
nagios-plugins-2.2.1-17.20190829gitfb792ff.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-fef2650216

Comment 9 Fedora Update System 2019-09-11 21:18:41 UTC
nagios-plugins-2.2.1-17.20190829gitfb792ff.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2019-09-14 00:40:41 UTC
nagios-plugins-2.2.1-17.20190829gitfb792ff.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2019-09-14 04:05:21 UTC
nagios-plugins-2.2.1-17.20190829gitfb792ff.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.