[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: /etc/init.d scripts



On 16 Apr 1999, Roderick Schertler wrote:

> > All scripts must have one of the following two contained in them:
> >
> > 1) A PATH environment setting that lists all the directories where any
> > programs invoked by the script may be found.
> 
> I don't think this is a good idea.  Why should the same information be
> coded into every single init.d script that we write, particularly since
> it is almost always unnecessary?  When the init.d scripts are run by the
> system, or by the admin at a shell prompt, they can rely on having a
> sane $PATH.

Unless, of course, the default system $PATH has been changed, for whatever
reason.

> The real problem you're trying to fix is that you don't have a reasonable
> path when you run something with rsh.  I agree that that's a problem.

What if I change the path? These scripts should work even if I change the
default path. And certainly adding a PATH line isn't going to break the
scripts, is it?

> Your proposal tries to deal with the symptom rather than the cause.  If
> you fix the real problem then it will benefit this case plus lots of
> others.

I happen to believe that putting a PATH line in will fix any cases where
people might change their default PATH.

> We've talked about setting up a policy about /etc/environment.  Perhaps
> that's how this should be dealt with.  The simple implementation
> wouldn't actually fix your problem, though, because you wouldn't want
> the sbin directories on the PATH in /etc/environment.  Perhaps we could
> say that programs would, after processing /etc/environment, append
> /usr/local/sbin, /sbin and /usr/sbin to the $PATH if this is being set
> up for root.  Perhaps we should instead specify that after
> /etc/environment is processed /etc/environment.root should be processed,
> if this is for root.  Perhaps we should specify that /etc/environment
> can be written in sh rather than being simple name=value pairs.  Perhaps
> there's a better answer.

Possible -- but I still think that people can change /etc/environment and
that we can still get people who change their default paths (or
/etc/environment.root or whatever) and get scripts in /etc/init.d that do
not work.

> > 2) All the programs be hard-linked (must contain a full directory setting)
> 
> Using full paths for commands is almost always a mistake.  It makes the
> script more fragile (commands sometimes move, or are located elsewhere
> on a different system) for no reason, plus it prevents the local admin
> from overriding a command by putting a different version of it under
> /usr/local and putting that first in the $PATH.

> PS:  For scripts which do add regular directories to $PATH, they should
> at the least always append them, else you have the same problem with not
> allowing the local admin to override the system's binaries.

So then that should be the policy, that each script should append the PATH
it needs. Thus, we hurt noone, help the scripts and anybody else who has
played around with their PATH.

-- 
Brock Rozen                                              brozen@torah.org
Director of Technical Services                              (410)358-9800
Project Genesis                                     http://www.torah.org/ 




Reply to: