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
, NDR_SCALARS
, &num_auths
));
38 NDR_CHECK(ndr_pull_dom_sid(ndr
, ndr_flags
, sid
));
39 if (sid
->num_auths
!= num_auths
) {
40 return ndr_pull_error(ndr
, NDR_ERR_ARRAY_SIZE
,
41 "Bad array size %u should exceed %u",
42 num_auths
, sid
->num_auths
);
48 parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field
50 NTSTATUS
ndr_push_dom_sid2(struct ndr_push
*ndr
, int ndr_flags
, const struct dom_sid
*sid
)
52 if (!(ndr_flags
& NDR_SCALARS
)) {
55 NDR_CHECK(ndr_push_uint32(ndr
, NDR_SCALARS
, sid
->num_auths
));
56 return ndr_push_dom_sid(ndr
, ndr_flags
, sid
);
60 parse a dom_sid28 - this is a dom_sid in a fixed 28 byte buffer, so we need to ensure there are only upto 5 sub_auth
62 NTSTATUS
ndr_pull_dom_sid28(struct ndr_pull
*ndr
, int ndr_flags
, struct dom_sid
*sid
)
65 struct ndr_pull
*subndr
;
67 if (!(ndr_flags
& NDR_SCALARS
)) {
71 subndr
= talloc_zero(ndr
, struct ndr_pull
);
72 NT_STATUS_HAVE_NO_MEMORY(subndr
);
73 subndr
->flags
= ndr
->flags
;
74 subndr
->current_mem_ctx
= ndr
->current_mem_ctx
;
76 subndr
->data
= ndr
->data
+ ndr
->offset
;
77 subndr
->data_size
= 28;
80 NDR_CHECK(ndr_pull_advance(ndr
, 28));
82 status
= ndr_pull_dom_sid(subndr
, ndr_flags
, sid
);
83 if (!NT_STATUS_IS_OK(status
)) {
84 /* handle a w2k bug which send random data in the buffer */
92 push a dom_sid28 - this is a dom_sid in a 28 byte fixed buffer
94 NTSTATUS
ndr_push_dom_sid28(struct ndr_push
*ndr
, int ndr_flags
, const struct dom_sid
*sid
)
99 if (!(ndr_flags
& NDR_SCALARS
)) {
103 if (sid
->num_auths
> 5) {
104 return ndr_push_error(ndr
, NDR_ERR_RANGE
,
105 "dom_sid28 allows only upto 5 sub auth [%u]",
109 old_offset
= ndr
->offset
;
110 NDR_CHECK(ndr_push_dom_sid(ndr
, ndr_flags
, sid
));
112 padding
= 28 - (ndr
->offset
- old_offset
);
115 NDR_CHECK(ndr_push_zero(ndr
, padding
));