Finding where an executable was run from -- a proposal.

Brandon S. Allbery allbery at ncoast.UUCP
Fri May 20 01:20:14 AEST 1988


As quoted from <4527 at hoptoad.uucp> by gnu at hoptoad.uucp (John Gilmore):
+---------------
| If exec() would pass this value to the executed program, say as
| argv[-1], then a program could reliably know its own name, and apply a
| simple transformation to it to find its data files (e.g. for program
| "XXXXXX/foo", its data files are found in "XXXXXX/lib/foo/whatever").
| This works for all values of XXXXXX, whether absolute or relative.
+---------------

...until the program does a chdir(), at which point the program must have
resolved a relative pathname into an absolute one or it won't be able to use
the path any more.

Actually, the biggest problem with this is that by the time the kernel has
the executable, the pathname has been changed to a (dev, ino) pair.  This is
less than useful.  And as far as know, the kernel doesn't keep the pathname
around any longer than necessary (that being namei()).

And what happens if I "ln /usr/lib/uucp/uucico ~/etc/poll"?  (Not that I
advocate doing so, but....)
-- 
	      Brandon S. Allbery, moderator of comp.sources.misc
	{well!hoptoad,uunet!marque,cbosgd,sun!mandrill}!ncoast!allbery
Delphi: ALLBERY						     MCI Mail: BALLBERY



More information about the Comp.unix.wizards mailing list