Possible bug in dhcpcd package or modify_resolvconf script???
I have been having an issue on a customized SuSE setup where my '/etc/resolv.conf' wasn't getting populated when using dhcp. After investigating further with debugging mode I found that my dhcp server was returning two hosts. dhcpcd would pass the information on to a SuSE script '/sbin/modify_resolvconf'. That script would then use 'getopt' to parse the command line parameters. To pass a nameserver to the script the '-n' flag is used. So in our case we want '-n $NS1 $NS2' however, getopt was parsing it as '-n $NS1' '$NS2'. $NS2 being a standalone parameter which the script was interpreting as an 'action' by modify_resolvconf. This was resulting in the following error: ERROR: Exactly one action may be given. Currently given actions: modify 10.4.21.11 I found that if I changed the command line to '-n $NS1 -n $NS2' it worked ok. So I made the following change to 'dhcpconfig.c' from the dhcpcd package. - sprintf(NameserverList + strlen(NameserverList), "%u.%u.%u.%u", + sprintf(NameserverList + strlen(NameserverList), "%u.%u.%u.%u -n ", However, this resulted in the following in my '/etc/resolv.conf': <clip> ### END INFO search xxxxxx.xxx.com nameserver 10.4.21.11 nameserver -n nameserver 10.4.21.10 nameserver -n So I made one last quick change to '/sbin/modify_resolvconf' to resolve this. - -n|--nameservers) DNS="$2"; shift 2;; + -n|--nameservers) DNS="`echo $2 | sed -e 's/-n//g'`"; shift 2;; I didn't have a great deal of time to mess around with this much, I just needed to get it working. So I am not sure if this is the best solution for this or if this possibly isn't a bug at all given our modified setup. I was able to reproduce the original problem on several pieces of hardware running the same modified SuSE system and the above appears to fix the problem on every system. Regards, -Nick
On Monday, 1 November 2004 17.54, Nicholas DeClario wrote:
- sprintf(NameserverList + strlen(NameserverList), "%u.%u.%u.%u", + sprintf(NameserverList + strlen(NameserverList), "%u.%u.%u.%u -n ",
If that's the only change you made, it will generate a buffer overflow. Look at how much memory is malloced for that string However, I think the correct solution is to put quotes around the argument, so it's -n "1.2.3.4 2.3.4.5"
Yes, you are right. The better solution would be to put quotes around
it.
I am modifying the cmdline to include a set of quotes around
cmdline[11] which holds the nameservers. This works as far as
allowing the resolv.conf to be correctly created. However, the
quoations are getting prepended to one nameserver and appended to the
other like this:
nameserver "10.4.21.10
nameserver 10.4.21.11"
I have tried with both single and double quotes. Perhaps I am doing
something wrong but shouldn't 'getopt' be filtering these out?
Regards,
Nick
On Mon, 1 Nov 2004 19:22:36 +0200, Anders Johansson
On Monday, 1 November 2004 17.54, Nicholas DeClario wrote:
- sprintf(NameserverList + strlen(NameserverList), "%u.%u.%u.%u", + sprintf(NameserverList + strlen(NameserverList), "%u.%u.%u.%u -n ",
If that's the only change you made, it will generate a buffer overflow. Look at how much memory is malloced for that string
However, I think the correct solution is to put quotes around the argument, so it's -n "1.2.3.4 2.3.4.5"
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On Mon, Nov 01, 2004 at 11:54:43AM -0500, Nicholas DeClario wrote:
I have been having an issue on a customized SuSE setup where my '/etc/resolv.conf' wasn't getting populated when using dhcp. After investigating further with debugging mode I found that my dhcp server was returning two hosts. dhcpcd would pass the information on to a SuSE script '/sbin/modify_resolvconf'. That script would then use 'getopt' to parse the command line parameters. To pass a nameserver to the script the '-n' flag is used. So in our case we want '-n $NS1 $NS2' however, getopt was parsing it as '-n $NS1' '$NS2'. $NS2 being a standalone parameter which the script was interpreting as an 'action' by modify_resolvconf. This was resulting in the following error:
What kind of DHCP server are you using? What's customized in your setup? I'm asking because the very same works for so many other people. Peter
participants (3)
-
Anders Johansson
-
Nicholas DeClario
-
poeml@cmdline.net