18202547 memcached lib comes with erroneous RPATH and RUNPATH s11-update
authorApril Chin <april.chin@oracle.com>
Thu, 06 Mar 2014 15:09:47 -0800
branchs11-update
changeset 2977 ad3b1b35e66d
parent 2975 633de78fc886
child 2978 59a50dbb2a15
18202547 memcached lib comes with erroneous RPATH and RUNPATH 18253985 pkglint should check for non-existent RUNPATH directories
components/memcached/Makefile
tools/python/pkglint/userland.py
--- a/components/memcached/Makefile	Tue Mar 04 15:26:51 2014 -0800
+++ b/components/memcached/Makefile	Thu Mar 06 15:09:47 2014 -0800
@@ -51,7 +51,13 @@
 CFLAGS += -D__ATTRIBUTE_DISABLED
 
 CONFIGURE_BINDIR.64 =	$(CONFIGURE_PREFIX)/lib/$(MACH64)
-CONFIGURE_OPTIONS.64 +=	--with-libevent=/usr/lib/${MACH64}
+CONFIGURE_OPTIONS.64 +=	--with-libevent=/usr/lib/$(MACH64)
+# The below works around a bug in configure/configure.ac that sets
+# an incorrect runpath.
+# Setting ac_cv_libevent bypasses libevent checks in configure,
+# including setting the runpath (-R), which is currently ok
+# because libevent is in a default library directory.
+CONFIGURE_OPTIONS.64 +=	"ac_cv_libevent_dir=/usr/lib/$(MACH64)"
 CONFIGURE_OPTIONS +=	--enable-dtrace --disable-docs --disable-coverage
 CONFIGURE_OPTIONS +=	--localstatedir=/var
 CONFIGURE_OPTIONS +=	CFLAGS="$(CFLAGS)"
--- a/tools/python/pkglint/userland.py	Tue Mar 04 15:26:51 2014 -0800
+++ b/tools/python/pkglint/userland.py	Thu Mar 06 15:09:47 2014 -0800
@@ -273,6 +273,45 @@
 
 			if match == False:
 				list.append(dir)
+			# Make sure RUNPATH matches against a packaged path.
+			# Don't check runpaths starting with $ORIGIN, which
+			# is specially handled by the linker.
+
+			elif not dir.startswith('$ORIGIN/'):
+
+			# Strip out leading and trailing '/' in the 
+			# runpath, since the reference paths don't start 
+			# with '/' and trailing '/' could cause mismatches.
+			# Check first if there is an exact match, then check
+			# if any reference path starts with this runpath
+			# plus a trailing slash, since it may still be a link
+			# to a directory that has no action because it uses
+			# the default attributes.
+
+				relative_dir = dir.strip('/')
+				if not relative_dir in self.ref_paths and \
+				    not any(key.startswith(relative_dir + '/')
+				        for key in self.ref_paths):
+
+			# If still no match, if the runpath contains
+			# an embedded symlink, emit a warning; it may or may
+			# not resolve to a legitimate path.
+			# E.g., for usr/openwin/lib, usr/openwin->X11 and
+			# usr/X11/lib are packaged, but usr/openwin/lib is not.
+			# Otherwise, runpath is bad; add it to list.
+					embedded_link = False
+					pdir = os.path.dirname(relative_dir)
+					while pdir != '':
+						if (pdir in self.ref_paths and 
+						    self.ref_paths[pdir][0][1].name == "link"):
+							embedded_link = True
+							engine.warning(
+								_("runpath '%s' in '%s' not found in reference paths but contains symlink at '%s'") % (dir, path, pdir),
+								msgid="%s%s.3" % (self.name, "001"))
+							break
+						pdir = os.path.dirname(pdir)
+					if not embedded_link:
+						list.append(dir)
 
 			if bits == 32:
 				for expr in self.runpath_64_re: