tags 520014 + upstream
tags 520014 + patch
thanks

Hi there!

On Mon, 23 Mar 2009 00:43:20 +0100, Luca Capello wrote:
> On Mon, 16 Mar 2009 22:04:33 +0100, manuk7 wrote:
>> Using udhcpc as DHCP client with wicd seems to be impossible.
>> wicd dependencies only support dhclient3-client, dhcpcd or pump.
[...]
> However, if we count the dependencies, only udhcpc requires nothing more
> than libc6, which means that its *real* Installed-Size is the lowest
> one.  Yet udhcpc is not considered by wicd.

It seems wicd does not support udhpc yet, there is a patch available at

  http://wicd.net/punbb/viewtopic.php?id=132

I modified that patch (attached), since in the ReleaseDHCP function I do
not see why the original author use the following check

  if self.DHCP_RELEASE.startswith("kill"):

instead of

  if self.DHCP_CLIENT == misc.UDHCPC:

self.DHCP_RELEASE starts with "kill" only for udhcpc (it does not have a
release lease option, see http://bugs.debian.org/520933 ), thus the
check should be udhcpc-specific.

I tested both versions above on my Openmoko FR: they seem to work as
expected, at least wicd is able to connect to my WPA2-PSK network with
then `apt-get update` completing fine.  For further tests, I put my
package at:

  http://people.debian.org/~gismo/tmp/wicd/

Thx, bye,
Gismo / Luca

--- wicd-1.5.9.orig/wicd/misc.py
+++ wicd-1.5.9/wicd/misc.py
@@ -40,6 +40,7 @@
 DHCLIENT = 1
 DHCPCD = 2
 PUMP = 3
+UDHCPC = 4
 
 ETHTOOL = 1
 MIITOOL = 2
--- wicd-1.5.9.orig/wicd/wnettools.py
+++ wicd-1.5.9/wicd/wnettools.py
@@ -155,7 +155,7 @@
 
 def StopDHCP():
     """ Stop the DHCP client. """
-    cmd = 'killall dhclient dhclient3 pump dhcpcd-bin'
+    cmd = 'killall dhclient dhclient3 pump dhcpcd-bin udhcpc'
     misc.Run(cmd)
 
 def GetWirelessInterfaces():
@@ -262,6 +262,8 @@
                 client = "dhclient"
             elif cl in [misc.DHCPCD, "dhcpcd"]:
                 client = "dhcpcd"
+            elif cl in [misc.UDHCPC, "udhcpc"]:
+                client = "udhcpc"
             else:
                 client = "pump"
             return client
@@ -275,7 +277,7 @@
         if not self.DHCP_CLIENT or not dhcp_path:
             dhcp_client = None
             dhcp_path = None
-            dhcpclients = ["dhclient", "dhcpcd", "pump"]
+            dhcpclients = ["dhclient", "dhcpcd", "pump", "udhcpc"]
             for client in dhcpclients:
                 dhcp_path = self._find_client_path(client)
                 if dhcp_path:
@@ -297,6 +299,10 @@
             dhcp_client = misc.DHCPCD
             dhcp_cmd = dhcp_path
             dhcp_release = dhcp_cmd + " -k"
+        elif dhcp_client in [misc.UDHCPC, "udhcpc"]:
+            dhcp_client = misc.UDHCPC
+            dhcp_cmd = dhcp_path + " -n -i"
+            dhcp_release = "killall -SIGUSR2 udhcpc"
         else:
             dhcp_client = None
             dhcp_cmd = None
@@ -486,6 +492,30 @@
 
         return self._check_dhcp_result(dhcpcd_success)
 
+    def _parse_udhcpc(self, pipe):
+        """ Determines if obtaining an IP using udhcpc succeeded.
+
+        Keyword arguments:
+        pipe -- stdout pipe to the dhcpcd process.
+
+        Returns:
+        'success' if succesful', an error code string otherwise.
+
+        """
+        udhcpc_complete = False
+        udhcpc_success = True
+
+        while not udhcpc_complete:
+            line = pipe.readline()
+            if line.endswith("failing"):
+                udhcpc_success = False
+                udhcpc_complete = True
+            elif line == '':
+                udhcpc_complete = True
+            print line
+
+        return self._check_dhcp_result(udhcpc_success)
+
     def _check_dhcp_result(self, success):
         """ Print and return the correct DHCP connection result.
 
@@ -524,11 +554,16 @@
             return self._parse_pump(pipe)
         elif DHCP_CLIENT == misc.DHCPCD:
             return self._parse_dhcpcd(pipe)
+        elif DHCP_CLIENT == misc.UDHCPC:
+            return self._parse_udhcpc(pipe)
 
     def ReleaseDHCP(self):
         """ Release the DHCP lease for this interface. """
         if not self.iface: return False
-        cmd = self.DHCP_RELEASE + " " + self.iface + " 2>/dev/null"
+        if self.DHCP_CLIENT == misc.UDHCPC:
+            cmd = self.DHCP_RELEASE
+        else:
+            cmd = self.DHCP_RELEASE + " " + self.iface + " 2>/dev/null"
         misc.Run(cmd)
 
     def FlushRoutes(self):
--- wicd-1.5.9.orig/wicd/wicd-daemon.py
+++ wicd-1.5.9/wicd/wicd-daemon.py
@@ -494,7 +494,7 @@
             self.wifi.connecting_thread.should_die = True
         if self.wired.connecting_thread:
             self.wired.connecting_thread.should_die = True
-        misc.Run("killall dhclient dhclient3 wpa_supplicant")
+        misc.Run("killall dhclient dhclient3 udhcpc wpa_supplicant")
 
     @dbus.service.method('org.wicd.daemon')
     def GetCurrentInterface(self):

Attachment: pgpLPmNQyzaFA.pgp
Description: PGP signature

Reply via email to