summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-10-15 21:12:03 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-10-15 21:12:03 -0700
commit41d4dc6644f73b9f3f75103fab03eeb38189265b (patch)
tree4f830f5e8d7e1f6b9d30e13c4a76af7c161a7329 /templates
parent4298b55e563520b04b5c06eb426a2b4cbf8229a7 (diff)
downloadvyatta-cfg-41d4dc6644f73b9f3f75103fab03eeb38189265b.tar.gz
vyatta-cfg-41d4dc6644f73b9f3f75103fab03eeb38189265b.zip
Enforce restrictions on loopback name
Add allowed completion and check type of device.
Diffstat (limited to 'templates')
-rw-r--r--templates/interfaces/loopback/node.def17
1 files changed, 11 insertions, 6 deletions
diff --git a/templates/interfaces/loopback/node.def b/templates/interfaces/loopback/node.def
index 7b7a304..b5235a0 100644
--- a/templates/interfaces/loopback/node.def
+++ b/templates/interfaces/loopback/node.def
@@ -1,9 +1,14 @@
tag:
type: txt
help: Set loopback interface
-syntax:expression: exec " \
- if [ -z \"`ip addr | grep $VAR(@) `\" ]; then \
- echo loopback interface $VAR(@) doesn\\'t exist on this system ; \
- exit 1 ; \
- fi ; "
-update:expression: "sudo ip link set $VAR(@) up"
+allowed: echo "lo"
+syntax:expression: exec "\
+ if [ !-d /sys/class/net/$VAR(@) ]; then \
+ echo \"loopback interface $VAR(@) does not exist\"; \
+ exit 1; \
+ elif [ $(cat /sys/class/net/$VAR(@)/type) -ne 772 ]; then \
+ echo \"interface $VAR(@) is not a loopback interface\"; \
+ exit 1; \
+ fi"
+
+update: sudo ip link set $VAR(@) up