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)


   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 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.


  25  */
  26 
  27 /*
  28  * ACL API for smbfs
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/errno.h>
  33 #include <sys/cred.h>
  34 #include <sys/cmn_err.h>
  35 #include <sys/kmem.h>
  36 #include <sys/sunddi.h>
  37 #include <sys/acl.h>
  38 #include <sys/vnode.h>
  39 #include <sys/vfs.h>
  40 #include <sys/byteorder.h>
  41 
  42 #include <errno.h>
  43 #include <stdio.h>
  44 #include <strings.h>


  66 
  67 /*
  68  * Get/set a Windows security descriptor (SD)
  69  * using the (private) smbfs ioctl mechanism.
  70  * Note: Get allocates mbp->mb_top
  71  */
  72 
  73 /* ARGSUSED */
  74 int
  75 smbfs_acl_iocget(int fd, uint32_t selector, mbdata_t *mbp)
  76 {
  77         ioc_sdbuf_t     iocb;
  78         struct mbuf     *m;
  79         int             error;
  80 
  81         error = mb_init_sz(mbp, MAX_RAW_SD_SIZE);
  82         if (error)
  83                 return (error);
  84 
  85         m = mbp->mb_top;

  86         iocb.addr = mtod(m, uintptr_t);
  87         iocb.alloc = m->m_maxlen;
  88         iocb.used = 0;
  89         iocb.selector = selector;
  90 
  91         /*
  92          * This does the OTW Get.
  93          */
  94         if (ioctl(fd, SMBFSIO_GETSD, &iocb) < 0) {
  95                 error = errno;
  96                 goto errout;
  97         }
  98 
  99         m->m_len = iocb.used;
 100         return (0);
 101 
 102 errout:
 103         mb_done(mbp);
 104         return (error);
 105 }
 106 
 107 /* ARGSUSED */
 108 int
 109 smbfs_acl_iocset(int fd, uint32_t selector, mbdata_t *mbp)
 110 {
 111         ioc_sdbuf_t     iocb;
 112         struct mbuf     *m;
 113         int             error;
 114 
 115         /* Make the data contiguous. */
 116         error = m_lineup(mbp->mb_top, &m);
 117         if (error)
 118                 return (error);
 119 
 120         if (mbp->mb_top != m)
 121                 mb_initm(mbp, m);
 122 

 123         iocb.addr = mtod(m, uintptr_t);
 124         iocb.alloc = m->m_maxlen;
 125         iocb.used  = m->m_len;
 126         iocb.selector = selector;
 127 
 128         /*
 129          * This does the OTW Set.
 130          */
 131         if (ioctl(fd, SMBFSIO_SETSD, &iocb) < 0)
 132                 error = errno;
 133 
 134         return (error);
 135 }
 136 
 137 /*
 138  * Get an NT SD from the open file via ioctl.
 139  */
 140 int
 141 smbfs_acl_getsd(int fd, uint32_t selector, i_ntsd_t **sdp)
 142 {
 143         mbdata_t *mbp, mb_store;
 144         int error;
 145 
 146         mbp = &mb_store;
 147         bzero(mbp, sizeof (*mbp));
 148 
 149         /*
 150          * Get the raw Windows SD via ioctl.
 151          * Returns allocated mbchain in mbp.




   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 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  27  */
  28 
  29 /*
  30  * ACL API for smbfs
  31  */
  32 
  33 #include <sys/types.h>
  34 #include <sys/errno.h>
  35 #include <sys/cred.h>
  36 #include <sys/cmn_err.h>
  37 #include <sys/kmem.h>
  38 #include <sys/sunddi.h>
  39 #include <sys/acl.h>
  40 #include <sys/vnode.h>
  41 #include <sys/vfs.h>
  42 #include <sys/byteorder.h>
  43 
  44 #include <errno.h>
  45 #include <stdio.h>
  46 #include <strings.h>


  68 
  69 /*
  70  * Get/set a Windows security descriptor (SD)
  71  * using the (private) smbfs ioctl mechanism.
  72  * Note: Get allocates mbp->mb_top
  73  */
  74 
  75 /* ARGSUSED */
  76 int
  77 smbfs_acl_iocget(int fd, uint32_t selector, mbdata_t *mbp)
  78 {
  79         ioc_sdbuf_t     iocb;
  80         struct mbuf     *m;
  81         int             error;
  82 
  83         error = mb_init_sz(mbp, MAX_RAW_SD_SIZE);
  84         if (error)
  85                 return (error);
  86 
  87         m = mbp->mb_top;
  88         bzero(&iocb, sizeof (iocb));
  89         iocb.addr = mtod(m, uintptr_t);
  90         iocb.alloc = m->m_maxlen;
  91         iocb.used = 0;
  92         iocb.selector = selector;
  93 
  94         /*
  95          * This does the OTW Get.
  96          */
  97         if (nsmb_ioctl(fd, SMBFSIO_GETSD, &iocb) < 0) {
  98                 error = errno;
  99                 goto errout;
 100         }
 101 
 102         m->m_len = iocb.used;
 103         return (0);
 104 
 105 errout:
 106         mb_done(mbp);
 107         return (error);
 108 }
 109 
 110 /* ARGSUSED */
 111 int
 112 smbfs_acl_iocset(int fd, uint32_t selector, mbdata_t *mbp)
 113 {
 114         ioc_sdbuf_t     iocb;
 115         struct mbuf     *m;
 116         int             error;
 117 
 118         /* Make the data contiguous. */
 119         error = m_lineup(mbp->mb_top, &m);
 120         if (error)
 121                 return (error);
 122 
 123         if (mbp->mb_top != m)
 124                 mb_initm(mbp, m);
 125 
 126         bzero(&iocb, sizeof (iocb));
 127         iocb.addr = mtod(m, uintptr_t);
 128         iocb.alloc = m->m_maxlen;
 129         iocb.used  = m->m_len;
 130         iocb.selector = selector;
 131 
 132         /*
 133          * This does the OTW Set.
 134          */
 135         if (nsmb_ioctl(fd, SMBFSIO_SETSD, &iocb) < 0)
 136                 error = errno;
 137 
 138         return (error);
 139 }
 140 
 141 /*
 142  * Get an NT SD from the open file via ioctl.
 143  */
 144 int
 145 smbfs_acl_getsd(int fd, uint32_t selector, i_ntsd_t **sdp)
 146 {
 147         mbdata_t *mbp, mb_store;
 148         int error;
 149 
 150         mbp = &mb_store;
 151         bzero(mbp, sizeof (*mbp));
 152 
 153         /*
 154          * Get the raw Windows SD via ioctl.
 155          * Returns allocated mbchain in mbp.