Date: Wed, 22 Sep 1999 04:21:34 +0400 From: "Oleg V. Volkov" <rover@lglobus.ru> To: freebsd-questions@freebsd.org Subject: Re: How to find name of binary... Message-ID: <19990922042134.C22892@fly.lglobus.ru> In-Reply-To: <19990921234843.CA27214E02@hub.freebsd.org> References: <19990921234843.CA27214E02@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Sep 21, 1999 at 10:15:32PM +0100, Ben Smithurst wrote: > Alfred Perlstein wrote: > > On Tue, 21 Sep 1999, Oleg V. Volkov wrote: >> Well subject says it all. How could i find absolute name of my running >> binary from inside it? References to man or C examples welcome. > I think some permutation of getcwd(3) and argv[0] should help, perhaps > with lstat (to check if you were run via a symlink) That won't do much if people give the program crap in argv[0], e.g. execlp("foo", "ha ha, fooled you!", "-x", "-y", "z", NULL), will it? There's some about this in some FAQ somewhere (comp.unix.programmer FAQ maybe, I'm not sure), and it basically boils down to "don't do it". I'd like to know what Oleg is doing and why he needs this information. Actually it's not me, i just promised author of UPX (executable compressor), that i will look for this info. UPX' uncompressing stub (for Linux) depends on knowing self name. If there any other way how to let binary read data from itself that's ok too. Just a reminder: CC all replies to me - i'm not on list. -- Oleg V. Volkov aka Rover E-mail: rover@lglobus.ru E-mail redirector: sr-13@mail.ru (always up) -=/ SR 13 /=- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990922042134.C22892>