Merge lp:~joetalbott/charms/trusty/snappy-proposed-image-builder/create_home into lp:~canonical-ci-engineering/charms/trusty/snappy-proposed-image-builder/trunk

Proposed by Joe Talbott
Status: Merged
Approved by: Joe Talbott
Approved revision: 6
Merged at revision: 6
Proposed branch: lp:~joetalbott/charms/trusty/snappy-proposed-image-builder/create_home
Merge into: lp:~canonical-ci-engineering/charms/trusty/snappy-proposed-image-builder/trunk
Diff against target: 41 lines (+17/-1)
2 files modified
hooks/actions.py (+16/-0)
templates/sudoers.conf (+1/-1)
To merge this branch: bzr merge lp:~joetalbott/charms/trusty/snappy-proposed-image-builder/create_home
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Review via email: mp+261105@code.launchpad.net

Commit message

Create worker's home (needed by u-d-f) and point to the correct u-d-f binary in the sudoers file.

Description of the change

Create worker's home (needed by u-d-f) and point to the correct u-d-f binary in the sudoers file.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

Approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/actions.py'
--- hooks/actions.py 2015-06-03 18:14:36 +0000
+++ hooks/actions.py 2015-06-04 15:35:31 +0000
@@ -1,5 +1,8 @@
1import base641import base64
2import errno
3import grp
2import os4import os
5import pwd
3import shutil6import shutil
4import subprocess7import subprocess
58
@@ -67,6 +70,19 @@
67 hookenv.log('Creating service user: %s', username)70 hookenv.log('Creating service user: %s', username)
68 adduser(username)71 adduser(username)
6972
73 # create user's home directory if it doesn't exist.
74 home = os.path.exists(os.path.join('/home', username))
75 try:
76 os.makedirs(home, 0o755)
77 except OSError as e:
78 if e.errno != errno.EEXIST:
79 raise
80
81 # make sure the user owns their home.
82 group_info = grp.getgrnam(username)
83 user_info = pwd.getpwdnam(username)
84 os.chown(home, user_info['pw_uid'], group_info['gr_gid'])
85
7086
71def install_python_packages(service_name):87def install_python_packages(service_name):
72 env_dir = os.path.join(_service_dir(), 've')88 env_dir = os.path.join(_service_dir(), 've')
7389
=== modified file 'templates/sudoers.conf'
--- templates/sudoers.conf 2015-05-27 13:56:25 +0000
+++ templates/sudoers.conf 2015-06-04 15:35:31 +0000
@@ -1,4 +1,4 @@
1# Specifically added for ubuntu-device-flash command for snappy-proposed-image-builder1# Specifically added for ubuntu-device-flash command for snappy-proposed-image-builder
22
3core-worker ALL=(ALL) NOPASSWD: /usr/bin/ubuntu-device-flash, /bin/rm3core-worker ALL=(ALL) NOPASSWD: /srv/{{ environment }}/snappy-proposed-image-builder/ubuntu-device-flash, /usr/sbin/chroot, /bin/rm
44

Subscribers

People subscribed via source and target branches