Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Apr 2010 03:22:18 GMT
From:      Jonathan Anderson <jona@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 177162 for review
Message-ID:  <201004210322.o3L3MIPD032067@repoman.freebsd.org>

index | next in thread | raw e-mail

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");
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004210322.o3L3MIPD032067>