slightly comical way of getting the created user added to the right groups

This commit is contained in:
Michael Hudson-Doyle 2017-10-11 20:31:09 +13:00
parent fd11d0c46e
commit 6bdeab6a08
2 changed files with 14 additions and 1 deletions

View File

@ -50,6 +50,14 @@ parts:
'bin/started': usr/bin/started 'bin/started': usr/bin/started
prime: prime:
- usr/bin - 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: probert:
plugin: python plugin: python
build-packages: [python-setuptools, libnl-3-dev, libnl-genl-3-dev, libnl-route-3-dev] build-packages: [python-setuptools, libnl-3-dev, libnl-genl-3-dev, libnl-route-3-dev]

View File

@ -76,12 +76,17 @@ POST_INSTALL_CONFIG = {
def curtin_userinfo_to_config(userinfo): 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']
user = { user = {
'name': userinfo['username'], 'name': userinfo['username'],
'gecos': userinfo['realname'], 'gecos': userinfo['realname'],
'passwd': userinfo['password'], 'passwd': userinfo['password'],
'shell': '/bin/bash', 'shell': '/bin/bash',
'groups': 'admin', 'groups': groups,
'lock-passwd': False, 'lock-passwd': False,
} }
if 'ssh_import_id' in userinfo: if 'ssh_import_id' in userinfo: