s3: smbd: In smb_file_rename_information() (SMB_FILE_RENAME_INFORMATION info level...
[Samba.git] / libcli / security / sddl.c
blob26049ec458a0ca3e809b714b5f2f293822e2be10
1 /*
2 Unix SMB/CIFS implementation.
4 security descriptor description language functions
6 Copyright (C) Andrew Tridgell 2005
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"
23 #include "libcli/security/security.h"
24 #include "librpc/gen_ndr/ndr_misc.h"
25 #include "system/locale.h"
27 struct flag_map {
28 const char *name;
29 uint32_t flag;
32 static bool sddl_map_flag(
33 const struct flag_map *map,
34 const char *str,
35 size_t *plen,
36 uint32_t *pflag)
38 while (map->name != NULL) {
39 size_t len = strlen(map->name);
40 int cmp = strncmp(map->name, str, len);
42 if (cmp == 0) {
43 *plen = len;
44 *pflag = map->flag;
45 return true;
47 map += 1;
49 return false;
53 map a series of letter codes into a uint32_t
55 static bool sddl_map_flags(const struct flag_map *map, const char *str,
56 uint32_t *pflags, size_t *plen)
58 const char *str0 = str;
59 if (plen != NULL) {
60 *plen = 0;
62 *pflags = 0;
63 while (str[0] && isupper(str[0])) {
64 size_t len;
65 uint32_t flags;
66 bool found;
68 found = sddl_map_flag(map, str, &len, &flags);
69 if (!found) {
70 DEBUG(1, ("Unknown flag - %s in %s\n", str, str0));
71 return false;
74 *pflags |= flags;
75 if (plen != NULL) {
76 *plen += len;
78 str += len;
80 return true;
84 a mapping between the 2 letter SID codes and sid strings
86 static const struct {
87 const char *code;
88 const char *sid;
89 uint32_t rid;
90 } sid_codes[] = {
91 { .code = "WD", .sid = SID_WORLD },
93 { .code = "CO", .sid = SID_CREATOR_OWNER },
94 { .code = "CG", .sid = SID_CREATOR_GROUP },
96 { .code = "NU", .sid = SID_NT_NETWORK },
97 { .code = "IU", .sid = SID_NT_INTERACTIVE },
98 { .code = "SU", .sid = SID_NT_SERVICE },
99 { .code = "AN", .sid = SID_NT_ANONYMOUS },
100 { .code = "ED", .sid = SID_NT_ENTERPRISE_DCS },
101 { .code = "PS", .sid = SID_NT_SELF },
102 { .code = "AU", .sid = SID_NT_AUTHENTICATED_USERS },
103 { .code = "RC", .sid = SID_NT_RESTRICTED },
104 { .code = "SY", .sid = SID_NT_SYSTEM },
105 { .code = "LS", .sid = SID_NT_LOCAL_SERVICE },
106 { .code = "NS", .sid = SID_NT_NETWORK_SERVICE },
107 { .code = "IS", .sid = SID_NT_IUSR },
109 { .code = "BA", .sid = SID_BUILTIN_ADMINISTRATORS },
110 { .code = "BU", .sid = SID_BUILTIN_USERS },
111 { .code = "BG", .sid = SID_BUILTIN_GUESTS },
112 { .code = "PU", .sid = SID_BUILTIN_POWER_USERS },
113 { .code = "AO", .sid = SID_BUILTIN_ACCOUNT_OPERATORS },
114 { .code = "SO", .sid = SID_BUILTIN_SERVER_OPERATORS },
115 { .code = "PO", .sid = SID_BUILTIN_PRINT_OPERATORS },
116 { .code = "BO", .sid = SID_BUILTIN_BACKUP_OPERATORS },
117 { .code = "RE", .sid = SID_BUILTIN_REPLICATOR },
118 { .code = "BR", .sid = SID_BUILTIN_RAS_SERVERS },
119 { .code = "RU", .sid = SID_BUILTIN_PREW2K },
120 { .code = "RD", .sid = SID_BUILTIN_REMOTE_DESKTOP_USERS },
121 { .code = "NO", .sid = SID_BUILTIN_NETWORK_CONF_OPERATORS },
122 { .code = "IF", .sid = SID_BUILTIN_INCOMING_FOREST_TRUST },
124 { .code = "LA", .sid = NULL, .rid = DOMAIN_RID_ADMINISTRATOR },
125 { .code = "LG", .sid = NULL, .rid = DOMAIN_RID_GUEST },
126 { .code = "LK", .sid = NULL, .rid = DOMAIN_RID_KRBTGT },
128 { .code = "ER", .sid = NULL, .rid = DOMAIN_RID_ENTERPRISE_READONLY_DCS },
129 { .code = "DA", .sid = NULL, .rid = DOMAIN_RID_ADMINS },
130 { .code = "DU", .sid = NULL, .rid = DOMAIN_RID_USERS },
131 { .code = "DG", .sid = NULL, .rid = DOMAIN_RID_GUESTS },
132 { .code = "DC", .sid = NULL, .rid = DOMAIN_RID_DOMAIN_MEMBERS },
133 { .code = "DD", .sid = NULL, .rid = DOMAIN_RID_DCS },
134 { .code = "CA", .sid = NULL, .rid = DOMAIN_RID_CERT_ADMINS },
135 { .code = "SA", .sid = NULL, .rid = DOMAIN_RID_SCHEMA_ADMINS },
136 { .code = "EA", .sid = NULL, .rid = DOMAIN_RID_ENTERPRISE_ADMINS },
137 { .code = "PA", .sid = NULL, .rid = DOMAIN_RID_POLICY_ADMINS },
138 { .code = "RO", .sid = NULL, .rid = DOMAIN_RID_READONLY_DCS },
139 { .code = "RS", .sid = NULL, .rid = DOMAIN_RID_RAS_SERVERS }
143 decode a SID
144 It can either be a special 2 letter code, or in S-* format
146 static struct dom_sid *sddl_decode_sid(TALLOC_CTX *mem_ctx, const char **sddlp,
147 const struct dom_sid *domain_sid)
149 const char *sddl = (*sddlp);
150 size_t i;
152 /* see if its in the numeric format */
153 if (strncmp(sddl, "S-", 2) == 0) {
154 struct dom_sid *sid;
155 char *sid_str;
156 size_t len = strspn(sddl+2, "-0123456789");
157 sid_str = talloc_strndup(mem_ctx, sddl, len+2);
158 if (!sid_str) {
159 return NULL;
161 (*sddlp) += len+2;
162 sid = dom_sid_parse_talloc(mem_ctx, sid_str);
163 talloc_free(sid_str);
164 return sid;
167 /* now check for one of the special codes */
168 for (i=0;i<ARRAY_SIZE(sid_codes);i++) {
169 if (strncmp(sid_codes[i].code, sddl, 2) == 0) break;
171 if (i == ARRAY_SIZE(sid_codes)) {
172 DEBUG(1,("Unknown sddl sid code '%2.2s'\n", sddl));
173 return NULL;
176 (*sddlp) += 2;
178 if (sid_codes[i].sid == NULL) {
179 return dom_sid_add_rid(mem_ctx, domain_sid, sid_codes[i].rid);
182 return dom_sid_parse_talloc(mem_ctx, sid_codes[i].sid);
185 static const struct flag_map ace_types[] = {
186 { "AU", SEC_ACE_TYPE_SYSTEM_AUDIT },
187 { "AL", SEC_ACE_TYPE_SYSTEM_ALARM },
188 { "OA", SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT },
189 { "OD", SEC_ACE_TYPE_ACCESS_DENIED_OBJECT },
190 { "OU", SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT },
191 { "OL", SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT },
192 { "A", SEC_ACE_TYPE_ACCESS_ALLOWED },
193 { "D", SEC_ACE_TYPE_ACCESS_DENIED },
194 { NULL, 0 }
197 static const struct flag_map ace_flags[] = {
198 { "OI", SEC_ACE_FLAG_OBJECT_INHERIT },
199 { "CI", SEC_ACE_FLAG_CONTAINER_INHERIT },
200 { "NP", SEC_ACE_FLAG_NO_PROPAGATE_INHERIT },
201 { "IO", SEC_ACE_FLAG_INHERIT_ONLY },
202 { "ID", SEC_ACE_FLAG_INHERITED_ACE },
203 { "SA", SEC_ACE_FLAG_SUCCESSFUL_ACCESS },
204 { "FA", SEC_ACE_FLAG_FAILED_ACCESS },
205 { NULL, 0 },
208 static const struct flag_map ace_access_mask[] = {
209 { "RP", SEC_ADS_READ_PROP },
210 { "WP", SEC_ADS_WRITE_PROP },
211 { "CR", SEC_ADS_CONTROL_ACCESS },
212 { "CC", SEC_ADS_CREATE_CHILD },
213 { "DC", SEC_ADS_DELETE_CHILD },
214 { "LC", SEC_ADS_LIST },
215 { "LO", SEC_ADS_LIST_OBJECT },
216 { "RC", SEC_STD_READ_CONTROL },
217 { "WO", SEC_STD_WRITE_OWNER },
218 { "WD", SEC_STD_WRITE_DAC },
219 { "SD", SEC_STD_DELETE },
220 { "DT", SEC_ADS_DELETE_TREE },
221 { "SW", SEC_ADS_SELF_WRITE },
222 { "GA", SEC_GENERIC_ALL },
223 { "GR", SEC_GENERIC_READ },
224 { "GW", SEC_GENERIC_WRITE },
225 { "GX", SEC_GENERIC_EXECUTE },
226 { NULL, 0 }
229 static const struct flag_map decode_ace_access_mask[] = {
230 { "FA", FILE_ALL_ACCESS },
231 { "FR", FILE_GENERIC_READ },
232 { "FW", FILE_GENERIC_WRITE },
233 { "FX", FILE_GENERIC_EXECUTE },
234 { NULL, 0 },
237 static bool sddl_decode_access(const char *str, uint32_t *pmask)
239 const char *str0 = str;
240 uint32_t mask = 0;
241 int cmp;
243 cmp = strncmp(str, "0x", 2);
244 if (cmp == 0) {
245 *pmask = strtol(str, NULL, 16);
246 return true;
249 while ((str[0] != '\0') && isupper(str[0])) {
250 uint32_t flags = 0;
251 size_t len = 0;
252 bool found;
254 found = sddl_map_flag(
255 ace_access_mask, str, &len, &flags);
256 found |= sddl_map_flag(
257 decode_ace_access_mask, str, &len, &flags);
258 if (!found) {
259 DEBUG(1, ("Unknown flag - %s in %s\n", str, str0));
260 return false;
262 mask |= flags;
263 str += len;
266 *pmask = mask;
267 return true;
271 decode an ACE
272 return true on success, false on failure
273 note that this routine modifies the string
275 static bool sddl_decode_ace(TALLOC_CTX *mem_ctx, struct security_ace *ace, char *str,
276 const struct dom_sid *domain_sid)
278 const char *tok[6];
279 const char *s;
280 int i;
281 uint32_t v;
282 struct dom_sid *sid;
283 bool ok;
285 ZERO_STRUCTP(ace);
287 /* parse out the 6 tokens */
288 tok[0] = str;
289 for (i=0;i<5;i++) {
290 char *ptr = strchr(str, ';');
291 if (ptr == NULL) return false;
292 *ptr = 0;
293 str = ptr+1;
294 tok[i+1] = str;
297 /* parse ace type */
298 if (!sddl_map_flags(ace_types, tok[0], &v, NULL)) {
299 return false;
301 ace->type = v;
303 /* ace flags */
304 if (!sddl_map_flags(ace_flags, tok[1], &v, NULL)) {
305 return false;
307 ace->flags = v;
309 /* access mask */
310 ok = sddl_decode_access(tok[2], &ace->access_mask);
311 if (!ok) {
312 return false;
315 /* object */
316 if (tok[3][0] != 0) {
317 NTSTATUS status = GUID_from_string(tok[3],
318 &ace->object.object.type.type);
319 if (!NT_STATUS_IS_OK(status)) {
320 return false;
322 ace->object.object.flags |= SEC_ACE_OBJECT_TYPE_PRESENT;
325 /* inherit object */
326 if (tok[4][0] != 0) {
327 NTSTATUS status = GUID_from_string(tok[4],
328 &ace->object.object.inherited_type.inherited_type);
329 if (!NT_STATUS_IS_OK(status)) {
330 return false;
332 ace->object.object.flags |= SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT;
335 /* trustee */
336 s = tok[5];
337 sid = sddl_decode_sid(mem_ctx, &s, domain_sid);
338 if (sid == NULL) {
339 return false;
341 ace->trustee = *sid;
342 talloc_free(sid);
344 return true;
347 static const struct flag_map acl_flags[] = {
348 { "P", SEC_DESC_DACL_PROTECTED },
349 { "AR", SEC_DESC_DACL_AUTO_INHERIT_REQ },
350 { "AI", SEC_DESC_DACL_AUTO_INHERITED },
351 { NULL, 0 }
355 decode an ACL
357 static struct security_acl *sddl_decode_acl(struct security_descriptor *sd,
358 const char **sddlp, uint32_t *flags,
359 const struct dom_sid *domain_sid)
361 const char *sddl = *sddlp;
362 struct security_acl *acl;
363 size_t len;
365 *flags = 0;
367 acl = talloc_zero(sd, struct security_acl);
368 if (acl == NULL) return NULL;
369 acl->revision = SECURITY_ACL_REVISION_ADS;
371 if (isupper(sddl[0]) && sddl[1] == ':') {
372 /* its an empty ACL */
373 return acl;
376 /* work out the ACL flags */
377 if (!sddl_map_flags(acl_flags, sddl, flags, &len)) {
378 talloc_free(acl);
379 return NULL;
381 sddl += len;
383 /* now the ACEs */
384 while (*sddl == '(') {
385 char *astr;
386 len = strcspn(sddl+1, ")");
387 astr = talloc_strndup(acl, sddl+1, len);
388 if (astr == NULL || sddl[len+1] != ')') {
389 talloc_free(acl);
390 return NULL;
392 acl->aces = talloc_realloc(acl, acl->aces, struct security_ace,
393 acl->num_aces+1);
394 if (acl->aces == NULL) {
395 talloc_free(acl);
396 return NULL;
398 if (!sddl_decode_ace(acl->aces, &acl->aces[acl->num_aces],
399 astr, domain_sid)) {
400 talloc_free(acl);
401 return NULL;
403 switch (acl->aces[acl->num_aces].type) {
404 case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
405 case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
406 case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT:
407 case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT:
408 acl->revision = SECURITY_ACL_REVISION_ADS;
409 break;
410 default:
411 break;
413 talloc_free(astr);
414 sddl += len+2;
415 acl->num_aces++;
418 (*sddlp) = sddl;
419 return acl;
423 decode a security descriptor in SDDL format
425 struct security_descriptor *sddl_decode(TALLOC_CTX *mem_ctx, const char *sddl,
426 const struct dom_sid *domain_sid)
428 struct security_descriptor *sd;
429 sd = talloc_zero(mem_ctx, struct security_descriptor);
431 sd->revision = SECURITY_DESCRIPTOR_REVISION_1;
432 sd->type = SEC_DESC_SELF_RELATIVE;
434 while (*sddl) {
435 uint32_t flags;
436 char c = sddl[0];
437 if (sddl[1] != ':') goto failed;
439 sddl += 2;
440 switch (c) {
441 case 'D':
442 if (sd->dacl != NULL) goto failed;
443 sd->dacl = sddl_decode_acl(sd, &sddl, &flags, domain_sid);
444 if (sd->dacl == NULL) goto failed;
445 sd->type |= flags | SEC_DESC_DACL_PRESENT;
446 break;
447 case 'S':
448 if (sd->sacl != NULL) goto failed;
449 sd->sacl = sddl_decode_acl(sd, &sddl, &flags, domain_sid);
450 if (sd->sacl == NULL) goto failed;
451 /* this relies on the SEC_DESC_SACL_* flags being
452 1 bit shifted from the SEC_DESC_DACL_* flags */
453 sd->type |= (flags<<1) | SEC_DESC_SACL_PRESENT;
454 break;
455 case 'O':
456 if (sd->owner_sid != NULL) goto failed;
457 sd->owner_sid = sddl_decode_sid(sd, &sddl, domain_sid);
458 if (sd->owner_sid == NULL) goto failed;
459 break;
460 case 'G':
461 if (sd->group_sid != NULL) goto failed;
462 sd->group_sid = sddl_decode_sid(sd, &sddl, domain_sid);
463 if (sd->group_sid == NULL) goto failed;
464 break;
468 return sd;
470 failed:
471 DEBUG(2,("Badly formatted SDDL '%s'\n", sddl));
472 talloc_free(sd);
473 return NULL;
477 turn a set of flags into a string
479 static char *sddl_flags_to_string(TALLOC_CTX *mem_ctx, const struct flag_map *map,
480 uint32_t flags, bool check_all)
482 int i;
483 char *s;
485 /* try to find an exact match */
486 for (i=0;map[i].name;i++) {
487 if (map[i].flag == flags) {
488 return talloc_strdup(mem_ctx, map[i].name);
492 s = talloc_strdup(mem_ctx, "");
494 /* now by bits */
495 for (i=0;map[i].name;i++) {
496 if ((flags & map[i].flag) != 0) {
497 s = talloc_asprintf_append_buffer(s, "%s", map[i].name);
498 if (s == NULL) goto failed;
499 flags &= ~map[i].flag;
503 if (check_all && flags != 0) {
504 goto failed;
507 return s;
509 failed:
510 talloc_free(s);
511 return NULL;
515 encode a sid in SDDL format
517 static char *sddl_encode_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
518 const struct dom_sid *domain_sid)
520 size_t i;
521 char *sidstr;
523 sidstr = dom_sid_string(mem_ctx, sid);
524 if (sidstr == NULL) return NULL;
526 /* seen if its a well known sid */
527 for (i=0;sid_codes[i].sid;i++) {
528 if (strcmp(sidstr, sid_codes[i].sid) == 0) {
529 talloc_free(sidstr);
530 return talloc_strdup(mem_ctx, sid_codes[i].code);
534 /* or a well known rid in our domain */
535 if (dom_sid_in_domain(domain_sid, sid)) {
536 uint32_t rid = sid->sub_auths[sid->num_auths-1];
537 for (;i<ARRAY_SIZE(sid_codes);i++) {
538 if (rid == sid_codes[i].rid) {
539 talloc_free(sidstr);
540 return talloc_strdup(mem_ctx, sid_codes[i].code);
545 talloc_free(sidstr);
547 /* TODO: encode well known sids as two letter codes */
548 return dom_sid_string(mem_ctx, sid);
553 encode an ACE in SDDL format
555 static char *sddl_encode_ace(TALLOC_CTX *mem_ctx, const struct security_ace *ace,
556 const struct dom_sid *domain_sid)
558 char *sddl = NULL;
559 TALLOC_CTX *tmp_ctx;
560 struct GUID_txt_buf object_buf, iobject_buf;
561 const char *sddl_type="", *sddl_flags="", *sddl_mask="",
562 *sddl_object="", *sddl_iobject="", *sddl_trustee="";
564 tmp_ctx = talloc_new(mem_ctx);
565 if (tmp_ctx == NULL) {
566 DEBUG(0, ("talloc_new failed\n"));
567 return NULL;
570 sddl_type = sddl_flags_to_string(tmp_ctx, ace_types, ace->type, true);
571 if (sddl_type == NULL) {
572 goto failed;
575 sddl_flags = sddl_flags_to_string(tmp_ctx, ace_flags, ace->flags,
576 true);
577 if (sddl_flags == NULL) {
578 goto failed;
581 sddl_mask = sddl_flags_to_string(tmp_ctx, ace_access_mask,
582 ace->access_mask, true);
583 if (sddl_mask == NULL) {
584 sddl_mask = talloc_asprintf(tmp_ctx, "0x%08x",
585 ace->access_mask);
586 if (sddl_mask == NULL) {
587 goto failed;
591 if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT ||
592 ace->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT ||
593 ace->type == SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT ||
594 ace->type == SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT) {
595 const struct security_ace_object *object = &ace->object.object;
597 if (ace->object.object.flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
598 sddl_object = GUID_buf_string(
599 &object->type.type, &object_buf);
602 if (ace->object.object.flags &
603 SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
604 sddl_iobject = GUID_buf_string(
605 &object->inherited_type.inherited_type,
606 &iobject_buf);
610 sddl_trustee = sddl_encode_sid(tmp_ctx, &ace->trustee, domain_sid);
611 if (sddl_trustee == NULL) {
612 goto failed;
615 sddl = talloc_asprintf(mem_ctx, "%s;%s;%s;%s;%s;%s",
616 sddl_type, sddl_flags, sddl_mask, sddl_object,
617 sddl_iobject, sddl_trustee);
619 failed:
620 talloc_free(tmp_ctx);
621 return sddl;
625 encode an ACL in SDDL format
627 static char *sddl_encode_acl(TALLOC_CTX *mem_ctx, const struct security_acl *acl,
628 uint32_t flags, const struct dom_sid *domain_sid)
630 char *sddl;
631 uint32_t i;
633 /* add any ACL flags */
634 sddl = sddl_flags_to_string(mem_ctx, acl_flags, flags, false);
635 if (sddl == NULL) goto failed;
637 /* now the ACEs, encoded in braces */
638 for (i=0;i<acl->num_aces;i++) {
639 char *ace = sddl_encode_ace(sddl, &acl->aces[i], domain_sid);
640 if (ace == NULL) goto failed;
641 sddl = talloc_asprintf_append_buffer(sddl, "(%s)", ace);
642 if (sddl == NULL) goto failed;
643 talloc_free(ace);
646 return sddl;
648 failed:
649 talloc_free(sddl);
650 return NULL;
655 encode a security descriptor to SDDL format
657 char *sddl_encode(TALLOC_CTX *mem_ctx, const struct security_descriptor *sd,
658 const struct dom_sid *domain_sid)
660 char *sddl;
661 TALLOC_CTX *tmp_ctx;
663 /* start with a blank string */
664 sddl = talloc_strdup(mem_ctx, "");
665 if (sddl == NULL) goto failed;
667 tmp_ctx = talloc_new(mem_ctx);
669 if (sd->owner_sid != NULL) {
670 char *sid = sddl_encode_sid(tmp_ctx, sd->owner_sid, domain_sid);
671 if (sid == NULL) goto failed;
672 sddl = talloc_asprintf_append_buffer(sddl, "O:%s", sid);
673 if (sddl == NULL) goto failed;
676 if (sd->group_sid != NULL) {
677 char *sid = sddl_encode_sid(tmp_ctx, sd->group_sid, domain_sid);
678 if (sid == NULL) goto failed;
679 sddl = talloc_asprintf_append_buffer(sddl, "G:%s", sid);
680 if (sddl == NULL) goto failed;
683 if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl != NULL) {
684 char *acl = sddl_encode_acl(tmp_ctx, sd->dacl, sd->type, domain_sid);
685 if (acl == NULL) goto failed;
686 sddl = talloc_asprintf_append_buffer(sddl, "D:%s", acl);
687 if (sddl == NULL) goto failed;
690 if ((sd->type & SEC_DESC_SACL_PRESENT) && sd->sacl != NULL) {
691 char *acl = sddl_encode_acl(tmp_ctx, sd->sacl, sd->type>>1, domain_sid);
692 if (acl == NULL) goto failed;
693 sddl = talloc_asprintf_append_buffer(sddl, "S:%s", acl);
694 if (sddl == NULL) goto failed;
697 talloc_free(tmp_ctx);
698 return sddl;
700 failed:
701 talloc_free(sddl);
702 return NULL;