[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200612271603.39454.rob@landley.net>
Date: Wed, 27 Dec 2006 16:03:38 -0500
From: Rob Landley <rob@...dley.net>
To: Denis Vlasenko <vda.linux@...glemail.com>
Cc: ray-gmail@...rabbit.org, linux-kernel@...r.kernel.org,
"David McCullough" <david_mccullough@...securecomputing.com>
Subject: Re: Feature request: exec self for NOMMU.
On Wednesday 27 December 2006 1:35 pm, Denis Vlasenko wrote:
> This solves chroot problem. How to find path-to-yourself reliably
> (for one, without using /proc/self/exe) is not obvious to me.
Been there, done that. Both my toybox and Firmware Linux projects do this.
In FWL it's line 115 of this file:
http://landley.net/hg/firmware?f=937346748ff4;file=sources/toys/gcc-uClibc.c
It's essentially the logic of the command line "which" utility applied to
argv[0]. If argv[0] has a relative or absolute path, then it's vs cwd (this
has to happen when you first run the program, before you cd). If argv[0] has
no path then look at $PATH.
Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists