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>
        
@@ -18,11 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #include <assert.h>
 #include <syslog.h>
 #include <door.h>
@@ -31,21 +31,24 @@
 #include <strings.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
 #include <sys/mman.h>
+#include <smb/wintypes.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/wintypes.h>
 #include <smbsrv/smb_door.h>
 
 static int smb_door_call(uint32_t, void *, xdrproc_t, void *, xdrproc_t);
 static int smb_door_call_private(int, smb_doorarg_t *);
 static int smb_door_encode(smb_doorarg_t *, uint32_t);
 static int smb_door_decode(smb_doorarg_t *);
 static void smb_door_sethdr(smb_doorhdr_t *, uint32_t, uint32_t);
 static boolean_t smb_door_chkhdr(smb_doorarg_t *, smb_doorhdr_t *);
 static void smb_door_free(door_arg_t *arg);
+static int smb_lookup_name_int(const char *name, sid_type_t sidtype,
+    lsa_account_t *acct, int);
+static int smb_lookup_sid_int(const char *sid, lsa_account_t *acct, int);
 
 /*
  * Given a SID, make a door call to get  the associated name.
  *
  * Returns 0 if the door call is successful, otherwise -1.
@@ -55,18 +58,32 @@
  * NT_STATUS_NONE_MAPPED        The SID could not be mapped to a name.
  */
 int
 smb_lookup_sid(const char *sid, lsa_account_t *acct)
 {
+        return (smb_lookup_sid_int(sid, acct, SMB_DR_LOOKUP_SID));
+}
+/*
+ * Variant of smb_lookup_sid to do a "local-only" lookup.
+ */
+int
+smb_lookup_lsid(const char *sid, lsa_account_t *acct)
+{
+        return (smb_lookup_sid_int(sid, acct, SMB_DR_LOOKUP_LSID));
+}
+
+static int
+smb_lookup_sid_int(const char *sid, lsa_account_t *acct, int dop)
+{
         int     rc;
 
         assert((sid != NULL) && (acct != NULL));
 
         bzero(acct, sizeof (lsa_account_t));
         (void) strlcpy(acct->a_sid, sid, SMB_SID_STRSZ);
 
-        rc = smb_door_call(SMB_DR_LOOKUP_SID, acct, lsa_account_xdr,
+        rc = smb_door_call(dop, acct, lsa_account_xdr,
             acct, lsa_account_xdr);
 
         if (rc != 0)
                 syslog(LOG_DEBUG, "smb_lookup_sid: %m");
         return (rc);
@@ -82,10 +99,23 @@
  * NT_STATUS_NONE_MAPPED        The name could not be mapped to a SID.
  */
 int
 smb_lookup_name(const char *name, sid_type_t sidtype, lsa_account_t *acct)
 {
+        return (smb_lookup_name_int(name, sidtype, acct, SMB_DR_LOOKUP_NAME));
+}
+
+int
+smb_lookup_lname(const char *name, sid_type_t sidtype, lsa_account_t *acct)
+{
+        return (smb_lookup_name_int(name, sidtype, acct, SMB_DR_LOOKUP_LNAME));
+}
+
+static int
+smb_lookup_name_int(const char *name, sid_type_t sidtype, lsa_account_t *acct,
+    int dop)
+{
         char            tmp[MAXNAMELEN];
         char            *dp = NULL;
         char            *np = NULL;
         int             rc;
 
@@ -102,11 +132,11 @@
                 (void) strlcpy(acct->a_name, np, MAXNAMELEN);
         } else {
                 (void) strlcpy(acct->a_name, name, MAXNAMELEN);
         }
 
-        rc = smb_door_call(SMB_DR_LOOKUP_NAME, acct, lsa_account_xdr,
+        rc = smb_door_call(dop, acct, lsa_account_xdr,
             acct, lsa_account_xdr);
 
         if (rc != 0)
                 syslog(LOG_DEBUG, "smb_lookup_name: %m");
         return (rc);