Skip to content

Commit

Permalink
Added default shell for system users
Browse files Browse the repository at this point in the history
  • Loading branch information
Adithya-Rajendran committed Jul 1, 2024
1 parent 8c23752 commit 1902124
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions charmhelpers/core/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1902124

Please sign in to comment.