#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
# Some userland consolidation specific lint checks
import platform
import re
import subprocess
import sys
"""An opensolaris.org-specific class to check actions."""
self.description = _(
"checks Userland packages for common content errors")
if path != None:
else:
self.proto_path = None
#
# These lists are used to check if a 32/64-bit binary
# is in a proper 32/64-bit directory.
#
self.pathlist32 = [
"i86",
"sparcv7",
"32",
"i86pc-solaris-64int", # perl path
"sun4-solaris-64int", # perl path
]
self.pathlist64 = [
"amd64",
"sparcv9",
"64",
"i86pc-solaris-64", # perl path
"sun4-solaris-64", # perl path
"i86pc-solaris-thread-multi-64", # perl path
"sun4-solaris-thread-multi-64", # perl path
]
self.runpath_re = [
]
self.runpath_64_re = [
# perl path
# perl path
# ruby path
# ruby path
# GCC path
# GCC path
]
self.lint_paths = {}
"""Initialize the checker with a dictionary of paths, so that we
can do link resolution.
This is copied from the core pkglint code, but should eventually
be made common.
"""
"""Updates a dictionary of { attr: [(fmri, action), ..]}
where attr is the value of that attribute from
actions of a given type atype, in the given
manifest."""
if atype:
else:
continue
continue
# Action attributes must be lists or strings.
if isinstance(v, set):
else:
# construct a set of FMRIs being presented for linting, and
# avoid seeding the reference dictionary with any for which
# we're delivering new packages.
lint_fmris = {}
for m in engine.lint_manifests:
_("Seeding reference action path dictionaries."))
# Only put this manifest into the reference dictionary
# if it's not an older version of the same package.
if not any(
for fmri
):
_("Seeding lint action path dictionaries."))
# we provide a search pattern, to allow users to lint a
# subset of the packages in the lint_repository
_("Seeding local action path dictionaries."))
"""Merges the given src dictionary into the target
dictionary, giving us the target content as it would appear,
were the packages in src to get published to the
repositories that made up target.
We need to only merge packages at the same or successive
version from the src dictionary into the target dictionary.
If the src dictionary contains a package with no version
information, it is assumed to be more recent than the same
package with no version in the target."""
for p in src:
if p not in target:
continue
"""Builds a dictionary of fmri:action entries"""
dic = {}
else:
return dic
# we want to remove entries deemed older than
# src_pfmri from targ_dic.
l = []
target[p] = l
"""Combine path and target to get the real path."""
if frag == '..':
elif frag == '.':
pass
else:
return result
result = None
if type != "exe":
return result
# get the ASLR tag string for this binary
# aslr_tag_string will get stdout; err will get stderr
# No ASLR tag was found; everything must be tagged
_("'%s' is not tagged for aslr") % (path),
return result
# look for "ENABLE" anywhere in the string;
# warn about binaries which are not ASLR enabled
return result
_("'%s' does not have aslr enabled") % (path),
return result
result = None
list = []
continue
break
# Make sure RUNPATH matches against a packaged path.
# Don't check runpaths starting with $ORIGIN, which
# is specially handled by the linker.
# 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.
# If still no match, if the runpath contains
# an embedded symlink, emit a warning; it may or may
# not resolve to a legitimate path.
# Otherwise, runpath is bad; add it to list.
while pdir != '':
_("runpath '%s' in '%s' not found in reference paths but contains symlink at '%s'") % (dir, path, pdir),
break
if not embedded_link:
if bits == 32:
else:
break
result = _("bad RUNPATH, '%%s' includes '%s'" %
return result
result = None
# Walk through the path elements backward and at the first
# 32/64 bit specific element, flag it and break.
for p in elems[::-1]:
if (p in self.pathlist32):
break
if (p in self.pathlist64):
break
# ignore 64-bit executables in normal (non-32-bit-specific)
# locations, that's ok now.
return result
result = _("64-bit object '%s' in 32-bit path")
return result
"""Checks for existence in the proto area."""
return
# check for writable files without a preserve attribute
_("%(path)s is writable (%(mode)s), but missing a preserve"
else:
# checks that require a physical file to look at
if self.proto_path is not None:
break
_("%s missing from proto area, skipping"
" content checks") % path,
# 32/64 bit in wrong place
if result != None:
if result != None:
"""Checks for link resolution."""
return
# Check against the target image (ref_paths), since links might
# resolve outside the packages delivering a particular
# component.
# links to files should directly match a patch in the reference
# repo.
return
# If it didn't match a path in the reference repo, it may still
# be a link to a directory that has no action because it uses
# the default attributes. Look for a path that starts with
# this value plus a trailing slash to be sure this it will be
# resolvable on a fully installed system.
realtarget += '/'
return
"""Checks for SVR4 startup scripts."""
return
_("SVR4 startup '%s', deliver SMF"
" service instead") % path,
init_script.pkglint_desc = _(
"SVR4 startup scripts should not be delivered.")
"""An opensolaris.org-specific class to check manifests."""
manifest_paths = []
break
return
break
if 'org.opensolaris.arc-caseid' not in manifest:
"license actions and ARC information are required if you deliver files.")
"Publishers mentioned in package FMRIs must be in fixed set.")
# CFFI names the modules it creates with a hash that includes the
# version of CFFI (since the schema may change from one version to
# another). This means that if a package depends on CFFI, then it must
# also incorporate the version it builds with, which should be the
# version in the gate.
cffi_require = None
cffi_incorp = None
if not any(
f
continue
try:
import cffi
except ImportError:
cffi_version = None
if not cffi_require:
return
if not cffi_version:
"cannot determine the version of CFFI needed") %
if not cffi_incorp:
"does not incorporate it (should be at %(should)s)")
# The final check can only be done if neither of the previous
# checks have fired.
if not cffi_version or not cffi_incorp:
return
if cffi_incorp_ver != cffi_version:
"incorporates it at the wrong version (%(actual)s "
uses_cffi.pkglint_desc = _(
"Packages using CFFI incorporate CFFI at the correct version.")