From owner-freebsd-arch@FreeBSD.ORG Sat Sep 7 12:22:17 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BF26FB69 for ; Sat, 7 Sep 2013 12:22:17 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) by mx1.freebsd.org (Postfix) with ESMTP id 7CE382DAF for ; Sat, 7 Sep 2013 12:22:17 +0000 (UTC) Received: from slw by zxy.spb.ru with local (Exim 4.69 (FreeBSD)) (envelope-from ) id 1VIHYr-0001Ug-Lo; Sat, 07 Sep 2013 16:24:21 +0400 Date: Sat, 7 Sep 2013 16:24:21 +0400 From: Slawa Olhovchenkov To: Dag-Erling Sm??rgrav Subject: Re: COMPAT_32BIT oddness in rtld-elf (was: Re: /usr/lib/private) Message-ID: <20130907122421.GA5004@zxy.spb.ru> References: <86zjrut4an.fsf@nine.des.no> <8638pgkg3m.fsf@nine.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8638pgkg3m.fsf@nine.des.no> User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false Cc: freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Sep 2013 12:22:17 -0000 On Sat, Sep 07, 2013 at 01:48:13PM +0200, Dag-Erling Sm??rgrav wrote: > I'm having trouble understanding this code in libexec/rtld-elf/rtld.c: > > static void * > path_enumerate(const char *path, path_enum_proc callback, void *arg) > { > #ifdef COMPAT_32BIT > const char *trans; > #endif > if (path == NULL) > return (NULL); > > path += strspn(path, ":;"); > while (*path != '\0') { > size_t len; > char *res; > > len = strcspn(path, ":;"); > #ifdef COMPAT_32BIT > trans = lm_findn(NULL, path, len); > if (trans) > res = callback(trans, strlen(trans), arg); > else > #endif > res = callback(path, len, arg); > > if (res != NULL) > return (res); > > path += len; > path += strspn(path, ":;"); > } > > return (NULL); > } > > This function is used to traverse paths, such as rtld's built-in search > path, LD_LIBRARY_PATH, an Elf object's rpath, etc. As far as I can > tell, the result of this is that *in the COMPAT_32BIT case only* it is > possible to list one directory as replacing another in libmap.conf. In > other words, we could have this in libmap32.conf: > > /lib /lib32 > /usr/lib /usr/lib32 > /usr/lib/private /usr/lib32/private > > instead of hardcoding a different standard search path in rtld.h. > > What I don't understand is why this functionality is only available in > the COMPAT_32BIT case. It seems universally useful to me. As you planed to touch this, can you build filtering of LD_PRELOAD from one "environment" to another? For example: 1. For working webcam in linux skype his running with LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so (linux library). 2. clicking by link in skype chat do running firefox (native binary), with same LD_PRELOAD. But native binary can't found this library and running failed. Can we sanitize environment if running from linux enviroment to native? Or in some other cases too?