Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only check minimum permissions on catalogue files #469

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modules/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __str__(self):
"unknown action type '{type}' in package "
"'{fmri}' in action '{action}'"
).format(type=self.type, fmri=self.fmri, action=self.actionstr)
return _("unknown action type '{type}' in action " "'{action}'").format(
return _("unknown action type '{type}' in action '{action}'").format(
type=self.type, action=self.actionstr
)

Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(self, *args):
def __str__(self):
if hasattr(self, "fmri") and self.fmri is not None:
return _(
"invalid action in package {fmri}: " "{action}: {error}"
"invalid action in package {fmri}: {action}: {error}"
).format(fmri=self.fmri, action=self.actionstr, error=self.errorstr)
return _("invalid action, '{action}': {error}").format(
action=self.actionstr, error=self.errorstr
Expand Down
28 changes: 12 additions & 16 deletions src/modules/actions/depend.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __check_parent_installed(self, image, pkg_fmri, fmri):
errors = []
if fmri.pkg_name not in ppkgs_dict:
errors.append(
_("Package is not installed in " "parent image {0}").format(
_("Package is not installed in parent image {0}").format(
fmri.pkg_name
)
)
Expand All @@ -137,7 +137,7 @@ def __check_parent_installed(self, image, pkg_fmri, fmri):
# package is from a different publisher
errors.append(
_(
"Package in parent is from a " "different publisher: {0}"
"Package in parent is from a different publisher: {0}"
).format(pf)
)
return errors
Expand All @@ -156,15 +156,11 @@ def __check_parent_installed(self, image, pkg_fmri, fmri):

if pf.version.is_successor(fmri.version, pkg.version.CONSTRAINT_NONE):
errors.append(
_("Parent image has a newer " "version of package {0}").format(
pf
)
_("Parent image has a newer version of package {0}").format(pf)
)
else:
errors.append(
_("Parent image has an older " "version of package {0}").format(
pf
)
_("Parent image has an older version of package {0}").format(pf)
)

return errors
Expand All @@ -183,7 +179,7 @@ def __check_installed(
):
errors.append(
_(
"{dep_type} dependency {dep_val} " "is downrev ({inst_ver})"
"{dep_type} dependency {dep_val} is downrev ({inst_ver})"
).format(
dep_type=ctype, dep_val=min_fmri, inst_ver=installed_version
)
Expand All @@ -199,7 +195,7 @@ def __check_installed(
):
errors.append(
_(
"{dep_type} dependency {dep_val} " "is uprev ({inst_ver})"
"{dep_type} dependency {dep_val} is uprev ({inst_ver})"
).format(
dep_type=ctype, dep_val=max_fmri, inst_ver=installed_version
)
Expand Down Expand Up @@ -313,7 +309,7 @@ def __min_version():
if group_stems and not matching_stems:
stems = ", ".join(p for p in group_stems)
errors.append(
_("Group dependency on one of {0} not " "met").format(stems)
_("Group dependency on one of {0} not met").format(stems)
)
return errors, warnings, info
elif ctype == "require-any":
Expand All @@ -328,7 +324,7 @@ def __min_version():
errors.extend(e)
if not errors: # none was installed
errors.append(
_("Required dependency on one of " "{0} not met").format(
_("Required dependency on one of {0} not met").format(
", ".join((str(p) for p in pfmris))
)
)
Expand All @@ -352,7 +348,7 @@ def __min_version():

if required and not installed_version:
errors.append(
_("Required dependency {0} is not " "installed").format(pfmri)
_("Required dependency {0} is not installed").format(pfmri)
)

# cannot verify origin since it applys to upgrade
Expand Down Expand Up @@ -571,9 +567,9 @@ def validate(self, fmri=None):
errors.append(
(
attr,
_(
"invalid {attr} value " "'{value}': {error}"
).format(attr=attr, value=f, error=str(e)),
_("invalid {attr} value '{value}': {error}").format(
attr=attr, value=f, error=str(e)
),
)
)

Expand Down
30 changes: 15 additions & 15 deletions src/modules/actions/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def remove_aliases(driver_name, aliases, image):
args = rem_base + ("-i", "{0}".format(i), driver_name)
DriverAction.__call(
args,
"driver ({name}) upgrade (removal " "of alias '{alias}')",
"driver ({name}) upgrade (removal of alias '{alias}')",
{"name": driver_name, "alias": i},
)

Expand Down Expand Up @@ -368,7 +368,7 @@ def install(self, pkgplan, orig):
)
self.__call(
args,
"driver ({name}) clone permission " "update",
"driver ({name}) clone permission update",
{"name": self.attrs["name"]},
)

Expand Down Expand Up @@ -433,7 +433,7 @@ def __update_install(self, image, orig):
args = add_base + ("-i", "{0}".format(i), self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (addition " "of alias '{alias}')",
"driver ({name}) upgrade (addition of alias '{alias}')",
{"name": self.attrs["name"], "alias": i},
)

Expand Down Expand Up @@ -597,31 +597,31 @@ def update_devlinks():
args = rem_base + ("-m", i, self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (removal " "of minor perm '{perm}')",
"driver ({name}) upgrade (removal of minor perm '{perm}')",
{"name": self.attrs["name"], "perm": i},
)

for i in add_perms:
args = add_base + ("-m", i, self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (addition " "of minor perm '{perm}')",
"driver ({name}) upgrade (addition of minor perm '{perm}')",
{"name": self.attrs["name"], "perm": i},
)

for i in add_privs:
args = add_base + ("-P", i, self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (addition " "of privilege '{priv}')",
"driver ({name}) upgrade (addition of privilege '{priv}')",
{"name": self.attrs["name"], "priv": i},
)

for i in rem_privs:
args = rem_base + ("-P", i, self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (removal " "of privilege '{priv}')",
"driver ({name}) upgrade (removal of privilege '{priv}')",
{"name": self.attrs["name"], "priv": i},
)

Expand Down Expand Up @@ -655,15 +655,15 @@ def update_devlinks():
args = rem_base + ("-p", minornode, self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (removal " "of policy '{policy}')",
"driver ({name}) upgrade (removal of policy '{policy}')",
{"name": self.attrs["name"], "policy": i},
)

for i in add_policy:
args = add_base + ("-p", i, self.attrs["name"])
self.__call(
args,
"driver ({name}) upgrade (addition " "of policy '{policy}')",
"driver ({name}) upgrade (addition of policy '{policy}')",
{"name": self.attrs["name"], "policy": i},
)

Expand Down Expand Up @@ -932,22 +932,22 @@ def verify(self, img, **args):
mfst_aliases = set(self.attrlist("alias"))
for a in onfs_aliases - mfst_aliases:
warnings.append(
_("extra alias '{0}' found in " "etc/driver_aliases").format(a)
_("extra alias '{0}' found in etc/driver_aliases").format(a)
)
for a in mfst_aliases - onfs_aliases:
errors.append(
_("alias '{0}' missing from " "etc/driver_aliases").format(a)
_("alias '{0}' missing from etc/driver_aliases").format(a)
)

onfs_classes = set(onfs.attrlist("class"))
mfst_classes = set(self.attrlist("class"))
for a in onfs_classes - mfst_classes:
warnings.append(
_("extra class '{0}' found in " "etc/driver_classes").format(a)
_("extra class '{0}' found in etc/driver_classes").format(a)
)
for a in mfst_classes - onfs_classes:
errors.append(
_("class '{0}' missing from " "etc/driver_classes").format(a)
_("class '{0}' missing from etc/driver_classes").format(a)
)

onfs_perms = set(onfs.attrlist("perms"))
Expand All @@ -962,7 +962,7 @@ def verify(self, img, **args):
for a in mfst_perms - onfs_perms:
errors.append(
_(
"minor node permission '{0}' missing " "from etc/minor_perm"
"minor node permission '{0}' missing from etc/minor_perm"
).format(a)
)

Expand Down Expand Up @@ -1038,7 +1038,7 @@ def remove(self, pkgplan):
)
self.__call(
args,
"driver ({name}) clone permission " "update",
"driver ({name}) clone permission update",
{"name": self.attrs["name"]},
)

Expand Down
26 changes: 13 additions & 13 deletions src/modules/actions/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def install(self, pkgplan, orig):
except zlib.error as e:
raise ActionExecutionError(
self,
details=_("Error decompressing payload: " "{0}").format(
details=_("Error decompressing payload: {0}").format(
" ".join([str(a) for a in e.args])
),
error=e,
Expand Down Expand Up @@ -398,7 +398,7 @@ def verify(self, img, **args):
!= misc.timestamp_to_time(self.attrs["timestamp"])
):
errors.append(
_("Timestamp: {found} should be " "{expected}").format(
_("Timestamp: {found} should be {expected}").format(
found=misc.time_to_timestamp(lstat.st_mtime),
expected=self.attrs["timestamp"],
)
Expand All @@ -416,7 +416,7 @@ def verify(self, img, **args):
and lstat.st_size != pkg_size
):
errors.append(
_("Size: {found:d} bytes should be " "{expected:d}").format(
_("Size: {found:d} bytes should be {expected:d}").format(
found=lstat.st_size, expected=pkg_size
)
)
Expand Down Expand Up @@ -484,7 +484,7 @@ def verify(self, img, **args):

if elfhash is not None and elf_hash_val != elfhash[0]:
elferror = _(
"ELF content hash: " "{found} " "should be {expected}"
"ELF content hash: {found} should be {expected}"
).format(found=elfhash[0], expected=elf_hash_val)

# Always check on the file hash because the ELF hash
Expand All @@ -496,15 +496,15 @@ def verify(self, img, **args):
if sha_hash != hash_val:
# Prefer the ELF content hash error message.
if preserve is not None:
info.append(_("editable file has " "been changed"))
info.append(_("editable file has been changed"))
elif elferror:
errors.append(elferror)
self.replace_required = True
else:
errors.append(
_(
"Hash: " "{found} should be " "{expected}"
).format(found=sha_hash, expected=hash_val)
_("Hash: {found} should be {expected}").format(
found=sha_hash, expected=hash_val
)
)
self.replace_required = True

Expand Down Expand Up @@ -532,7 +532,7 @@ def verify(self, img, **args):
for a in sattrs:
if a not in set_attrs:
errors.append(
_("System attribute '{0}' " "not set").format(a)
_("System attribute '{0}' not set").format(a)
)

except EnvironmentError as e:
Expand Down Expand Up @@ -1001,28 +1001,28 @@ def validate(self, fmri=None):
errors.append(
(
"preserve-version",
_("preserve-version must specify " "the release"),
_("preserve-version must specify the release"),
)
)
if build_release != "":
errors.append(
(
"preserve-version",
_("preserve-version must specify " "the release"),
_("preserve-version must specify the release"),
)
)
if branch:
errors.append(
(
"preserve-version",
_("preserve-version must not specify " "the branch"),
_("preserve-version must not specify the branch"),
)
)
if timestr:
errors.append(
(
"preserve-version",
_("preserve-version must not specify " "the timestamp"),
_("preserve-version must not specify the timestamp"),
)
)

Expand Down
14 changes: 7 additions & 7 deletions src/modules/actions/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def _validate_fsobj_common(self):
)
)
elif isinstance(raw_mode, list):
errors.append(("mode", _("mode may only be " "specified once")))
errors.append(("mode", _("mode may only be specified once")))
else:
errors.append(
(
Expand All @@ -858,12 +858,12 @@ def _validate_fsobj_common(self):
try:
owner = self.attrs.get("owner", "").rstrip()
except AttributeError:
errors.append(("owner", _("owner may only be specified " "once")))
errors.append(("owner", _("owner may only be specified once")))

try:
group = self.attrs.get("group", "").rstrip()
except AttributeError:
errors.append(("group", _("group may only be specified " "once")))
errors.append(("group", _("group may only be specified once")))

return errors

Expand Down Expand Up @@ -1064,7 +1064,7 @@ def ftype_to_name(ftype):

if ftype is not None and ftype != stat.S_IFMT(lstat.st_mode):
errors.append(
_("file type: '{found}' should be " "'{expected}'").format(
_("file type: '{found}' should be '{expected}'").format(
found=ftype_to_name(stat.S_IFMT(lstat.st_mode)),
expected=ftype_to_name(ftype),
)
Expand Down Expand Up @@ -1101,7 +1101,7 @@ def ftype_to_name(ftype):

if mode is not None and stat.S_IMODE(lstat.st_mode) != mode:
errors.append(
_("mode: {found:04o} should be " "{expected:04o}").format(
_("mode: {found:04o} should be {expected:04o}").format(
found=stat.S_IMODE(lstat.st_mode), expected=mode
)
)
Expand Down Expand Up @@ -1276,14 +1276,14 @@ def _validate(
or attr in single_attrs
) and type(self.attrs[attr]) is list:
errors.append(
(attr, _("{0} may only be " "specified once").format(attr))
(attr, _("{0} may only be specified once").format(attr))
)
elif attr in numeric_attrs:
try:
int(self.attrs[attr])
except (TypeError, ValueError):
errors.append(
(attr, _("{0} must be an " "integer").format(attr))
(attr, _("{0} must be an integer").format(attr))
)

for attr in required_attrs:
Expand Down
Loading
Loading