# No wired connection with wicd + dhclient [SOLVED]

## lexming

It's being rather difficult to make wicd work on my system. I thought that it would be almost straightforward, but maybe I made some silly mistake so I would appreciate your help.

The system: "almost" stable amd64; gentoo-sources-3.2.6; xfce-4.8; net-misc/dhcp-4.2.3_p1; net-misc/wicd-1.7.1-r2.

I've been using the net connection on this computer for ages using the net init.d scripts. No problem at all neither with wired or wireless connections. But anyway, I will just focus on the wired connection to a DHCP router on my lan. Nothing fancy, a wire on eth0 and automatic dhcp connection.

# /etc/init.d/net.eth0 works with dhclient

```
# /etc/init.d/net.eth0 start

 * Bringing up interface eth0

 *   dhclient ...

 *     Running dhclient ...                                                                                               [ ok ]

 *     received address 192.168.0.21/24
```

However, wicd cannot stablish the dhcp connection

/var/log/wicd/wicd.log

```
Putting interface down

Releasing DHCP leases...

attempting to set hostname with dhclient

using dhcpcd or another supported client may work better

Setting false IP...

Stopping wpa_supplicant

Flushing the routing table...

Putting interface up...

Running DHCP with hostname negook

attempting to set hostname with dhclient

using dhcpcd or another supported client may work better

Internet Systems Consortium DHCP Client 4.2.3-P1 Gentoo-r0

Copyright 2004-2011 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/

failed to read stdin!

This version of ISC DHCP is based on the release available

on ftp.isc.org.  Features have been added and other changes

have been made to the base software release in order to make

it work better with this distribution.

Please report for this software via the Gentoo Bugzilla site:

    http://bugs.gentoo.org/

exiting.

DHCP connection failed

exiting connection thread

Sending connection attempt result dhcp_failed

```

Neither using the applet, the gtk gui or the wicd-cli. All of them fail saying that they could not get an IP address. Additionally, what makes me wonder is the line in the wicd log that corresponds to dhclient (I believe) and says failed to read stdin!. I googled for that but nothing relevant came out.

Any suggestion on how I could solve this problem?

Thanks for your helpLast edited by lexming on Thu Mar 08, 2012 1:22 am; edited 1 time in total

----------

## lexming

Well, I think I fixed this problem. 

Somehow the call from wicd to dhclient was misbehaving and causing dhclient to not be able to read the stdin (see error on first post). I disabled the PIPE object assigned to stdin in the wicd call to dhclient.

TL;DR

The call to dhclient is found in wicd/wnettools.py 

```
self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
```

 Where the cmd is a string with the command and arguments to call dhclient (or any other dhcp client). See the return_obj=True, that will be important further on.

This misc.Run function is defined in wicd/misc.py, which basically calls python Popen in this way

```
 f = Popen(cmd, shell=False, stdout=PIPE, stdin=std_in, stderr=err, close_fds=fds, cwd='/', env=tmpenv)
```

The stdin parameter is defined by the std_in variable and depends on the return_obj setting in the following way

```
if return_obj:

        std_in = PIPE

    else:

        std_in = None
```

Therefore, dhclient was being called with a PIPE object in the stdin making dhclient to fail. I just disabled this and hardcoded a None in the stdin.

So far, this works  :Very Happy:  I'm the only one using wicd with dhclient?? If not, please tell me, because then there could be the real source of the problem somewhere else. But if I'm the only one I will just open a bug upstream  :Smile: 

(Disclaimer: I have no idea to code in Python)

----------

