From 7aa665f2b29ecb4bcd9367a71eeca4944d3a8faf Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 25 Apr 2003 06:43:28 +0000 Subject: More code to store ACEs and SIDs. I have almost enough to start testing the writing of a registry tree, since I can store the header, and the first key (NK_REC) and the SD associated with that key, the SK_REC. (This used to be commit abced0ed9eec7b8467065892c56cef9b86cff947) --- source3/utils/editreg.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/utils/editreg.c b/source3/utils/editreg.c index 273707114f..a367c92d32 100644 --- a/source3/utils/editreg.c +++ b/source3/utils/editreg.c @@ -2653,17 +2653,93 @@ unsigned int sec_desc_size(SEC_DESC *sd) return size; } -int nt_store_SID(REGF *regf, DOM_SID *sid, char *locn) +/* + * Store a SID at the location provided + */ + +int nt_store_SID(REGF *regf, DOM_SID *sid, unsigned char *locn) { + int i; + unsigned char *p = locn; - return 0; + if (!regf || !sid || !locn) return 0; + + *p = sid->ver; p++; + *p = sid->auths; p++; + + for (i=0; i < 6; i++) { + *p = sid->auth[i]; p++; + } + + for (i=0; i < sid->auths; i++) { + SIVAL(p, sid->sub_auths[i]); p+=4; + } + + return p - locn; } -int nt_store_acl(REGF *regf, ACL *acl, char *locn) +int nt_store_ace(REGF *regf, ACE *ace, unsigned char *locn) { + int size = 0; + REG_ACE *reg_ace = (REG_ACE *)locn; + unsigned char *p; - return 0; + if (!regf || !ace || !locn) return 0; + + reg_ace->type = ace->type; + reg_ace->flags = ace->flags; + + /* Deal with the length when we have stored the SID */ + + p = (unsigned char *)®_ace->perms; + + SIVAL(p, ace->perms); p += 4; + + size = nt_store_SID(regf, ace->trustee, p); + + size += 8; /* Size of the fixed header */ + + p = (unsigned char *)®_ace->length; + + SSVAL(p, size); + + return size; +} + +/* + * Store an ACL at the location provided + */ + +int nt_store_acl(REGF *regf, ACL *acl, unsigned char *locn) +{ + int size = 0, i; + unsigned char *p = locn, *s; + + if (!regf || !acl || !locn) return 0; + + /* + * Now store the header and then the ACEs ... + */ + + SSVAL(p, acl->rev); + + p += 2; s = p; /* Save this for the size field */ + + p += 2; + + SIVAL(p, acl->num_aces); + + p += 4; + + for (i = 0; i < acl->num_aces; i++) { + size = nt_store_ace(regf, acl->aces[i], p); + p += size; + } + + size = s - locn; + SSVAL(s, size); + return size; } /* -- cgit