mirror of
https://github.com/gryf/wicd.git
synced 2026-01-03 20:34:17 +01:00
Change behaviour when dealing with hostnames: don't send any if the user didn't tick the box (previously, the current system name was sent).
This commit is contained in:
@@ -17,6 +17,6 @@
|
|||||||
# configuration, you need to change dhclient.conf.template,
|
# configuration, you need to change dhclient.conf.template,
|
||||||
# NOT dhclient.conf.template.default
|
# NOT dhclient.conf.template.default
|
||||||
|
|
||||||
# wicd will replace $_HOSTNAME in the following line with
|
# wicd will replace the following line with the appropriate
|
||||||
# the appropriate hostname for this system
|
# "send host-name" command, based on what the user chose
|
||||||
send host-name "$_HOSTNAME";
|
# <WICDHOSTNAME>
|
||||||
|
|||||||
@@ -470,11 +470,12 @@ class ConnectThread(threading.Thread):
|
|||||||
self.network['usedhcphostname'] = False
|
self.network['usedhcphostname'] = False
|
||||||
if self.network.get('dhcphostname') == None:
|
if self.network.get('dhcphostname') == None:
|
||||||
self.network['dhcphostname'] = os.uname()[1]
|
self.network['dhcphostname'] = os.uname()[1]
|
||||||
if not self.network['usedhcphostname']:
|
if self.network['usedhcphostname']:
|
||||||
hname = os.uname()[1]
|
|
||||||
else:
|
|
||||||
hname = self.network['dhcphostname']
|
hname = self.network['dhcphostname']
|
||||||
print "Running DHCP with hostname", hname
|
print "Running DHCP with hostname", hname
|
||||||
|
else:
|
||||||
|
hname = None
|
||||||
|
print "Running DHCP with NO hostname"
|
||||||
dhcp_status = iface.StartDHCP(hname)
|
dhcp_status = iface.StartDHCP(hname)
|
||||||
if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']:
|
if dhcp_status in ['no_dhcp_offers', 'dhcp_failed']:
|
||||||
if self.connect_result != "aborted":
|
if self.connect_result != "aborted":
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import time
|
|||||||
from string import maketrans, translate
|
from string import maketrans, translate
|
||||||
import dbus
|
import dbus
|
||||||
import socket, fcntl
|
import socket, fcntl
|
||||||
|
import shutil
|
||||||
|
|
||||||
import wpath
|
import wpath
|
||||||
import misc
|
import misc
|
||||||
@@ -333,21 +334,25 @@ class BaseInterface(object):
|
|||||||
client_dict = {
|
client_dict = {
|
||||||
"dhclient" :
|
"dhclient" :
|
||||||
{'connect' : r"%(cmd)s -cf %(dhclientconf)s %(iface)s",
|
{'connect' : r"%(cmd)s -cf %(dhclientconf)s %(iface)s",
|
||||||
|
'connect_with_hostname' : r"%(cmd)s -cf %(dhclientconf)s %(iface)s",
|
||||||
'release' : r"%(cmd)s -r %(iface)s",
|
'release' : r"%(cmd)s -r %(iface)s",
|
||||||
'id' : misc.DHCLIENT,
|
'id' : misc.DHCLIENT,
|
||||||
},
|
},
|
||||||
"pump" :
|
"pump" :
|
||||||
{ 'connect' : r"%(cmd)s -i %(iface)s -h %(hostname)s",
|
{ 'connect' : r"%(cmd)s -i %(iface)s",
|
||||||
|
'connect_with_hostname' : r"%(cmd)s -i %(iface)s -h %(hostname)s",
|
||||||
'release' : r"%(cmd)s -r -i %(iface)s",
|
'release' : r"%(cmd)s -r -i %(iface)s",
|
||||||
'id' : misc.PUMP,
|
'id' : misc.PUMP,
|
||||||
},
|
},
|
||||||
"dhcpcd" :
|
"dhcpcd" :
|
||||||
{'connect' : r"%(cmd)s -h %(hostname)s --noipv4ll %(iface)s ",
|
{'connect' : r"%(cmd)s --noipv4ll %(iface)s",
|
||||||
|
'connect_with_hostname' : r"%(cmd)s -h %(hostname)s --noipv4ll %(iface)s ",
|
||||||
'release' : r"%(cmd)s -k %(iface)s",
|
'release' : r"%(cmd)s -k %(iface)s",
|
||||||
'id' : misc.DHCPCD,
|
'id' : misc.DHCPCD,
|
||||||
},
|
},
|
||||||
"udhcpc":
|
"udhcpc":
|
||||||
{'connect' : r"%(cmd)s -n -i %(iface)s -H %(hostname)s ",
|
{'connect' : r"%(cmd)s -n -i %(iface)s",
|
||||||
|
'connect_with_hostname' : r"%(cmd)s -n -i %(iface)s -H %(hostname)s ",
|
||||||
'release' : r"killall -SIGUSR2 %(cmd)s",
|
'release' : r"killall -SIGUSR2 %(cmd)s",
|
||||||
'id' : misc.UDHCPC,
|
'id' : misc.UDHCPC,
|
||||||
},
|
},
|
||||||
@@ -357,24 +362,25 @@ class BaseInterface(object):
|
|||||||
# cause dhclient doesn't have a handy dandy argument
|
# cause dhclient doesn't have a handy dandy argument
|
||||||
# for specifing the hostname to be sent
|
# for specifing the hostname to be sent
|
||||||
if client_name == "dhclient" and flavor:
|
if client_name == "dhclient" and flavor:
|
||||||
if hostname == None:
|
if hostname:
|
||||||
# <hostname> will use the system hostname
|
print 'attempting to set hostname with dhclient'
|
||||||
# we'll use that if there is hostname passed
|
print 'using dhcpcd or another supported client may work better'
|
||||||
# that shouldn't happen, though
|
|
||||||
hostname = '<hostname>'
|
|
||||||
print 'attempting to set hostname with dhclient'
|
|
||||||
print 'using dhcpcd or another supported client may work better'
|
|
||||||
dhclient_template = \
|
|
||||||
open(os.path.join(wpath.etc, 'dhclient.conf.template'), 'r')
|
|
||||||
|
|
||||||
output_conf = open(dhclient_conf_path, 'w')
|
dhclient_template = \
|
||||||
|
open(os.path.join(wpath.etc, 'dhclient.conf.template'), 'r')
|
||||||
|
output_conf = open(dhclient_conf_path, 'w')
|
||||||
|
|
||||||
for line in dhclient_template.readlines():
|
for line in dhclient_template.readlines():
|
||||||
line = line.replace('$_HOSTNAME', hostname)
|
line = line.replace('# <WICDHOSTNAME>', 'send host-name "%s";' \
|
||||||
output_conf.write(line)
|
% hostname)
|
||||||
|
output_conf.write(line)
|
||||||
|
|
||||||
|
output_conf.close()
|
||||||
|
dhclient_template.close()
|
||||||
|
else:
|
||||||
|
shutil.copy(os.path.join(wpath.etc, 'dhclient.conf.template'), \
|
||||||
|
dhclient_conf_path)
|
||||||
|
|
||||||
output_conf.close()
|
|
||||||
dhclient_template.close()
|
|
||||||
os.chmod(dhclient_conf_path, 0644)
|
os.chmod(dhclient_conf_path, 0644)
|
||||||
|
|
||||||
if not client_name or not cmd:
|
if not client_name or not cmd:
|
||||||
@@ -382,13 +388,17 @@ class BaseInterface(object):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
if flavor == "connect":
|
if flavor == "connect":
|
||||||
if not hostname:
|
if hostname:
|
||||||
hostname = os.uname()[1]
|
return client_dict[client_name]['connect_with_hostname'] % \
|
||||||
return client_dict[client_name]['connect'] % \
|
|
||||||
{ "cmd" : cmd,
|
{ "cmd" : cmd,
|
||||||
"iface" : self.iface,
|
"iface" : self.iface,
|
||||||
"hostname" : hostname,
|
"hostname" : hostname,
|
||||||
'dhclientconf' : dhclient_conf_path }
|
'dhclientconf' : dhclient_conf_path }
|
||||||
|
else:
|
||||||
|
return client_dict[client_name]['connect'] % \
|
||||||
|
{ "cmd" : cmd,
|
||||||
|
"iface" : self.iface,
|
||||||
|
'dhclientconf' : dhclient_conf_path }
|
||||||
elif flavor == "release":
|
elif flavor == "release":
|
||||||
return client_dict[client_name]['release'] % \
|
return client_dict[client_name]['release'] % \
|
||||||
{"cmd": cmd, "iface": self.iface}
|
{"cmd": cmd, "iface": self.iface}
|
||||||
|
|||||||
Reference in New Issue
Block a user