Print this page
NEX-17589 Get "too high" smbd error when copy big file to cifs share
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-17795 SMB logon should tolerate idmap problems
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-15558 SMB logon fails during 1st second after service start
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15558 SMB logon fails during 1st second after service start
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-9497 SMB should bypass ACL traverse checking
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-3080 SMB1 signing problem with Kerberos auth.
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
NEX-2461 smb_split_sid uses wrong allocation size
NEX-1810 extended security Kerberos (inbound)
SMB-126 Unable to map share from win2003/win2003R2 client ...
SMB-107 Unable to map network drive in workgroup mode using Windows XP...
SMB-68 NTLM(v1) inbound with Extended Session Security
SMB-56 extended security NTLMSSP, inbound

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libmlsvc/common/smb_logon.c
          +++ new/usr/src/lib/smbsrv/libmlsvc/common/smb_logon.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24   23   * Copyright (c) 2016 by Delphix. All rights reserved.
       24 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  25   25   */
  26   26  
  27   27  #include <unistd.h>
  28   28  #include <strings.h>
  29   29  #include <pwd.h>
  30   30  #include <grp.h>
  31   31  #include <time.h>
  32   32  #include <syslog.h>
  33   33  #include <assert.h>
  34   34  #include <synch.h>
↓ open down ↓ 87 lines elided ↑ open up ↑
 122  122                          break;
 123  123          }
 124  124  
 125  125          return (stat);
 126  126  }
 127  127  
 128  128  /*
 129  129   * smb_token_sids2ids
 130  130   *
 131  131   * This will map all the SIDs of the access token to UIDs/GIDs.
      132 + * However, if there are some SIDs we can't map to UIDs/GIDs,
      133 + * we don't want to fail the logon, and instead just log the
      134 + * SIDs we could not map and continue as best we can.
      135 + * The flag SMB_IDMAP_SKIP_ERRS below does that.
 132  136   *
 133  137   * Returns 0 upon success.  Otherwise, returns -1.
 134  138   */
 135  139  static int
 136  140  smb_token_sids2ids(smb_token_t *token)
 137  141  {
 138  142          idmap_stat stat;
 139  143          int nmaps;
 140  144          smb_idmap_batch_t sib;
 141  145  
 142  146          /*
 143  147           * Number of idmap lookups: user SID, owner SID, primary group SID,
 144  148           * and all Windows group SIDs. Skip user/owner SID for Anonymous.
 145  149           */
 146  150          if (token->tkn_flags & SMB_ATF_ANON)
 147  151                  nmaps = token->tkn_win_grps.i_cnt + 1;
 148  152          else
 149  153                  nmaps = token->tkn_win_grps.i_cnt + 3;
 150  154  
 151      -        stat = smb_idmap_batch_create(&sib, nmaps, SMB_IDMAP_SID2ID);
      155 +        stat = smb_idmap_batch_create(&sib, nmaps,
      156 +            SMB_IDMAP_SID2ID | SMB_IDMAP_SKIP_ERRS);
 152  157          if (stat != IDMAP_SUCCESS)
 153  158                  return (-1);
 154  159  
 155  160          stat = smb_token_idmap(token, &sib);
 156  161          if (stat != IDMAP_SUCCESS) {
 157  162                  smb_idmap_batch_destroy(&sib);
 158  163                  return (-1);
 159  164          }
 160  165  
 161  166          stat = smb_idmap_batch_getmappings(&sib);
↓ open down ↓ 154 lines elided ↑ open up ↑
 316  321                          smb_privset_merge(privs, grp.sg_privs);
 317  322                          smb_lgrp_free(&grp);
 318  323                  }
 319  324  
 320  325                  /*
 321  326                   * This privilege is required to view/edit SACL
 322  327                   */
 323  328                  smb_privset_enable(privs, SE_SECURITY_LUID);
 324  329          }
 325  330  
      331 +        /*
      332 +         * Members of "Authenticated Users" (!anon) should normally get
      333 +         * "Bypass traverse checking" privilege, though we allow this
      334 +         * to be disabled (see smb.4).  For historical reasons, the
      335 +         * internal privilege name is "SeChangeNotifyPrivilege".
      336 +         */
      337 +        if ((token->tkn_flags & SMB_ATF_ANON) == 0 &&
      338 +            smb_config_getbool(SMB_CI_BYPASS_TRAVERSE_CHECKING))
      339 +                smb_privset_enable(privs, SE_CHANGE_NOTIFY_LUID);
      340 +
 326  341          return (privs);
 327  342  }
 328  343  
 329  344  static void
 330  345  smb_token_set_flags(smb_token_t *token)
 331  346  {
 332  347          if (smb_token_is_member(token, smb_wka_get_sid("Administrators")))
 333  348                  token->tkn_flags |= SMB_ATF_ADMIN;
 334  349  
 335  350          if (smb_token_is_member(token, smb_wka_get_sid("Power Users")))
↓ open down ↓ 74 lines elided ↑ open up ↑
 410  425          (void) rw_unlock(&smb_logoninit_rwl);
 411  426  }
 412  427  
 413  428  /*
 414  429   * Perform user authentication.
 415  430   *
 416  431   * The dispatched functions must only update the user_info status if they
 417  432   * attempt to authenticate the user.
 418  433   *
 419  434   * On success, a pointer to a new access token is returned.
      435 + * On failure, NULL return and status in user_info->lg_status
 420  436   */
 421  437  smb_token_t *
 422  438  smb_logon(smb_logon_t *user_info)
 423  439  {
 424  440          static smb_logonop_t    ops[] = {
 425  441                  smb_logon_anon,
 426  442                  smb_logon_local,
 427  443                  smb_logon_domain,
 428  444                  smb_logon_guest
 429  445          };
 430  446          smb_token_t             *token = NULL;
 431  447          smb_domain_t            domain;
 432  448          int                     n_op = (sizeof (ops) / sizeof (ops[0]));
 433  449          int                     i;
 434  450  
 435  451          user_info->lg_secmode = smb_config_get_secmode();
 436      -        user_info->lg_status = NT_STATUS_NO_SUCH_USER;
 437  452  
 438  453          if (smb_domain_lookup_name(user_info->lg_e_domain, &domain))
 439  454                  user_info->lg_domain_type = domain.di_type;
 440  455          else
 441  456                  user_info->lg_domain_type = SMB_DOMAIN_NULL;
 442  457  
 443  458          if ((token = calloc(1, sizeof (smb_token_t))) == NULL) {
 444  459                  syslog(LOG_ERR, "logon[%s\\%s]: %m",
 445  460                      user_info->lg_e_domain, user_info->lg_e_username);
 446  461                  return (NULL);
 447  462          }
 448  463  
      464 +        /*
      465 +         * If any logonop function takes significant action
      466 +         * (logon or authoratative failure) it will change
      467 +         * this status field to something else.
      468 +         */
      469 +        user_info->lg_status = NT_STATUS_NO_SUCH_USER;
 449  470          for (i = 0; i < n_op; ++i) {
 450  471                  (*ops[i])(user_info, token);
 451  472  
 452  473                  if (user_info->lg_status == NT_STATUS_SUCCESS)
 453  474                          break;
 454  475          }
 455  476  
 456  477          if (user_info->lg_status == NT_STATUS_SUCCESS) {
 457  478                  if (smb_token_setup_common(token))
 458      -                        return (token);
      479 +                        return (token); /* success */
      480 +                /*
      481 +                 * (else) smb_token_setup_common failed, which usually
      482 +                 * means smb_token_sids2ids() failed to map some SIDs to
      483 +                 * Unix IDs.  This indicates an idmap config problem.
      484 +                 */
      485 +                user_info->lg_status = NT_STATUS_INTERNAL_ERROR;
 459  486          }
 460  487  
 461  488          smb_token_destroy(token);
      489 +
      490 +        /*
      491 +         * Any unknown user or bad password should result in
      492 +         * NT_STATUS_LOGON_FAILURE (so we don't give hints).
      493 +         */
      494 +        if (user_info->lg_status == NT_STATUS_NO_SUCH_USER ||
      495 +            user_info->lg_status == NT_STATUS_WRONG_PASSWORD)
      496 +                user_info->lg_status = NT_STATUS_LOGON_FAILURE;
      497 +
 462  498          return (NULL);
 463  499  }
 464  500  
 465  501  /*
 466  502   * If the user has an entry in the local database, attempt local authentication.
 467  503   *
 468  504   * In domain mode, we try to exclude domain accounts, which we do by only
 469  505   * accepting local or null (blank) domain names here.  Some clients (Mac OS)
 470  506   * don't always send the domain name.
 471  507   *
↓ open down ↓ 478 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX