diff options
author | Michael Adam <obnox@samba.org> | 2007-12-25 02:55:07 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2007-12-25 02:55:07 +0100 |
commit | 8e53343a74ab6c8947523ca9bd9a8c1583a8691e (patch) | |
tree | 2f607ca613ccaec305bbbd55538235166801c091 /source3/libnet | |
parent | 9626fffe14ebedba7ce53441bb4f9e2288a8410d (diff) | |
download | samba-8e53343a74ab6c8947523ca9bd9a8c1583a8691e.tar.gz samba-8e53343a74ab6c8947523ca9bd9a8c1583a8691e.tar.bz2 samba-8e53343a74ab6c8947523ca9bd9a8c1583a8691e.zip |
Move drop_smbconf_internal() to libnet_conf.c
Michael
(This used to be commit 4c2a3396bb687703f6b74655fda2014d1f75200b)
Diffstat (limited to 'source3/libnet')
-rw-r--r-- | source3/libnet/libnet_conf.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 4c5a0829d6..e81b8b4111 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,6 +243,56 @@ done: * **********************************************************************/ +WERROR drop_smbconf_internal(TALLOC_CTX *ctx) +{ + char *path, *p; + WERROR werr = WERR_OK; + NT_USER_TOKEN *token; + struct registry_key *parent_key = NULL; + struct registry_key *new_key = NULL; + TALLOC_CTX* tmp_ctx = NULL; + enum winreg_CreateAction action; + + tmp_ctx = talloc_new(ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + if (!(token = registry_create_admin_token(tmp_ctx))) { + /* what is the appropriate error code here? */ + werr = WERR_CAN_NOT_COMPLETE; + goto done; + } + + path = talloc_strdup(tmp_ctx, KEY_SMBCONF); + if (path == NULL) { + d_fprintf(stderr, "ERROR: out of memory!\n"); + werr = WERR_NOMEM; + goto done; + } + p = strrchr(path, '\\'); + *p = '\0'; + werr = reg_open_path(tmp_ctx, path, REG_KEY_WRITE, token, &parent_key); + + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = reg_deletekey_recursive(tmp_ctx, parent_key, p+1); + + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = reg_createkey(tmp_ctx, parent_key, p+1, REG_KEY_WRITE, + &new_key, &action); + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} + /** * delete a service from configuration */ |