Operating System - HP-UX
1834168 Members
2217 Online
110064 Solutions
New Discussion

PATH variable on system startup

 
C W_1
Occasional Contributor

PATH variable on system startup

What controls the default PATH variable upon system startup (processing /sbin/rc?.d scripts)? Is it just /sbin/rc?

I have an app trying to su but they have no path...obviously I told them to include the full path in the script, but then I got to wondering why the PATH wouldn't be broader to begin with.

Usage: /sbin/rc3.d/S799patrol {start|stop} Output from "/sbin/rc3.d/S799patrol start":
/sbin/rc3.d/S799patrol[27]: su: not found
/sbin/rc3.d/S799patrol[28]: su: not found "/sbin/rc3.d/S799patrol start" FAILED
4 REPLIES 4
RAC_1
Honored Contributor

Re: PATH variable on system startup

Default path is taken from /etc/PATH. It is btter to keep it as it is. You script should explicitely define it and use it.
Changes to /etc/PATH will be applied globally. So a user who does not need path like /xxxyyy, will also get it.

Anil
There is no substitute to HARDWORK
Mel Burslan
Honored Contributor

Re: PATH variable on system startup

It is quite odd that any user can have nothing in PATH variable upon loggin in. Unless of course someone has fatfingered and cleared out your /etc/PATH file or god forbit delete it :)

If there is a /etc/PATH file on your system and it has some directories listed in it delimited by : (colon that is), make sure it has at least permission 444 (read for everyone). 644 or 744 is acceptable as long as the owner is root, but do not give more than read to group and others to protect it from getting fatfingered by unknowing people.
________________________________
UNIX because I majored in cryptology...
Ermin Borovac
Honored Contributor

Re: PATH variable on system startup

Default PATH set in /sbin/rc is

PATH=/sbin
export PATH

Most of the processing scripts in /sbin/init.d (/sbin/rc?.d) have the following line at the beginning of the file.

PATH=/usr/sbin:/usr/bin:/sbin
export PATH

Make sure your startup script contains this file.
Bill Hassell
Honored Contributor

Re: PATH variable on system startup

PATH is a fairly serious security risk and at best, undependable, especially for scripting. The very first line of code in all my scripts is:

export PATH=/usr/bin

Then as you code additional commands, you add to your local PATH, knowing that you are in control. Some software packages go a bit too far in appending directories to /etc/PATH and you end up with a huge PATH. You can adjust your PATH for your local shell, but for startup scripts and cron and batch jobs, never assume anything about the current PATH value--and you won't go wrong.


Bill Hassell, sysadmin