Package: ifupdown
Version:  0.6.4-4

ifup has a subtle but annoying problem when used with dhclient3. The
problem is to do with environment variable setting.

The version of DHCP I have tested this with is:

  Source: dhcp3
  Version: 3.0+3.0.1rc9-2.2


When the dhcp method is used ifup passes IF_xxx environment variables
representing the configuration stanzas to the dhcp program, eg:

  iface eth1 inet dhcp
       metric 10

results in /sbin/dhclient3 being called with this in the environment:

  IF_METRIC=10

However, dhclient3 does not pass arbritary environment variables on to
the client configuration script. Instead it has some command line
syntax to allow you to specify env vars and their values:

  dhclient3 -e IF_METRIC=10 eth1

Without the argument the env var is not passed through and
consequently the dhclient-script does not get a chance to use stanzas
from the interfaces definition, eg: IF_METRIC.


I think that ifup, for the dhclient3 case, should work out what env
vars it has set on the environment and then do this:

  dhclient3 -e IF_xxx=$IF_xxx -e ... ethX

where IF_xxx is one of the env vars ifup has set.

I think this would work because the following manual config of ifup
works:

  iface eth1 inet manual
        metric 10
        up dhclient3 -e IF_METRIC=$IF_METRIC \
                     -pf /var/run/dhclient.eth1.pid \
                     -lf /var/run/dhclient.eth1.leases eth1


But the fact that ifup works via a config file (I mean inet.dfn) looks
like it might present a real problem in getting this right (because
code to work out the env vars might be hard to add for just
dhclient3).

The only solution I can think of is changing the inet.dfn for
dhclient3 to provide the env vars. I'm not sure of the syntax
limitations of the file... maybe this would be ok:

  up
    [[ifconfig %iface% hw %hwaddress%]]
    dhclient3 $(set | awk  '/IF_/  { print "-e " $1 "=$" $1 " " }') \
        -pf /var/run/dhclient.%iface%.pid -lf /var/run/dhclient.%iface%.leases 
%iface% \
        if (execable("/sbin/dhclient3"))
    .
    .
    .


If that's not possible then an ifupdown package supplied shell script
could call dhclient3 with the correct -e ... statements.

I mean a script like this:

  #!/bin/sh
  ENVVARS=$(set | awk  '/IF_/  { print "-e " $1 "=$" $1 " " }')
  dhclient3 $ENVVARS $*
  # End.



Nic Ferrier
http://www.tapsellferrier.co.uk

PS I've taken a look at the ifup source code and it is way too
complicated for me to change. A large part of the reason for that is
the documentation system (a neat idea but it stops idle patches from
people like me).


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to