Merge pull request #260 from CanonicalLtd/mwhudson/users-and-groups
add user to the correct set of default groups
This commit is contained in:
commit
1634c91948
|
@ -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]
|
||||||
|
|
|
@ -76,12 +76,18 @@ 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']
|
||||||
|
groups.append('sudo')
|
||||||
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:
|
||||||
|
|
Loading…
Reference in New Issue