1832296 Members
1836 Online
110041 Solutions
New Discussion

double slash in PATH

 
SOLVED
Go to solution
John Kittel
Trusted Contributor

double slash in PATH

HP-UX 11.11

What is the reason for or purpose of allowing double slashes in the PATH variable? Why does the default PATH variable on a system delivered from HP with HP-UX already installed contain double slashes in some of the directory specifications? From the limited testing and searching I have done, it looks as though a double slash is silently interpreted as a single slash, so it appears to have no effect whatever.

- John
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: double slash in PATH

Hi John:

That sounds like a filter (script) gone wrong. As noted, the extra slash(es) are benignly interpreted as one slash.

Regards!

...JRF...
H.Merijn Brand (procura
Honored Contributor

Re: double slash in PATH

Your interpretation is correct.

I've seen this more than once. IIRC /opt/hpnp is a known offender.
Just ignore it

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
John Kittel
Trusted Contributor

Re: double slash in PATH

I was thinking that someone must have gone to some trouble to implement the feature of ignoring the multiple slashes, and maybe there was or still is a reason for it, whether the reason is still valid or not.

In the posix shell, from the command line, it makes no difference whether I issue an ls command with a single slash, or several:

# ls /opt/perl
bin html lib man

# ls /opt//////perl
bin html lib man

#
Patrick Wallek
Honored Contributor

Re: double slash in PATH

The main culprit is generally a scipt, as JRF said.

What can happen is:

Some script does the following:

export APP_PATH=/dir1/dir2/
export PATH=${APP_PATH}/bin:${APP_PATH}/sbin:${PATH}

That will lead to:

/dir1/dir2//bin:/dir1/dir2//sbin:a bunch of other stuff

in your path. It essentially falls into the bad coding category.

If it bothers you, it should be relatively easy to check /etc/PATH, /etc/profile, ~/.profile or whatever and find the offending entries.
Bill Hassell
Honored Contributor
Solution

Re: double slash in PATH

As mentioned, the multiple slashes are ignored and cause no problems or performance issues. The default PATH statement starts in /etc/PATH and for most sysadmins, it is in serious need of revising. Many of the listed paths have no business being in every user's environment and a long PATH string is indeed a potential performance issue, but more important, a potential security issue. I recommand trimming /etc/PATH to just the basics such as:

/usr/bin

and then add any specific paths that *ALL* users need. Do NOT include root users as they will need paths in directories that normal users can't even read. Adjust specific user by appending specialty directories, and of course, root gets all sorts of special directories appended in .profile.

One of the biggest errors in PATH is the occurance of the current working directory. Most sysadmins realize how bad the security risk is with this element, but just as many will fail to see the PWD in $PATH because it can appear in several different ways. The most common error is :: which is the same as :.: but also a trailing colon at the end of $PATH.

Another really important issue in PATH is the actual directory: Does it exist at all? Are the permissions secure enough to prevent dropping a Trojan horse into it? Has the directory appeared more than onec in $PATH? Is the directory actually a symlink?

Here is a script that will analyze /etc/PATH as well as the current user's $PATH.


Bill Hassell, sysadmin
Peter Nikitka
Honored Contributor

Re: double slash in PATH

Hi,

I want to remark, that in DomainOS - some may rememeber - a double slash at the beginning of a pathname meant something really different - the superroot of a network.
E.g. //node_4671/usr/local was a pathname locating at an other host.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
John Kittel
Trusted Contributor

Re: double slash in PATH

Thank you, everyone.