Skip to content

Commit b8ed9da

Browse files
meetakshi253smfrench
authored andcommitted
cifs: support reconnect with alternate password for SMB1
SMB1 shares the mount and remount code paths with SMB2/3 and already supports password rotation in some scenarios. This patch extends the password rotation support to SMB1 reconnects as well. Cc: [email protected] Signed-off-by: Meetakshi Setiya <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 5bc55a3 commit b8ed9da

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/smb/client/cifssmb.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,17 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
152152
spin_unlock(&ses->ses_lock);
153153

154154
rc = cifs_negotiate_protocol(0, ses, server);
155-
if (!rc)
155+
if (!rc) {
156156
rc = cifs_setup_session(0, ses, server, ses->local_nls);
157+
if ((rc == -EACCES) || (rc == -EHOSTDOWN) || (rc == -EKEYREVOKED)) {
158+
/*
159+
* Try alternate password for next reconnect if an alternate
160+
* password is available.
161+
*/
162+
if (ses->password2)
163+
swap(ses->password2, ses->password);
164+
}
165+
}
157166

158167
/* do we need to reconnect tcon? */
159168
if (rc || !tcon->need_reconnect) {

0 commit comments

Comments
 (0)