Revert "Fix bug #7067 - Linux asynchronous IO (aio) can cause smbd to fail to respond...
[Samba.git] / source3 / librpc / ndr / sid.c
blob252da85929102ceb229cab74d99554256251492f
1 /*
2 Unix SMB/CIFS implementation.
4 libndr interface
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/>.
22 #include "includes.h"
25 convert a dom_sid to a string
27 char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
29 int i, ofs, maxlen;
30 uint32_t ia;
31 char *ret;
33 if (!sid) {
34 return talloc_strdup(mem_ctx, "(NULL SID)");
37 maxlen = sid->num_auths * 11 + 25;
38 ret = (char *)talloc_size(mem_ctx, maxlen);
39 if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
42 * BIG NOTE: this function only does SIDS where the identauth is not
43 * >= ^32 in a range of 2^48.
46 ia = (sid->id_auth[5]) +
47 (sid->id_auth[4] << 8 ) +
48 (sid->id_auth[3] << 16) +
49 (sid->id_auth[2] << 24);
51 ofs = snprintf(ret, maxlen, "S-%u-%lu",
52 (unsigned int)sid->sid_rev_num, (unsigned long)ia);
54 for (i = 0; i < sid->num_auths; i++) {
55 ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]);
58 return ret;