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>
1575 untangle libmlrpc from SMB server
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
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-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-2286 smbadm join error messages are uninformative
NEX-1638 Updated DC Locator
 Includes work by: matt.barden@nexenta.com, kevin.crowe@nexenta.com
NEX-816 smbadm dumps core during first join attempt
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 #include <assert.h>
  27 #include <syslog.h>
  28 #include <door.h>
  29 #include <fcntl.h>
  30 #include <string.h>
  31 #include <strings.h>
  32 #include <stdlib.h>
  33 #include <unistd.h>
  34 #include <errno.h>
  35 #include <sys/mman.h>

  36 #include <smbsrv/libsmb.h>
  37 #include <smbsrv/wintypes.h>
  38 #include <smbsrv/smb_door.h>
  39 
  40 static int smb_door_call(uint32_t, void *, xdrproc_t, void *, xdrproc_t);
  41 static int smb_door_call_private(int, smb_doorarg_t *);
  42 static int smb_door_encode(smb_doorarg_t *, uint32_t);
  43 static int smb_door_decode(smb_doorarg_t *);
  44 static void smb_door_sethdr(smb_doorhdr_t *, uint32_t, uint32_t);
  45 static boolean_t smb_door_chkhdr(smb_doorarg_t *, smb_doorhdr_t *);
  46 static void smb_door_free(door_arg_t *arg);



  47 
  48 /*
  49  * Given a SID, make a door call to get  the associated name.
  50  *
  51  * Returns 0 if the door call is successful, otherwise -1.
  52  *
  53  * If 0 is returned, the lookup result will be available in a_status.
  54  * NT_STATUS_SUCCESS            The SID was mapped to a name.
  55  * NT_STATUS_NONE_MAPPED        The SID could not be mapped to a name.
  56  */
  57 int
  58 smb_lookup_sid(const char *sid, lsa_account_t *acct)
  59 {














  60         int     rc;
  61 
  62         assert((sid != NULL) && (acct != NULL));
  63 
  64         bzero(acct, sizeof (lsa_account_t));
  65         (void) strlcpy(acct->a_sid, sid, SMB_SID_STRSZ);
  66 
  67         rc = smb_door_call(SMB_DR_LOOKUP_SID, acct, lsa_account_xdr,
  68             acct, lsa_account_xdr);
  69 
  70         if (rc != 0)
  71                 syslog(LOG_DEBUG, "smb_lookup_sid: %m");
  72         return (rc);
  73 }
  74 
  75 /*
  76  * Given a name, make a door call to get the associated SID.
  77  *
  78  * Returns 0 if the door call is successful, otherwise -1.
  79  *
  80  * If 0 is returned, the lookup result will be available in a_status.
  81  * NT_STATUS_SUCCESS            The name was mapped to a SID.
  82  * NT_STATUS_NONE_MAPPED        The name could not be mapped to a SID.
  83  */
  84 int
  85 smb_lookup_name(const char *name, sid_type_t sidtype, lsa_account_t *acct)
  86 {













  87         char            tmp[MAXNAMELEN];
  88         char            *dp = NULL;
  89         char            *np = NULL;
  90         int             rc;
  91 
  92         assert((name != NULL) && (acct != NULL));
  93 
  94         (void) strlcpy(tmp, name, MAXNAMELEN);
  95         smb_name_parse(tmp, &np, &dp);
  96 
  97         bzero(acct, sizeof (lsa_account_t));
  98         acct->a_sidtype = sidtype;
  99 
 100         if (dp != NULL && np != NULL) {
 101                 (void) strlcpy(acct->a_domain, dp, MAXNAMELEN);
 102                 (void) strlcpy(acct->a_name, np, MAXNAMELEN);
 103         } else {
 104                 (void) strlcpy(acct->a_name, name, MAXNAMELEN);
 105         }
 106 
 107         rc = smb_door_call(SMB_DR_LOOKUP_NAME, acct, lsa_account_xdr,
 108             acct, lsa_account_xdr);
 109 
 110         if (rc != 0)
 111                 syslog(LOG_DEBUG, "smb_lookup_name: %m");
 112         return (rc);
 113 }
 114 
 115 int
 116 smb_join(smb_joininfo_t *jdi, smb_joinres_t *jres)
 117 {
 118         int             rc;
 119 
 120         rc = smb_door_call(SMB_DR_JOIN, jdi, smb_joininfo_xdr,
 121             jres, smb_joinres_xdr);
 122 
 123         if (rc != 0) {
 124                 /*
 125                  * This usually means the SMB service is not running.
 126                  */
 127                 syslog(LOG_DEBUG, "smb_join: %m");




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 #include <assert.h>
  27 #include <syslog.h>
  28 #include <door.h>
  29 #include <fcntl.h>
  30 #include <string.h>
  31 #include <strings.h>
  32 #include <stdlib.h>
  33 #include <unistd.h>
  34 #include <errno.h>
  35 #include <sys/mman.h>
  36 #include <smb/wintypes.h>
  37 #include <smbsrv/libsmb.h>

  38 #include <smbsrv/smb_door.h>
  39 
  40 static int smb_door_call(uint32_t, void *, xdrproc_t, void *, xdrproc_t);
  41 static int smb_door_call_private(int, smb_doorarg_t *);
  42 static int smb_door_encode(smb_doorarg_t *, uint32_t);
  43 static int smb_door_decode(smb_doorarg_t *);
  44 static void smb_door_sethdr(smb_doorhdr_t *, uint32_t, uint32_t);
  45 static boolean_t smb_door_chkhdr(smb_doorarg_t *, smb_doorhdr_t *);
  46 static void smb_door_free(door_arg_t *arg);
  47 static int smb_lookup_name_int(const char *name, sid_type_t sidtype,
  48     lsa_account_t *acct, int);
  49 static int smb_lookup_sid_int(const char *sid, lsa_account_t *acct, int);
  50 
  51 /*
  52  * Given a SID, make a door call to get  the associated name.
  53  *
  54  * Returns 0 if the door call is successful, otherwise -1.
  55  *
  56  * If 0 is returned, the lookup result will be available in a_status.
  57  * NT_STATUS_SUCCESS            The SID was mapped to a name.
  58  * NT_STATUS_NONE_MAPPED        The SID could not be mapped to a name.
  59  */
  60 int
  61 smb_lookup_sid(const char *sid, lsa_account_t *acct)
  62 {
  63         return (smb_lookup_sid_int(sid, acct, SMB_DR_LOOKUP_SID));
  64 }
  65 /*
  66  * Variant of smb_lookup_sid to do a "local-only" lookup.
  67  */
  68 int
  69 smb_lookup_lsid(const char *sid, lsa_account_t *acct)
  70 {
  71         return (smb_lookup_sid_int(sid, acct, SMB_DR_LOOKUP_LSID));
  72 }
  73 
  74 static int
  75 smb_lookup_sid_int(const char *sid, lsa_account_t *acct, int dop)
  76 {
  77         int     rc;
  78 
  79         assert((sid != NULL) && (acct != NULL));
  80 
  81         bzero(acct, sizeof (lsa_account_t));
  82         (void) strlcpy(acct->a_sid, sid, SMB_SID_STRSZ);
  83 
  84         rc = smb_door_call(dop, acct, lsa_account_xdr,
  85             acct, lsa_account_xdr);
  86 
  87         if (rc != 0)
  88                 syslog(LOG_DEBUG, "smb_lookup_sid: %m");
  89         return (rc);
  90 }
  91 
  92 /*
  93  * Given a name, make a door call to get the associated SID.
  94  *
  95  * Returns 0 if the door call is successful, otherwise -1.
  96  *
  97  * If 0 is returned, the lookup result will be available in a_status.
  98  * NT_STATUS_SUCCESS            The name was mapped to a SID.
  99  * NT_STATUS_NONE_MAPPED        The name could not be mapped to a SID.
 100  */
 101 int
 102 smb_lookup_name(const char *name, sid_type_t sidtype, lsa_account_t *acct)
 103 {
 104         return (smb_lookup_name_int(name, sidtype, acct, SMB_DR_LOOKUP_NAME));
 105 }
 106 
 107 int
 108 smb_lookup_lname(const char *name, sid_type_t sidtype, lsa_account_t *acct)
 109 {
 110         return (smb_lookup_name_int(name, sidtype, acct, SMB_DR_LOOKUP_LNAME));
 111 }
 112 
 113 static int
 114 smb_lookup_name_int(const char *name, sid_type_t sidtype, lsa_account_t *acct,
 115     int dop)
 116 {
 117         char            tmp[MAXNAMELEN];
 118         char            *dp = NULL;
 119         char            *np = NULL;
 120         int             rc;
 121 
 122         assert((name != NULL) && (acct != NULL));
 123 
 124         (void) strlcpy(tmp, name, MAXNAMELEN);
 125         smb_name_parse(tmp, &np, &dp);
 126 
 127         bzero(acct, sizeof (lsa_account_t));
 128         acct->a_sidtype = sidtype;
 129 
 130         if (dp != NULL && np != NULL) {
 131                 (void) strlcpy(acct->a_domain, dp, MAXNAMELEN);
 132                 (void) strlcpy(acct->a_name, np, MAXNAMELEN);
 133         } else {
 134                 (void) strlcpy(acct->a_name, name, MAXNAMELEN);
 135         }
 136 
 137         rc = smb_door_call(dop, acct, lsa_account_xdr,
 138             acct, lsa_account_xdr);
 139 
 140         if (rc != 0)
 141                 syslog(LOG_DEBUG, "smb_lookup_name: %m");
 142         return (rc);
 143 }
 144 
 145 int
 146 smb_join(smb_joininfo_t *jdi, smb_joinres_t *jres)
 147 {
 148         int             rc;
 149 
 150         rc = smb_door_call(SMB_DR_JOIN, jdi, smb_joininfo_xdr,
 151             jres, smb_joinres_xdr);
 152 
 153         if (rc != 0) {
 154                 /*
 155                  * This usually means the SMB service is not running.
 156                  */
 157                 syslog(LOG_DEBUG, "smb_join: %m");