From 7372dc207962c6e16a5f9e73c6d082b39861b9cd Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 24 Nov 2022 14:42:43 +0100 Subject: [PATCH] be able to change the loginShell of a user --- src/user.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/user.py b/src/user.py index 84923106c..74a11e99d 100644 --- a/src/user.py +++ b/src/user.py @@ -134,6 +134,7 @@ def user_create( lastname=None, mailbox_quota="0", admin=False, + loginShell="/bin/bash", from_import=False, ): @@ -253,7 +254,7 @@ def user_create( "gidNumber": [uid], "uidNumber": [uid], "homeDirectory": ["/home/" + username], - "loginShell": ["/bin/bash"], + "loginShell": [loginShell], } try: @@ -363,6 +364,7 @@ def user_update( mailbox_quota=None, from_import=False, fullname=None, + loginShell=None, ): if firstname or lastname: @@ -524,6 +526,10 @@ def user_update( new_attr_dict["mailuserquota"] = [mailbox_quota] env_dict["YNH_USER_MAILQUOTA"] = mailbox_quota + if loginShell is not None: + new_attr_dict["loginShell"] = [loginShell] + env_dict["YNH_USER_LOGINSHELL"] = loginShell + if not from_import: operation_logger.start() @@ -532,6 +538,10 @@ def user_update( except Exception as e: raise YunohostError("user_update_failed", user=username, error=e) + # Invalidate passwd and group to update the loginShell + subprocess.call(["nscd", "-i", "passwd"]) + subprocess.call(["nscd", "-i", "group"]) + # Trigger post_user_update hooks hook_callback("post_user_update", env=env_dict)