Print this page
NEX-19057 All zfs/nfs/smb threads in door calls to idle idmap
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-5260 smbd segfaults while running smbtorture:rpc.lsa.lookupnames
NEX-5261 smbd segfaults while running smbtorture:rpc.winreg
NEX-5262 smbd segfaults while running smbtorture:rpc.samba3
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-2667 Wrong error when join domain with wrong password
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
NEX-2225 Unable to join NexentaStor to 2008 AD

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libmlsvc/common/lsalib.c
          +++ new/usr/src/lib/smbsrv/libmlsvc/common/lsalib.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       24 + * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
  25   25   */
  26   26  
  27   27  /*
  28   28   * This module provides the high level interface to the LSA RPC functions.
  29   29   */
  30   30  
  31   31  #include <strings.h>
  32   32  #include <unistd.h>
  33   33  
  34   34  #include <smbsrv/libsmb.h>
  35   35  #include <smbsrv/libmlsvc.h>
  36   36  #include <smbsrv/smbinfo.h>
  37   37  #include <smbsrv/smb_token.h>
  38   38  
  39   39  #include <lsalib.h>
  40   40  
       41 +static uint32_t lsa_lookup_name_int(char *, uint16_t, smb_account_t *,
       42 +    boolean_t);
       43 +static uint32_t lsa_lookup_sid_int(smb_sid_t *, smb_account_t *, boolean_t);
       44 +
  41   45  static uint32_t lsa_lookup_name_builtin(char *, char *, smb_account_t *);
  42   46  static uint32_t lsa_lookup_name_domain(char *, smb_account_t *);
  43   47  
  44   48  static uint32_t lsa_lookup_sid_builtin(smb_sid_t *, smb_account_t *);
  45   49  static uint32_t lsa_lookup_sid_domain(smb_sid_t *, smb_account_t *);
  46   50  
  47   51  static uint32_t lsa_list_accounts(mlsvc_handle_t *);
  48   52  static uint32_t lsa_map_status(uint32_t);
  49   53  
  50   54  /*
↓ open down ↓ 17 lines elided ↑ open up ↑
  68   72   * account argument could be either [domain\]name or [domain/]name.
  69   73   *
  70   74   * Return status:
  71   75   *
  72   76   *   NT_STATUS_SUCCESS          Account is successfully translated
  73   77   *   NT_STATUS_NONE_MAPPED      Couldn't translate the account
  74   78   */
  75   79  uint32_t
  76   80  lsa_lookup_name(char *account, uint16_t type, smb_account_t *info)
  77   81  {
       82 +        return (lsa_lookup_name_int(account, type, info, B_TRUE));
       83 +}
       84 +
       85 +/* Variant that avoids the call out to AD. */
       86 +uint32_t
       87 +lsa_lookup_lname(char *account, uint16_t type, smb_account_t *info)
       88 +{
       89 +        return (lsa_lookup_name_int(account, type, info, B_FALSE));
       90 +}
       91 +
       92 +uint32_t
       93 +lsa_lookup_name_int(char *account, uint16_t type, smb_account_t *info,
       94 +    boolean_t try_ad)
       95 +{
  78   96          char nambuf[SMB_USERNAME_MAXLEN];
  79   97          char dombuf[SMB_PI_MAX_DOMAIN];
  80   98          char *name, *domain;
  81   99          uint32_t status;
  82  100          char *slash;
  83  101  
      102 +        if (account == NULL)
      103 +                return (NT_STATUS_NONE_MAPPED);
      104 +
  84  105          (void) strsubst(account, '/', '\\');
  85  106          (void) strcanon(account, "\\");
  86  107          /* \john -> john */
  87  108          account += strspn(account, "\\");
  88  109  
  89  110          if ((slash = strchr(account, '\\')) != NULL) {
  90  111                  *slash = '\0';
  91  112                  (void) strlcpy(dombuf, account, sizeof (dombuf));
  92  113                  (void) strlcpy(nambuf, slash + 1, sizeof (nambuf));
  93  114                  *slash = '\\';
↓ open down ↓ 3 lines elided ↑ open up ↑
  97  118                  name = account;
  98  119                  domain = NULL;
  99  120          }
 100  121  
 101  122          status = lsa_lookup_name_builtin(domain, name, info);
 102  123          if (status == NT_STATUS_NOT_FOUND) {
 103  124                  status = smb_sam_lookup_name(domain, name, type, info);
 104  125                  if (status == NT_STATUS_SUCCESS)
 105  126                          return (status);
 106  127  
 107      -                if ((domain == NULL) || (status == NT_STATUS_NOT_FOUND))
      128 +                if (try_ad && ((domain == NULL) ||
      129 +                    (status == NT_STATUS_NOT_FOUND))) {
 108  130                          status = lsa_lookup_name_domain(account, info);
      131 +                }
 109  132          }
 110  133  
 111  134          return ((status == NT_STATUS_SUCCESS) ? status : NT_STATUS_NONE_MAPPED);
 112  135  }
 113  136  
 114  137  uint32_t
 115  138  lsa_lookup_sid(smb_sid_t *sid, smb_account_t *info)
 116  139  {
      140 +        return (lsa_lookup_sid_int(sid, info, B_TRUE));
      141 +}
      142 +
      143 +/* Variant that avoids the call out to AD. */
      144 +uint32_t
      145 +lsa_lookup_lsid(smb_sid_t *sid, smb_account_t *info)
      146 +{
      147 +        return (lsa_lookup_sid_int(sid, info, B_FALSE));
      148 +}
      149 +
      150 +static uint32_t
      151 +lsa_lookup_sid_int(smb_sid_t *sid, smb_account_t *info, boolean_t try_ad)
      152 +{
 117  153          uint32_t status;
 118  154  
 119  155          if (!smb_sid_isvalid(sid))
 120  156                  return (NT_STATUS_INVALID_SID);
 121  157  
 122  158          status = lsa_lookup_sid_builtin(sid, info);
 123  159          if (status == NT_STATUS_NOT_FOUND) {
 124  160                  status = smb_sam_lookup_sid(sid, info);
 125      -                if (status == NT_STATUS_NOT_FOUND)
      161 +                if (try_ad && status == NT_STATUS_NOT_FOUND) {
 126  162                          status = lsa_lookup_sid_domain(sid, info);
      163 +                }
 127  164          }
 128  165  
 129  166          return ((status == NT_STATUS_SUCCESS) ? status : NT_STATUS_NONE_MAPPED);
 130  167  }
 131  168  
 132  169  /*
 133  170   * Obtains the primary domain SID and name from the specified server
 134  171   * (domain controller).
 135  172   *
 136  173   * The requested information will be returned via 'info' argument.
↓ open down ↓ 463 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX