Commit a761ac579b89bc1f00212a42401398108deba65c

Authored by Steve French
1 parent abb63d6c3d

[CIFS] log better errors on failed mounts

Also returns more accurate errors to mount for the cases of
account expired and password expired

Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>

Showing 6 changed files with 35 additions and 26 deletions Side-by-side Diff

... ... @@ -50,7 +50,8 @@
50 50 int * /* bytes returned */ , const int long_op);
51 51 extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *,
52 52 struct kvec *, int /* nvec to send */,
53   - int * /* type of buf returned */ , const int long_op);
  53 + int * /* type of buf returned */ , const int long_op,
  54 + const int logError /* whether to log status code*/ );
54 55 extern int SendReceiveBlockingLock(const unsigned int /* xid */ ,
55 56 struct cifsTconInfo *,
56 57 struct smb_hdr * /* input */ ,
... ... @@ -65,7 +66,7 @@
65 66 extern int decode_negTokenInit(unsigned char *security_blob, int length,
66 67 enum securityEnum *secType);
67 68 extern int cifs_inet_pton(int, char *source, void *dst);
68   -extern int map_smb_to_linux_error(struct smb_hdr *smb);
  69 +extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr);
69 70 extern void header_assemble(struct smb_hdr *, char /* command */ ,
70 71 const struct cifsTconInfo *, int /* length of
71 72 fixed section (word count) in two byte units */);
... ... @@ -1446,9 +1446,8 @@
1446 1446  
1447 1447 iov[0].iov_base = (char *)pSMB;
1448 1448 iov[0].iov_len = pSMB->hdr.smb_buf_length + 4;
1449   - rc = SendReceive2(xid, tcon->ses, iov,
1450   - 1 /* num iovecs */,
1451   - &resp_buf_type, 0);
  1449 + rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovecs */,
  1450 + &resp_buf_type, 0 /* not long op */, 1 /* log err */ );
1452 1451 cifs_stats_inc(&tcon->num_reads);
1453 1452 pSMBr = (READ_RSP *)iov[0].iov_base;
1454 1453 if (rc) {
... ... @@ -1667,7 +1666,7 @@
1667 1666  
1668 1667  
1669 1668 rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &resp_buf_type,
1670   - long_op);
  1669 + long_op, 0 /* do not log STATUS code */ );
1671 1670 cifs_stats_inc(&tcon->num_writes);
1672 1671 if (rc) {
1673 1672 cFYI(1, ("Send error Write2 = %d", rc));
... ... @@ -3094,7 +3093,8 @@
3094 3093 iov[0].iov_base = (char *)pSMB;
3095 3094 iov[0].iov_len = pSMB->hdr.smb_buf_length + 4;
3096 3095  
3097   - rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type, 0);
  3096 + rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type,
  3097 + 0 /* not long op */, 0 /* do not log STATUS codes */ );
3098 3098 cifs_stats_inc(&tcon->num_acl_get);
3099 3099 if (rc) {
3100 3100 cFYI(1, ("Send error in QuerySecDesc = %d", rc));
... ... @@ -114,10 +114,16 @@
114 114 {ERRusempx, -EIO},
115 115 {ERRusestd, -EIO},
116 116 {ERR_NOTIFY_ENUM_DIR, -ENOBUFS},
117   - {ERRaccountexpired, -EACCES},
  117 + {ERRnoSuchUser, -EACCES},
  118 +/* {ERRaccountexpired, -EACCES},
118 119 {ERRbadclient, -EACCES},
119 120 {ERRbadLogonTime, -EACCES},
120   - {ERRpasswordExpired, -EACCES},
  121 + {ERRpasswordExpired, -EACCES},*/
  122 + {ERRaccountexpired, -EKEYEXPIRED},
  123 + {ERRbadclient, -EACCES},
  124 + {ERRbadLogonTime, -EACCES},
  125 + {ERRpasswordExpired, -EKEYEXPIRED},
  126 +
121 127 {ERRnosupport, -EINVAL},
122 128 {0, 0}
123 129 };
... ... @@ -270,7 +276,7 @@
270 276 from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
271 277 during the session setup } */
272 278 {
273   - ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, {
  279 + ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { /* could map to 2238 */
274 280 ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, {
275 281 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, {
276 282 ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, {
277 283  
... ... @@ -285,10 +291,10 @@
285 291 ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, {
286 292 ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, {
287 293 ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, {
288   - ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS}, {
289   - ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION}, {
  294 + ERRSRV, ERRbadLogonTime, NT_STATUS_INVALID_LOGON_HOURS}, {
  295 + ERRSRV, ERRbadclient, NT_STATUS_INVALID_WORKSTATION}, {
290 296 ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, {
291   - ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED}, {
  297 + ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_DISABLED}, {
292 298 ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, {
293 299 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, {
294 300 ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, {
... ... @@ -585,7 +591,7 @@
585 591 ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, {
586 592 ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, {
587 593 ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, {
588   - ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED}, {
  594 + ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_EXPIRED}, {
589 595 ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, {
590 596 ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, {
591 597 ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, {
... ... @@ -754,7 +760,7 @@
754 760 }
755 761  
756 762 int
757   -map_smb_to_linux_error(struct smb_hdr *smb)
  763 +map_smb_to_linux_error(struct smb_hdr *smb, int logErr)
758 764 {
759 765 unsigned int i;
760 766 int rc = -EIO; /* if transport error smb error may not be set */
761 767  
... ... @@ -771,8 +777,10 @@
771 777 /* translate the newer STATUS codes to old style SMB errors
772 778 * and then to POSIX errors */
773 779 __u32 err = le32_to_cpu(smb->Status.CifsError);
774   - if (cifsFYI & CIFS_RC)
  780 + if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED)))
775 781 cifs_print_status(err);
  782 + else if (cifsFYI & CIFS_RC)
  783 + cifs_print_status(err);
776 784 ntstatus_to_dos(err, &smberrclass, &smberrcode);
777 785 } else {
778 786 smberrclass = smb->Status.DosError.ErrorClass;
... ... @@ -813,7 +821,7 @@
813 821 }
814 822 /* else ERRHRD class errors or junk - return EIO */
815 823  
816   - cFYI(1, (" !!Mapping smb error code %d to POSIX err %d !!",
  824 + cFYI(1, ("Mapping smb error code %d to POSIX err %d",
817 825 smberrcode, rc));
818 826  
819 827 /* generic corrective action e.g. reconnect SMB session on
... ... @@ -513,7 +513,8 @@
513 513  
514 514 iov[1].iov_base = str_area;
515 515 iov[1].iov_len = count;
516   - rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0);
  516 + rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type,
  517 + 0 /* not long op */, 1 /* log NT STATUS if any */ );
517 518 /* SMB request buf freed in SendReceive2 */
518 519  
519 520 cFYI(1, ("ssetup rc from sendrecv2 is %d", rc));
... ... @@ -173,9 +173,10 @@
173 173 #define ERRusestd 251 /* temporarily unable to use either raw
174 174 or mpx */
175 175 #define ERR_NOTIFY_ENUM_DIR 1024
  176 +#define ERRnoSuchUser 2238 /* user account does not exist */
176 177 #define ERRaccountexpired 2239
177   -#define ERRbadclient 2240
178   -#define ERRbadLogonTime 2241
  178 +#define ERRbadclient 2240 /* can not logon from this client */
  179 +#define ERRbadLogonTime 2241 /* logon hours do not allow this */
179 180 #define ERRpasswordExpired 2242
180 181 #define ERRnetlogonNotStarted 2455
181 182 #define ERRnosupport 0xFFFF
... ... @@ -418,7 +418,7 @@
418 418 int
419 419 SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
420 420 struct kvec *iov, int n_vec, int *pRespBufType /* ret */,
421   - const int long_op)
  421 + const int long_op, const int logError)
422 422 {
423 423 int rc = 0;
424 424 unsigned int receive_len;
... ... @@ -464,7 +464,6 @@
464 464 wake_up(&ses->server->request_q);
465 465 return rc;
466 466 }
467   -
468 467 rc = cifs_sign_smb2(iov, n_vec, ses->server, &midQ->sequence_number);
469 468  
470 469 midQ->midState = MID_REQUEST_SUBMITTED;
... ... @@ -567,8 +566,7 @@
567 566 }
568 567  
569 568 /* BB special case reconnect tid and uid here? */
570   - /* BB special case Errbadpassword and pwdexpired here */
571   - rc = map_smb_to_linux_error(midQ->resp_buf);
  569 + rc = map_smb_to_linux_error(midQ->resp_buf, logError);
572 570  
573 571 /* convert ByteCount if necessary */
574 572 if (receive_len >= sizeof(struct smb_hdr) - 4
... ... @@ -747,7 +745,7 @@
747 745 *pbytes_returned = out_buf->smb_buf_length;
748 746  
749 747 /* BB special case reconnect tid and uid here? */
750   - rc = map_smb_to_linux_error(out_buf);
  748 + rc = map_smb_to_linux_error(out_buf, 0 /* no log */ );
751 749  
752 750 /* convert ByteCount if necessary */
753 751 if (receive_len >= sizeof(struct smb_hdr) - 4
... ... @@ -990,7 +988,7 @@
990 988 *pbytes_returned = out_buf->smb_buf_length;
991 989  
992 990 /* BB special case reconnect tid and uid here? */
993   - rc = map_smb_to_linux_error(out_buf);
  991 + rc = map_smb_to_linux_error(out_buf, 0 /* no log */ );
994 992  
995 993 /* convert ByteCount if necessary */
996 994 if (receive_len >= sizeof(struct smb_hdr) - 4