diff --git a/server/modules/adduser.py b/server/modules/adduser.py index 576a5fd..54b3797 100755 --- a/server/modules/adduser.py +++ b/server/modules/adduser.py @@ -26,6 +26,10 @@ parser.add_argument( dest='username', action='store', required=True) +parser.add_argument( + '--groups', + dest='groups', + action='store') FLAGS = parser.parse_args() @@ -38,6 +42,10 @@ def main(): with open(os.path.join(FLAGS.chroot_path, 'etc', 'sudoers.d', FLAGS.username), 'w') as fh: fh.write('%s\tALL=(ALL) NOPASSWD: ALL\n' % FLAGS.username) + if FLAGS.groups: + for group in FLAGS.groups.split(","): + module.ExecChroot('adduser', FLAGS.username, group) + if FLAGS.authorized_keys_file: dest_dir = os.path.join(FLAGS.chroot_path, 'home', FLAGS.username, '.ssh') dest_path = os.path.join(dest_dir, 'authorized_keys')