Mike Sullivan
2011-12-14 048c871baff67e3ddca657d2dc394dc927858fbe
7109831 userland pkglint should audit runpaths
4 files modified
38 ■■■■■ changed files
components/Makefile 9 ●●●● patch | view | raw | blame | history
components/gnuplot/Makefile 1 ●●●● patch | view | raw | blame | history
components/graphviz/Makefile 1 ●●●● patch | view | raw | blame | history
tools/python/pkglint/userland.py 27 ●●●●● patch | view | raw | blame | history
components/Makefile
@@ -61,7 +61,9 @@
prep build install publish test:    LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
# turn off pkglint for the individual component builds.
ifeq   ($(strip $(PKGLINT_COMPONENT)),)
publish:        MAKEFLAGS += PKGLINT=/bin/true
endif
.DEFAULT:    publish
@@ -86,10 +88,15 @@
    $(PKGREPO) create $(PKG_REPO)
    $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
DUMMYPKG =  "set name=fmri value=pkg:/dummy@0,$(BUILD_VERSION)\n"
DUMMYPKG += "set pkg.summary=dummy\n"
DUMMYPKG += "set org.opensolaris.consolidation=userland\n"
DUMMYPKG += "set info.classification=org.opensolaris.category.2008:System/Core"
$(WS_LINT_CACHE):    $(WS_LOGS)
ifdef CANONICAL_REPO
    @echo "Generating pkglint(1) cache from $(CANONICAL_REPO)..."
    @(echo "set name=fmri value=pkg:/dummy@0,$(BUILD_VERSION)" | $(PKGLINT) \
    @(echo $(DUMMYPKG) | $(PKGLINT) \
        -c $(WS_LINT_CACHE) -r $(CANONICAL_REPO) /dev/fd/0 \
        >$(WS_LOGS)/naughty-canonical-repo-actions 2>&1 ; exit 0)
else
components/gnuplot/Makefile
@@ -44,6 +44,7 @@
CONFIGURE_OPTIONS  += --libexecdir=$(CONFIGURE_LIBDIR.$(BITS))
CONFIGURE_OPTIONS  += --sysconfdir=/etc/gnu
CONFIGURE_OPTIONS  += --infodir=$(CONFIGURE_INFODIR)
CONFIGURE_OPTIONS  += --x-libraries=$(CONFIGURE_LIBDIR.$(BITS))
CONFIGURE_OPTIONS  += CFLAGS="$(CFLAGS)"
CONFIGURE_OPTIONS  += CXXFLAGS="$(CXXFLAGS)"
components/graphviz/Makefile
@@ -55,6 +55,7 @@
CONFIGURE_OPTIONS +=    --without-included-ltdl
CONFIGURE_OPTIONS +=    --enable-python=no
CONFIGURE_OPTIONS +=    --enable-python26=yes
CONFIGURE_OPTIONS +=    --x-libraries=$(CONFIGURE_LIBDIR.$(BITS))
COMPONENT_BUILD_ARGS +=     GREP=/usr/bin/ggrep
tools/python/pkglint/userland.py
@@ -50,6 +50,11 @@
            re.compile('^/usr/'),
            re.compile('^\$ORIGIN/')
        ]
        self.runpath_64_re = [
            re.compile('^.*/64(/.*)?$'),
            re.compile('^.*/amd64(/.*)?$'),
            re.compile('^.*/sparcv9(/.*)?$')
        ]
        self.initscript_re = re.compile("^etc/(rc.|init)\.d")
                self.lint_paths = {}
@@ -195,11 +200,13 @@
        return result
    def __elf_runpath_check(self, path):
    def __elf_runpath_check(self, path, engine):
        result = None
        list = []
        ed = elf.get_dynamic(path)
        ei = elf.get_info(path)
        bits = ei.get("bits")
        for dir in ed.get("runpath", "").split(":"):
            if dir == None or dir == '':
                continue
@@ -213,6 +220,22 @@
            if match == False:
                list.append(dir)
            if bits == 32:
                for expr in self.runpath_64_re:
                    if expr.search(dir):
                        engine.warning(
                            _("64-bit runpath in 32-bit binary, '%s' includes '%s'") % (path, dir),
                            msgid="%s%s.3" % (self.name, "001"))
            else:
                match = False
                for expr in self.runpath_64_re:
                    if expr.search(dir):
                        match = True
                        break
                if match == False:
                    engine.warning(
                        _("32-bit runpath in 64-bit binary, '%s' includes '%s'") % (path, dir),
                        msgid="%s%s.3" % (self.name, "001"))
        if len(list) > 0:
            result = _("bad RUNPATH, '%%s' includes '%s'" %
                   ":".join(list))
@@ -298,7 +321,7 @@
                if result != None:
                    engine.error(result % path, 
                        msgid="%s%s.2" % (self.name, pkglint_id))
                result = self.__elf_runpath_check(fullpath)
                result = self.__elf_runpath_check(fullpath, engine)
                if result != None:
                    engine.error(result % path, 
                        msgid="%s%s.3" % (self.name, pkglint_id))