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,28 ****
--- 19,29 ----
* 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,69 ****
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/acl.h>
#include <sys/byteorder.h>
! #ifdef _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 */
#include <netsmb/mchain.h>
#include <netsmb/smb.h>
#include "smbfs_ntacl.h"
#define NT_SD_REVISION 1
#define NT_ACL_REVISION 2
! #ifdef _KERNEL
#define MALLOC(size) kmem_alloc(size, KM_SLEEP)
#define FREESZ(p, sz) kmem_free(p, sz)
#else /* _KERNEL */
#define MALLOC(size) malloc(size)
/*
--- 32,72 ----
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/acl.h>
#include <sys/byteorder.h>
! #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>
#else /* _KERNEL */
#include <stdio.h>
#include <stdlib.h>
#include <strings.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
! #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,895 ****
* second building a ZFS-style ACL using the idmap results.
*/
int
smbfs_acl_sd2zfs(
i_ntsd_t *sd,
! #ifdef _KERNEL
vsecattr_t *acl_info,
#else /* _KERNEL */
acl_t *acl_info,
#endif /* _KERNEL */
uid_t *uidp, gid_t *gidp)
--- 888,898 ----
* second building a ZFS-style ACL using the idmap results.
*/
int
smbfs_acl_sd2zfs(
i_ntsd_t *sd,
! #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,921 ****
/*
* sanity checks
*/
if (acl_info) {
! #ifndef _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 */
if ((sd->sd_flags & SD_DACL_PRESENT) == 0)
return (EINVAL);
}
/*
--- 909,924 ----
/*
* sanity checks
*/
if (acl_info) {
! #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 */
if ((sd->sd_flags & SD_DACL_PRESENT) == 0)
return (EINVAL);
}
/*
*** 1115,1125 ****
ACE_READ_ACL | ACE_WRITE_ACL;
zacep->a_flags = ACE_OWNER;
zacep->a_type = ACCESS_ALLOWED_ACE_TYPE;
}
! #ifdef _KERNEL
acl_info->vsa_aclcnt = zacecnt;
acl_info->vsa_aclentp = zacep0;
acl_info->vsa_aclentsz = zacl_size;
#else /* _KERNEL */
acl_info->acl_cnt = zacecnt;
--- 1118,1128 ----
ACE_READ_ACL | ACE_WRITE_ACL;
zacep->a_flags = ACE_OWNER;
zacep->a_type = ACCESS_ALLOWED_ACE_TYPE;
}
! #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,1234 ****
if (*p != '-') {
err = EINVAL;
goto out;
}
p++;
! #ifdef _KERNEL
err = ddi_strtoul(p, &np, 10, &sa);
if (err != 0)
goto out;
#else /* _KERNEL */
sa = strtoul(p, &np, 10);
--- 1227,1237 ----
if (*p != '-') {
err = EINVAL;
goto out;
}
p++;
! #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,1417 ****
* "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
vsecattr_t *acl_info,
#else /* _KERNEL */
acl_t *acl_info,
#endif /* _KERNEL */
uid_t own_uid,
--- 1410,1420 ----
* "batch" request for idmap with results in mapinfo, and the
* second builds the NT SD using the idmap SID results.
*/
int
smbfs_acl_zfs2sd(
! #if defined(_KERNEL) || defined(_FAKE_KERNEL)
vsecattr_t *acl_info,
#else /* _KERNEL */
acl_t *acl_info,
#endif /* _KERNEL */
uid_t own_uid,
*** 1453,1463 ****
return (EINVAL);
if (own_uid == (uid_t)-1)
return (EINVAL);
if (own_gid == (gid_t)-1)
return (EINVAL);
! #ifdef _KERNEL
if ((acl_info->vsa_mask & VSA_ACE) == 0)
return (EINVAL);
zacecnt = acl_info->vsa_aclcnt;
zacevec = acl_info->vsa_aclentp;
#else /* _KERNEL */
--- 1456,1466 ----
return (EINVAL);
if (own_uid == (uid_t)-1)
return (EINVAL);
if (own_gid == (gid_t)-1)
return (EINVAL);
! #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 */