suidregister and `set -e`, bash-2.0 scoping problem
Here's the scoop:
8<----------------------------------------------------------------->8
# help set
[... I read that, then editted as shown...]
# head /var/lib/dpkg/info/rlpr.postinst
#!/bin/sh
set -ex # set 'errexit' and 'xtrace' options
# Permission processing inserted by debmake on Fri, 17 Jan 1997 14:52:40 +0900
if [ -e /etc/suid.conf ]; then
suidregister -s rlpr /usr/bin/rlpr root root 4755
else
chown root.root /usr/bin/rlpr
chmod 4755 /usr/bin/rlpr
fi
# /var/lib/dpkg/info/rlpr.postinst
+ '[' -e /etc/suid.conf ']'
+ suidregister -s rlpr /usr/bin/rlpr root root 4755
+ '[' -s = '' ']'
+ '[' -s = -s ']'
+ shift
+ PACKAGE=rlpr
+ shift
+ '[' 4755 = '' ']'
+ '[' '!' -e /usr/bin/rlpr ']'
++ grep '.* /usr/bin/rlpr' /etc/suid.conf
+ X=
[status 1]
# grep '.* /usr/bin/rlpr' /etc/suid.conf
[status 1]
8<----------------------------------------------------------------->8
If 'errexit' is set when `suidregister` executes, AND the file being
registered is NOT yet in "/etc/suid.conf", the `grep` will fail,
returning code 1, and `suidregister` will exit with code 1.
`suidregister` worked fine from an xterm, since 'errexit' was not set
there. It would add the entry to "/etc/suid.conf", and thereafter,
the `*.postinst` will run, since the `grep` in `suidregister` will
find something and return code 0.
Q: Why does Bash-2.0 (2.0-3) pass the 'errexit' setting on to scripts
run from within the script it is set in? From this experience, I
would say that the 'errexit' setting should be file or lexically
scoped, not global and inherited.
Gee, I sure would like to learn how to fix things like that...
I see the solution as being to turn 'errexit' off inside
`suidregister`. But will that leave it turned off after it
completes???
--
Karl M. Hegbloom <karlheg@inetarena.com>
http://www.inetarena.com/~karlheg
Portland, OR USA
Debian GNU 1.2 Linux 2.1.36 AMD K5 PR-133
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: