Print this page
NEX-16818 Add fksmbcl development tool
NEX-17264 SMB client test tp_smbutil_013 fails after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (fix ref leaks)

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
  * ACL conversion support for smbfs
  * (To/from NT/ZFS-style ACLs.)

@@ -31,39 +32,41 @@
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <sys/acl.h>
 #include <sys/byteorder.h>
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
 
 #include <sys/cred.h>
 #include <sys/cmn_err.h>
 #include <sys/kmem.h>
 #include <sys/sunddi.h>
 #include <sys/vnode.h>
 #include <sys/vfs.h>
 
-#include <sys/kidmap.h>
-
 #else   /* _KERNEL */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <strings.h>
 
-#include <idmap.h>
+#endif  /* _KERNEL */
 
+#ifdef _KERNEL
+#include <sys/kidmap.h>
+#else   /* _KERNEL */
+#include <idmap.h>
 #endif  /* _KERNEL */
 
 #include <netsmb/mchain.h>
 #include <netsmb/smb.h>
 #include "smbfs_ntacl.h"
 
 #define NT_SD_REVISION  1
 #define NT_ACL_REVISION 2
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
 #define MALLOC(size) kmem_alloc(size, KM_SLEEP)
 #define FREESZ(p, sz) kmem_free(p, sz)
 #else   /* _KERNEL */
 #define MALLOC(size) malloc(size)
 /*

@@ -885,11 +888,11 @@
  * second building a ZFS-style ACL using the idmap results.
  */
 int
 smbfs_acl_sd2zfs(
         i_ntsd_t *sd,
-#ifdef  _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
         vsecattr_t *acl_info,
 #else /* _KERNEL */
         acl_t *acl_info,
 #endif /* _KERNEL */
         uid_t *uidp, gid_t *gidp)

@@ -906,16 +909,16 @@
 
         /*
          * sanity checks
          */
         if (acl_info) {
-#ifndef _KERNEL
+#if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
                 if (acl_info->acl_type != ACE_T ||
                     acl_info->acl_aclp != NULL ||
                     acl_info->acl_entry_size != sizeof (ace_t))
                         return (EINVAL);
-#endif /* _KERNEL */
+#endif /* !_KERNEL */
                 if ((sd->sd_flags & SD_DACL_PRESENT) == 0)
                         return (EINVAL);
         }
 
         /*

@@ -1115,11 +1118,11 @@
                     ACE_READ_ACL | ACE_WRITE_ACL;
                 zacep->a_flags = ACE_OWNER;
                 zacep->a_type = ACCESS_ALLOWED_ACE_TYPE;
         }
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
         acl_info->vsa_aclcnt = zacecnt;
         acl_info->vsa_aclentp = zacep0;
         acl_info->vsa_aclentsz = zacl_size;
 #else   /* _KERNEL */
         acl_info->acl_cnt = zacecnt;

@@ -1224,11 +1227,11 @@
                 if (*p != '-') {
                         err = EINVAL;
                         goto out;
                 }
                 p++;
-#ifdef  _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
                 err = ddi_strtoul(p, &np, 10, &sa);
                 if (err != 0)
                         goto out;
 #else   /* _KERNEL */
                 sa = strtoul(p, &np, 10);

@@ -1407,11 +1410,11 @@
  * "batch" request for idmap with results in mapinfo, and the
  * second builds the NT SD using the idmap SID results.
  */
 int
 smbfs_acl_zfs2sd(
-#ifdef  _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
         vsecattr_t *acl_info,
 #else /* _KERNEL */
         acl_t *acl_info,
 #endif /* _KERNEL */
         uid_t own_uid,

@@ -1453,11 +1456,11 @@
                         return (EINVAL);
                 if (own_uid == (uid_t)-1)
                         return (EINVAL);
                 if (own_gid == (gid_t)-1)
                         return (EINVAL);
-#ifdef  _KERNEL
+#if defined(_KERNEL) || defined(_FAKE_KERNEL)
                 if ((acl_info->vsa_mask & VSA_ACE) == 0)
                         return (EINVAL);
                 zacecnt = acl_info->vsa_aclcnt;
                 zacevec = acl_info->vsa_aclentp;
 #else   /* _KERNEL */