summaryrefslogtreecommitdiffstats
path: root/src-wireless/wireless-dbus
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-02-17 08:06:05 +0100
committerJames Rayner <james@archlinux.org>2009-02-17 08:06:05 +0100
commitc2838593ab2cc04cb702042066d912f1bcbcc201 (patch)
tree0d16b4d06163315a7fd70989d2c3d2a226e2e80d /src-wireless/wireless-dbus
parent9692fac721339ce22b5b46e382589587e3e01d78 (diff)
downloadnetctl-c2838593ab2cc04cb702042066d912f1bcbcc201.tar.gz
netctl-c2838593ab2cc04cb702042066d912f1bcbcc201.tar.xz
Remove possibly redundant code, add structure to support WEP
Diffstat (limited to 'src-wireless/wireless-dbus')
-rwxr-xr-xsrc-wireless/wireless-dbus40
1 files changed, 23 insertions, 17 deletions
diff --git a/src-wireless/wireless-dbus b/src-wireless/wireless-dbus
index bdbb3fb..2a60fc4 100755
--- a/src-wireless/wireless-dbus
+++ b/src-wireless/wireless-dbus
@@ -28,17 +28,16 @@ def read_config(config):
def start(profile):
# TODO: Add check if it's even a wireless interface
- # Interface up...
- try:
- subprocess.check_call(["ifconfig", profile['INTERFACE'], "up"])
- except CalledProcessError:
- print " - Could not bring interface up"
- return False
-
- # Manually set any iwconfig options, ignoring errors
- if profile.has_key('IWCONFIG'):
- subprocess.call(["iwconfig", profile['INTERFACE'], profile['IWCONFIG']])
+ # 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
+ # Manually set any iwconfig options - redundant, use custom wpa_supplicant config instead.
+ #if profile.has_key('IWCONFIG'):
+ # subprocess.call(["iwconfig", profile['INTERFACE'], profile['IWCONFIG']])
# Base arguments
args=["wpa_supplicant", "-Bu", "-P/var/run/wpa_supplicant.pid"]
@@ -53,7 +52,7 @@ def start(profile):
args.append("-c" + profile["WPA_CONF"])
except KeyError:
args.append("-c/etc/wpa_supplicant.conf")
- elif not profile['SECURITY'] in ['yes', 'wpa', 'wep']:
+ elif not profile['SECURITY'] in ['wpa', 'wep']:
print " - Invalid security chosen"
return False
@@ -86,15 +85,22 @@ def start(profile):
iface = dbus.Interface(if_obj, WPAS_DBUS_INTERFACES_INTERFACE);
# Connect
- if profile['SECURITY'] in ['wpa','yes','wep']:
+
+ if profile['SECURITY'] in ['wpa','wep']:
# Add+select the 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)
- # Set the options
- opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']), "psk": dbus.String(profile['KEY'])}, signature="sv")
- rnet.set(opts)
+
+ if profile['SECURITY'] == "wpa":
+ # Set the options
+ opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']), "psk": dbus.String(profile['KEY'])}, signature="sv")
+ elif profile['SECURITY'] == "wep":
+ opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']), "wpa_key0": dbus.String(profile['KEY'])}, signature="sv")
+
+ rnet.set(opts)
+
# Determine timeout
try:
@@ -117,8 +123,8 @@ def start(profile):
# Run ethernet and get an ip.
try:
- subprocess.check_call(["/usr/lib/network/connections/ethernet", "up", sys.argv[2]])
- except CalledProcessError:
+ subprocess.check_call(["/usr/lib/network/connections/ethernet-iproute", "up", sys.argv[2]])
+ except subprocess.CalledProcessError:
return False
return True