diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-11-30 07:38:40 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:16:16 -0500 |
commit | 575845ccbeb2acc5dcb5133b80fd19b1d80169f2 (patch) | |
tree | 0ec427819a9f6e9e417a1e34b9bbcfd23badc1b7 /source3/lib | |
parent | 3fda843ac16d3d8c66a398a93b5de81f7d74276d (diff) | |
download | samba-575845ccbeb2acc5dcb5133b80fd19b1d80169f2.tar.gz samba-575845ccbeb2acc5dcb5133b80fd19b1d80169f2.tar.bz2 samba-575845ccbeb2acc5dcb5133b80fd19b1d80169f2.zip |
r19963: Add 'registry shares = yes' and registry key security descriptors.
(This used to be commit 6cab254c49e07b11c170511ec613f0f33914c3e6)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/secdesc.c | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/source3/lib/secdesc.c b/source3/lib/secdesc.c index 2f592769b3..762dc2f6d8 100644 --- a/source3/lib/secdesc.c +++ b/source3/lib/secdesc.c @@ -216,16 +216,16 @@ SEC_DESC *make_sec_desc(TALLOC_CTX *ctx, uint16 revision, uint16 type, dst->sacl = NULL; dst->dacl = NULL; - if(owner_sid && ((dst->owner_sid = sid_dup_talloc(ctx,owner_sid)) == NULL)) + if(owner_sid && ((dst->owner_sid = sid_dup_talloc(dst,owner_sid)) == NULL)) goto error_exit; - if(grp_sid && ((dst->group_sid = sid_dup_talloc(ctx,grp_sid)) == NULL)) + if(grp_sid && ((dst->group_sid = sid_dup_talloc(dst,grp_sid)) == NULL)) goto error_exit; - if(sacl && ((dst->sacl = dup_sec_acl(ctx, sacl)) == NULL)) + if(sacl && ((dst->sacl = dup_sec_acl(dst, sacl)) == NULL)) goto error_exit; - if(dacl && ((dst->dacl = dup_sec_acl(ctx, dacl)) == NULL)) + if(dacl && ((dst->dacl = dup_sec_acl(dst, dacl)) == NULL)) goto error_exit; offset = SEC_DESC_HEADER_SIZE; @@ -275,6 +275,63 @@ SEC_DESC *dup_sec_desc(TALLOC_CTX *ctx, const SEC_DESC *src) } /******************************************************************* + Convert a secdesc into a byte stream +********************************************************************/ +NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx, + struct security_descriptor *secdesc, + uint8 **data, size_t *len) +{ + prs_struct ps; + + if (!prs_init(&ps, sec_desc_size(secdesc), mem_ctx, MARSHALL)) { + return NT_STATUS_NO_MEMORY; + } + + if (!sec_io_desc("security_descriptor", &secdesc, &ps, 1)) { + prs_mem_free(&ps); + return NT_STATUS_INVALID_PARAMETER; + } + + if (!(*data = (uint8 *)talloc_memdup(mem_ctx, ps.data_p, + prs_offset(&ps)))) { + prs_mem_free(&ps); + return NT_STATUS_NO_MEMORY; + } + + *len = prs_offset(&ps); + prs_mem_free(&ps); + return NT_STATUS_OK; +} + +/******************************************************************* + Parse a byte stream into a secdesc +********************************************************************/ +NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len, + struct security_descriptor **psecdesc) +{ + prs_struct ps; + struct security_descriptor *secdesc = NULL; + + if (!(secdesc = TALLOC_ZERO_P(mem_ctx, struct security_descriptor))) { + return NT_STATUS_NO_MEMORY; + } + + if (!prs_init(&ps, 0, secdesc, UNMARSHALL)) { + return NT_STATUS_NO_MEMORY; + } + + prs_give_memory(&ps, (char *)data, len, False); + + if (!sec_io_desc("security_descriptor", &secdesc, &ps, 1)) { + return NT_STATUS_INVALID_PARAMETER; + } + + prs_mem_free(&ps); + *psecdesc = secdesc; + return NT_STATUS_OK; +} + +/******************************************************************* Creates a SEC_DESC structure with typical defaults. ********************************************************************/ |