summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-10-15 21:09:35 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-10-15 21:09:35 -0700
commit4298b55e563520b04b5c06eb426a2b4cbf8229a7 (patch)
tree9a59e4e0ef51ccb0b69259cfb9d6f18ad518d87e
parent72c0e938c3ce7eaf02a4d1a324be81500762f557 (diff)
downloadvyatta-cfg-4298b55e563520b04b5c06eb426a2b4cbf8229a7.tar.gz
vyatta-cfg-4298b55e563520b04b5c06eb426a2b4cbf8229a7.zip
enforce syntax restrictions on ethernet device names
Only allow devices name ethXXX and check that device exists Bugfix 3495
-rw-r--r--templates/interfaces/ethernet/node.def17
1 files changed, 9 insertions, 8 deletions
diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def
index ba15828..3023a70 100644
--- a/templates/interfaces/ethernet/node.def
+++ b/templates/interfaces/ethernet/node.def
@@ -1,19 +1,20 @@
tag:
type: txt
help: Set ethernet interface
+syntax:expression: pattern $VAR(@) "^eth[0-9]+$" \
+ ; "interface must be (eth0 - eth999)"
syntax:expression: exec " \
- if [ -z \"`ip link | grep eth | egrep -v 'eth[0-9]+[.]' | grep $VAR(@)`\" ]; then \
- echo Invalid ethernet interface [$VAR(@)]; \
- exit 1 ; \
- fi ; "
+ if [ -f /sys/class/net/$VAR(@) ]; then \
+ echo \"Ethernet interface does not exist: $VAR(@)\"; \
+ exit 1; \
+ fi"
+
update: sudo ip link set "$VAR(@)" up
vyatta-vtysh -c "configure terminal" \
-c "interface $VAR(@)" -c "link-detect"
delete: sudo ip link set "$VAR(@)" down
-allowed: for dev in /sys/class/net/*;
+allowed: for dev in /sys/class/net/eth*;
do if [[ -d $dev && -L $dev/device ]]
- then if [[ $(cat $dev/type) -eq 1 ]]
- then echo -n ${dev##*/} " "
- fi
+ then echo -n ${dev##*/} " "
fi
done