From owner-p4-projects@FreeBSD.ORG Wed Apr 21 03:22:18 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 98D1B1065675; Wed, 21 Apr 2010 03:22:18 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41993106566C for ; Wed, 21 Apr 2010 03:22:18 +0000 (UTC) (envelope-from jona@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2FD818FC1E for ; Wed, 21 Apr 2010 03:22:18 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o3L3MI86032069 for ; Wed, 21 Apr 2010 03:22:18 GMT (envelope-from jona@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o3L3MIPD032067 for perforce@freebsd.org; Wed, 21 Apr 2010 03:22:18 GMT (envelope-from jona@FreeBSD.org) Date: Wed, 21 Apr 2010 03:22:18 GMT Message-Id: <201004210322.o3L3MIPD032067@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jona@FreeBSD.org using -f From: Jonathan Anderson To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 177162 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Apr 2010 03:22:18 -0000 http://p4web.freebsd.org/@@177162?ac=10 Change 177162 by jona@jona-belle-freebsd8 on 2010/04/21 03:21:33 Allow libraries to be named by file descriptor number when in capability mode. Also, moved the initialization of the library_dirs FDArray. Affected files ... .. //depot/projects/trustedbsd/capabilities/src/libexec/rtld-elf/rtld.c#42 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/libexec/rtld-elf/rtld.c#42 (text+ko) ==== @@ -1284,12 +1284,7 @@ int fd, i; int lockstate = fdarray_lock(&library_dirs); - - if (library_dirs.content == NULL) { - fdarray_init(&library_dirs); - init_libdirs(); - } - + if (library_dirs.content == NULL) init_libdirs(); fdarray_unlock(&library_dirs, lockstate); @@ -1712,11 +1707,18 @@ _rtld_error("Absolute paths to shared objects not supported \"%s\"", name); return NULL; } - path = xstrdup(name); - if ((fd = find_library_fd(path)) < 0) { - _rtld_error("Unable to find \"%s\" in LD_LIBRARY_DIRS", path); - free(path); - return NULL; + + /* is the name actually a file descriptor? */ + long long long_fd = strtonum(name, 0, 10000, NULL); + fd = (int) long_fd; + if (fstat(fd, &sb) == -1) { + /* if not, search the library path */ + path = xstrdup(name); + if ((fd = find_library_fd(path)) < 0) { + _rtld_error("Unable to find \"%s\" in LD_LIBRARY_DIRS", path); + free(path); + return NULL; + } } #else path = find_library(name, refobj); @@ -2216,6 +2218,8 @@ static void init_libdirs(void) { + fdarray_init(&library_dirs); + #ifdef IN_RTLD_CAP char *envvar = getenv(LD_ "LIBRARY_DIRS");