1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 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 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * 25 * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 26 */ 27 28 /* 29 * This file was originally generated using rpcgen. 30 */ 31 32 #if !defined(_KERNEL) && !defined(_FAKE_KERNEL) 33 #include <stdlib.h> 34 #endif /* !_KERNEL */ 35 #include <smbsrv/wintypes.h> 36 #include <smbsrv/smb_sid.h> 37 #include <smbsrv/smb_xdr.h> 38 #include <smbsrv/smb_token.h> 39 40 static bool_t smb_privset_xdr(XDR *, smb_privset_t *); 41 static bool_t smb_sid_xdr(XDR *, smb_sid_t *); 42 43 static bool_t 44 smb_privset_helper_xdr(XDR *xdrs, char **privs) 45 { 46 uint32_t pos, len; 47 uint32_t cnt; 48 bool_t rc; 49 smb_privset_t *p; 50 51 if (xdrs->x_op == XDR_DECODE) { 52 pos = xdr_getpos(xdrs); 53 54 if (!xdr_bool(xdrs, &rc)) 55 return (FALSE); 56 57 if (!xdr_uint32_t(xdrs, &cnt)) 58 return (FALSE); 59 60 rc = xdr_setpos(xdrs, pos); 61 62 if (rc == FALSE) 63 return (FALSE); 64 } else { 65 if (*privs == NULL) 66 return (FALSE); 67 68 p = (smb_privset_t *)(uintptr_t)*privs; 69 cnt = p->priv_cnt; 70 } 71 72 len = sizeof (smb_privset_t) 73 - sizeof (smb_luid_attrs_t) 74 + (cnt * sizeof (smb_luid_attrs_t)); 75 76 if (!xdr_pointer(xdrs, privs, len, (xdrproc_t)smb_privset_xdr)) 77 return (FALSE); 78 79 return (TRUE); 80 } 81 82 static bool_t 83 smb_id_xdr(XDR *xdrs, smb_id_t *objp) 84 { 85 uint8_t len; 86 87 if ((xdrs->x_op == XDR_ENCODE) || (xdrs->x_op == XDR_FREE)) 88 len = smb_sid_len(objp->i_sid); 89 90 if (!xdr_uint32_t(xdrs, &objp->i_attrs)) 91 return (FALSE); 92 93 if (!xdr_uint8_t(xdrs, &len)) 94 return (FALSE); 95 96 if (!xdr_pointer(xdrs, (char **)&objp->i_sid, len, 97 (xdrproc_t)smb_sid_xdr)) 98 return (FALSE); 99 100 if (!xdr_uint32_t(xdrs, (uint32_t *)&objp->i_id)) 101 return (FALSE); 102 103 return (TRUE); 104 } 105 106 static bool_t 107 smb_ids_xdr(XDR *xdrs, smb_ids_t *objp) 108 { 109 if (!xdr_array(xdrs, (char **)&objp->i_ids, (uint32_t *)&objp->i_cnt, 110 ~0, sizeof (smb_id_t), (xdrproc_t)smb_id_xdr)) 111 return (FALSE); 112 113 return (TRUE); 114 } 115 116 static bool_t 117 smb_posix_grps_xdr(XDR *xdrs, smb_posix_grps_t *objp) 118 { 119 if (!xdr_uint32_t(xdrs, &objp->pg_ngrps)) 120 return (FALSE); 121 if (!xdr_vector(xdrs, (char *)objp->pg_grps, objp->pg_ngrps, 122 sizeof (uint32_t), (xdrproc_t)xdr_uint32_t)) 123 return (FALSE); 124 return (TRUE); 125 } 126 127 static bool_t 128 smb_posix_grps_helper_xdr(XDR *xdrs, char **identity) 129 { 130 uint32_t pos, len; 131 uint32_t cnt; 132 bool_t rc; 133 134 if (xdrs->x_op == XDR_DECODE) { 135 pos = xdr_getpos(xdrs); 136 137 if (!xdr_bool(xdrs, &rc)) 138 return (FALSE); 139 140 if (!xdr_uint32_t(xdrs, &cnt)) 141 return (FALSE); 142 143 rc = xdr_setpos(xdrs, pos); 144 if (rc == FALSE) 145 return (FALSE); 146 } else { 147 if (*identity == NULL) 148 return (FALSE); 149 cnt = ((smb_posix_grps_t *)(uintptr_t)*identity)->pg_ngrps; 150 } 151 152 len = SMB_POSIX_GRPS_SIZE(cnt); 153 154 if (!xdr_pointer(xdrs, identity, len, (xdrproc_t)smb_posix_grps_xdr)) 155 return (FALSE); 156 return (TRUE); 157 } 158 159 bool_t 160 smb_logon_xdr(XDR *xdrs, smb_logon_t *objp) 161 { 162 if (!xdr_uint16_t(xdrs, &objp->lg_level)) 163 return (FALSE); 164 if (!xdr_string(xdrs, &objp->lg_username, ~0)) 165 return (FALSE); 166 if (!xdr_string(xdrs, &objp->lg_domain, ~0)) 167 return (FALSE); 168 if (!xdr_string(xdrs, &objp->lg_e_username, ~0)) 169 return (FALSE); 170 if (!xdr_string(xdrs, &objp->lg_e_domain, ~0)) 171 return (FALSE); 172 if (!xdr_string(xdrs, &objp->lg_workstation, ~0)) 173 return (FALSE); 174 if (!smb_inaddr_xdr(xdrs, &objp->lg_clnt_ipaddr)) 175 return (FALSE); 176 if (!smb_inaddr_xdr(xdrs, &objp->lg_local_ipaddr)) 177 return (FALSE); 178 if (!xdr_uint16_t(xdrs, &objp->lg_local_port)) 179 return (FALSE); 180 if (!smb_buf32_xdr(xdrs, &objp->lg_challenge_key)) 181 return (FALSE); 182 if (!smb_buf32_xdr(xdrs, &objp->lg_nt_password)) 183 return (FALSE); 184 if (!smb_buf32_xdr(xdrs, &objp->lg_lm_password)) 185 return (FALSE); 186 if (!xdr_uint32_t(xdrs, &objp->lg_ntlm_flags)) 187 return (FALSE); 188 if (!xdr_int(xdrs, &objp->lg_native_os)) 189 return (FALSE); 190 if (!xdr_int(xdrs, &objp->lg_native_lm)) 191 return (FALSE); 192 if (!xdr_uint32_t(xdrs, &objp->lg_flags)) 193 return (FALSE); 194 if (!xdr_uint32_t(xdrs, &objp->lg_logon_id)) 195 return (FALSE); 196 if (!xdr_uint32_t(xdrs, &objp->lg_domain_type)) 197 return (FALSE); 198 if (!xdr_uint32_t(xdrs, &objp->lg_secmode)) 199 return (FALSE); 200 if (!xdr_uint32_t(xdrs, &objp->lg_status)) 201 return (FALSE); 202 return (TRUE); 203 } 204 205 static bool_t 206 smb_sid_xdr(XDR *xdrs, smb_sid_t *objp) 207 { 208 if (!xdr_uint8_t(xdrs, &objp->sid_revision)) 209 return (FALSE); 210 if (!xdr_uint8_t(xdrs, &objp->sid_subauthcnt)) 211 return (FALSE); 212 if (!xdr_vector(xdrs, (char *)objp->sid_authority, NT_SID_AUTH_MAX, 213 sizeof (uint8_t), (xdrproc_t)xdr_uint8_t)) 214 return (FALSE); 215 if (!xdr_vector(xdrs, (char *)objp->sid_subauth, objp->sid_subauthcnt, 216 sizeof (uint32_t), (xdrproc_t)xdr_uint32_t)) 217 return (FALSE); 218 return (TRUE); 219 } 220 221 static bool_t 222 smb_luid_xdr(XDR *xdrs, smb_luid_t *objp) 223 { 224 if (!xdr_uint32_t(xdrs, &objp->lo_part)) 225 return (FALSE); 226 if (!xdr_uint32_t(xdrs, &objp->hi_part)) 227 return (FALSE); 228 return (TRUE); 229 } 230 231 static bool_t 232 smb_luid_attrs_xdr(XDR *xdrs, smb_luid_attrs_t *objp) 233 { 234 if (!smb_luid_xdr(xdrs, &objp->luid)) 235 return (FALSE); 236 if (!xdr_uint32_t(xdrs, &objp->attrs)) 237 return (FALSE); 238 return (TRUE); 239 } 240 241 static bool_t 242 smb_privset_xdr(XDR *xdrs, smb_privset_t *objp) 243 { 244 if (!xdr_uint32_t(xdrs, &objp->priv_cnt)) 245 return (FALSE); 246 if (!xdr_uint32_t(xdrs, &objp->control)) 247 return (FALSE); 248 if (!xdr_vector(xdrs, (char *)objp->priv, objp->priv_cnt, 249 sizeof (smb_luid_attrs_t), 250 (xdrproc_t)smb_luid_attrs_xdr)) 251 return (FALSE); 252 return (TRUE); 253 } 254 255 bool_t 256 smb_token_xdr(XDR *xdrs, smb_token_t *objp) 257 { 258 if (!smb_id_xdr(xdrs, &objp->tkn_user)) 259 return (FALSE); 260 if (!smb_id_xdr(xdrs, &objp->tkn_owner)) 261 return (FALSE); 262 if (!smb_id_xdr(xdrs, &objp->tkn_primary_grp)) 263 return (FALSE); 264 if (!smb_ids_xdr(xdrs, &objp->tkn_win_grps)) 265 return (FALSE); 266 if (!smb_privset_helper_xdr(xdrs, (char **)&objp->tkn_privileges)) 267 return (FALSE); 268 if (!xdr_string(xdrs, &objp->tkn_account_name, ~0)) 269 return (FALSE); 270 if (!xdr_string(xdrs, &objp->tkn_domain_name, ~0)) 271 return (FALSE); 272 if (!xdr_uint32_t(xdrs, &objp->tkn_flags)) 273 return (FALSE); 274 if (!xdr_uint32_t(xdrs, &objp->tkn_audit_sid)) 275 return (FALSE); 276 if (!smb_buf32_xdr(xdrs, &objp->tkn_ssnkey)) 277 return (FALSE); 278 if (!smb_posix_grps_helper_xdr(xdrs, (char **)&objp->tkn_posix_grps)) 279 return (FALSE); 280 return (TRUE); 281 }