Which script (was Re: comp.unix.questions)

Dr A. N. Walker anw at maths.nott.ac.uk
Fri Sep 14 01:11:30 AEST 1990


In article <563 at DIALix.UUCP> bernie at DIALix.oz.au (Bernd Felsche) writes:
>In article <1990Sep7.152354.9439 at ecn.purdue.edu> patkar at helium.ecn.purdue.edu
(The Silent Dodo) writes:
>>[...] How can a shell script
>>(sh or csh) find out [the directory of] its own file name?
> [gives shell script to parse the PATH]

	Just to point out that any such script is easily spoofed, in case
this is a security- or accounting-related problem.  Try something like

	$ PATH=/something/innocuous export PATH
	$ /bin/sh
	$ PATH=/secret/directory	# note, no export
	$ spoof

and "spoof" will look for itself in "/something/innocuous", even though it
was found in "/secret/directory".  At least, it does in SunOS 4.0.3, and it
does with our somewhat modded SysV shell, though I don't remember seeing
anywhere a definition of what *should* happen if an exported variable is
masked by an unexported one.

-- 
Andy Walker, Maths Dept., Nott'm Univ., UK.
anw at maths.nott.ac.uk



More information about the Comp.unix.questions mailing list