PERFORCE change 177162 for review
Jonathan Anderson
jona at FreeBSD.org
Wed Apr 21 03:22:18 UTC 2010
http://p4web.freebsd.org/@@177162?ac=10
Change 177162 by jona at 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");
More information about the p4-projects
mailing list