Print this page
NEX-16031 Samba's smbclient fails to authenticate using Kerberos with NT_STATUS_WRONG_PASSWORD
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/gss_mechs/mech_krb5/mech/accept_sec_context.c
          +++ new/usr/src/lib/gss_mechs/mech_krb5/mech/accept_sec_context.c
   1    1  /*
   2    2   * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
        3 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
   3    4   */
   4    5  /*
   5    6   * Copyright 2000, 2004  by the Massachusetts Institute of Technology.
   6    7   * All Rights Reserved.
   7    8   *
   8    9   * Export of this software from the United States of America may
   9   10   *   require a specific license from the United States Government.
  10   11   *   It is the responsibility of any person or organization contemplating
  11   12   *   export to obtain such a license before exporting.
  12   13   * 
↓ open down ↓ 118 lines elided ↑ open up ↑
 131  132           * all -- at this level.  So if the first call to krb5_rd_cred fails,
 132  133           * we should call it a second time with another auth context freshly
 133  134           * created by krb5_auth_con_init.  All of its keyblock fields will be
 134  135           * NULL, so krb5_rd_cred will assume that the KRB_CRED message is
 135  136           * unencrypted.  (The MIT code doesn't actually send the KRB_CRED
 136  137           * message in the clear -- the "authenticator" whose "checksum" ends up
 137  138           * containing the KRB_CRED message does get encrypted.)
 138  139           */
 139  140      /* Solaris Kerberos */
 140  141      if ((retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL))) {
 141      -        krb5_enctype enctype = ENCTYPE_NULL;
 142      -        /*
 143      -         * If the client is using non-DES enctypes it really ought to
 144      -         * send encrypted KRB-CREDs...
 145      -         */
 146      -        if (auth_context->keyblock != NULL)
 147      -            enctype = auth_context->keyblock->enctype;
 148      -        switch (enctype) {
 149      -        case ENCTYPE_DES_CBC_MD5:
 150      -        case ENCTYPE_DES_CBC_CRC:
 151      -        case ENCTYPE_DES3_CBC_SHA1:
 152      -            break;
 153      -        default:
 154      -            KRB5_LOG(KRB5_ERR, "rd_and_store_for_creds() error "
 155      -                    "krb5_rd_cred() retval = %d\n", retval);
 156      -            goto cleanup;
 157      -            /* NOTREACHED */
 158      -            break;
 159      -        }
      142 +        krb5_error_code retval2 = retval;
 160  143  
 161  144          /* Try to krb5_rd_cred() likely unencrypted KRB-CRED */
 162  145                  if ((retval = krb5_auth_con_init(context, &new_auth_ctx)))
 163  146                          goto cleanup;
 164  147                  krb5_auth_con_setflags(context, new_auth_ctx, 0);
 165  148                  if ((retval = krb5_rd_cred(context, new_auth_ctx, inbuf,
 166  149                                             &creds, NULL))) {
 167  150                          /* Solaris Kerberos */
 168      -                        KRB5_LOG(KRB5_ERR, "rd_and_store_for_creds() error "
 169      -                            "krb5_rd_cred() retval = %d\n", retval);
      151 +                        KRB5_LOG1(KRB5_ERR, "rd_and_store_for_creds() error "
      152 +                            "krb5_rd_cred() retval = %d original = %d\n",
      153 +                            retval, retval2);
 170  154                          goto cleanup;
 171  155                  }
 172  156      }
 173  157  
 174  158      if ((retval = krb5_cc_new_unique(context, "MEMORY", NULL, &ccache))) {
 175  159          ccache = NULL;
 176  160          goto cleanup;
 177  161      }
 178  162  
 179  163      if ((retval = krb5_cc_initialize(context, ccache, creds[0]->client))) {
↓ open down ↓ 1164 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX