summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/udev/files/network.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/udev/files/network.sh')
-rw-r--r--meta/recipes-core/udev/files/network.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/meta/recipes-core/udev/files/network.sh b/meta/recipes-core/udev/files/network.sh
new file mode 100644
index 0000000000..5016328df4
--- /dev/null
+++ b/meta/recipes-core/udev/files/network.sh
@@ -0,0 +1,55 @@
1#!/bin/sh
2
3# Do not run when pcmcia-cs is installed
4test -x /sbin/cardctl && exit 0
5
6# We get two "add" events for hostap cards due to wifi0
7echo "$INTERFACE" | grep -q wifi && exit 0
8
9
10# Check if /etc/init.d/network has been run yet to see if we are
11# called by starting /etc/rcS.d/S03udev and not by hotplugging a device
12#
13# At this stage, network interfaces should not be brought up
14# automatically because:
15# a) /etc/init.d/network has not been run yet (security issue)
16# b) /var has not been populated yet so /etc/resolv,conf points to
17# oblivion, making the network unusable
18#
19
20spoofp="`grep ^spoofprotect /etc/network/options`"
21if test -z "$spoofp"
22then
23 # This is the default from /etc/init.d/network
24 spoofp_val=yes
25else
26 spoofp_val=${spoofp#spoofprotect=}
27fi
28
29test "$spoofp_val" = yes && spoofp_val=1 || spoofp_val=0
30
31# I think it is safe to assume that "lo" will always be there ;)
32if test "`cat /proc/sys/net/ipv4/conf/lo/rp_filter`" != "$spoofp_val" -a -n "$spoofp_val"
33then
34 echo "$INTERFACE" >> /dev/udev_network_queue
35 exit 0
36fi
37
38#
39# Code taken from pcmcia-cs:/etc/pcmcia/network
40#
41
42# if this interface has an entry in /etc/network/interfaces, let ifupdown
43# handle it
44if grep -q "iface \+$INTERFACE" /etc/network/interfaces; then
45 case $ACTION in
46 add)
47 ifconfig | grep -q "^$INTERFACE" || ifup $INTERFACE
48 ;;
49 remove)
50 ifdown $INTERFACE
51 ;;
52 esac
53
54 exit 0
55fi