summaryrefslogtreecommitdiff
path: root/network
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-08-19 13:17:41 -0400
committerDave Reisner <dreisner@archlinux.org>2011-08-19 13:26:06 -0400
commit3ee7b326ad6d60b0d713cfd5c958c18e111b9e28 (patch)
tree2aca8a60448f861618f906e2ced88a87a06ed51b /network
parent7f840b99aa649eb899aa11f5e91e1e81f4f3672a (diff)
network: error out on missing or unknown interface
This was caused by commit fc9ce46483fc4d -- if the user has no interface defined but also has no legacy variables defined, our legacy check fails, and we try to bring up the network using an empty declaration. Add in an additional safeguard of checking sysfs to see that the interface really does exist. Fixes FS#25671 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'network')
-rwxr-xr-xnetwork16
1 files changed, 16 insertions, 0 deletions
diff --git a/network b/network
index 4fafb97..b94d170 100755
--- a/network
+++ b/network
@@ -23,7 +23,21 @@ deprecated() {
printf " connection, or use a utility such as netcfg.\n"
}
+have_interface() {
+ if [[ -z $1 ]]; then
+ printf "\n${C_FAIL}Error:${C_CLEAR} \`interface' is undefined in /etc/rc.conf\n"
+ return 1
+ fi
+
+ if [[ ! -d /sys/class/net/$1 ]]; then
+ printf "\n${C_FAIL}Error:${C_CLEAR} unknown interface in /etc/rc.conf: \`%s'\n" "$1"
+ return 1
+ fi
+}
+
network_up() {
+ have_interface "$interface" || return 1
+
ip link set dev $interface up || return 1
if [[ $address ]]; then
@@ -35,6 +49,8 @@ network_up() {
}
network_down() {
+ have_interface "$interface" || return 1
+
if [[ -f /var/run/dhcpcd-$interface.pid ]]; then
dhcpcd -k $interface || return 1
else