From 770480715b15e1645c98a3eabade878e8f757e74 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 15 Mar 2026 11:06:21 +0100 Subject: [PATCH] Services: Network Time: PPS - remove stale symlink when pps is disabled, closes https://github.com/opnsense/core/pull/9969 --- src/etc/inc/plugins.inc.d/ntpd.inc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/ntpd.inc b/src/etc/inc/plugins.inc.d/ntpd.inc index d2a03374d9..f696b613b6 100644 --- a/src/etc/inc/plugins.inc.d/ntpd.inc +++ b/src/etc/inc/plugins.inc.d/ntpd.inc @@ -152,17 +152,17 @@ function ntpd_configure_gps($serialport) return true; } -function ntpd_configure_pps($serialport) +function ntpd_configure_pps($port) { $pps_device = '/dev/pps0'; - $serialport = "/dev/{$serialport}"; + $serialport = "/dev/{$port}"; - if (!file_exists($serialport)) { + @unlink($pps_device); + if (empty($port)) { + return false + } elseif (!file_exists($serialport)) { return false; } - - // Create symlink that ntpd requires - @unlink($pps_device); @symlink($serialport, $pps_device); return true; @@ -213,11 +213,7 @@ function ntpd_configure_do($verbose = false) $ntpcfg .= "\n"; /* Add PPS configuration */ - if ( - !empty($config['ntpd']['pps']) - && file_exists('/dev/' . $config['ntpd']['pps']['port']) - && ntpd_configure_pps($config['ntpd']['pps']['port']) - ) { + if (!empty($config['ntpd']['pps']) && ntpd_configure_pps($config['ntpd']['pps']['port'])) { $ntpcfg .= "\n"; $ntpcfg .= "# PPS Setup\n"; $ntpcfg .= 'server 127.127.22.0';