From c07dbc85b515202760e3a77c326cfacfdf3d4f2d Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Fri, 30 Aug 2024 14:09:13 -0600 Subject: [PATCH] override user shell when performing homedir copy User may have nologin shell set and so we should make sure a usable shell is always selected when switching to the user when copying the homedir. If we don't do this then PAM will reject the pam_open_session() request causing the copy to fail. --- src/middlewared/middlewared/plugins/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewared/middlewared/plugins/account.py b/src/middlewared/middlewared/plugins/account.py index bc5c96738a748..7367c000c02a9 100644 --- a/src/middlewared/middlewared/plugins/account.py +++ b/src/middlewared/middlewared/plugins/account.py @@ -1305,7 +1305,7 @@ async def do_home_copy(self, job, home_old, home_new, username, new_mode, uid): await perm_job.wait() command = f"/bin/cp -a {shlex.quote(home_old) + '/' + '.'} {shlex.quote(home_new + '/')}" - do_copy = await run(["/usr/bin/su", "-", username, "-c", command], check=False) + do_copy = await run(["/usr/bin/su", "-s", "/usr/sbin/bash", "-", username, "-c", command], check=False) if do_copy.returncode != 0: raise CallError(f"Failed to copy homedir [{home_old}] to [{home_new}]: {do_copy.stderr.decode()}")