2 Unix SMB/CIFS implementation.
4 fast routines for getting the wire size of security objects
6 Copyright (C) Andrew Tridgell 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 return the wire size of a dom_sid
28 size_t ndr_size_dom_sid(const struct dom_sid *sid, int flags)
31 return 8 + 4*sid->num_auths;
34 size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags)
36 struct dom_sid zero_sid;
40 ZERO_STRUCT(zero_sid);
42 if (memcmp(&zero_sid, sid, sizeof(zero_sid)) == 0) {
46 return 8 + 4*sid->num_auths;
49 size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags)
51 return ndr_size_dom_sid28(sid, flags);
55 return the wire size of a security_ace
57 size_t ndr_size_security_ace(const struct security_ace *ace, int flags)
60 return 8 + ndr_size_dom_sid(&ace->trustee, flags);
65 return the wire size of a security_acl
67 size_t ndr_size_security_acl(const struct security_acl *acl, int flags)
73 for (i=0;i<acl->num_aces;i++) {
74 ret += ndr_size_security_ace(&acl->aces[i], flags);
80 return the wire size of a security descriptor
82 size_t ndr_size_security_descriptor(const struct security_descriptor *sd, int flags)
88 ret += ndr_size_dom_sid(sd->owner_sid, flags);
89 ret += ndr_size_dom_sid(sd->group_sid, flags);
90 ret += ndr_size_security_acl(sd->dacl, flags);
91 ret += ndr_size_security_acl(sd->sacl, flags);
98 void ndr_print_dom_sid(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
100 ndr->print(ndr, "%-25s: %s", name, dom_sid_string(ndr, sid));
103 void ndr_print_dom_sid2(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
105 ndr_print_dom_sid(ndr, name, sid);
108 void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
110 ndr_print_dom_sid(ndr, name, sid);
113 void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
115 ndr_print_dom_sid(ndr, name, sid);