Commit Graph

5 Commits

Author SHA1 Message Date
Fabrice Coulon b02da021b1 useradd-staticids.bbclass: Fix for Bug 6633
When using the useradd-staticids.bbclass under meta/classes,
this error occurs:
"<username> - <username>: Username  does not have a static uid defined."
There was a problem with the regular expression for parsing parameters,
it was sometimes returning an empty string.

I have fixed this by skipping empty strings.

(From OE-Core rev: f249ef32709069a2680b92dc5a5b4f6545d014b7)

Signed-off-by: Fabrice Coulon <fabrice@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-09-03 16:00:28 +01:00
Mark Hatle 29ee5c139e useradd{-static}: Ignore useradds on nativesdk
The code was supposed to ignore both native and nativesdk operations when
using the useradd and useradd-static code.  However, somewhere along the way
the code was dropped.  This didn't cause any issues until someone enabled the
enforcing mode in the new useradd-static and various nativesdk packages
started to fail.

(From OE-Core rev: 6b9705892400a1da1fcd973c64d1911c7c4463f6)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-21 12:05:49 +00:00
Mark Hatle 287efe1494 useradd-staticids: Adjust USERADD_ERROR_DYNAMIC condition and error message
The USERADD_ERROR_DYNAMIC needs to check that both users and groups that are
defined need to be represented as static ids, or an error should occur.

For the user check, we want to make sure the uid is a numeric value.  (The gid
can be name, as the GROUPADD check will validate for a number there -- or
during install useradd will fail if that group is not defined.)

For the group check, we verify that the gid is specified and not left as a name.

Also two statements that can be uncommented for debugging were added so that
future development work on this code would be easier to do.

(From OE-Core rev: f35bbba65e3e41f8dea1f9ff872d3a9fbd84bf6d)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-02-11 12:04:38 +00:00
Mark Hatle 39d9414b95 useradd-staticids: Fix groupadd when --user-group is selected
When --user-group is selected (it's on by default as well) we want
to translate that to a groupname and disable the --user-group.  Before
we just disabled --user-group, but didn't always add the group to the
system.

This change ensures that we add the group (as long as we have enough
information to actually add the group), and we disable --user-group
in that case.  If a static groupid is not specified we continue to
use the groupname, but via an explicit groupadd.

(From OE-Core rev: ae83db0fdcf0b807ffdfc901f4d1c463fffee82a)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-02-11 12:04:38 +00:00
Mark Hatle 4bc6982ea6 useradd.bbclass: Add ability to select a static uid/gid automatically
[YOCTO #5436]

Automatic selection of static uid/gid is needed for a dynamically generated
passwd and group file to have a deterministic outcome.

When a package is installed and instructs the system to add a new user or
group, unless it selects a static uid/gid value, the next available uid/gid
will be used.  The order in which packages are installed is dynamically
computed, and may change from one installation to the next.  This results
in a non-deterministic set of uid/gid values.

Enabling this code by adding USERADDEXTENSION = "useradd-staticids", and
adding a preconfigured passwd/group file will allow the continued dynamic
generation of the rootfs passwd/group files, but will ensure a deterministic
outcome.  (Dynamic generation is desired so that users and groups that have
no corresponding functionality are not present within the final system image.)

The rewrite params function will override each of the fields in the
useradd and groupadd calls with the values specified.  Note, the password
field is ignored as is the member groups field in the group file.  If the
field is empty, the value will not be overridden.  (Note, there is no way
to 'blank' a field, as this would only generally affect the 'comment' field
and there really is no reason to blank it.)

Enabling USERADD_ERROR_DYNAMIC will cause packages without static uid/gid
to generate an error and be skipped for the purpose of building.  This is
used to prevent non-deterministic behavior.

USERADD_UID_TABLES and USERADD_GID_TABLES may be used to specify the name
of the passwd and group files.  By default they are assumed to be
'files/passwd' and 'files/group'.  Layers are searched in BBPATH order.

(From OE-Core rev: 18c99dac52b746b88cd084eb4c2a2ef0329a6ff3)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-02-09 09:40:41 +00:00