diff --git a/charmhelpers/core/host.py b/charmhelpers/core/host.py index e8077eea7..8371daac3 100644 --- a/charmhelpers/core/host.py +++ b/charmhelpers/core/host.py @@ -357,7 +357,7 @@ def init_is_systemd(service_name=None): return os.path.isdir(SYSTEMD_SYSTEM) -def adduser(username, password=None, shell='/bin/bash', +def adduser(username, password=None, shell=None, system_user=False, primary_group=None, secondary_groups=None, uid=None, home_dir=None): """Add a user to the system. @@ -389,13 +389,14 @@ def adduser(username, password=None, shell='/bin/bash', if home_dir: cmd.extend(['--home', str(home_dir)]) if system_user or password is None: - cmd.append('--system') - if shell != adduser.__defaults__[1]: - cmd.extend(['--shell', shell]) + cmd.extend([ + '--system', + '--shell', shell if shell else '/usr/sbin/nologin' + ]) else: cmd.extend([ '--create-home', - '--shell', shell, + '--shell', shell if shell else '/bin/bash', '--password', password, ]) if not primary_group: