Project

General

Profile

Actions

Bug #12775

closed

NTP service is not listed on ``status_services.php`` unless ``config.xml`` contains NTP configuration data

Added by Jim Pingle almost 3 years ago. Updated almost 3 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Services
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
22.05
Release Notes:
Default
Affected Version:
Affected Architecture:

Description

The NTP service is active by default and is running even on a fresh installation before the user configures NTP, which is expected and correct.

However, status_services.php does not list the ntpd service until the user saves the NTP settings (e.g. Services > NTP , click Save) even if they make no changes. This populates config.xml with an NTP config section which is not present in the default configuration.

The code in get_services() in etc/inc/service-utils.inc checks for the presence of the NTP config which isn't a prerequisite for the service to be active. The check appears to be a safety check to ensure that the actual check for the disabled flag will not cause a PHP error.

This change works around the need for that safety check without adding more potentially confusing logic to the test:

diff --git a/src/etc/inc/service-utils.inc b/src/etc/inc/service-utils.inc
index 35a74f74af..6bc304ba20 100644
--- a/src/etc/inc/service-utils.inc
+++ b/src/etc/inc/service-utils.inc
@@ -279,7 +279,8 @@ function get_services() {
                $services[] = $pconfig;
        }

-       if (is_array($config['ntpd']) && ($config['ntpd']['enable'] != 'disabled')) {
+       init_config_arr(array('ntpd'));
+       if ($config['ntpd']['enable'] != 'disabled') {
                $pconfig = array();
                $pconfig['name'] = "ntpd";
                $pconfig['description'] = gettext("NTP clock sync");
Actions #1

Updated by Jim Pingle almost 3 years ago

  • Status changed from New to Pull Request Review
Actions #2

Updated by Jim Pingle almost 3 years ago

  • Status changed from Pull Request Review to Feedback
  • % Done changed from 0 to 100
Actions #3

Updated by Danilo Zrenjanin almost 3 years ago

  • Status changed from Feedback to Resolved

Tested:

2.7.0-DEVELOPMENT (amd64)
built on Wed Feb 16 06:17:48 UTC 2022
FreeBSD 12.3-STABLE

The NTP service is listed under status_services.php.

I am marking this ticket resolved.

Actions

Also available in: Atom PDF