diff --git a/snapcraft.yaml b/snapcraft.yaml index 78b0b74d..e0af4262 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -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] diff --git a/subiquity/curtin.py b/subiquity/curtin.py index 45a783cb..6a71ebe8 100644 --- a/subiquity/curtin.py +++ b/subiquity/curtin.py @@ -76,12 +76,17 @@ 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'] 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: