diff options
author | Wilco Baan Hofman <wilco@synlap.(none)> | 2008-04-15 19:57:29 +0200 |
---|---|---|
committer | Wilco Baan Hofman <wilco@synlap.(none)> | 2008-04-15 19:57:29 +0200 |
commit | 5e687d79533684949deb9bd9bc86f88eab4ae310 (patch) | |
tree | 8da94d0a96250cc3d05566e9d71ee258acd0babc /source4/lib/registry/patchfile.c | |
parent | 0b8d2b3cb779463a1e24039300ac2669862f9b64 (diff) | |
download | samba-5e687d79533684949deb9bd9bc86f88eab4ae310.tar.gz samba-5e687d79533684949deb9bd9bc86f88eab4ae310.tar.bz2 samba-5e687d79533684949deb9bd9bc86f88eab4ae310.zip |
Fix PReg write support.
Add tests for patch files (.REG and PReg).
(This used to be commit 497977c36c621a4820be51cbcb7b78eac1e292b7)
Diffstat (limited to 'source4/lib/registry/patchfile.c')
-rw-r--r-- | source4/lib/registry/patchfile.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c index eaeef341bb..0ede3106f0 100644 --- a/source4/lib/registry/patchfile.c +++ b/source4/lib/registry/patchfile.c @@ -320,12 +320,33 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name) { struct registry_context *ctx = (struct registry_context *)_ctx; struct registry_key *tmp; + char *buf, *buf_ptr; WERROR error; + /* Recursively create the path */ + buf = talloc_strdup(ctx, key_name); + buf_ptr = buf; + + while (*buf_ptr++ != '\0' ) { + if (*buf_ptr == '\\') { + *buf_ptr = '\0'; + error = reg_key_add_abs(ctx, ctx, buf, 0, NULL, &tmp); + + if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) && + !W_ERROR_IS_OK(error)) { + DEBUG(0, ("Error adding new key '%s': %s\n", + key_name, win_errstr(error))); + return error; + } + *buf_ptr++ = '\\'; + } + } + + /* Add the key */ error = reg_key_add_abs(ctx, ctx, key_name, 0, NULL, &tmp); if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) && - !W_ERROR_IS_OK(error)) { + !W_ERROR_IS_OK(error)) { DEBUG(0, ("Error adding new key '%s': %s\n", key_name, win_errstr(error))); return error; |