Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Shared Libraries for internal use by packages don't necessarily have to be called 'libsomething.so.N' -- when searching for shlibs on RPATH or RUNPATH, accept anything ending in .so or .so.N
Matthew Seaman committed 13 years ago
commit 9388e83f84c0b9a13d45efa3628dcc2cefcf9d3d
parent 5e7f8eb
2 files changed +26 -9
modified libpkg/elfhints.c
@@ -59,7 +59,8 @@ struct shlib_list {
static int	shlib_list_add(struct shlib_list **shlib_list,
				const char *dir, const char *shlib_file);
static int	scan_dirs_for_shlibs(struct shlib_list **shlib_list,
-
				     int numdirs, const char **dirlist);
+
				     int numdirs, const char **dirlist,
+
	                             bool strictnames);
static void	add_dir(const char *, const char *, int);
static void	read_dirs_from_file(const char *, const char *);
static void	read_elf_hints(const char *, int);
@@ -200,10 +201,19 @@ add_dir(const char *hintsfile, const char *name, int trusted)

static int
scan_dirs_for_shlibs(struct shlib_list **shlib_list, int numdirs,
-
    const char **dirlist)
+
		     const char **dirlist, bool strictnames)
{
	int	i;

+
	/* Expect shlibs to follow the name pattern libfoo.so.N if
+
	   strictnames is true -- ie. when searching the default
+
	   library search path.
+

+
	   Otherwise, allow any name ending in .so or .so.N --
+
	   ie. when searching RPATH or RUNPATH and assuming it
+
	   contains private shared libraries which can follow just
+
	   about any naming convention */
+

	for (i = 0;  i < numdirs;  i++) {
		DIR		*dirp;
		struct dirent	*dp;
@@ -219,10 +229,14 @@ scan_dirs_for_shlibs(struct shlib_list **shlib_list, int numdirs,
			if (dp->d_type != DT_REG && dp->d_type != DT_LNK)
				continue;

-
			/* Name can't be shorter than "libx.so" */
-
			if ((len = strlen(dp->d_name)) < 7 ||
-
			    strncmp(dp->d_name, "lib", 3) != 0)
-
				continue;
+
			len = strlen(dp->d_name);
+
			if (strictnames) {
+
				/* Name can't be shorter than "libx.so" */
+
				if (len < 7 ||
+
				    strncmp(dp->d_name, "lib", 3) != 0)
+
					continue;
+
			}
+

			vers = dp->d_name + len;
			while (vers > dp->d_name &&
			       (isdigit(*(vers-1)) || *(vers-1) == '.'))
@@ -294,7 +308,7 @@ int shlib_list_from_rpath(const char *rpath_str, const char *dirpath)

	assert(i <= numdirs);

-
	ret = scan_dirs_for_shlibs(&rpath, i, dirlist);
+
	ret = scan_dirs_for_shlibs(&rpath, i, dirlist, false);

	free(dirlist);

@@ -306,7 +320,7 @@ shlib_list_from_elf_hints(const char *hintsfile)
{
	read_elf_hints(hintsfile, 1);

-
	return (scan_dirs_for_shlibs(&shlibs, ndirs, dirs));
+
	return (scan_dirs_for_shlibs(&shlibs, ndirs, dirs, true));
}

void
modified libpkg/pkg_elf.c
@@ -192,7 +192,10 @@ warn_about_name_format(struct pkg *pkg, const char *fpath, const char *shlib)
	/* Shlib names in NEEDED records in the Dynamic section of an
           ELF object are expected to look like libfoo.so.N where the
           ABI version N is an integer or libfoo.so without ABI
-
           version at all. */
+
           version at all.  Well, actually, this should probably only
+
           apply to shlibs which are publicly available.  shlibs for
+
           the private use of some package can have whatever naming
+
           convention they want.  So this is a bit too strict. */

	len = strlen(shlib);
	if (len < 9)		/* libx.so.0 */