Merge pull request #260 from CanonicalLtd/mwhudson/users-and-groups

add user to the correct set of default groups
This commit is contained in:
vorlonofportland 2017-10-12 09:31:33 -04:00 committed by GitHub
commit 1634c91948
2 changed files with 15 additions and 1 deletions

View File

@ -50,6 +50,14 @@ parts:
'bin/started': usr/bin/started
prime:
- usr/bin
users-and-groups:
plugin: dump
build-packages:
- user-setup
prepare: |
echo "get passwd/user-default-groups" | \
debconf-communicate user-setup | \
cut -d ' ' -f 2- > users-and-groups
probert:
plugin: python
build-packages: [python-setuptools, libnl-3-dev, libnl-genl-3-dev, libnl-route-3-dev]

View File

@ -76,12 +76,18 @@ POST_INSTALL_CONFIG = {
def curtin_userinfo_to_config(userinfo):
users_and_groups_path = os.path.join(os.environ.get("SNAP", "/does-not-exist"), "users-and-groups")
if os.path.exists(users_and_groups_path):
groups = open(users_and_groups_path).read().split()
else:
groups = ['admin']
groups.append('sudo')
user = {
'name': userinfo['username'],
'gecos': userinfo['realname'],
'passwd': userinfo['password'],
'shell': '/bin/bash',
'groups': 'admin',
'groups': groups,
'lock-passwd': False,
}
if 'ssh_import_id' in userinfo: