From 70dd367261797f80ea1c3d4a89174eb1f8f42588 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 29 Apr 2016 18:55:13 +0000 Subject: [PATCH] Set shell, switch to passwordless sudo --- server/modules/adduser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/modules/adduser.py b/server/modules/adduser.py index 2da67ca..1f6819d 100755 --- a/server/modules/adduser.py +++ b/server/modules/adduser.py @@ -39,10 +39,11 @@ def ExecChroot(*args, **kwargs): def main(): ExecChroot('adduser', '--system', '--group', '--disabled-password', - FLAGS.username) + '--shell=/bin/bash', FLAGS.username) if FLAGS.sudo: - ExecChroot('usermod', '--append', '--groups', 'sudo', FLAGS.username) + with open(os.path.join(FLAGS.chroot_path, 'etc', 'sudoers.d', FLAGS.username), 'w') as fh: + fh.write('%s\tALL=(ALL) NOPASSWD: ALL\n') if FLAGS.authorized_keys_file: dest_dir = os.path.join(FLAGS.chroot_path, 'home', FLAGS.username, '.ssh')