From 6bdeab6a084f977ab6e8d2400129efeac9092c06 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 11 Oct 2017 20:31:09 +1300 Subject: [PATCH 1/3] slightly comical way of getting the created user added to the right groups --- snapcraft.yaml | 8 ++++++++ subiquity/curtin.py | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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: From 8be8bbe6326af0280af2e3e4f68532f1754653f6 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 11 Oct 2017 20:52:13 +1300 Subject: [PATCH 2/3] add user to sudo group too! --- subiquity/curtin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/subiquity/curtin.py b/subiquity/curtin.py index 6a71ebe8..3ae9466b 100644 --- a/subiquity/curtin.py +++ b/subiquity/curtin.py @@ -81,6 +81,7 @@ def curtin_userinfo_to_config(userinfo): groups = open(users_and_groups_path).read().split() else: groups = ['admin'] + groups.append('sudo') user = { 'name': userinfo['username'], 'gecos': userinfo['realname'], From a05289b90e37f8da7ee75aa81b1d90a9a1522771 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 11 Oct 2017 20:57:12 +1300 Subject: [PATCH 3/3] add missing \ --- snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index e0af4262..4998b1bd 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -56,7 +56,7 @@ parts: - user-setup prepare: | echo "get passwd/user-default-groups" | \ - debconf-communicate user-setup | + debconf-communicate user-setup | \ cut -d ' ' -f 2- > users-and-groups probert: plugin: python