2 Unix SMB/CIFS implementation.
4 routines for marshalling/unmarshalling security descriptors
7 Copyright (C) Andrew Tridgell 2003
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "librpc/gen_ndr/ndr_security.h"
29 parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field
31 NTSTATUS ndr_pull_dom_sid2(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid)
34 if (!(ndr_flags & NDR_SCALARS)) {
37 NDR_CHECK(ndr_pull_uint32(ndr, &num_auths));
38 return ndr_pull_dom_sid(ndr, ndr_flags, sid);
42 parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field
44 NTSTATUS ndr_push_dom_sid2(struct ndr_push *ndr, int ndr_flags, struct dom_sid *sid)
46 if (!(ndr_flags & NDR_SCALARS)) {
49 NDR_CHECK(ndr_push_uint32(ndr, sid->num_auths));
50 return ndr_push_dom_sid(ndr, ndr_flags, sid);
57 void ndr_print_dom_sid(struct ndr_print *ndr, const char *name, struct dom_sid *sid)
59 ndr->print(ndr, "%-25s: %s", name, dom_sid_string(ndr, sid));
62 void ndr_print_dom_sid2(struct ndr_print *ndr, const char *name, struct dom_sid2 *sid)
64 ndr_print_dom_sid(ndr, name, sid);
68 return the wire size of a dom_sid
70 size_t ndr_size_dom_sid(struct dom_sid *sid)
73 return 8 + 4*sid->num_auths;
77 return the wire size of a security_ace
79 size_t ndr_size_security_ace(struct security_ace *ace)
82 return 8 + ndr_size_dom_sid(&ace->trustee);
87 return the wire size of a security_acl
89 size_t ndr_size_security_acl(struct security_acl *acl)
95 for (i=0;i<acl->num_aces;i++) {
96 ret += ndr_size_security_ace(&acl->aces[i]);
102 return the wire size of a security descriptor
104 size_t ndr_size_security_descriptor(struct security_descriptor *sd)
110 ret += ndr_size_dom_sid(sd->owner_sid);
111 ret += ndr_size_dom_sid(sd->group_sid);
112 ret += ndr_size_security_acl(sd->dacl);
113 ret += ndr_size_security_acl(sd->sacl);