#
# 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
#
#
#
"""module describing a user packaging object
This module contains the UserAction class, which represents a user
packaging object. This contains the attributes necessary to create
a new user."""
from . import generic
try:
except ImportError:
"""Class representing a group packaging object.
note that grouplist members are selected via the user action,
group passwds is not supported."""
__slots__ = []
""" return a dictionary containing attrs in attr list
from self.attrs; omit if no such attrs in self.attrs"""
if a in attrlist)
"""client-side method that adds the group
use gid from disk if different"""
if not have_cfgfiles:
# the group action is ignored if cfgfiles is not
# available.
return
try:
except EnvironmentError as e:
raise
pw = None
# check for (wrong) pre-existing definition
# if so, rewrite entry using existing defs but new group entry
# (XXX this doesn't chown any files on-disk)
# else, nothing to do
if cur_attrs:
# Update the user database with the new gid
# as well in case group is someone's primary
# group.
try:
"gid"]
except Exception as e:
if pw:
txt = _("Group cannot be installed. "
"Updating related user entries "
"failed.")
# NOTE: needs modification if more attrs are used
try:
if pw:
except EnvironmentError as e:
raise
# If we're in the postinstall phase and the
# files *still* aren't there, bail gracefully.
if retry:
txt = _("Group cannot be installed "
"without group database files "
"present.")
finally:
if pw:
if groups:
"""Returns a tuple of lists of the form (errors, warnings,
info). The error list will be empty if the action has been
correctly installed in the given image."""
errors = []
warnings = []
info = []
if not have_cfgfiles:
# The user action is ignored if cfgfiles is not
# available.
# Get the default values if they're non-empty
(k, v)
if v != ""
))
# If "gid" is set dynamically, ignore what's on disk.
# Note where attributes are missing
for k in should_be:
# Note where attributes should be empty
for k in cur_attrs:
if cur_attrs[k]:
# Ignore "user-list", as it is only modified by user actions
errors = [
_("{entry}: '{found}' should be '{expected}'").format(
for a in should_be
]
"""client-side method that removes this group"""
if not have_cfgfiles:
# The user action is ignored if cfgfiles is not
# available.
return
try:
except KeyError as e:
# Already gone; don't care.
pass
else:
"""Generates the indices needed by the search dictionary. See
generic.py for a more detailed explanation."""
"""Performs additional validation of action attributes that
for performance or other reasons cannot or should not be done
during Action object creation. An ActionError exception (or
subclass of) will be raised if any attributes are not valid.
This is primarily intended for use during publication or during
error handling to provide additional diagonostics.
'fmri' is an optional package FMRI (object or string) indicating
what package contained this action.
"""
"""Arrange for group actions to be installed in gid order. This
will only hold true for actions installed at one time, but that's
generally what we need on initial install."""
# put unspecifed gids at the end
return (a > b) - (a < b)