~ci-train-bot/libertine/libertine-ubuntu-zesty-2086

« back to all changes in this revision

Viewing changes to python/libertine/LxcContainer.py

  • Committer: Chris Townsend
  • Date: 2016-07-15 18:39:58 UTC
  • mto: This revision was merged to the branch mainline in revision 272.
  • Revision ID: christopher.townsend@canonical.com-20160715183958-l95grj44p272lfz4
Rework the whole way we handle updating the necessary system files for unprivileged LXC's:
- Add new script that does the updates.
- Add sudoers file for this script.
- Remove the password dialog in the UI.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    return found
42
42
 
43
43
 
44
 
def setup_host_environment(username, password):
 
44
def setup_host_environment(username):
45
45
    lxc_net_entry = "%s veth lxcbr0 10" % str(username)
46
46
 
47
47
    if not check_lxc_net_entry(lxc_net_entry):
48
 
        passwd = subprocess.Popen(["sudo", "--stdin", "usermod", "--add-subuids", "100000-165536",
49
 
                                   "--add-subgids", "100000-165536", str(username)],
50
 
                                  stdin=subprocess.PIPE, stdout=subprocess.DEVNULL,
51
 
                                  stderr=subprocess.STDOUT)
52
 
        passwd.communicate((password + '\n').encode('UTF-8'))
53
 
 
54
 
        add_user_cmd = "echo %s | sudo tee -a /etc/lxc/lxc-usernet > /dev/null" % lxc_net_entry
55
 
        subprocess.Popen(add_user_cmd, shell=True)
 
48
        subprocess.Popen(["sudo", "libertine-lxc-setup", str(username)]).wait()
56
49
 
57
50
 
58
51
def get_lxc_default_config_path():
151
144
        user_id = os.getuid()
152
145
        group_id = os.getgid()
153
146
 
154
 
        setup_host_environment(username, password)
 
147
        setup_host_environment(username)
155
148
 
156
149
        # Generate the default lxc default config, if it doesn't exist
157
150
        config_path = get_lxc_default_config_path()