Re: "Boot time scripts should have an .sh extension"
[email protected] (Joep Vesseur)
| Newsgroups | gmane.comp.security.sun |
|---|---|
| Message-ID | <[email protected]> |
Paul,
> The umask has .sh (/etc/init.d/umask.sh)
>
> Note: The trailing .sh is very important because boot time scripts which
> do not end in .sh get executed in a child shell rather in the
> environment of the parent init process. The parent will not inherit the
> umask value from a child shell, so the new umask value would be lost.
It is sort of true, but not completely. init(1M) will fork of a shell
that runs /sbin/rc<L> where <L> is the runlevel. So, to start with the
false part: none of the subsequent scripts "run in the environment of
the parent init process".
Then the correct part: each of the /sbin/rc* files will "source" an
init file that ends with ".sh", and will start a new shell for other
files, e.g. see /sbin/rc2:
[...]
if [ -s $f ]; then
case $f in
*.sh) . $f ;;
*) /sbin/sh $f start ;;
esac
[...]
So you can alter the environment of, in this case, /sbin/rc2 and thus of
all scripts subsequently run by rc2, but you can't alter the environment
of init(1M) itself.
Hope this helps,
Joep