Rev 5299: refactoring: put deletion of a subkey (aka regshare) into
a static in http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/
Michael Adam
ma at sernet.de
Thu Mar 22 13:47:55 GMT 2007
At http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/
------------------------------------------------------------
revno: 5299
revision-id: ma at sernet.de-20070322134752-496c2a22c1a3ca5d
parent: ma at sernet.de-20070322101118-9de028650dea3522
committer: Michael Adam <ma at sernet.de>
branch nick: SAMBA_3_0-registry.bzr
timestamp: Thu 2007-03-22 14:47:52 +0100
message:
refactoring: put deletion of a subkey (aka regshare) into a static
function to be able to use it in other places (e.g. net conf import).
modified:
source/utils/net_conf.c net_conf.c-20070228210606-uywdn1acd043wgvt-1
=== modified file 'source/utils/net_conf.c'
--- a/source/utils/net_conf.c 2007-03-21 16:16:32 +0000
+++ b/source/utils/net_conf.c 2007-03-22 13:47:52 +0000
@@ -184,6 +184,33 @@
return werr;
}
+/*
+ * delete a subkey of smbconf
+ */
+static WERROR reg_delkey_internal(TALLOC_CTX *ctx, const char *keyname)
+{
+ WERROR werr = WERR_OK;
+ struct registry_key *key = NULL;
+
+ werr = reg_open_path(ctx, KEY_SMBCONF, REG_KEY_WRITE,
+ get_root_nt_token(), &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, "Error opening registry path '%s': %s\n",
+ KEY_SMBCONF, dos_errstr(werr));
+ goto done;
+ }
+
+ werr = reg_deletekey(key, keyname);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, "Error deleting registry key %s\\%s: %s\n",
+ KEY_SMBCONF, keyname, dos_errstr(werr));
+ }
+
+done:
+ TALLOC_FREE(key);
+ return werr;
+}
+
static WERROR list_values(TALLOC_CTX *ctx, struct registry_key *key)
{
WERROR werr = WERR_OK;
@@ -311,6 +338,8 @@
goto done;
}
+ /* global params would be handled here... */
+
if (!(shares = share_list_all(ctx))) {
d_fprintf(stderr, "Could not list shares...\n");
goto done;
@@ -652,8 +681,6 @@
int net_conf_delshare(int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
- struct registry_key *key = NULL;
const char *sharename = NULL;
if (argc != 1) {
@@ -662,23 +689,10 @@
}
sharename = argv[0];
- werr = reg_open_path(NULL, KEY_SMBCONF, REG_KEY_WRITE,
- get_root_nt_token(), &key);
- if (!W_ERROR_IS_OK(werr)) {
- d_fprintf(stderr, "Error opening registry path '%s': %s\n",
- KEY_SMBCONF, dos_errstr(werr));
- goto done;
- }
-
- werr = reg_deletekey(key, sharename);
- if (!W_ERROR_IS_OK(werr)) {
- d_fprintf(stderr, "Error deleting registry key %s\\%s: %s\n",
- KEY_SMBCONF, sharename, dos_errstr(werr));
- }
- ret = 0;
-
+ if (W_ERROR_IS_OK(reg_delkey_internal(NULL, sharename))) {
+ ret = 0;
+ }
done:
- TALLOC_FREE(key);
return ret;
}
More information about the samba-cvs
mailing list