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-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-2225 Unable to join NexentaStor to 2008 AD
NEX-2286 smbadm join error messages are uninformative
NEX-1638 Updated DC Locator
 Includes work by: matt.barden@nexenta.com, kevin.crowe@nexenta.com
SMB-149 mount.cifs RedHat\Centos 6 doesn't work with default security options (fix lint)
SMB-149 mount.cifs RedHat\Centos 6 doesn't work with default security options
SMB-136 Snapshots not visible in Windows previous versions
SMB-39 Use AF_UNIX pipes for RPC
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.c
          +++ new/usr/src/cmd/smbsrv/smbd/smbd_doorsvc.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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       23 + * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  
  26   26  #include <sys/list.h>
  27   27  #include <assert.h>
  28   28  #include <alloca.h>
  29   29  #include <door.h>
  30   30  #include <errno.h>
  31   31  #include <syslog.h>
  32   32  #include <unistd.h>
  33   33  #include <stdio.h>
↓ open down ↓ 62 lines elided ↑ open up ↑
  96   96          { SMB_DR_GET_DCINFO,            smbd_dop_get_dcinfo },
  97   97          { SMB_DR_VSS_GET_COUNT,         smbd_dop_vss_get_count },
  98   98          { SMB_DR_VSS_GET_SNAPSHOTS,     smbd_dop_vss_get_snapshots },
  99   99          { SMB_DR_VSS_MAP_GMTTOKEN,      smbd_dop_vss_map_gmttoken },
 100  100          { SMB_DR_ADS_FIND_HOST,         smbd_dop_ads_find_host },
 101  101          { SMB_DR_QUOTA_QUERY,           smbd_dop_quota_query },
 102  102          { SMB_DR_QUOTA_SET,             smbd_dop_quota_set },
 103  103          { SMB_DR_DFS_GET_REFERRALS,     smbd_dop_dfs_get_referrals },
 104  104          { SMB_DR_SHR_HOSTACCESS,        smbd_dop_shr_hostaccess },
 105  105          { SMB_DR_SHR_EXEC,              smbd_dop_shr_exec },
 106      -        { SMB_DR_NOTIFY_DC_CHANGED,     smbd_dop_notify_dc_changed }
      106 +        { SMB_DR_NOTIFY_DC_CHANGED,     smbd_dop_notify_dc_changed },
      107 +        { SMB_DR_LOOKUP_LSID,           smbd_dop_lookup_sid },
      108 +        { SMB_DR_LOOKUP_LNAME,          smbd_dop_lookup_name }
 107  109  };
 108  110  
 109  111  static int smbd_ndoorop = (sizeof (smbd_doorops) / sizeof (smbd_doorops[0]));
 110  112  
 111  113  static smbd_doorsvc_t smbd_doorsvc;
 112  114  static int smbd_door_fd = -1;
 113  115  static int smbd_door_cookie = 0x534D4244;       /* SMBD */
 114  116  static smbd_door_t smbd_door_sdh;
 115  117  static char *smbd_door_name = NULL;
 116  118  
↓ open down ↓ 457 lines elided ↑ open up ↑
 574  576   */
 575  577  static int
 576  578  smbd_dop_user_auth_logon(smbd_arg_t *arg)
 577  579  {
 578  580          _NOTE(ARGUNUSED(arg))
 579  581  
 580  582          /* No longer used */
 581  583          return (SMB_DOP_EMPTYBUF);
 582  584  }
 583  585  
      586 +/*
      587 + * SMB_DR_LOOKUP_NAME,
      588 + * SMB_DR_LOOKUP_LNAME (local-only, for idmap)
      589 + */
 584  590  static int
 585  591  smbd_dop_lookup_name(smbd_arg_t *arg)
 586  592  {
 587  593          smb_domain_t    dinfo;
 588  594          smb_account_t   ainfo;
 589  595          lsa_account_t   acct;
 590  596          char            buf[MAXNAMELEN];
 591  597  
 592  598          bzero(&acct, sizeof (lsa_account_t));
 593  599  
↓ open down ↓ 3 lines elided ↑ open up ↑
 597  603  
 598  604          if (*acct.a_domain == '\0')
 599  605                  (void) snprintf(buf, MAXNAMELEN, "%s", acct.a_name);
 600  606          else if (strchr(acct.a_domain, '.') != NULL)
 601  607                  (void) snprintf(buf, MAXNAMELEN, "%s@%s", acct.a_name,
 602  608                      acct.a_domain);
 603  609          else
 604  610                  (void) snprintf(buf, MAXNAMELEN, "%s\\%s", acct.a_domain,
 605  611                      acct.a_name);
 606  612  
 607      -        acct.a_status = lsa_lookup_name(buf, acct.a_sidtype, &ainfo);
      613 +        switch (arg->hdr.dh_op) {
      614 +        case SMB_DR_LOOKUP_NAME:
      615 +                acct.a_status = lsa_lookup_name(buf, acct.a_sidtype, &ainfo);
      616 +                break;
      617 +
      618 +        case SMB_DR_LOOKUP_LNAME:
      619 +                /*
      620 +                 * Basically for idmap.  Don't call out to AD.
      621 +                 */
      622 +                acct.a_status = lsa_lookup_lname(buf, acct.a_sidtype, &ainfo);
      623 +                break;
      624 +
      625 +        default:
      626 +                assert(!"arg->hdr.dh_op");
      627 +                acct.a_status = NT_STATUS_INTERNAL_ERROR;
      628 +                break;
      629 +        }
      630 +
 608  631          if (acct.a_status == NT_STATUS_SUCCESS) {
 609  632                  acct.a_sidtype = ainfo.a_type;
 610  633                  smb_sid_tostr(ainfo.a_sid, acct.a_sid);
 611  634                  (void) strlcpy(acct.a_name, ainfo.a_name, MAXNAMELEN);
 612  635  
 613  636                  if (smb_domain_lookup_name(ainfo.a_domain, &dinfo))
 614  637                          (void) strlcpy(acct.a_domain, dinfo.di_fqname,
 615  638                              MAXNAMELEN);
 616  639                  else
 617  640                          (void) strlcpy(acct.a_domain, ainfo.a_domain,
↓ open down ↓ 1 lines elided ↑ open up ↑
 619  642                  smb_account_free(&ainfo);
 620  643          }
 621  644  
 622  645          arg->rbuf = smb_common_encode(&acct, lsa_account_xdr, &arg->rsize);
 623  646  
 624  647          if (arg->rbuf == NULL)
 625  648                  return (SMB_DOP_ENCODE_ERROR);
 626  649          return (SMB_DOP_SUCCESS);
 627  650  }
 628  651  
      652 +/*
      653 + * SMB_DR_LOOKUP_SID,
      654 + * SMB_DR_LOOKUP_LSID (local-only, for idmap)
      655 + */
 629  656  static int
 630  657  smbd_dop_lookup_sid(smbd_arg_t *arg)
 631  658  {
 632  659          smb_domain_t    dinfo;
 633  660          smb_account_t   ainfo;
 634  661          lsa_account_t   acct;
 635  662          smb_sid_t       *sid;
 636  663  
 637  664          bzero(&acct, sizeof (lsa_account_t));
 638  665  
 639  666          if (smb_common_decode(arg->data, arg->datalen,
 640  667              lsa_account_xdr, &acct) != 0)
 641  668                  return (SMB_DOP_DECODE_ERROR);
 642  669  
 643  670          sid = smb_sid_fromstr(acct.a_sid);
 644      -        acct.a_status = lsa_lookup_sid(sid, &ainfo);
      671 +
      672 +        switch (arg->hdr.dh_op) {
      673 +        case SMB_DR_LOOKUP_SID:
      674 +                acct.a_status = lsa_lookup_sid(sid, &ainfo);
      675 +                break;
      676 +
      677 +        case SMB_DR_LOOKUP_LSID:
      678 +                /*
      679 +                 * Basically for idmap.  Don't call out to AD.
      680 +                 */
      681 +                acct.a_status = lsa_lookup_lsid(sid, &ainfo);
      682 +                break;
      683 +
      684 +        default:
      685 +                assert(!"arg->hdr.dh_op");
      686 +                acct.a_status = NT_STATUS_INTERNAL_ERROR;
      687 +                break;
      688 +        }
      689 +
 645  690          smb_sid_free(sid);
 646  691  
 647  692          if (acct.a_status == NT_STATUS_SUCCESS) {
 648  693                  acct.a_sidtype = ainfo.a_type;
 649  694                  smb_sid_tostr(ainfo.a_sid, acct.a_sid);
 650  695                  (void) strlcpy(acct.a_name, ainfo.a_name, MAXNAMELEN);
 651  696  
 652  697                  if (smb_domain_lookup_name(ainfo.a_domain, &dinfo))
 653  698                          (void) strlcpy(acct.a_domain, dinfo.di_fqname,
 654  699                              MAXNAMELEN);
↓ open down ↓ 342 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX