PERFORCE change 163661 for review
Robert Watson
rwatson at FreeBSD.org
Sat Jun 6 20:07:07 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163661
Change 163661 by rwatson at rwatson_freebsd_capabilities on 2009/06/06 20:06:37
Expand coverage of !IN_RTLD_CAP sections -- things we don't need
to do in capability mode, such as library path processing.
Affected files ...
.. //depot/projects/trustedbsd/capabilities/src/libexec/rtld-elf/rtld.c#12 edit
Differences ...
==== //depot/projects/trustedbsd/capabilities/src/libexec/rtld-elf/rtld.c#12 (text+ko) ====
@@ -92,9 +92,9 @@
static bool donelist_check(DoneList *, const Obj_Entry *);
static void errmsg_restore(char *);
static char *errmsg_save(void);
+#ifndef IN_RTLD_CAP
static void *fill_search_info(const char *, size_t, void *);
static char *find_library(const char *, const Obj_Entry *);
-#ifndef IN_RTLD_CAP
static const char *gethints(void);
#endif
static void init_dag(Obj_Entry *);
@@ -118,12 +118,16 @@
static void objlist_push_tail(Objlist *, Obj_Entry *);
static void objlist_remove(Objlist *, Obj_Entry *);
static void objlist_remove_unref(Objlist *);
+#ifndef IN_RTLD_CAP
static void *path_enumerate(const char *, path_enum_proc, void *);
+#endif
static int relocate_objects(Obj_Entry *, bool, Obj_Entry *);
static int rtld_dirname(const char *, char *);
static int rtld_dirname_abs(const char *, char *);
static void rtld_exit(void);
+#ifndef IN_RTLD_CAP
static char *search_library_path(const char *, const char *);
+#endif
static const void **get_program_var_addr(const char *);
static void set_program_var(const char *, const void *);
static const Elf_Sym *symlook_default(const char *, unsigned long,
@@ -1153,6 +1157,7 @@
* ldconfig hints
* /lib:/usr/lib
*/
+#ifndef IN_RTLD_CAP
static char *
find_library(const char *xname, const Obj_Entry *refobj)
{
@@ -1160,35 +1165,27 @@
char *name;
if (strchr(xname, '/') != NULL) { /* Hard coded pathname */
-#ifndef IN_RTLD_CAP
if (xname[0] != '/' && !trust) {
-#endif
_rtld_error("Absolute pathname required for shared object \"%s\"",
xname);
return NULL;
-#ifndef IN_RTLD_CAP
}
if (refobj != NULL && refobj->z_origin)
return origin_subst(xname, refobj->origin_path);
else
return xstrdup(xname);
-#endif
}
-#ifndef IN_RTLD_CAP
if (libmap_disable || (refobj == NULL) ||
(name = lm_find(refobj->path, xname)) == NULL)
name = (char *)xname;
-#endif
dbg(" Searching for \"%s\"", name);
if ((pathname = search_library_path(name, ld_library_path)) != NULL ||
(refobj != NULL &&
(pathname = search_library_path(name, refobj->rpath)) != NULL) ||
-#ifndef IN_RTLD_CAP
(pathname = search_library_path(name, gethints())) != NULL ||
-#endif
(pathname = search_library_path(name, STANDARD_LIBRARY_PATH)) != NULL)
return pathname;
@@ -1200,6 +1197,7 @@
}
return NULL;
}
+#endif
/*
* Given a symbol number in a referencing object, find the corresponding
@@ -1537,9 +1535,17 @@
if (object_match_name(obj, name))
return obj;
+#ifdef IN_RTLD_CAP
+ if (strchr(name, '/') != NULL) {
+ _rtld_error("Paths to shared objects not supported \"%s\"", name);
+ return NULL;
+ }
+ path = xstrdup(name);
+#else
path = find_library(name, refobj);
if (path == NULL)
return NULL;
+#endif
/*
* If we didn't find a match by pathname, open the file and check
@@ -1872,6 +1878,7 @@
wlock_release(rtld_bind_lock, lockstate);
}
+#ifndef IN_RTLD_CAP
static void *
path_enumerate(const char *path, path_enum_proc callback, void *arg)
{
@@ -1959,6 +1966,7 @@
return (p);
}
+#endif
int
dlclose(void *handle)
@@ -2389,6 +2397,7 @@
char *strspace;
};
+#ifndef IN_RTLD_CAP
static void *
fill_search_info(const char *dir, size_t dirlen, void *param)
{
@@ -2415,24 +2424,26 @@
return (NULL);
}
+#endif
static int
do_search_info(const Obj_Entry *obj, int request, struct dl_serinfo *info)
{
struct dl_serinfo _info;
+#ifndef IN_RTLD_CAP
struct fill_search_info_args args;
args.request = RTLD_DI_SERINFOSIZE;
args.serinfo = &_info;
+#endif
_info.dls_size = __offsetof(struct dl_serinfo, dls_serpath);
_info.dls_cnt = 0;
+#ifndef IN_RTLD_CAP
path_enumerate(ld_library_path, fill_search_info, &args);
path_enumerate(obj->rpath, fill_search_info, &args);
-#ifndef IN_RTLD_CAP
path_enumerate(gethints(), fill_search_info, &args);
-#endif
path_enumerate(STANDARD_LIBRARY_PATH, fill_search_info, &args);
@@ -2441,12 +2452,14 @@
info->dls_cnt = _info.dls_cnt;
return (0);
}
+#endif
if (info->dls_cnt != _info.dls_cnt || info->dls_size != _info.dls_size) {
_rtld_error("Uninitialized Dl_serinfo struct passed to dlinfo()");
return (-1);
}
+#ifndef IN_RTLD_CAP
args.request = RTLD_DI_SERINFO;
args.serinfo = info;
args.serpath = &info->dls_serpath[0];
@@ -2460,15 +2473,14 @@
if (path_enumerate(obj->rpath, fill_search_info, &args) != NULL)
return (-1);
-#ifndef IN_RTLD_CAP
args.flags = LA_SER_CONFIG;
if (path_enumerate(gethints(), fill_search_info, &args) != NULL)
return (-1);
-#endif
args.flags = LA_SER_DEFAULT;
if (path_enumerate(STANDARD_LIBRARY_PATH, fill_search_info, &args) != NULL)
return (-1);
+#endif
return (0);
}
More information about the p4-projects
mailing list