Bug 486251

Summary: /sbin/dhclient-script has really strange code
Product: [Fedora] Fedora Reporter: Michal Jaegermann <michal>
Component: dhcpAssignee: David Cantrell <dcantrell>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: dcantrell, wwoods
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-18 22:26:03 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Michal Jaegermann 2009-02-18 21:21:02 EST
Description of problem:

Bringing up a network interface configured via dhcp ends up with errors like these:

/sbin/dhclient-script: line 363: ${subsystem}_config: command not found


The code in question looks like follows:

 for f in /etc/dhcp/dhclient.d/*.sh ; do
      if [ -x ${f} ]; then
          subsystem="$(basename ${f} .sh)"
          . ${f}

and indeed attempts to use a command with a literal '$' in it like in the error message.  Eh???  Forgotten 'eval' or something of that sort?  Or this was rather supposed to read

    . ${f} "${subsystem}_config"

BTW - a 'basename' invocation is spurious as variable expansion does the job:


Version-Release number of selected component (if applicable):

How reproducible:
Comment 1 David Cantrell 2009-02-18 21:37:38 EST
How is this:

Index: dhclient-script
RCS file: /cvs/pkgs/rpms/dhcp/devel/dhclient-script,v
retrieving revision 1.5
diff -u -p -r1.5 dhclient-script
--- dhclient-script	18 Feb 2009 04:12:59 -0000	1.5
+++ dhclient-script	19 Feb 2009 02:36:16 -0000
@@ -358,9 +358,8 @@ dhconfig() {
     if [ -d /etc/dhcp/dhclient.d ]; then
         for f in /etc/dhcp/dhclient.d/*.sh ; do
             if [ -x ${f} ]; then
-                subsystem="$(basename ${f} .sh)"
-                . ${f}
-                \${subsystem}_config
+                subsystem="${f%.sh}"
+                . ${f} "${subsystem}_config"
Comment 2 Michal Jaegermann 2009-02-18 22:19:23 EST
> How is this: ...

That will work just fine (if this was an intention).

As a matter of fact I did such change already on my copy of dhclient-script, as a "temporary" fix, and nothing bad happened. :-)
Comment 3 David Cantrell 2009-02-18 22:26:03 EST
Very good, thanks.  Will be fixed in dhcp-4.1.0-8.fc11

I really find shell scripts frustrating.  I spend the majority of my time writing C or Python and when I have to do something simple in shell, I almost always fail.  Oh well.

BTW, this addition to dhclient-script is so that other services can latch on to the dhclient-script run by providing their own scripts in /etc/dhcp/dhclient.d.  It's so I don't have to keep maintaining dhclient-script and updating for every little change to ntp, nis, and other such services that may be pulling info from the DHCP lease.
Comment 4 Michal Jaegermann 2009-02-18 22:35:52 EST
> BTW, this addition to dhclient-script is so that other services can latch on to
> the dhclient-script

Yes, that how it looked to me.  At least one of existing scripts, nis.sh, takes an argument but I was not entirely sure if a dhclient-script code resulted from  a slip of a finger in an editor or you had in mind something fiendishly clever.