summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Simon Möller <jsmoeller@linuxfoundation.org>2016-10-04 00:09:14 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2016-10-05 08:41:48 +0000
commitd17b71363bfc8633b7694ff905a2256ffdf5687c (patch)
tree3f625391e24277797d64affd639c27a7b076c68c
parenta43a56b5a2db1a351f95d18fb328447055299367 (diff)
Remove backport for useradd classes
The krogoth branch has the fix backported now. Change-Id: I8f6ad125ef4614b02cd8f10c5c29eec0fd2fd53c Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
-rw-r--r--meta-agl/classes/useradd-staticids.bbclass329
-rw-r--r--meta-agl/classes/useradd.bbclass244
-rw-r--r--meta-agl/classes/useradd_base.bbclass137
3 files changed, 0 insertions, 710 deletions
diff --git a/meta-agl/classes/useradd-staticids.bbclass b/meta-agl/classes/useradd-staticids.bbclass
deleted file mode 100644
index 46d4a4b3d..000000000
--- a/meta-agl/classes/useradd-staticids.bbclass
+++ /dev/null
@@ -1,329 +0,0 @@
-# In order to support a deterministic set of 'dynamic' users/groups,
-# we need a function to reformat the params based on a static file
-def update_useradd_static_config(d):
- import argparse
- import itertools
- import re
- import errno
-
- class myArgumentParser( argparse.ArgumentParser ):
- def _print_message(self, message, file=None):
- bb.warn("%s - %s: %s" % (d.getVar('PN', True), pkg, message))
-
- # This should never be called...
- def exit(self, status=0, message=None):
- message = message or ("%s - %s: useradd.bbclass: Argument parsing exited" % (d.getVar('PN', True), pkg))
- error(message)
-
- def error(self, message):
- raise bb.build.FuncFailed(message)
-
- def list_extend(iterable, length, obj = None):
- """Ensure that iterable is the specified length by extending with obj
- and return it as a list"""
- return list(itertools.islice(itertools.chain(iterable, itertools.repeat(obj)), length))
-
- def merge_files(file_list, exp_fields):
- """Read each passwd/group file in file_list, split each line and create
- a dictionary with the user/group names as keys and the split lines as
- values. If the user/group name already exists in the dictionary, then
- update any fields in the list with the values from the new list (if they
- are set)."""
- id_table = dict()
- for conf in file_list.split():
- try:
- with open(conf, "r") as f:
- for line in f:
- if line.startswith('#'):
- continue
- # Make sure there always are at least exp_fields
- # elements in the field list. This allows for leaving
- # out trailing colons in the files.
- fields = list_extend(line.rstrip().split(":"), exp_fields)
- if fields[0] not in id_table:
- id_table[fields[0]] = fields
- else:
- id_table[fields[0]] = list(map(lambda x, y: x or y, fields, id_table[fields[0]]))
- except IOError as e:
- if e.errno == errno.ENOENT:
- pass
-
- return id_table
-
- def handle_missing_id(id, type, pkg):
- # For backwards compatibility we accept "1" in addition to "error"
- if d.getVar('USERADD_ERROR_DYNAMIC', True) == 'error' or d.getVar('USERADD_ERROR_DYNAMIC', True) == '1':
- #bb.error("Skipping recipe %s, package %s which adds %sname %s does not have a static ID defined." % (d.getVar('PN', True), pkg, type, id))
- raise bb.build.FuncFailed("%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN', True), pkg, type, id))
- elif d.getVar('USERADD_ERROR_DYNAMIC', True) == 'warn':
- bb.warn("%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN', True), pkg, type, id))
-
- # We parse and rewrite the useradd components
- def rewrite_useradd(params):
- # The following comes from --help on useradd from shadow
- parser = myArgumentParser(prog='useradd')
- parser.add_argument("-b", "--base-dir", metavar="BASE_DIR", help="base directory for the home directory of the new account")
- parser.add_argument("-c", "--comment", metavar="COMMENT", help="GECOS field of the new account")
- parser.add_argument("-d", "--home-dir", metavar="HOME_DIR", help="home directory of the new account")
- parser.add_argument("-D", "--defaults", help="print or change default useradd configuration", action="store_true")
- parser.add_argument("-e", "--expiredate", metavar="EXPIRE_DATE", help="expiration date of the new account")
- parser.add_argument("-f", "--inactive", metavar="INACTIVE", help="password inactivity period of the new account")
- parser.add_argument("-g", "--gid", metavar="GROUP", help="name or ID of the primary group of the new account")
- parser.add_argument("-G", "--groups", metavar="GROUPS", help="list of supplementary groups of the new account")
- parser.add_argument("-k", "--skel", metavar="SKEL_DIR", help="use this alternative skeleton directory")
- parser.add_argument("-K", "--key", metavar="KEY=VALUE", help="override /etc/login.defs defaults")
- parser.add_argument("-l", "--no-log-init", help="do not add the user to the lastlog and faillog databases", action="store_true")
- parser.add_argument("-m", "--create-home", help="create the user's home directory", action="store_const", const=True)
- parser.add_argument("-M", "--no-create-home", dest="create_home", help="do not create the user's home directory", action="store_const", const=False)
- parser.add_argument("-N", "--no-user-group", dest="user_group", help="do not create a group with the same name as the user", action="store_const", const=False)
- parser.add_argument("-o", "--non-unique", help="allow to create users with duplicate (non-unique UID)", action="store_true")
- parser.add_argument("-p", "--password", metavar="PASSWORD", help="encrypted password of the new account")
- parser.add_argument("-R", "--root", metavar="CHROOT_DIR", help="directory to chroot into")
- parser.add_argument("-r", "--system", help="create a system account", action="store_true")
- parser.add_argument("-s", "--shell", metavar="SHELL", help="login shell of the new account")
- parser.add_argument("-u", "--uid", metavar="UID", help="user ID of the new account")
- parser.add_argument("-U", "--user-group", help="create a group with the same name as the user", action="store_const", const=True)
- parser.add_argument("LOGIN", help="Login name of the new user")
-
- # Return a list of configuration files based on either the default
- # files/passwd or the contents of USERADD_UID_TABLES
- # paths are resolved via BBPATH
- def get_passwd_list(d):
- str = ""
- bbpath = d.getVar('BBPATH', True)
- passwd_tables = d.getVar('USERADD_UID_TABLES', True)
- if not passwd_tables:
- passwd_tables = 'files/passwd'
- for conf_file in passwd_tables.split():
- str += " %s" % bb.utils.which(bbpath, conf_file)
- return str
-
- newparams = []
- users = None
- for param in re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', params):
- param = param.strip()
- if not param:
- continue
- try:
- uaargs = parser.parse_args(re.split('''[ \t]+(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', param))
- except:
- raise bb.build.FuncFailed("%s: Unable to parse arguments for USERADD_PARAM_%s: '%s'" % (d.getVar('PN', True), pkg, param))
-
- # Read all passwd files specified in USERADD_UID_TABLES or files/passwd
- # Use the standard passwd layout:
- # username:password:user_id:group_id:comment:home_directory:login_shell
- #
- # If a field is left blank, the original value will be used. The 'username'
- # field is required.
- #
- # Note: we ignore the password field, as including even the hashed password
- # in the useradd command may introduce a security hole. It's assumed that
- # all new users get the default ('*' which prevents login) until the user is
- # specifically configured by the system admin.
- if not users:
- users = merge_files(get_passwd_list(d), 7)
-
- if uaargs.LOGIN not in users:
- if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid:
- handle_missing_id(uaargs.LOGIN, 'user', pkg)
- continue
-
- field = users[uaargs.LOGIN]
-
- if uaargs.uid and field[2] and (uaargs.uid != field[2]):
- bb.warn("%s: Changing username %s's uid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.uid, field[2]))
- uaargs.uid = field[2] or uaargs.uid
-
- # Determine the possible groupname
- # Unless the group name (or gid) is specified, we assume that the LOGIN is the groupname
- #
- # By default the system has creation of the matching groups enabled
- # So if the implicit username-group creation is on, then the implicit groupname (LOGIN)
- # is used, and we disable the user_group option.
- #
- user_group = uaargs.user_group is None or uaargs.user_group is True
- uaargs.groupname = uaargs.LOGIN if user_group else uaargs.gid
- uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname
-
- if uaargs.groupid and uaargs.gid != uaargs.groupid:
- newgroup = None
- if not uaargs.groupid.isdigit():
- # We don't have a group number, so we have to add a name
- bb.debug(1, "Adding group %s!" % uaargs.groupid)
- newgroup = "%s %s" % (' --system' if uaargs.system else '', uaargs.groupid)
- elif uaargs.groupname and not uaargs.groupname.isdigit():
- # We have a group name and a group number to assign it to
- bb.debug(1, "Adding group %s (gid %s)!" % (uaargs.groupname, uaargs.groupid))
- newgroup = "-g %s %s" % (uaargs.groupid, uaargs.groupname)
- else:
- # We want to add a group, but we don't know it's name... so we can't add the group...
- # We have to assume the group has previously been added or we'll fail on the adduser...
- # Note: specifying the actual gid is very rare in OE, usually the group name is specified.
- bb.warn("%s: Changing gid for login %s to %s, verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.groupid))
-
- uaargs.gid = uaargs.groupid
- uaargs.user_group = None
- if newgroup:
- groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True)
- if groupadd:
- d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % (groupadd, newgroup))
- else:
- d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup)
-
- uaargs.comment = "'%s'" % field[4] if field[4] else uaargs.comment
- uaargs.home_dir = field[5] or uaargs.home_dir
- uaargs.shell = field[6] or uaargs.shell
-
- # Should be an error if a specific option is set...
- if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid:
- handle_missing_id(uaargs.LOGIN, 'user', pkg)
-
- # Reconstruct the args...
- newparam = ['', ' --defaults'][uaargs.defaults]
- newparam += ['', ' --base-dir %s' % uaargs.base_dir][uaargs.base_dir != None]
- newparam += ['', ' --comment %s' % uaargs.comment][uaargs.comment != None]
- newparam += ['', ' --home-dir %s' % uaargs.home_dir][uaargs.home_dir != None]
- newparam += ['', ' --expiredata %s' % uaargs.expiredate][uaargs.expiredate != None]
- newparam += ['', ' --inactive %s' % uaargs.inactive][uaargs.inactive != None]
- newparam += ['', ' --gid %s' % uaargs.gid][uaargs.gid != None]
- newparam += ['', ' --groups %s' % uaargs.groups][uaargs.groups != None]
- newparam += ['', ' --skel %s' % uaargs.skel][uaargs.skel != None]
- newparam += ['', ' --key %s' % uaargs.key][uaargs.key != None]
- newparam += ['', ' --no-log-init'][uaargs.no_log_init]
- newparam += ['', ' --create-home'][uaargs.create_home is True]
- newparam += ['', ' --no-create-home'][uaargs.create_home is False]
- newparam += ['', ' --no-user-group'][uaargs.user_group is False]
- newparam += ['', ' --non-unique'][uaargs.non_unique]
- newparam += ['', ' --password %s' % uaargs.password][uaargs.password != None]
- newparam += ['', ' --root %s' % uaargs.root][uaargs.root != None]
- newparam += ['', ' --system'][uaargs.system]
- newparam += ['', ' --shell %s' % uaargs.shell][uaargs.shell != None]
- newparam += ['', ' --uid %s' % uaargs.uid][uaargs.uid != None]
- newparam += ['', ' --user-group'][uaargs.user_group is True]
- newparam += ' %s' % uaargs.LOGIN
-
- newparams.append(newparam)
-
- return ";".join(newparams).strip()
-
- # We parse and rewrite the groupadd components
- def rewrite_groupadd(params):
- # The following comes from --help on groupadd from shadow
- parser = myArgumentParser(prog='groupadd')
- parser.add_argument("-f", "--force", help="exit successfully if the group already exists, and cancel -g if the GID is already used", action="store_true")
- parser.add_argument("-g", "--gid", metavar="GID", help="use GID for the new group")
- parser.add_argument("-K", "--key", metavar="KEY=VALUE", help="override /etc/login.defs defaults")
- parser.add_argument("-o", "--non-unique", help="allow to create groups with duplicate (non-unique) GID", action="store_true")
- parser.add_argument("-p", "--password", metavar="PASSWORD", help="use this encrypted password for the new group")
- parser.add_argument("-R", "--root", metavar="CHROOT_DIR", help="directory to chroot into")
- parser.add_argument("-r", "--system", help="create a system account", action="store_true")
- parser.add_argument("GROUP", help="Group name of the new group")
-
- # Return a list of configuration files based on either the default
- # files/group or the contents of USERADD_GID_TABLES
- # paths are resolved via BBPATH
- def get_group_list(d):
- str = ""
- bbpath = d.getVar('BBPATH', True)
- group_tables = d.getVar('USERADD_GID_TABLES', True)
- if not group_tables:
- group_tables = 'files/group'
- for conf_file in group_tables.split():
- str += " %s" % bb.utils.which(bbpath, conf_file)
- return str
-
- newparams = []
- groups = None
- for param in re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', params):
- param = param.strip()
- if not param:
- continue
- try:
- # If we're processing multiple lines, we could have left over values here...
- gaargs = parser.parse_args(re.split('''[ \t]+(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', param))
- except:
- raise bb.build.FuncFailed("%s: Unable to parse arguments for GROUPADD_PARAM_%s: '%s'" % (d.getVar('PN', True), pkg, param))
-
- # Read all group files specified in USERADD_GID_TABLES or files/group
- # Use the standard group layout:
- # groupname:password:group_id:group_members
- #
- # If a field is left blank, the original value will be used. The 'groupname' field
- # is required.
- #
- # Note: similar to the passwd file, the 'password' filed is ignored
- # Note: group_members is ignored, group members must be configured with the GROUPMEMS_PARAM
- if not groups:
- groups = merge_files(get_group_list(d), 4)
-
- if gaargs.GROUP not in groups:
- if not gaargs.gid or not gaargs.gid.isdigit():
- handle_missing_id(gaargs.GROUP, 'group', pkg)
- continue
-
- field = groups[gaargs.GROUP]
-
- if field[2]:
- if gaargs.gid and (gaargs.gid != field[2]):
- bb.warn("%s: Changing groupname %s's gid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), gaargs.GROUP, gaargs.gid, field[2]))
- gaargs.gid = field[2]
-
- if not gaargs.gid or not gaargs.gid.isdigit():
- handle_missing_id(gaargs.GROUP, 'group', pkg)
-
- # Reconstruct the args...
- newparam = ['', ' --force'][gaargs.force]
- newparam += ['', ' --gid %s' % gaargs.gid][gaargs.gid != None]
- newparam += ['', ' --key %s' % gaargs.key][gaargs.key != None]
- newparam += ['', ' --non-unique'][gaargs.non_unique]
- newparam += ['', ' --password %s' % gaargs.password][gaargs.password != None]
- newparam += ['', ' --root %s' % gaargs.root][gaargs.root != None]
- newparam += ['', ' --system'][gaargs.system]
- newparam += ' %s' % gaargs.GROUP
-
- newparams.append(newparam)
-
- return ";".join(newparams).strip()
-
- # The parsing of the current recipe depends on the content of
- # the files listed in USERADD_UID/GID_TABLES. We need to tell bitbake
- # about that explicitly to trigger re-parsing and thus re-execution of
- # this code when the files change.
- bbpath = d.getVar('BBPATH', True)
- for varname, default in (('USERADD_UID_TABLES', 'files/passwd'),
- ('USERADD_GID_TABLES', 'files/group')):
- tables = d.getVar(varname, True)
- if not tables:
- tables = default
- for conf_file in tables.split():
- bb.parse.mark_dependency(d, bb.utils.which(bbpath, conf_file))
-
- # Load and process the users and groups, rewriting the adduser/addgroup params
- useradd_packages = d.getVar('USERADD_PACKAGES', True)
-
- for pkg in useradd_packages.split():
- # Groupmems doesn't have anything we might want to change, so simply validating
- # is a bit of a waste -- only process useradd/groupadd
- useradd_param = d.getVar('USERADD_PARAM_%s' % pkg, True)
- if useradd_param:
- #bb.warn("Before: 'USERADD_PARAM_%s' - '%s'" % (pkg, useradd_param))
- d.setVar('USERADD_PARAM_%s' % pkg, rewrite_useradd(useradd_param))
- #bb.warn("After: 'USERADD_PARAM_%s' - '%s'" % (pkg, d.getVar('USERADD_PARAM_%s' % pkg, True)))
-
- groupadd_param = d.getVar('GROUPADD_PARAM_%s' % pkg, True)
- if groupadd_param:
- #bb.warn("Before: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, groupadd_param))
- d.setVar('GROUPADD_PARAM_%s' % pkg, rewrite_groupadd(groupadd_param))
- #bb.warn("After: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, d.getVar('GROUPADD_PARAM_%s' % pkg, True)))
-
-
-
-python __anonymous() {
- if not bb.data.inherits_class('nativesdk', d) \
- and not bb.data.inherits_class('native', d):
- try:
- update_useradd_static_config(d)
- except bb.build.FuncFailed as f:
- bb.debug(1, "Skipping recipe %s: %s" % (d.getVar('PN', True), f))
- raise bb.parse.SkipPackage(f)
-}
diff --git a/meta-agl/classes/useradd.bbclass b/meta-agl/classes/useradd.bbclass
deleted file mode 100644
index bf62ada8b..000000000
--- a/meta-agl/classes/useradd.bbclass
+++ /dev/null
@@ -1,244 +0,0 @@
-inherit useradd_base
-
-# base-passwd-cross provides the default passwd and group files in the
-# target sysroot, and shadow -native and -sysroot provide the utilities
-# and support files needed to add and modify user and group accounts
-DEPENDS_append_class-target = " base-files shadow-native shadow-sysroot shadow"
-
-# This preinstall function can be run in four different contexts:
-#
-# a) Before do_install
-# b) At do_populate_sysroot_setscene when installing from sstate packages
-# c) As the preinst script in the target package at do_rootfs time
-# d) As the preinst script in the target package on device as a package upgrade
-#
-useradd_preinst () {
-OPT=""
-SYSROOT=""
-
-if test "x$D" != "x"; then
- # Installing into a sysroot
- SYSROOT="$D"
- OPT="--root $D"
-
- # Make sure login.defs is there, this is to make debian package backend work
- # correctly while doing rootfs.
- # The problem here is that if /etc/login.defs is treated as a config file for
- # shadow package, then while performing preinsts for packages that depend on
- # shadow, there might only be /etc/login.def.dpkg-new there in root filesystem.
- if [ ! -e $D${sysconfdir}/login.defs -a -e $D${sysconfdir}/login.defs.dpkg-new ]; then
- cp $D${sysconfdir}/login.defs.dpkg-new $D${sysconfdir}/login.defs
- fi
-
- # user/group lookups should match useradd/groupadd --root
- export PSEUDO_PASSWD="$SYSROOT:${STAGING_DIR_NATIVE}"
-fi
-
-# If we're not doing a special SSTATE/SYSROOT install
-# then set the values, otherwise use the environment
-if test "x$UA_SYSROOT" = "x"; then
- # Installing onto a target
- # Add groups and users defined only for this package
- GROUPADD_PARAM="${GROUPADD_PARAM}"
- USERADD_PARAM="${USERADD_PARAM}"
- GROUPMEMS_PARAM="${GROUPMEMS_PARAM}"
-fi
-
-# Perform group additions first, since user additions may depend
-# on these groups existing
-if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then
- echo "Running groupadd commands..."
- # Invoke multiple instances of groupadd for parameter lists
- # separated by ';'
- opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
- remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
- while test "x$opts" != "x"; do
- perform_groupadd "$SYSROOT" "$OPT $opts"
- if test "x$opts" = "x$remaining"; then
- break
- fi
- opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
- remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
- done
-fi
-
-if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then
- echo "Running useradd commands..."
- # Invoke multiple instances of useradd for parameter lists
- # separated by ';'
- opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
- remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
- while test "x$opts" != "x"; do
- perform_useradd "$SYSROOT" "$OPT $opts"
- if test "x$opts" = "x$remaining"; then
- break
- fi
- opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
- remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
- done
-fi
-
-if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
- echo "Running groupmems commands..."
- # Invoke multiple instances of groupmems for parameter lists
- # separated by ';'
- opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
- remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
- while test "x$opts" != "x"; do
- perform_groupmems "$SYSROOT" "$OPT $opts"
- if test "x$opts" = "x$remaining"; then
- break
- fi
- opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
- remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
- done
-fi
-}
-
-useradd_sysroot () {
- # Pseudo may (do_install) or may not (do_populate_sysroot_setscene) be running
- # at this point so we're explicit about the environment so pseudo can load if
- # not already present.
- export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir_native}/pseudo"
-
- # Explicitly set $D since it isn't set to anything
- # before do_install
- D=${STAGING_DIR_TARGET}
-
- # Add groups and users defined for all recipe packages
- GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}"
- USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}"
- GROUPMEMS_PARAM="${@get_all_cmd_params(d, 'groupmems')}"
-
- # Tell the system to use the environment vars
- UA_SYSROOT=1
-
- useradd_preinst
-}
-
-useradd_sysroot_sstate () {
- if [ "${BB_CURRENTTASK}" = "package_setscene" -o "${BB_CURRENTTASK}" = "populate_sysroot_setscene" ]
- then
- useradd_sysroot
- fi
-}
-
-userdel_sysroot_sstate () {
-if test "x${STAGING_DIR_TARGET}" != "x"; then
- if [ "${BB_CURRENTTASK}" = "clean" ]; then
- export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir_native}/pseudo"
- OPT="--root ${STAGING_DIR_TARGET}"
-
- # Remove groups and users defined for package
- GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}"
- USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}"
-
- user=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
- remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
- while test "x$user" != "x"; do
- perform_userdel "${STAGING_DIR_TARGET}" "$OPT $user"
- user=`echo "$remaining" | cut -d ';' -f 1 | awk '{ print $NF }'`
- remaining=`echo "$remaining" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
- done
-
- user=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
- remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
- while test "x$user" != "x"; do
- perform_groupdel "${STAGING_DIR_TARGET}" "$OPT $user"
- user=`echo "$remaining" | cut -d ';' -f 1 | awk '{ print $NF }'`
- remaining=`echo "$remaining" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
- done
-
- fi
-fi
-}
-
-SSTATECLEANFUNCS_append_class-target = " userdel_sysroot_sstate"
-
-do_install[prefuncs] += "${SYSROOTFUNC}"
-SYSROOTFUNC_class-target = "useradd_sysroot"
-SYSROOTFUNC = ""
-
-SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate"
-
-do_package_setscene[depends] += "${USERADDSETSCENEDEPS}"
-do_populate_sysroot_setscene[depends] += "${USERADDSETSCENEDEPS}"
-USERADDSETSCENEDEPS_class-target = "${MLPREFIX}base-passwd:do_populate_sysroot_setscene pseudo-native:do_populate_sysroot_setscene shadow-native:do_populate_sysroot_setscene ${MLPREFIX}shadow-sysroot:do_populate_sysroot_setscene"
-USERADDSETSCENEDEPS = ""
-
-# Recipe parse-time sanity checks
-def update_useradd_after_parse(d):
- useradd_packages = d.getVar('USERADD_PACKAGES', True)
-
- if not useradd_packages:
- raise bb.build.FuncFailed("%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE', False))
-
- for pkg in useradd_packages.split():
- if not d.getVar('USERADD_PARAM_%s' % pkg, True) and not d.getVar('GROUPADD_PARAM_%s' % pkg, True) and not d.getVar('GROUPMEMS_PARAM_%s' % pkg, True):
- bb.fatal("%s inherits useradd but doesn't set USERADD_PARAM, GROUPADD_PARAM or GROUPMEMS_PARAM for package %s" % (d.getVar('FILE', False), pkg))
-
-python __anonymous() {
- if not bb.data.inherits_class('nativesdk', d) \
- and not bb.data.inherits_class('native', d):
- update_useradd_after_parse(d)
-}
-
-# Return a single [GROUP|USER]ADD_PARAM formatted string which includes the
-# [group|user]add parameters for all USERADD_PACKAGES in this recipe
-def get_all_cmd_params(d, cmd_type):
- import string
-
- param_type = cmd_type.upper() + "_PARAM_%s"
- params = []
-
- useradd_packages = d.getVar('USERADD_PACKAGES', True) or ""
- for pkg in useradd_packages.split():
- param = d.getVar(param_type % pkg, True)
- if param:
- params.append(param.rstrip(" ;"))
-
- return "; ".join(params)
-
-# Adds the preinst script into generated packages
-fakeroot python populate_packages_prepend () {
- def update_useradd_package(pkg):
- bb.debug(1, 'adding user/group calls to preinst for %s' % pkg)
-
- """
- useradd preinst is appended here because pkg_preinst may be
- required to execute on the target. Not doing so may cause
- useradd preinst to be invoked twice, causing unwanted warnings.
- """
- preinst = d.getVar('pkg_preinst_%s' % pkg, True) or d.getVar('pkg_preinst', True)
- if not preinst:
- preinst = '#!/bin/sh\n'
- preinst += 'bbnote () {\n\techo "NOTE: $*"\n}\n'
- preinst += 'bbwarn () {\n\techo "WARNING: $*"\n}\n'
- preinst += 'bbfatal () {\n\techo "ERROR: $*"\n\texit 1\n}\n'
- preinst += 'perform_groupadd () {\n%s}\n' % d.getVar('perform_groupadd', True)
- preinst += 'perform_useradd () {\n%s}\n' % d.getVar('perform_useradd', True)
- preinst += 'perform_groupmems () {\n%s}\n' % d.getVar('perform_groupmems', True)
- preinst += d.getVar('useradd_preinst', True)
- d.setVar('pkg_preinst_%s' % pkg, preinst)
-
- # RDEPENDS setup
- rdepends = d.getVar("RDEPENDS_%s" % pkg, True) or ""
- rdepends += ' ' + d.getVar('MLPREFIX', False) + 'base-passwd'
- rdepends += ' ' + d.getVar('MLPREFIX', False) + 'shadow'
- # base-files is where the default /etc/skel is packaged
- rdepends += ' ' + d.getVar('MLPREFIX', False) + 'base-files'
- d.setVar("RDEPENDS_%s" % pkg, rdepends)
-
- # Add the user/group preinstall scripts and RDEPENDS requirements
- # to packages specified by USERADD_PACKAGES
- if not bb.data.inherits_class('nativesdk', d) \
- and not bb.data.inherits_class('native', d):
- useradd_packages = d.getVar('USERADD_PACKAGES', True) or ""
- for pkg in useradd_packages.split():
- update_useradd_package(pkg)
-}
-
-# Use the following to extend the useradd with custom functions
-USERADDEXTENSION ?= ""
-
-inherit ${USERADDEXTENSION}
diff --git a/meta-agl/classes/useradd_base.bbclass b/meta-agl/classes/useradd_base.bbclass
deleted file mode 100644
index ba87edc57..000000000
--- a/meta-agl/classes/useradd_base.bbclass
+++ /dev/null
@@ -1,137 +0,0 @@
-# This bbclass provides basic functionality for user/group settings.
-# This bbclass is intended to be inherited by useradd.bbclass and
-# extrausers.bbclass.
-
-# The following functions basically have similar logic.
-# *) Perform necessary checks before invoking the actual command
-# *) Invoke the actual command with flock
-# *) Error out if an error occurs.
-
-# Note that before invoking these functions, make sure the global variable
-# PSEUDO is set up correctly.
-
-perform_groupadd () {
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing groupadd with [$opts]"
- local groupname=`echo "$opts" | awk '{ print $NF }'`
- local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
- if test "x$group_exists" = "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupadd \$opts\" || true
- group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
- if test "x$group_exists" = "x"; then
- bbfatal "${PN}: groupadd command did not succeed."
- fi
- else
- bbnote "${PN}: group $groupname already exists, not re-creating it"
- fi
-}
-
-perform_useradd () {
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing useradd with [$opts]"
- local username=`echo "$opts" | awk '{ print $NF }'`
- local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
- if test "x$user_exists" = "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO useradd \$opts\" || true
- user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
- if test "x$user_exists" = "x"; then
- bbfatal "${PN}: useradd command did not succeed."
- fi
- else
- bbnote "${PN}: user $username already exists, not re-creating it"
- fi
-}
-
-perform_groupmems () {
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing groupmems with [$opts]"
- local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
- local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
- bbnote "${PN}: Running groupmems command with group $groupname and user $username"
- local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
- if test "x$mem_exists" = "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmems \$opts\" || true
- mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
- if test "x$mem_exists" = "x"; then
- bbfatal "${PN}: groupmems command did not succeed."
- fi
- else
- bbnote "${PN}: group $groupname already contains $username, not re-adding it"
- fi
-}
-
-perform_groupdel () {
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing groupdel with [$opts]"
- local groupname=`echo "$opts" | awk '{ print $NF }'`
- local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
- if test "x$group_exists" != "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupdel \$opts\" || true
- group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
- if test "x$group_exists" != "x"; then
- bbfatal "${PN}: groupdel command did not succeed."
- fi
- else
- bbnote "${PN}: group $groupname doesn't exist, not removing it"
- fi
-}
-
-perform_userdel () {
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing userdel with [$opts]"
- local username=`echo "$opts" | awk '{ print $NF }'`
- local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
- if test "x$user_exists" != "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO userdel \$opts\" || true
- user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
- if test "x$user_exists" != "x"; then
- bbfatal "${PN}: userdel command did not succeed."
- fi
- else
- bbnote "${PN}: user $username doesn't exist, not removing it"
- fi
-}
-
-perform_groupmod () {
- # Other than the return value of groupmod, there's no simple way to judge whether the command
- # succeeds, so we disable -e option temporarily
- set +e
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing groupmod with [$opts]"
- local groupname=`echo "$opts" | awk '{ print $NF }'`
- local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
- if test "x$group_exists" != "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmod \$opts\"
- if test $? != 0; then
- bbwarn "${PN}: groupmod command did not succeed."
- fi
- else
- bbwarn "${PN}: group $groupname doesn't exist, unable to modify it"
- fi
- set -e
-}
-
-perform_usermod () {
- # Same reason with groupmod, temporarily disable -e option
- set +e
- local rootdir="$1"
- local opts="$2"
- bbnote "${PN}: Performing usermod with [$opts]"
- local username=`echo "$opts" | awk '{ print $NF }'`
- local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
- if test "x$user_exists" != "x"; then
- eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO usermod \$opts\"
- if test $? != 0; then
- bbfatal "${PN}: usermod command did not succeed."
- fi
- else
- bbwarn "${PN}: user $username doesn't exist, unable to modify it"
- fi
- set -e
-}
id='n1612' href='#n1612'>1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434