Print this page
1575 untangle libmlrpc ... (libmlrpc)


  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 /*
  27  * Server side RPC handler.
  28  */
  29 
  30 #include <sys/byteorder.h>
  31 #include <sys/uio.h>
  32 #include <errno.h>
  33 #include <synch.h>
  34 #include <stdlib.h>
  35 #include <strings.h>
  36 #include <string.h>
  37 #include <thread.h>
  38 
  39 #include <smbsrv/libsmb.h>
  40 #include <smbsrv/libmlrpc.h>
  41 #include <smbsrv/ntaccess.h>
  42 
  43 #define NDR_PIPE_SEND(np, buf, len) \
  44         ((np)->np_send)((np), (buf), (len))
  45 #define NDR_PIPE_RECV(np, buf, len) \
  46         ((np)->np_recv)((np), (buf), (len))
  47 
  48 static int ndr_svc_process(ndr_xa_t *);
  49 static int ndr_svc_bind(ndr_xa_t *);
  50 static int ndr_svc_request(ndr_xa_t *);
  51 static void ndr_reply_prepare_hdr(ndr_xa_t *);
  52 static int ndr_svc_alter_context(ndr_xa_t *);
  53 static void ndr_reply_fault(ndr_xa_t *, unsigned long);
  54 
  55 static int ndr_recv_request(ndr_xa_t *mxa);
  56 static int ndr_recv_frag(ndr_xa_t *mxa);
  57 static int ndr_send_reply(ndr_xa_t *);
  58 
  59 static int ndr_pipe_process(ndr_pipe_t *, ndr_xa_t *);
  60 
  61 /*


 114                 goto out3;
 115 
 116         rc = ndr_recv_request(mxa);
 117         if (rc != 0)
 118                 goto out4;
 119 
 120         (void) ndr_svc_process(mxa);
 121         (void) ndr_send_reply(mxa);
 122         rc = 0;
 123 
 124 out4:
 125         nds_destruct(&mxa->send_nds);
 126 out3:
 127         nds_destruct(&mxa->recv_nds);
 128 out2:
 129         ndr_heap_destroy(mxa->heap);
 130 out1:
 131         return (rc);
 132 }
 133 
 134 /*
 135  * Check whether or not the specified user has administrator privileges,
 136  * i.e. is a member of Domain Admins or Administrators.
 137  * Returns true if the user is an administrator, otherwise returns false.
 138  */
 139 boolean_t
 140 ndr_is_admin(ndr_xa_t *xa)
 141 {
 142         smb_netuserinfo_t *ctx = xa->pipe->np_user;
 143 
 144         return (ctx->ui_flags & SMB_ATF_ADMIN);
 145 }
 146 
 147 /*
 148  * Check whether or not the specified user has power-user privileges,
 149  * i.e. is a member of Domain Admins, Administrators or Power Users.
 150  * This is typically required for operations such as managing shares.
 151  * Returns true if the user is a power user, otherwise returns false.
 152  */
 153 boolean_t
 154 ndr_is_poweruser(ndr_xa_t *xa)
 155 {
 156         smb_netuserinfo_t *ctx = xa->pipe->np_user;
 157 
 158         return ((ctx->ui_flags & SMB_ATF_ADMIN) ||
 159             (ctx->ui_flags & SMB_ATF_POWERUSER));
 160 }
 161 
 162 int32_t
 163 ndr_native_os(ndr_xa_t *xa)
 164 {
 165         smb_netuserinfo_t *ctx = xa->pipe->np_user;
 166 
 167         return (ctx->ui_native_os);
 168 }
 169 
 170 /*
 171  * Receive an entire RPC request (all fragments)
 172  * Returns zero or an NDR fault code.
 173  */
 174 static int
 175 ndr_recv_request(ndr_xa_t *mxa)
 176 {
 177         ndr_common_header_t     *hdr = &mxa->recv_hdr.common_hdr;
 178         ndr_stream_t            *nds = &mxa->recv_nds;
 179         unsigned long           saved_size;
 180         int                     rc;
 181 
 182         rc = ndr_recv_frag(mxa);
 183         if (rc != 0)
 184                 return (rc);
 185         if (!NDR_IS_FIRST_FRAG(hdr->pfc_flags))
 186                 return (NDR_DRC_FAULT_DECODE_FAILED);
 187 
 188         while (!NDR_IS_LAST_FRAG(hdr->pfc_flags)) {
 189                 rc = ndr_recv_frag(mxa);




  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 /*
  27  * Server side RPC handler.
  28  */
  29 
  30 #include <sys/byteorder.h>
  31 #include <sys/uio.h>
  32 #include <errno.h>
  33 #include <synch.h>
  34 #include <stdlib.h>
  35 #include <strings.h>
  36 #include <string.h>
  37 #include <thread.h>
  38 
  39 #include <libmlrpc.h>


  40 
  41 #define NDR_PIPE_SEND(np, buf, len) \
  42         ((np)->np_send)((np), (buf), (len))
  43 #define NDR_PIPE_RECV(np, buf, len) \
  44         ((np)->np_recv)((np), (buf), (len))
  45 
  46 static int ndr_svc_process(ndr_xa_t *);
  47 static int ndr_svc_bind(ndr_xa_t *);
  48 static int ndr_svc_request(ndr_xa_t *);
  49 static void ndr_reply_prepare_hdr(ndr_xa_t *);
  50 static int ndr_svc_alter_context(ndr_xa_t *);
  51 static void ndr_reply_fault(ndr_xa_t *, unsigned long);
  52 
  53 static int ndr_recv_request(ndr_xa_t *mxa);
  54 static int ndr_recv_frag(ndr_xa_t *mxa);
  55 static int ndr_send_reply(ndr_xa_t *);
  56 
  57 static int ndr_pipe_process(ndr_pipe_t *, ndr_xa_t *);
  58 
  59 /*


 112                 goto out3;
 113 
 114         rc = ndr_recv_request(mxa);
 115         if (rc != 0)
 116                 goto out4;
 117 
 118         (void) ndr_svc_process(mxa);
 119         (void) ndr_send_reply(mxa);
 120         rc = 0;
 121 
 122 out4:
 123         nds_destruct(&mxa->send_nds);
 124 out3:
 125         nds_destruct(&mxa->recv_nds);
 126 out2:
 127         ndr_heap_destroy(mxa->heap);
 128 out1:
 129         return (rc);
 130 }
 131 




































 132 /*
 133  * Receive an entire RPC request (all fragments)
 134  * Returns zero or an NDR fault code.
 135  */
 136 static int
 137 ndr_recv_request(ndr_xa_t *mxa)
 138 {
 139         ndr_common_header_t     *hdr = &mxa->recv_hdr.common_hdr;
 140         ndr_stream_t            *nds = &mxa->recv_nds;
 141         unsigned long           saved_size;
 142         int                     rc;
 143 
 144         rc = ndr_recv_frag(mxa);
 145         if (rc != 0)
 146                 return (rc);
 147         if (!NDR_IS_FIRST_FRAG(hdr->pfc_flags))
 148                 return (NDR_DRC_FAULT_DECODE_FAILED);
 149 
 150         while (!NDR_IS_LAST_FRAG(hdr->pfc_flags)) {
 151                 rc = ndr_recv_frag(mxa);