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