/* Unix SMB/CIFS implementation. routines for marshalling/unmarshalling security descriptors and related structures Copyright (C) Andrew Tridgell 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "includes.h" /* parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field */ NTSTATUS ndr_pull_dom_sid2(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid) { uint32 num_auths; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } NDR_CHECK(ndr_pull_uint32(ndr, &num_auths)); return ndr_pull_dom_sid(ndr, ndr_flags, sid); } /* parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field */ NTSTATUS ndr_push_dom_sid2(struct ndr_push *ndr, int ndr_flags, struct dom_sid *sid) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } NDR_CHECK(ndr_push_uint32(ndr, sid->num_auths)); return ndr_push_dom_sid(ndr, ndr_flags, sid); } /* print a dom_sid */ void ndr_print_dom_sid(struct ndr_print *ndr, const char *name, struct dom_sid *sid) { int i, ofs, maxlen; uint32 ia; char *ret; if (!sid) { ndr->print(ndr, "%-25s: (NULL SID)", name); return; } maxlen = sid->num_auths * 11 + 25; ret = talloc(ndr->mem_ctx, maxlen); if (!ret) return; ia = (sid->id_auth[5]) + (sid->id_auth[4] << 8 ) + (sid->id_auth[3] << 16) + (sid->id_auth[2] << 24); ofs = snprintf(ret, maxlen, "S-%u-%lu", (unsigned int)sid->sid_rev_num, (unsigned long)ia); for (i = 0; i < sid->num_auths; i++) { ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]); } ndr->print(ndr, "%-25s: %s", name, ret); } void ndr_print_dom_sid2(struct ndr_print *ndr, const char *name, struct dom_sid2 *sid) { ndr_print_dom_sid(ndr, name, sid); }