userland.py revision 2541
45N/A# The contents of this file are subject to the terms of the 45N/A# Common Development and Distribution License (the "License"). 45N/A# You may not use this file except in compliance with the License. 45N/A# See the License for the specific language governing permissions 45N/A# and limitations under the License. 45N/A# When distributing Covered Code, include this CDDL HEADER in each 45N/A# If applicable, add the following below this CDDL HEADER, with the 45N/A# fields enclosed by brackets "[]" replaced with your own identifying 45N/A# information: Portions Copyright [yyyy] [name of copyright owner] 84N/A# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 45N/A# Some userland consolidation specific lint checks 45N/A """An opensolaris.org-specific class to check actions.""" 117N/A "checks Userland packages for common content errors")
45N/A # These lists are used to check if a 32/64-bit binary 45N/A # is in a proper 32/64-bit directory. 84N/A "i86pc-solaris-64int",
# perl path 84N/A "sun4-solaris-64int",
# perl path 84N/A "i86pc-solaris-64",
# perl path 84N/A "sun4-solaris-64",
# perl path 84N/A """Initialize the checker with a dictionary of paths, so that we 84N/A can do link resolution. 84N/A This is copied from the core pkglint code, but should eventually 84N/A """Updates a dictionary of { attr: [(fmri, action), ..]} 168N/A where attr is the value of that attribute from 168N/A actions of a given type atype, in the given 84N/A # construct a set of FMRIs being presented for linting, and 84N/A # avoid seeding the reference dictionary with any for which 84N/A # we're delivering new packages. 145N/A _(
"Seeding reference action path dictionaries."))
145N/A # Only put this manifest into the reference dictionary 145N/A # if it's not an older version of the same package. 84N/A _(
"Seeding lint action path dictionaries."))
84N/A # we provide a search pattern, to allow users to lint a 84N/A # subset of the packages in the lint_repository 84N/A _(
"Seeding local action path dictionaries."))
84N/A """Merges the given src dictionary into the target 84N/A dictionary, giving us the target content as it would appear, 84N/A were the packages in src to get published to the 84N/A repositories that made up target. 84N/A We need to only merge packages at the same or successive 84N/A version from the src dictionary into the target dictionary. 84N/A If the src dictionary contains a package with no version 84N/A information, it is assumed to be more recent than the same 84N/A package with no version in the target.""" 84N/A """Builds a dictionary of fmri:action entries""" 84N/A # we want to remove entries deemed older than 84N/A # src_pfmri from targ_dic. 45N/A """Combine path and target to get the real path.""" 84N/A # 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),
# look for "ENABLE" anywhere in the string; # warn about binaries which are not ASLR enabled _(
"'%s' does not have aslr enabled") % (
path),
# 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. _(
"runpath '%s' in '%s' not found in reference paths but contains symlink at '%s'") % (
dir,
path,
pdir),
_(
"64-bit runpath in 32-bit binary, '%s' includes '%s'") % (
path,
dir),
_(
"32-bit runpath in 64-bit binary, '%s' includes '%s'") % (
path,
dir),
result = _(
"bad RUNPATH, '%%s' includes '%s'" %
# ignore 64-bit executables in normal (non-32-bit-specific) # locations, that's ok now. result = _(
"32-bit object '%s' in 64-bit path")
result = _(
"64-bit object '%s' in 32-bit path")
"""Checks for existence in the proto area.""" # check for writable files without a preserve attribute _(
"%(path)s is writable (%(mode)s), but missing a preserve" " attribute") % {
"path":
path,
"mode":
mode},
_(
"%(path)s has a preserve action, but is not writable (%(mode)s)") % {
"path":
path,
"mode":
mode},
_(
"%(path)s has a preserve action, but no mode") % {
"path":
path,
"mode":
mode},
# checks that require a physical file to look at _(
"%s missing from proto area, skipping" " content checks") %
path,
# 32/64 bit in wrong place """Checks for link resolution.""" # Check against the target image (ref_paths), since links might # resolve outside the packages delivering a particular # links to files should directly match a patch in the reference # 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. """Checks for SVR4 startup scripts.""" if action.
name not in [
"file",
"dir",
"link",
"hardlink"]:
_(
"SVR4 startup '%s', deliver SMF" " service instead") %
path,
"SVR4 startup scripts should not be delivered.")
"""An opensolaris.org-specific class to check manifests.""" name =
"userland.manifest" if 'org.opensolaris.arc-caseid' not in manifest:
engine.
error( _(
"missing ARC data (org.opensolaris.arc-caseid)"),
"license actions and ARC information are required if you deliver files.")