Bug 450427 - bad grep'ing of network configuration scripts
Summary: bad grep'ing of network configuration scripts
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: 8
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-06-08 05:59 UTC by JW
Modified: 2014-03-17 03:15 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2008-06-09 14:22:16 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description JW 2008-06-08 05:59:05 UTC
Description of problem:
Some init scripts, especially network, attempt to grep parameters out of what
are otherwise source'able shell scripts.

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

How reproducible:
Always

Steps to Reproduce:
1. read /etc/rc.d/init.d/network
  
Actual results:
1. Not a good look

Expected results:
1. Should be better

Additional info:
At various points in 'network' there are lines such as "eval $(LANG=C fgrep
"DEVICE=" ifcfg-$i)" and worse with grep/sed.

Too bad if ifcfg-ppp1 might source ifcfg-ppp or similar.

Scripts such as ifup very clearly source these config files as shell scripts
(see source_config()).  Why should 'network' goes its own way and handle them
differently?

Is "eval $(LANG=C fgrep "DEVICE=" ifcfg-$i)" really nicer than ". ifcfg-$i"?
I don't think so.  It is pointless, ugly, inaccurate, a hack, incredibly bad
form, and totally unnecessary.

Comment 1 Bill Nottingham 2008-06-09 13:46:27 UTC
Having configurations include other configurations is not guaranteed to work,
and never has been. Configurations aren't sources so that they can be found
instead of polluting the environment, as doing otherwise involves playing tricks
with subshells and pipes.

Comment 2 JW 2008-06-09 14:12:20 UTC
So why do ifup-* all invoke 'source_config()' which actually sources the config
files as shell sources.

If what you say is true, then you have exposed an enormous bug in all of those
ifup-* scripts.  They must be changed because of what you have just decreed.

This bug can therefore be restated as: All ifup-* scripts must no longer invoke
source_config() and must instead do some 'LC_All=C grep this and that' so as to
conform to the better way of doing things.

Viva la grep. Down with bash!



Comment 3 Bill Nottingham 2008-06-09 14:22:16 UTC
You misunderstood what I said, but thanks anyway.

If you want to write a patch to source via a subshell and then pass the needed
information back over a pipe (or whatever), go ahead. But configurations that
directly include other configurations are *not* supported, any more than
configurations that define and override functions used by the network scripts.


Note You need to log in before you can comment on or make changes to this bug.