Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (31 sloc) 1.3 KB
# vi: ts=4 expandtab
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from builder import util
def modify(name, root, cfg):
user_names = cfg.get('add_users')
if not user_names:
header="Adding the following sudo users in module %s" %
for uname in user_names:
cmd = ['chroot', root, 'useradd', '-m', str(uname)]
util.subp(cmd, capture=False)
if os.path.isfile(os.path.join(root, 'etc', 'sudoers')):
with open(os.path.join(root, 'etc', 'sudoers'), 'a') as fh:
new_entry = "%s ALL=(ALL) ALL" % (uname)
fh.write("%s\n" % (new_entry))