diff --git a/wicd/networking.py b/wicd/networking.py index 1269e5c..a7c9caa 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -22,6 +22,7 @@ class WiredConnectThread() -- Connection thread for wired # Copyright (C) 2007 - 2009 Adam Blackburn # Copyright (C) 2007 - 2009 Dan O'Reilly # Copyright (C) 2007 - 2009 Byron Hillis +# Copyright (C) 2009 Andrew Psaltis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as @@ -281,7 +282,8 @@ class ConnectThread(threading.Thread): def __init__(self, network, interface_name, before_script, after_script, pre_disconnect_script, post_disconnect_script, gdns1, - gdns2, gdns3, gdns_dom, gsearch_dom, iface, debug): + gdns2, gdns3, gdns_dom, gsearch_dom, iface, + debug): """ Initialise the required object variables and the thread. Keyword arguments: @@ -316,7 +318,7 @@ class ConnectThread(threading.Thread): self.global_dns_3 = gdns3 self.global_dns_dom = gdns_dom self.global_search_dom = gsearch_dom - + self.iface = iface self.connecting_message = None @@ -436,8 +438,8 @@ class ConnectThread(threading.Thread): else: # Run dhcp... self.SetStatus('running_dhcp') - print "Running DHCP" - dhcp_status = iface.StartDHCP() + print "Running DHCP with hostname",self.network["dhcphostname"] + dhcp_status = iface.StartDHCP(self.network["dhcphostname"]) if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']: if self.connect_result != "aborted": self.abort_connection(dhcp_status) @@ -1028,7 +1030,8 @@ class WiredConnectThread(ConnectThread): ConnectThread.__init__(self, network, wired, before_script, after_script, pre_disconnect_script, post_disconnect_script, gdns1, gdns2, - gdns3, gdns_dom, gsearch_dom, liface, debug) + gdns3, gdns_dom, gsearch_dom, liface, + debug) def _connect(self): """ The main function of the connection thread. diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 3cd7bb4..a5bbba9 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -18,6 +18,7 @@ class WirelessDaemon() -- DBus interface to managed the wireless network. # Copyright (C) 2007 - 2009 Adam Blackburn # Copyright (C) 2007 - 2009 Dan O'Reilly # Copyright (C) 2007 - 2009 Byron Hillis +# Copyright (C) 2009 Andrew Psaltis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as @@ -1457,6 +1458,7 @@ class WiredDaemon(dbus.service.Object): "postdisconnectscript"]: self.config.set(profilename, option, None) self.config.set(profilename, "default", default) + self.config.set(profilename,"dhcphostname",os.uname()[1]) self.config.write() return True diff --git a/wicd/wnettools.py b/wicd/wnettools.py index b088049..c4e63f4 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -16,6 +16,7 @@ class BaseWirelessInterface() -- Control a wireless network interface. # Copyright (C) 2007 - 2009 Adam Blackburn # Copyright (C) 2007 - 2009 Dan O'Reilly # Copyright (C) 2007 - 2009 Byron Hillis +# Copyright (C) 2009 Andrew Psaltis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as @@ -230,7 +231,7 @@ class BaseInterface(object): return path - def _get_dhcp_command(self, flavor=None): + def _get_dhcp_command(self, flavor=None, hostname=None): """ Returns the correct DHCP client command. Given a type of DHCP request (create or release a lease), @@ -266,17 +267,17 @@ class BaseInterface(object): 'id' : misc.DHCLIENT, }, "pump" : - { 'connect' : r"%(cmd)s -i %(iface)s", + { 'connect' : r"%(cmd)s -h '%(hostname)s' -i %(iface)s", 'release' : r"%(cmd)s -r -i %(iface)s", 'id' : misc.PUMP, }, "dhcpcd" : - {'connect' : r"%(cmd)s %(iface)s", + {'connect' : r"%(cmd)s -h '%(hostname)s' %(iface)s ", 'release' : r"%(cmd)s -k %(iface)s", 'id' : misc.DHCPCD, }, "udhcpc": - {'connect' : r"%(cmd)s -n -i %(iface)s", + {'connect' : r"%(cmd)s -H '%(hostname)s' -n -i %(iface)s", 'release' : r"killall -SIGUSR2 %(cmd)s", 'id' : misc.UDHCPC, }, @@ -287,7 +288,7 @@ class BaseInterface(object): return "" if flavor == "connect": - return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface} + return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface, "hostname":hostname} elif flavor == "release": return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface} else: @@ -538,7 +539,7 @@ class BaseInterface(object): return 'dhcp_failed' @neediface(False) - def StartDHCP(self): + def StartDHCP(self,hostname): """ Start the DHCP client to obtain an IP address. Returns: @@ -546,7 +547,7 @@ class BaseInterface(object): _check_dhcp_result for the possible values. """ - cmd = self._get_dhcp_command('connect') + cmd = self._get_dhcp_command('connect',hostname) if self.verbose: print cmd self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True) pipe = self.dhcp_object.stdout