diff --git a/ncm-ntpd/src/main/pan/components/ntpd/schema.pan b/ncm-ntpd/src/main/pan/components/ntpd/schema.pan index 8c898cdaea..7e64689fad 100644 --- a/ncm-ntpd/src/main/pan/components/ntpd/schema.pan +++ b/ncm-ntpd/src/main/pan/components/ntpd/schema.pan @@ -101,7 +101,13 @@ type ntpd_system_options = { } type ntpd_interface_options = { "action" : choice("listen", "ignore", "drop") - "match" : string + "match" : string_trimmed with { + match(SELF, '^(all|ipv4|ipv6|wildcard)$') + || is_ip(SELF) + || is_ipv4_netmask_pair(SELF) + || is_ipv6_network_block(SELF) + || path_exists(format('/system/network/interfaces/%s', SELF)); + } }; # logging configuration @@ -110,15 +116,11 @@ function valid_ntpd_logconfig_list = { foreach (idx; configkeyword; ARGV[0]) { # all keywords can be prefixed with +-= if (!match(configkeyword, '^(\=|\-|\+)\w+')) { - error("invalid logconfig value " - + to_string(ARGV[0]) - + " all configkeywords must precede by +,-, or ="); + error("invalid logconfig value %s all configkeywords must precede by +,-, or =", ARGV[0]); }; configkeyword = substr("configkeyword", 1); if (!match(configkeyword, '^(all)?(clock|peer|sys|sync)?(status|events|statistics)?')) { - error("invalid logconfig value " - + to_string(ARGV[0]) - + " failed to match regex '" + match_logkw + "'"); + error("invalid logconfig value %s failed to match regex '%s'", ARGV[0], match_logkw); }; }; true; diff --git a/ncm-ntpd/src/test/resources/interface.pan b/ncm-ntpd/src/test/resources/interface.pan index 0ff407e628..4daee097e3 100644 --- a/ncm-ntpd/src/test/resources/interface.pan +++ b/ncm-ntpd/src/test/resources/interface.pan @@ -2,6 +2,8 @@ object template interface; include 'only_timeservers_base'; +'/system/network/interfaces/eth0' = dict(); + prefix "/software/components/ntpd"; 'interface' = append(dict('action', 'listen', 'match', 'eth0'));