Skip to content

Commit

Permalink
override user shell when performing homedir copy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anodos325 committed Aug 30, 2024
1 parent 1218dea commit c07dbc8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}")

Expand Down

0 comments on commit c07dbc8

Please sign in to comment.