From 1ae65419448153a611e5804e539d8d127788a513 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 17 Oct 2015 18:09:50 +0100 Subject: vyatta-cfg-system: add listen-address and port checks for telnet Check that both the listen-address is a valid local address and that the port given is available for use before commiting the telnet service configuation. Bug #43 http://bugzilla.vyos.net/show_bug.cgi?id=43 --- templates/service/telnet/listen-address/node.def | 3 +++ templates/service/telnet/port/node.def | 2 ++ 2 files changed, 5 insertions(+) (limited to 'templates/service') diff --git a/templates/service/telnet/listen-address/node.def b/templates/service/telnet/listen-address/node.def index 9faea595..cd016628 100644 --- a/templates/service/telnet/listen-address/node.def +++ b/templates/service/telnet/listen-address/node.def @@ -2,3 +2,6 @@ type: ipv4,ipv6 help: Local addresses telnet should listen on val_help: ipv4: IP address to listen for incoming connections val_help: ipv6: IPv6 address to listen for incoming connections + +commit:expression: exec "/opt/vyatta/sbin/local_ip $VAR(@)"; \ + "IP address $VAR(@) doesn\'t exist on this system" diff --git a/templates/service/telnet/port/node.def b/templates/service/telnet/port/node.def index b15d4b6a..c4db688a 100644 --- a/templates/service/telnet/port/node.def +++ b/templates/service/telnet/port/node.def @@ -5,3 +5,5 @@ help: Port for TELNET service val_help: u32:1-65535; Numeric IP port syntax:expression: $VAR(@) > 0 && $VAR(@) <= 65535 ; \ "Port number must be in range 1 to 65535" +commit:expression: exec "sudo /opt/vyatta/sbin/is_port_available.pl $VAR(@)"; \ + "Port $VAR(@) is already in use!" -- cgit v1.2.3