userland.py revision 2337
#
# 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 re
import subprocess
"""An opensolaris.org-specific class to check actions."""
name = "userland.action"
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
]
self.runpath_re = [
]
self.runpath_64_re = [
]
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
# 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
if bits == 32:
else:
break
result = _("bad RUNPATH, '%%s' includes '%s'" %
return result
result = None
for p in self.pathlist64:
if (p in elems):
for p in self.pathlist32:
if (p in elems):
# ignore 64-bit executables in normal (non-32-bit-specific)
# locations, that's ok now.
return result
result = _("32-bit object '%s' in 64-bit path")
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."""
name = "userland.manifest"
manifest_paths = []
break
return
break
if 'org.opensolaris.arc-caseid' not in manifest:
"license actions and ARC information are required if you deliver files.")