Skip to content

Commit

Permalink
Merge pull request #479 from citrus-it/merge
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
hadfl authored May 25, 2024
2 parents 38067a0 + 659b200 commit 9ae1aa1
Show file tree
Hide file tree
Showing 298 changed files with 10,048 additions and 9,833 deletions.
6 changes: 3 additions & 3 deletions README.sync
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
The pkg5 components have been updated to the latest upstream solaris-ips
as of:

commit aabf00838e04ed9a266354e598b408dd245773b3
commit c7efe165236d9243c6bc6a9b0abd6042ad9c04a3
Author: Jakub Kulik <[email protected]>
Date: Mon Feb 5 06:41:13 2024 -0800
Date: Thu May 16 02:41:50 2024 -0700

36255456 fix most 'statement' pycodestyle issues
36591165 clean up packaging and pkgdepend bypasses

-----------------------------------------------------------------------------

5 changes: 4 additions & 1 deletion exception_lists/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#

#
# Copyright (c) 2009, 2021, Oracle and/or its affiliates.
# Copyright (c) 2009, 2024, Oracle and/or its affiliates.
#

syntax: glob
Expand All @@ -30,3 +30,6 @@ src/pkg/external_deps.txt
src/tests/bandit-baseline.json
src/tests/baseline.txt
doc/*
src/tests/*.txt
src/po/LINGUAS
src/po/POTFILES.*
14 changes: 8 additions & 6 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ clobber := TARGET = clobber
packages := TARGET = install
test := TARGET = test

SUBDIRS=brand util/mkcert
SUBDIRS=brand util/mkcert po

all: build $(SUBDIRS)

Expand All @@ -68,14 +68,16 @@ fmt: FRC
python$(PYVER) -mpip install --quiet --user --upgrade black
$(HOME)/.local/bin/black --config $(CODE_WS)/.black $(CODE_WS)/src

bandit: FRC
_bandit: FRC
python$(PYVER) -mpip install --quiet --user --upgrade bandit

check: bandit
python$(PYVER) setup.py bandit
check: _bandit
python$(PYVER) -m bandit -r -q -c tests/banditrc . \
-b tests/bandit-baseline.json

baseline: bandit
-python$(PYVER) setup.py bandit -g
baseline: _bandit
python$(PYVER) -m bandit -r -q -c tests/banditrc . \
-o tests/bandit-baseline.json -f json || true

$(SUBDIRS) cffi_src: FRC
@cd $@; pwd; $(MAKE) $(TARGET) CC=$(CC)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __str__(self):

# This must be imported *after* all of the exception classes are defined as
# _actions module init needs the exception objects.
from ._actions import fromstr
from pkg.actions._actions import fromstr


def attrsfromstr(string):
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
attribute of a package (package metadata). Attributes are typed, and the
possible types are: XXX."""

from . import generic
from pkg.actions import generic
import pkg.fmri
import pkg.actions

Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/depend.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
relationship between the package containing the action and another package.
"""

from . import generic
from pkg.actions import generic
import re

import pkg.actions
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
directory-type packaging object."""

import errno
from . import generic
from pkg.actions import generic
import os
import pkg.portable as portable
import pkg.actions
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"""

import os
from . import generic
from pkg.actions import generic

from tempfile import mkstemp

Expand Down
4 changes: 2 additions & 2 deletions src/modules/actions/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
packaging object."""

import errno
from . import generic
from pkg.actions import generic
import os
import stat
import tempfile
import types
import zlib
import time

from . import _common
from pkg.actions import _common
import pkg.actions
import pkg.client.api_errors as api_errors
import pkg.digest as digest
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import pkg.portable as portable
import pkg.variant as variant

from . import _common
from pkg.actions import _common
from pkg.misc import EmptyDict, CMP_ALL, CMP_UNSIGNED

# Directories must precede all filesystem object actions; hardlinks must follow
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
packaging object. This contains the attributes necessary to create
a new user."""

from . import generic
from pkg.actions import generic

try:
from pkg.cfgfiles import *
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/hardlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
packaging object."""

import errno
from . import generic, link
from pkg.actions import generic, link
import os
import stat

Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import itertools
import time

from . import generic
from pkg.actions import generic
from pkg import misc


Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import os
from stat import S_IWRITE, S_IREAD

from . import generic
from pkg.actions import generic
import pkg.digest as digest
import pkg.misc as misc
import pkg.portable as portable
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import os
import stat

from . import generic
from pkg.actions import generic
import pkg.actions
import pkg.mediator as med

Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import padding

from . import generic
from pkg.actions import generic
import pkg.actions
import pkg.client.api_errors as apx
import pkg.digest as digest
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/unknown.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
publishing transaction is not given enough information to determine what type of
object it is. No datastreams or attributes aside from a path are stored."""

from . import generic
from pkg.actions import generic


class UnknownAction(generic.Action):
Expand Down
2 changes: 1 addition & 1 deletion src/modules/actions/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
packaging object. This contains the attributes necessary to create
a new user."""

from . import generic
from pkg.actions import generic

try:
from pkg.cfgfiles import *
Expand Down
13 changes: 6 additions & 7 deletions src/modules/cfgfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,12 @@ def getfilelines(self):

def readfile(self):
if os.path.exists(self.filename):
file = open(self.filename, "rb")
file = open(
self.filename, "r", encoding="utf-8", errors="surrogateescape"
)
lineno = 1
for line in file:
linecnt = 1
try:
line = line.decode("utf-8")
except UnicodeDecodeError:
# ignore bad utf-8 lines
continue

while self.continuation_lines and line[-2:] == "\\\n":
linecnt += 1
Expand Down Expand Up @@ -205,7 +202,9 @@ def writefile(self):
st = os.stat(self.filename)

tempdata = tempfile.mkstemp(dir=os.path.dirname(self.filename))
file = os.fdopen(tempdata[0], "w")
file = os.fdopen(
tempdata[0], "w", encoding="utf-8", errors="surrogateescape"
)
name = tempdata[1]

os.chmod(name, st.st_mode)
Expand Down
5 changes: 5 additions & 0 deletions src/modules/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ def __set_be_creation(self):
# installed.
self.__backup_be = self._img.imageplan.reboot_advised()

if self.__new_be and self.__backup_be:
# No policy or CLI arg combiation should result in
# a new BE and an extra backup be.
self.__backup_be = False

def abort(self, result=RESULT_FAILED_UNKNOWN):
"""Indicate that execution was unexpectedly aborted and log
operation failure if possible."""
Expand Down
26 changes: 4 additions & 22 deletions src/modules/client/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import re as relib

from contextlib import contextmanager
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from urllib.parse import quote, unquote

import pkg.actions
Expand Down Expand Up @@ -358,26 +356,9 @@ def trust_anchors(self):
)
self.__trust_anchors = {}
if loc_is_dir:
for fn in os.listdir(trust_anchor_loc):
pth = os.path.join(trust_anchor_loc, fn)
if os.path.islink(pth):
continue
try:
with open(pth, "rb") as f:
raw = f.read()
trusted_ca = x509.load_pem_x509_certificate(
raw, default_backend()
)
except (ValueError, IOError) as e:
self.__bad_trust_anchors.append((pth, str(e)))
else:
# We store certificates internally by
# the SHA-1 hash of its subject.
s = hashlib.sha1(
misc.force_bytes(trusted_ca.subject)
).hexdigest()
self.__trust_anchors.setdefault(s, [])
self.__trust_anchors[s].append(trusted_ca)
misc.load_trust_anchors(
trust_anchor_loc, self.__trust_anchors, self.__bad_trust_anchors
)
for s in pkg_trust_anchors:
if s not in self.__trust_anchors:
self.__trust_anchors[s] = pkg_trust_anchors[s]
Expand Down Expand Up @@ -2638,6 +2619,7 @@ def __get_manifest(self, fmri, excludes=EmptyI, intent=None, alt_pub=None):
alt_repo = None
if alt_pub:
alt_repo = alt_pub.repository

try:
self.transport.touch_manifest(
fmri, intent, alt_repo=alt_repo
Expand Down
4 changes: 2 additions & 2 deletions src/modules/client/linkedimage/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#

#
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2024, Oracle and/or its affiliates.
#

"""
Expand All @@ -34,7 +34,7 @@
import pkg.client.pkgdefs as pkgdefs

# import linked image common code
from . import common as li # Relative import; pylint: disable=W0403
from pkg.client.linkedimage import common as li


class LinkedImageSystemPlugin(li.LinkedImagePlugin):
Expand Down
6 changes: 1 addition & 5 deletions src/modules/client/linkedimage/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
from pkg.client.debugvalues import DebugValues

# import linked image common code
from . import common as li # Relative import; pylint: disable=W0403

# W0511 XXX / FIXME Comments; pylint: disable=W0511
# XXX: should be defined by libzonecfg python wrapper
# pylint: enable=W0511
from pkg.client.linkedimage import common as li

ZONE_GLOBAL = "global"

Expand Down
Loading

0 comments on commit 9ae1aa1

Please sign in to comment.