Bug 4074 - During filesystem construction add a method to add/modify users and groups settings
Summary: During filesystem construction add a method to add/modify users and groups se...
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: deployment (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 1.5 M3
Assignee: Chen Qi
QA Contact:
URL:
Whiteboard:
: 4729 (view as bug list)
Depends on:
Blocks: 1577 4106
  Show dependency tree
 
Reported: 2013-03-21 15:01 UTC by Mark Hatle
Modified: 2013-07-31 08:36 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hatle 2013-03-21 15:01:23 UTC
During the filesystem construction, there should be a method to add users/groups, modify existing users/groups (including shadow/expiration settings), and configure passwords.

One suggestion would be to construct a table that can be processed to make the changes requested by the user.  This behavior is difficult then a package with a pre/post-install script as this is more of a system admin functionality.
Comment 1 Chen Qi 2013-06-26 10:20:17 UTC
Hi Mark,

These days, I've been thinking about this problem from time to time.

I thought about several ways to accomplish this task, but at last I came to the conclusion that the consistent way to achieve image level user/group setting still falls into the useradd.bbclass solution.

Let's consider two possible scenarios.

1) I want to add a user/group which doesn't logically belong to a specific package.
In this case, I think a dedicated package should be created in the corresponding layer, which inherits useradd class. 
Say, we have a layer, meta-product, and we want to add two users 'developer' and 'tester' to the image. A recipe dedicated for creating these two users will do the job for us, and in my opinion, in a consistent and manageable way, considering the possibility of the package upgrade.


2) I want to modify the user/group setting in some packages.
In this case, I think using a bbappend file and overriding the some variable like USERADD_PARAM would be sufficient.

Any thoughts on this?

Best Regards,
Chen Qi
Comment 2 Saul Wold 2013-07-17 07:14:16 UTC
*** Bug 4729 has been marked as a duplicate of this bug. ***
Comment 3 venkata ramana g 2013-07-17 11:58:24 UTC
>>1) I want to add a user/group which doesn't logically belong to a specific package.

This method can be safely implemented by adding "adduser" config command using binary configuration feature.

Please refer to 
https://wiki.yoctoproject.org/wiki/Binary_configuration_support

>>2) I want to modify the user/group setting in some packages.

Yes, Poky supports using existing useradd.bbclass.
Comment 4 Chen Qi 2013-07-25 06:08:50 UTC
merged into poky/master: 6d42c2718373a13b67986627b4c7a91719194c4b

http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=4b6deb521183b728d9a1c651d4805fe635e6cb50
Comment 5 Yi Zhao 2013-07-31 08:35:42 UTC
Test Cases

Steps:
1. Download the poky source and set the environment

2. Add the following lines in conf/local.conf

INHERIT += "extrausers"

EXTRA_USERS_PARAMS = "\
useradd -p '' tester1; \
useradd -p 'vz4kBbiMF9z6E' tester2; \
groupadd developers; \
userdel games; \
groupdel -g video; \
groupmod -g 1020 developers; \
usermod -s /bin/sh tester1; \
usermod -g users -G developers,sys tester2; \
"

The above settings do the following things:
a. Add a user tester1 with empty password
b. Add a user tester2 with password 123456
c. Add a group developers
d. Delete user games
e. Delete group video
f. Set the gid of developers to 1020
g. For tester1, set the login shell to /bin/sh
h. For tester2, set the initial group to users. Set the supplementary groups to developers and sys.

3. Build the image

Expected Results:
1. No errors when building the image.  
2. The image can boot up. The /etc/group, /etc/passwd, and /etc/shadow should no errors.
3. Login with tester1 and tester2 without problems. Run "id" command to check the user status.
Comment 6 Yi Zhao 2013-07-31 08:36:21 UTC
Verified with master/9de0ad47462c13ac4a2d73e12e92be6c1b4e0415