linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / tools / networking / wicd / dhclient.patch
blobfbda1caacb7a2129d0c57b2a6c1d4b6f29b28b49
1 diff -ruN wicd-1.7.2.4.orig/wicd/wicd-daemon.py wicd-1.7.2.4/wicd/wicd-daemon.py
2 --- wicd-1.7.2.4.orig/wicd/wicd-daemon.py 2013-06-22 18:55:02.641242947 +0000
3 +++ wicd-1.7.2.4/wicd/wicd-daemon.py 2013-06-22 18:58:33.990244153 +0000
4 @@ -69,6 +69,7 @@
5 wireless_conf = os.path.join(wpath.etc, "wireless-settings.conf")
6 wired_conf = os.path.join(wpath.etc, "wired-settings.conf")
7 dhclient_conf = os.path.join(wpath.etc, "dhclient.conf.template")
8 +dhclient_conf_default = os.path.join(wpath.share, "other", "dhclient.conf.template.default")
10 class WicdDaemon(dbus.service.Object):
11 """ The main wicd daemon class.
12 @@ -910,7 +911,7 @@
14 if not os.path.isfile(dhclient_conf):
15 print "dhclient.conf.template not found, copying..."
16 - shutil.copy(dhclient_conf + ".default", dhclient_conf)
17 + shutil.copy(dhclient_conf_default, dhclient_conf)
18 # Hide the files, so the keys aren't exposed.
19 print "chmoding configuration files 0600..."
20 os.chmod(app_conf.get_config(), 0600)diff -ruN wicd-1.7.2.4.orig/wicd/wnettools.py wicd-1.7.2.4/wicd/wnettools.py
21 --- wicd-1.7.2.4.orig/wicd/wnettools.py 2013-03-30 21:47:19.804907552 +0000
22 +++ wicd-1.7.2.4/wicd/wnettools.py 2013-03-31 08:44:37.572792110 +0000
23 @@ -37,6 +37,7 @@
24 import time
25 from string import maketrans, translate
27 +import tempfile
28 import wpath
29 import misc
30 from misc import find_path
31 @@ -216,6 +217,7 @@
32 self.flush_tool = None
33 self.link_detect = None
34 self.dhcp_object = None
35 + self.dhclient_conf_path = None;
37 def SetDebugMode(self, value):
38 """ If True, verbose output is enabled. """
39 @@ -277,12 +279,6 @@
40 cmd = ""
41 return (client, cmd)
43 - # probably /var/lib/wicd/dhclient.conf with defaults
44 - dhclient_conf_path = os.path.join(
45 - wpath.varlib,
46 - 'dhclient.conf'
47 - )
49 client_dict = {
50 "dhclient" :
51 {'connect' : r"%(cmd)s -cf %(dhclientconf)s %(iface)s",
52 @@ -307,41 +303,44 @@
54 (client_name, cmd) = get_client_name(self.DHCP_CLIENT)
56 - # cause dhclient doesn't have a handy dandy argument
57 - # for specifing the hostname to be sent
58 - if client_name == "dhclient" and flavor:
59 - if hostname == None:
60 - # <hostname> will use the system hostname
61 - # we'll use that if there is hostname passed
62 - # that shouldn't happen, though
63 - hostname = '<hostname>'
64 - print 'attempting to set hostname with dhclient'
65 - print 'using dhcpcd or another supported client may work better'
66 - dhclient_template = \
67 - open(os.path.join(wpath.etc, 'dhclient.conf.template'), 'r')
69 - output_conf = open(dhclient_conf_path, 'w')
71 - for line in dhclient_template.readlines():
72 - line = line.replace('$_HOSTNAME', hostname)
73 - output_conf.write(line)
75 - output_conf.close()
76 - dhclient_template.close()
77 - os.chmod(dhclient_conf_path, 0644)
79 if not client_name or not cmd:
80 print "WARNING: Failed to find a valid dhcp client!"
81 return ""
83 if flavor == "connect":
84 + # cause dhclient doesn't have a handy dandy argument
85 + # for specifing the hostname to be sent
86 + if client_name == "dhclient" and flavor:
87 + if hostname == None:
88 + # <hostname> will use the system hostname
89 + # we'll use that if there is hostname passed
90 + # that shouldn't happen, though
91 + hostname = '<hostname>'
92 + print 'attempting to set hostname with dhclient'
93 + print 'using dhcpcd or another supported client may work better'
94 + if not self.dhclient_conf_path:
95 + _,self.dhclient_conf_path = tempfile.mkstemp()
96 + print 'New dhclient conf path: %s ' % self.dhclient_conf_path
97 + dhclient_template = \
98 + open(os.path.join(wpath.etc, 'dhclient.conf.template'), 'r')
100 + output_conf = open(self.dhclient_conf_path, 'w')
102 + for line in dhclient_template.readlines():
103 + line = line.replace('$_HOSTNAME', hostname)
104 + output_conf.write(line)
106 + output_conf.close()
107 + dhclient_template.close()
108 + os.chmod(self.dhclient_conf_path, 0644)
110 if not hostname:
111 hostname = os.uname()[1]
112 return client_dict[client_name]['connect'] % \
113 { "cmd" : cmd,
114 "iface" : self.iface,
115 "hostname" : hostname,
116 - 'dhclientconf' : dhclient_conf_path }
117 + 'dhclientconf' : self.dhclient_conf_path }
118 elif flavor == "release":
119 return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface}
120 else: