Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 26429 - filter_environ in rc-services.sh fubar's svc_homegrown in runscript.sh (baselayout-1.8.6.10)
Summary: filter_environ in rc-services.sh fubar's svc_homegrown in runscript.sh (basel...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
: 26556 26858 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-11 15:36 UTC by Mark Wagner
Modified: 2003-09-04 14:38 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wagner 2003-08-11 15:36:06 UTC
In svc_homegrown in runscript.sh there is the loop

for x in ${opts}
...
  (filter_environ; "${x}")
...
fi

In filter_environ in rc-services.sh there is the loop

for x in $(declare -F)
...
fi

In these functions neither x is local. Thus the last value of x in
filter_environ is the value after it returns, trouncing the value of x in
svc_homegrown, which would be the homegrown opt.

To fix, add

local x

to filter_environ. In fact, all functions should use local variables.


Reproducible: Always
Steps to Reproduce:
1. Take your init.d script (e.g., /etc/init.d/privoxy)
2. Add opts="${opts} foo"
3. Add foo() {
     einfo "Hello world"
   }
4. run /etc/init.d/privoxy foo


Actual Results:  
cat: : No such file or directory

Expected Results:  
* Hello world  [ok]

Portage 2.0.48-r7 (default-x86-1.4, gcc-3.2.3, glibc-2.3.2-r1)
=================================================================
System uname: 2.4.20-gentoo-r5 i686 Mobile Intel(R) Pentium(R) 4 - M CPU
2.20GHzGENTOO_MIRRORS="http://gentoo.oregonstate.edu
http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config
/usr/kde/3/share/config /usr/X11R6/lib/X11/xkb /usr/kde/3.1/share/config
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/
/usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY=""
USE="3dnow foomaticdb kde gnome libg++ mikmod nls png berkdb slang arts bonobo
svga guile python esd qt motif alsa apm avi cdr crypt cups dga dvd emacs encode
ethereal fbcon gd gdbm gif gpm gtk gtk2 gtkhtml icc icc-pgo imlib java jikes
jpeg libwww lirc mad mmx mozilla mpeg ncurses oggvorbis opengl oss pam pcmcia
pda pdflib perl quicktime readline samba sasl sdl slp snmp spell sse ssl tcpd
tetex tiff truetype trusted usb wmf X Xaw3d xinerama xml xml2 xmms xv zlib x86"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -O3 -pipe"
CXXFLAGS="-march=pentium3 -O3 -pipe"
ACCEPT_KEYWORDS="x86 ~x86"
MAKEOPTS="-j2"
AUTOCLEAN="yes"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
FEATURES="sandbox ccache"
Comment 1 Mark Wagner 2003-08-11 15:37:57 UTC
I forgot to add: I've been fiddling around with "stuff" so I hope this is actually a bug and I'm not wasting everybody's time.
Comment 2 SpanKY gentoo-dev 2003-08-11 17:15:51 UTC
x is local in homegrown, but not in filter_env

svc_homegrown() { 
        local arg="$1"
        local x=

        # Walk through the list of available options, looking for the
        # requested one.
        for x in ${opts}
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2003-08-12 07:52:33 UTC
Good call, thanks - shows you not to add a 'quick hack' =)

Fixed in CVS, thanks.
Comment 4 SpanKY gentoo-dev 2003-08-18 16:25:30 UTC
*** Bug 26858 has been marked as a duplicate of this bug. ***
Comment 5 SpanKY gentoo-dev 2003-09-04 12:54:17 UTC
*** Bug 26556 has been marked as a duplicate of this bug. ***
Comment 6 SpanKY gentoo-dev 2003-09-04 12:54:53 UTC
az: this is a very good reason to push a .11 out the door ... all custom functions in init.d scripts are currently broken ...
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-04 14:38:14 UTC
Yes I know, just a bad week for me (still?) :/  I will really make effort this
weekend to squich all the small ones, and get .11 going.