Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Apr 2010 14:43:28 GMT
From:      Jonathan Anderson <jona@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 177354 for review
Message-ID:  <201004261443.o3QEhSL3032873@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@177354?ac=10

Change 177354 by jona@jona-belle-freebsd8 on 2010/04/26 14:42:36

	Allow objects to be loaded by FD number instead of name

Affected files ...

.. //depot/projects/trustedbsd/capabilities/src/libexec/rtld-elf/rtld.c#43 edit

Differences ...

==== //depot/projects/trustedbsd/capabilities/src/libexec/rtld-elf/rtld.c#43 (text+ko) ====

@@ -1703,17 +1703,22 @@
 	    return obj;
 
 #ifdef IN_RTLD_CAP
-    if (strchr(name, '/') != NULL) {
-	_rtld_error("Absolute paths to shared objects not supported \"%s\"", name);
-	return NULL;
-    }
+    path = xstrdup(name);
 
     /* 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);
+    long long long_fd = strtonum(path, 0, __INT_MAX, NULL);
+    if ((long_fd >= 0) && (fstat((int) long_fd, &sb) == 0))
+	fd = (int) long_fd;
+
+    /* if not, search the library path */
+    else {
+	dbg("preload by name: %s", name);
+	if (strchr(name, '/') != NULL) {
+	    _rtld_error("Absolute paths (e.g. \"%s\") not supported", path);
+	    free(path);
+	    return NULL;
+	}
+
 	if ((fd = find_library_fd(path)) < 0) {
 	    _rtld_error("Unable to find \"%s\" in LD_LIBRARY_DIRS", path);
 	    free(path);
@@ -1791,7 +1796,7 @@
     if (dangerous_ld_env) {
 	if (fstatfs(fd, &fs) != 0) {
 	    _rtld_error("Cannot fstatfs \"%s\"", path);
-		return NULL;
+	    return NULL;
 	}
 	if (fs.f_flags & MNT_NOEXEC) {
 	    _rtld_error("Cannot execute objects on %s\n", fs.f_mntonname);



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