summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-04-09 13:33:34 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2012-04-09 13:33:34 +0200
commite4cbb65924b7ad4f3c2a89a53a59dcda8257a29e (patch)
tree4c3c26ecba7aa72063c1587c10dba611d92b7ae1
parentc6ad0bd1294bddb78d1b47e48e8ce7657f91e1df (diff)
downloadnetctl-e4cbb65924b7ad4f3c2a89a53a59dcda8257a29e.tar.gz
netctl-e4cbb65924b7ad4f3c2a89a53a59dcda8257a29e.tar.xz
Remove wireless-dbus and ethernet-iproute support
- wireless-dbus is not simple enough for netcfg - some contributed code was not used and the rest of the code had caught up functionality wise - we switched to iproute so we need to stop pretending it is an 'option' - it is no longer fatal in the ifplugd scrict to have multiple preferred profiles
-rw-r--r--Makefile9
-rw-r--r--scripts/ifplugd.action21
-rw-r--r--src-wireless/net-auto51
-rw-r--r--src-wireless/netcfg-auto-wireless91
-rw-r--r--src-wireless/wireless-dbus213
5 files changed, 8 insertions, 377 deletions
diff --git a/Makefile b/Makefile
index 4ec4cb9..558ca3e 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,6 @@ install: install-docs
install -d $(DESTDIR)/usr/lib/network/{connections,hooks}
install -m644 src/{network,rfkill,8021x,globals} $(DESTDIR)/usr/lib/network/
install -m755 src/connections/* $(DESTDIR)/usr/lib/network/connections/
- -ln -s wireless $(DESTDIR)/usr/lib/network/connections/wireless-dbus
- -ln -s ethernet $(DESTDIR)/usr/lib/network/connections/ethernet-iproute
# Hooks
install -m755 src/hooks/* ${DESTDIR}/usr/lib/network/hooks/
# Scripts
@@ -41,13 +39,6 @@ install: install-docs
systemd/net-auto-wired.service \
$(DESTDIR)/lib/systemd/system/
-install-wireless:
- install -d $(DESTDIR)/usr/lib/network/connections $(DESTDIR)/usr/bin \
- $(DESTDIR)/etc/rc.d
- install -m755 src-wireless/wireless-dbus $(DESTDIR)/usr/lib/network/connections/
- install -m755 src-wireless/netcfg-auto-wireless $(DESTDIR)/usr/bin/
- install -m755 src-wireless/net-auto $(DESTDIR)/etc/rc.d/
-
install-docs: docs
install -d $(DESTDIR)/usr/share/man/man5
install -m644 docs/*.5 $(DESTDIR)/usr/share/man/man5/
diff --git a/scripts/ifplugd.action b/scripts/ifplugd.action
index 573131d..ea3a16c 100644
--- a/scripts/ifplugd.action
+++ b/scripts/ifplugd.action
@@ -2,10 +2,7 @@
#
# ifplugd.action script for netcfg
-. /etc/rc.conf
-. /etc/rc.d/functions
. /usr/lib/network/network
-shopt -s extglob
case "$2" in
up)
@@ -17,11 +14,11 @@ case "$2" in
declare -a preferred_profiles
declare -a dhcp_profiles
declare -a static_profiles
- for profile in $(list_profiles); do (
- load_profile "$profile"
+ for profile in $(list_profiles); do
+ (
echo "loading $profile"
- [[ "$INTERFACE" != "$1" ]] && continue
- [[ "$CONNECTION" != @(ethernet|ethernet-iproute) ]] && continue
+ load_profile "$profile"
+ [[ "$INTERFACE" == "$1" && "$CONNECTION" == "ethernet" ]] || continue
checkyesno "${AUTO_WIRED:-no}" && exit 1 # user preferred AUTO profile
[[ "$IP" == "dhcp" ]] && exit 2 # dhcp profile
exit 3 # static profile
@@ -34,16 +31,14 @@ case "$2" in
done
if [[ ${#preferred_profiles[@]} > 1 ]]; then
echo "AUTO_WIRED flag for $1 set in more than one profile (${preferred_profiles[*]})"
- else
- for profile in "${preferred_profiles[@]}" "${dhcp_profiles[@]}" "${static_profiles[@]}"; do (
- netcfg "$profile" && exit 1
- exit 0
- ) || exit 0; done
fi
+ for profile in "${preferred_profiles[@]}" "${dhcp_profiles[@]}" "${static_profiles[@]}"; do
+ profile_up "$profile" && exit 0
+ done
;;
down)
if check_iface "$1"; then
- netcfg -i "$1" && exit 0
+ interface_down "$1" && exit 0
fi
;;
*)
diff --git a/src-wireless/net-auto b/src-wireless/net-auto
deleted file mode 100644
index 5f972c3..0000000
--- a/src-wireless/net-auto
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-. /usr/lib/network/globals
-
-case "$1" in
- start)
- if ! ck_daemon net-auto; then # JP: check if it's already running
- exit_stderr "net-auto has already been started: try \"/etc/rc.d/net-auto restart\""
- fi
- # Ensure any device renaming has occurred as intended
- for daemon in "${DAEMONS[@]}"; do
- if [[ "$daemon" = "net-rename" ]]; then
- if ck_daemon net-rename; then
- /etc/rc.d/net-rename start
- fi
- fi
- done
-
- # TODO: check if any way of using 'stacks' in bash
- rm -f "$STATE_DIR/net-auto"
- for iface in "${AUTO_NETWORKS[@]}"; do
- if [[ "${iface:0:4}" = "auto" ]]; then
- auto="$iface"
- elif [[ -n "$auto" ]]; then
- if /usr/bin/netcfg-"$auto" "$iface"; then
- echo "$iface" >> "$STATE_DIR/net-auto"
- add_daemon net-auto # JP: was this forgotten?
- fi
- unset auto
- fi
- done
- ;;
- stop)
- if ck_daemon net-auto; then
- exit_stderr "net-auto not running"
- fi
-
- while read iface; do
- /usr/bin/netcfg2 iface-down "$iface"
- done < "$STATE_DIR/net-auto"
- rm -f "$STATE_DIR/net-auto"
- rm_daemon net-auto
- ;;
- restart)
- "$0" stop; sleep 1; "$0" start
- ;;
- *)
- exit_stderr "Usage: $0 {start|stop|restart}"
-esac
-
-# vim: ft=sh ts=4 et sw=4:
diff --git a/src-wireless/netcfg-auto-wireless b/src-wireless/netcfg-auto-wireless
deleted file mode 100644
index e541155..0000000
--- a/src-wireless/netcfg-auto-wireless
+++ /dev/null
@@ -1,91 +0,0 @@
-#! /bin/bash
-# Originally contributed by Neuro: http://bbs.archlinux.org/viewtopic.php?pid=278148#p278148
-
-. /usr/lib/network/network
-. "$SUBR_DIR/rfkill"
-. "$SUBR_DIR/8021x"
-. /etc/conf.d/netcfg
-
-# wifi_auto
-# autoconnect wireless interface
-# $1 - wireless interface
-wifi_auto()
-{
- local interface="$1"
- report_try "Scanning for networks"
- [[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface"
-
- if [[ -n "$RFKILL" ]]; then
- set_rf_state "$interface" up || exit $?
- fi
-
- bring_interface up "$interface" # uses iproute methods - is there an option to use ifconfig?
- networks=$(list_networks "$interface")
-
- if [[ -z "$networks" ]]; then
- bring_interface forcedown "$interface"
- exit_fail "- No networks available."
- fi
-
- # Loop through all the found essid's, then find a matching profile.
-
- local found_profile
-
- [[ "$AUTO_PROFILES" ]] || AUTO_PROFILES=$(list_profiles)
-
- # JP: add ability to use AP instead of ESSID
- while read ap essid; do
- echo $AUTO_PROFILES | while read network; do
- (
- unset CONNECTION INTERFACE AP ESSID
- load_profile "$network"
- case "$CONNECTION" in
- wireless-old|wireless|wireless-dbus)
- if [[ "$interface" = "$INTERFACE" ]]; then
- if [[ "$ap" == "$AP" ]]; then
- exit 2
- elif [[ -z "$found_profile" ]]; then
- if [[ "$essid" == "$ESSID" ]]; then
- exit 1
- fi
- fi
- fi
- ;;
- esac
- exit 0
- )
- case $? in
- 2) found_profile="$network"
- break 2
- ;;
- 1) found_profile="$network"
- ;;
- esac
- done
- done < "$networks" # avoid subshell; list_networks returns name of a tmp file
- rm -f "$networks" # shouldn't we delete the tmp file?
-
- if [[ -n "$found_profile" ]]; then
- report_success
- if profile_up "$found_profile"; then
- exit 0
- else
- bring_interface forcedown "$interface"
- exit_fail "Couldn't connect profile $found_profile."
- fi
- else
- bring_interface forcedown "$interface"
- exit_fail "No profiles matched the local networks."
- fi
-
-}
-
-if [[ $(id -u) -ne 0 ]]; then
- exit_stderr "This script needs to be run with root privileges"
-fi
-if [[ -z "$1" ]]; then
- exit_stderr "Please supply an interface to connect"
-fi
-wifi_auto "$1"
-
-# vim: ft=sh ts=4 et sw=4:
diff --git a/src-wireless/wireless-dbus b/src-wireless/wireless-dbus
deleted file mode 100644
index f48ed52..0000000
--- a/src-wireless/wireless-dbus
+++ /dev/null
@@ -1,213 +0,0 @@
-#! /usr/bin/env python
-import sys
-import dbus
-import shlex
-import subprocess
-from signal import SIGTERM
-import os
-from time import sleep
-
-# dbus constants.
-WPAS_DBUS_SERVICE = "fi.epitest.hostap.WPASupplicant"
-WPAS_DBUS_INTERFACE = "fi.epitest.hostap.WPASupplicant"
-WPAS_DBUS_OPATH = "/fi/epitest/hostap/WPASupplicant"
-
-WPAS_DBUS_INTERFACES_INTERFACE = "fi.epitest.hostap.WPASupplicant.Interface"
-WPAS_DBUS_INTERFACES_OPATH = "/fi/epitest/hostap/WPASupplicant/Interfaces"
-WPAS_DBUS_BSSID_INTERFACE = "fi.epitest.hostap.WPASupplicant.BSSID"
-WPAS_DBUS_NETWORKS_INTERFACE = "fi.epitest.hostap.WPASupplicant.Network"
-
-def read_config(config):
- cfg = shlex.split(open(config, "r").read())
- options = {}
- for line in cfg:
- (var, delim, value) = line.partition('=')
- if delim:
- var = var.lstrip() # JP: allow assignments to be indented, as they can be when sourced
- if var[0] != '#':
- value = value.partition("#")[0].rstrip() # JP: strip off comments and trailing whitespace
- if value[0] == value[-1] and value[0] in ('"',"'"): # JP: strip any surrounding quotes
- value=value[1:-1]
- options[var] = value
- return options
-
-
-def wep_hex2dec(key):
- if len(key) not in [10, 26]:
- fail("Bad key", report_type="err")
-
- x=0
- new_key=[]
- while x<len(key):
- new_key.append(int(key[x:x+2],16))
- x+=2
-
- return new_key
-
-# JP: connect to our hookable reporting functions in /usr/lib/network/globals
-
-def report(report_type, *args):
- report_handler.stdin.write('report_%s %s\n' % (report_type, ' '.join(map(repr,args))))
-
-def fail(msg=None, report_type="fail"):
- if msg:
- report(report_type, msg)
- try:
- pid = open("/run/wpa_supplicant.pid").read()
- except IOError:
- pass
- else:
- os.kill(int(pid),SIGTERM)
- sys.exit(1)
-
-
-def start(profile, essid):
- # TODO: Add check if it's even a wireless interface
- # Interface up - probably redundant, should be 'ip' instead.
- #try:
- # subprocess.check_call(["ifconfig", profile['INTERFACE'], "up"])
- #except subprocess.CalledProcessError:
- # print " - Could not bring interface up"
- # return False
-
- # Base arguments
- args=["wpa_supplicant", "-Bu", "-P/run/wpa_supplicant.pid"]
-
- try:
- args.append(profile['WPA_OPTS'])
- except KeyError:
- args.append("-Dwext")
-
- if profile['SECURITY'] == "wpa-config":
- try:
- args.append("-c" + profile["WPA_CONF"])
- except KeyError:
- args.append("-c/etc/wpa_supplicant.conf")
- elif not profile['SECURITY'] in ['wpa', 'wep', 'none']:
- fail("Invalid security chosen", report_type="err")
-
- # Start wpa_supplicant
- report('debug', 'wireless_dbus', 'starting wpa_supplicant')
- supplicant = subprocess.Popen(args,stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
- output = supplicant.communicate()[0]
- if supplicant.returncode not in [255,0]:
- print >>sys.stderr, output # JP: print to stderr
- fail("Could not start wpa_supplicant")
-
- # Connect to wpa_supplicant
- report('debug', 'wireless_dbus', 'connecting to wpa_supplicant')
- bus = dbus.SystemBus()
- wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
- wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
-
- # Add/Get interface path
- try:
- driver=profile["WPA_DRIVER"]
- except KeyError:
- driver="wext"
-
- try:
- path = wpas.getInterface(profile["INTERFACE"])
- except dbus.exceptions.DBusException:
- path = wpas.addInterface(profile["INTERFACE"], {"driver":dbus.String(driver,variant_level=1)})
-
- # Get interface object
- if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
- iface = dbus.Interface(if_obj, WPAS_DBUS_INTERFACES_INTERFACE);
-
- # Add and select the network. Networks already specified for wpa-config
- if profile['SECURITY'] in ['wpa','wep','none']:
- report('debug', 'wireless_dbus', 'add and select network')
-
- path = iface.addNetwork()
- net_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
- rnet = dbus.Interface(net_obj, WPAS_DBUS_NETWORKS_INTERFACE)
- iface.selectNetwork(rnet)
-
- if not essid:
- essid = profile["ESSID"]
-
- if profile['SECURITY'] == "wpa":
- opts = dbus.Dictionary({"ssid": dbus.ByteArray(essid),
- "psk": dbus.String(profile['KEY'])},
- signature="sv")
- report('debug', 'wireless_dbus', 'connect to network with security=wpa')
- rnet.set(opts)
- elif profile['SECURITY'] == "wep":
- key=profile['KEY']
- if key[:2] == "s:": # String key prefixed by "s:"
- keydbus=key[2:]
- else: # Hex key
- key=wep_hex2dec(key)
- keydbus = dbus.ByteArray()
- for l in key:
- keydbus+=chr(l)
-
- opts = dbus.Dictionary({"ssid": dbus.ByteArray(essid),
- "key_mgmt": dbus.String("NONE"),
- "wep_tx_keyidx": dbus.Int32(1),
- "wep_key0": dbus.ByteArray(keydbus)},
- signature="sv")
- report('debug', 'wireless_dbus', 'connect to network with security=wep')
- rnet.set(opts)
- elif profile['SECURITY'] == "none":
- opts = dbus.Dictionary({"ssid": dbus.ByteArray(essid)},
- signature="sv")
- report('debug', 'wireless_dbus', 'connect to network with security=none')
- rnet.set(opts)
-
- # Determine timeout
- try:
- timeout = int(profile["TIMEOUT"])
- except KeyError:
- timeout = 15
-
- # Check for association
- n=0
- while n <= timeout:
- n+=1
- sleep(1)
- state = iface.state()
- if state == "COMPLETED":
- break
-
- if n == timeout:
- fail("Association/Authentication failed:" + state)
-
- # Run ethernet and get an ip.
- try:
- subprocess.check_call([ETHERNET_IPROUTE, "up", sys.argv[2]])
- except subprocess.CalledProcessError:
- fail()
- sys.exit(0)
-
-def stop(profile):
- ret = subprocess.call([ETHERNET_IPROUTE, "down", sys.argv[2]])
- os.kill(int(open("/run/wpa_supplicant.pid").read()),SIGTERM)
- sys.exit(ret)
-
-if __name__ == "__main__":
-
- CONN_DIR = os.path.abspath(os.path.dirname(sys.argv[0]))
- ETHERNET_IPROUTE = os.path.join(CONN_DIR,"ethernet-iproute")
- WIRELESS = os.path.join(CONN_DIR,"wireless")
-
- # setup bash report_* handler
- report_handler_script = 'source %s/../globals; while read cmd args; do eval $cmd "$args"; done' % (CONN_DIR,)
- report_handler = subprocess.Popen(report_handler_script, executable='/bin/bash', stdin=subprocess.PIPE, shell=True)
-
- try:
- profile_name = sys.argv[2]
- profile = read_config("/etc/network.d/"+profile_name)
-
- essid = sys.argv[3] if len(sys.argv)>3 else "" # JP: pass literal ESSID as an argument, so that we can have entry in profile be a regexp
- if sys.argv[1] == "up":
- start(profile, essid)
- elif sys.argv[1] == "down":
- stop(profile)
-
- finally:
- report_handler.stdin.close()
- report_handler.wait()
-
-# vim: et ts=4