2 * Unix SMB/CIFS implementation.
3 * libsmbconf - Samba configuration library, registry backend
4 * Copyright (C) Michael Adam 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "smbconf_private.h"
23 #define INCLUDES_VALNAME "includes"
25 struct reg_private_data {
27 bool open; /* did _we_ open the registry? */
30 /**********************************************************************
34 **********************************************************************/
37 * a convenience helper to cast the private data structure
39 static struct reg_private_data *rpd(struct smbconf_ctx *ctx)
41 return (struct reg_private_data *)(ctx->data);
45 * check whether a given value name is forbidden in registry (smbconf)
47 static bool smbconf_reg_valname_forbidden(const char *valname)
49 /* hard code the list of forbidden names here for now */
50 const char *forbidden_valnames[] = {
57 const char **forbidden = NULL;
59 for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) {
60 if (strwicmp(valname, *forbidden) == 0) {
67 static bool smbconf_reg_valname_valid(const char *valname)
69 return (lp_parameter_is_valid(valname) &&
70 !smbconf_reg_valname_forbidden(valname));
74 * Open a registry key specified by "path"
76 static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
77 struct smbconf_ctx *ctx,
79 uint32 desired_access,
80 struct registry_key **key)
82 WERROR werr = WERR_OK;
85 DEBUG(1, ("Error: configuration is not open!\n"));
86 werr = WERR_INVALID_PARAM;
90 if (rpd(ctx)->token == NULL) {
91 DEBUG(1, ("Error: token missing from smbconf_ctx. "
92 "was smbconf_init() called?\n"));
93 werr = WERR_INVALID_PARAM;
97 werr = ctx->ops->open_conf(ctx);
98 if (!W_ERROR_IS_OK(werr)) {
99 DEBUG(1, ("Error opening the registry.\n"));
104 DEBUG(1, ("Error: NULL path string given\n"));
105 werr = WERR_INVALID_PARAM;
109 werr = reg_open_path(mem_ctx, path, desired_access, rpd(ctx)->token,
112 if (!W_ERROR_IS_OK(werr)) {
113 DEBUG(5, ("Error opening registry path '%s': %s\n",
114 path, dos_errstr(werr)));
122 * Open a subkey of the base key (i.e a service)
124 static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
125 struct smbconf_ctx *ctx,
126 const char *servicename,
127 uint32 desired_access,
128 struct registry_key **key)
130 WERROR werr = WERR_OK;
133 if (servicename == NULL) {
134 path = talloc_strdup(mem_ctx, ctx->path);
136 path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path,
144 werr = smbconf_reg_open_path(mem_ctx, ctx, path, desired_access, key);
154 static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx,
155 struct smbconf_ctx *ctx,
156 uint32 desired_access,
157 struct registry_key **key)
159 return smbconf_reg_open_path(mem_ctx, ctx, ctx->path, desired_access,
164 * check if a value exists in a given registry key
166 static bool smbconf_value_exists(struct registry_key *key, const char *param)
169 WERROR werr = WERR_OK;
170 TALLOC_CTX *ctx = talloc_stackframe();
171 struct registry_value *value = NULL;
173 werr = reg_queryvalue(ctx, key, param, &value);
174 if (W_ERROR_IS_OK(werr)) {
183 * create a subkey of the base key (i.e. a service...)
185 static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
186 struct smbconf_ctx *ctx,
187 const char * subkeyname,
188 struct registry_key **newkey)
190 WERROR werr = WERR_OK;
191 struct registry_key *create_parent = NULL;
192 TALLOC_CTX *create_ctx;
193 enum winreg_CreateAction action = REG_ACTION_NONE;
195 /* create a new talloc ctx for creation. it will hold
196 * the intermediate parent key (SMBCONF) for creation
197 * and will be destroyed when leaving this function... */
198 create_ctx = talloc_stackframe();
200 werr = smbconf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE,
202 if (!W_ERROR_IS_OK(werr)) {
206 werr = reg_createkey(mem_ctx, create_parent, subkeyname,
207 REG_KEY_WRITE, newkey, &action);
208 if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
209 DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
210 werr = WERR_ALREADY_EXISTS;
212 if (!W_ERROR_IS_OK(werr)) {
213 DEBUG(5, ("Error creating key %s: %s\n",
214 subkeyname, dos_errstr(werr)));
218 TALLOC_FREE(create_ctx);
223 * add a value to a key.
225 static WERROR smbconf_reg_set_value(struct registry_key *key,
229 struct registry_value val;
230 WERROR werr = WERR_OK;
232 const char *canon_valname;
233 const char *canon_valstr;
235 if (!lp_canonicalize_parameter_with_value(valname, valstr,
239 if (canon_valname == NULL) {
240 DEBUG(5, ("invalid parameter '%s' given\n",
243 DEBUG(5, ("invalid value '%s' given for "
244 "parameter '%s'\n", valstr, valname));
246 werr = WERR_INVALID_PARAM;
250 if (smbconf_reg_valname_forbidden(canon_valname)) {
251 DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
253 werr = WERR_INVALID_PARAM;
257 subkeyname = strrchr_m(key->key->name, '\\');
258 if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
259 DEBUG(5, ("Invalid registry key '%s' given as "
260 "smbconf section.\n", key->key->name));
261 werr = WERR_INVALID_PARAM;
265 if (!strequal(subkeyname, GLOBAL_NAME) &&
266 lp_parameter_is_global(valname))
268 DEBUG(5, ("Global paramter '%s' not allowed in "
269 "service definition ('%s').\n", canon_valname,
271 werr = WERR_INVALID_PARAM;
278 val.v.sz.str = CONST_DISCARD(char *, canon_valstr);
279 val.v.sz.len = strlen(canon_valstr) + 1;
281 werr = reg_setvalue(key, canon_valname, &val);
282 if (!W_ERROR_IS_OK(werr)) {
283 DEBUG(5, ("Error adding value '%s' to "
285 canon_valname, key->key->name, dos_errstr(werr)));
292 static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
294 const uint32_t num_strings,
295 const char **strings)
298 struct registry_value *value;
300 TALLOC_CTX *tmp_ctx = talloc_stackframe();
302 if (strings == NULL) {
303 werr = WERR_INVALID_PARAM;
307 value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
309 value->type = REG_MULTI_SZ;
310 value->v.multi_sz.num_strings = num_strings;
311 value->v.multi_sz.strings = TALLOC_ARRAY(tmp_ctx, char *, num_strings);
312 if (value->v.multi_sz.strings == NULL) {
316 for (count = 0; count < num_strings; count++) {
317 value->v.multi_sz.strings[count] =
318 talloc_strdup(value->v.multi_sz.strings,
320 if (value->v.multi_sz.strings[count] == NULL) {
326 werr = reg_setvalue(key, valname, value);
327 if (!W_ERROR_IS_OK(werr)) {
328 DEBUG(5, ("Error adding value '%s' to key '%s': %s\n",
329 valname, key->key->name, dos_errstr(werr)));
333 TALLOC_FREE(tmp_ctx);
338 * format a registry_value into a string.
340 * This is intended to be used for smbconf registry values,
341 * which are ar stored as REG_SZ values, so the incomplete
342 * handling should be ok.
344 static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
345 struct registry_value *value)
349 /* alternatively, create a new talloc context? */
350 if (mem_ctx == NULL) {
354 switch (value->type) {
356 result = talloc_asprintf(mem_ctx, "%d", value->v.dword);
360 result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str);
364 for (j = 0; j < value->v.multi_sz.num_strings; j++) {
365 result = talloc_asprintf(mem_ctx, "%s\"%s\" ",
366 result ? result : "" ,
367 value->v.multi_sz.strings[j]);
368 if (result == NULL) {
375 result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
376 (int)value->v.binary.length);
379 result = talloc_asprintf(mem_ctx, "<unprintable>");
385 static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
386 struct registry_key *key,
387 uint32_t *num_includes,
392 struct registry_value *value = NULL;
393 char **tmp_includes = NULL;
394 TALLOC_CTX *tmp_ctx = talloc_stackframe();
396 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
404 werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value);
405 if (!W_ERROR_IS_OK(werr)) {
409 if (value->type != REG_MULTI_SZ) {
410 /* wront type -- ignore */
414 for (count = 0; count < value->v.multi_sz.num_strings; count++)
416 werr = smbconf_add_string_to_array(tmp_ctx,
419 value->v.multi_sz.strings[count]);
420 if (!W_ERROR_IS_OK(werr)) {
426 *includes = talloc_move(mem_ctx, &tmp_includes);
427 if (*includes == NULL) {
431 *num_includes = count;
438 TALLOC_FREE(tmp_ctx);
443 * Get the values of a key as a list of value names
444 * and a list of value strings (ordered)
446 static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
447 struct registry_key *key,
448 uint32_t *num_values,
450 char ***value_strings)
452 TALLOC_CTX *tmp_ctx = NULL;
453 WERROR werr = WERR_OK;
455 struct registry_value *valvalue = NULL;
456 char *valname = NULL;
457 uint32_t tmp_num_values = 0;
458 char **tmp_valnames = NULL;
459 char **tmp_valstrings = NULL;
460 uint32_t num_includes = 0;
461 char **includes = NULL;
463 if ((num_values == NULL) || (value_names == NULL) ||
464 (value_strings == NULL))
466 werr = WERR_INVALID_PARAM;
470 tmp_ctx = talloc_stackframe();
473 werr = reg_enumvalue(tmp_ctx, key, count, &valname, &valvalue),
479 if (!smbconf_reg_valname_valid(valname)) {
483 werr = smbconf_add_string_to_array(tmp_ctx,
485 tmp_num_values, valname);
486 if (!W_ERROR_IS_OK(werr)) {
490 valstring = smbconf_format_registry_value(tmp_ctx, valvalue);
491 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
492 tmp_num_values, valstring);
493 if (!W_ERROR_IS_OK(werr)) {
498 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
502 /* now add the includes at the end */
503 werr = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
505 if (!W_ERROR_IS_OK(werr)) {
508 for (count = 0; count < num_includes; count++) {
509 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valnames,
510 tmp_num_values, "include");
511 if (!W_ERROR_IS_OK(werr)) {
515 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
518 if (!W_ERROR_IS_OK(werr)) {
525 *num_values = tmp_num_values;
526 if (tmp_num_values > 0) {
527 *value_names = talloc_move(mem_ctx, &tmp_valnames);
528 *value_strings = talloc_move(mem_ctx, &tmp_valstrings);
531 *value_strings = NULL;
535 TALLOC_FREE(tmp_ctx);
539 static bool smbconf_reg_key_has_values(struct registry_key *key)
542 uint32_t num_subkeys;
543 uint32_t max_subkeylen;
544 uint32_t max_subkeysize;
546 uint32_t max_valnamelen;
547 uint32_t max_valbufsize;
548 uint32_t secdescsize;
549 NTTIME last_changed_time;
551 werr = reg_queryinfokey(key, &num_subkeys, &max_subkeylen,
552 &max_subkeysize, &num_values, &max_valnamelen,
553 &max_valbufsize, &secdescsize,
555 if (!W_ERROR_IS_OK(werr)) {
559 return (num_values != 0);
563 * delete all values from a key
565 static WERROR smbconf_reg_delete_values(struct registry_key *key)
569 struct registry_value *valvalue;
571 TALLOC_CTX *mem_ctx = talloc_stackframe();
574 werr = reg_enumvalue(mem_ctx, key, count, &valname, &valvalue),
578 werr = reg_deletevalue(key, valname);
579 if (!W_ERROR_IS_OK(werr)) {
583 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
584 DEBUG(1, ("smbconf_reg_delete_values: "
585 "Error enumerating values of %s: %s\n",
594 TALLOC_FREE(mem_ctx);
598 /**********************************************************************
600 * smbconf operations: registry implementations
602 **********************************************************************/
605 * initialize the registry smbconf backend
607 static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
609 WERROR werr = WERR_OK;
614 ctx->path = talloc_strdup(ctx, path);
615 if (ctx->path == NULL) {
620 ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
622 werr = ntstatus_to_werror(registry_create_admin_token(ctx,
623 &(rpd(ctx)->token)));
624 if (!W_ERROR_IS_OK(werr)) {
625 DEBUG(1, ("Error creating admin token\n"));
628 rpd(ctx)->open = false;
630 werr = registry_init_smbconf(path);
631 if (!W_ERROR_IS_OK(werr)) {
639 static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
641 return ctx->ops->close_conf(ctx);
644 static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
648 if (rpd(ctx)->open) {
653 if (W_ERROR_IS_OK(werr)) {
654 rpd(ctx)->open = true;
659 static int smbconf_reg_close(struct smbconf_ctx *ctx)
663 if (!rpd(ctx)->open) {
669 rpd(ctx)->open = false;
675 * Get the change sequence number of the given service/parameter.
676 * service and parameter strings may be NULL.
678 static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
679 struct smbconf_csn *csn,
680 const char *service, const char *param)
686 if (!W_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
690 csn->csn = (uint64_t)regdb_get_seqnum();
694 * Drop the whole configuration (restarting empty) - registry version
696 static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
699 WERROR werr = WERR_OK;
700 struct registry_key *parent_key = NULL;
701 struct registry_key *new_key = NULL;
702 TALLOC_CTX* mem_ctx = talloc_stackframe();
703 enum winreg_CreateAction action;
705 path = talloc_strdup(mem_ctx, ctx->path);
710 p = strrchr(path, '\\');
712 werr = smbconf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE,
715 if (!W_ERROR_IS_OK(werr)) {
719 werr = reg_deletekey_recursive(mem_ctx, parent_key, p+1);
721 if (!W_ERROR_IS_OK(werr)) {
725 werr = reg_createkey(mem_ctx, parent_key, p+1, REG_KEY_WRITE,
729 TALLOC_FREE(mem_ctx);
734 * get the list of share names defined in the configuration.
737 static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
739 uint32_t *num_shares,
743 uint32_t added_count = 0;
744 TALLOC_CTX *tmp_ctx = NULL;
745 WERROR werr = WERR_OK;
746 struct registry_key *key = NULL;
747 char *subkey_name = NULL;
748 char **tmp_share_names = NULL;
750 if ((num_shares == NULL) || (share_names == NULL)) {
751 werr = WERR_INVALID_PARAM;
755 tmp_ctx = talloc_stackframe();
757 /* if there are values in the base key, return NULL as share name */
758 werr = smbconf_reg_open_base_key(tmp_ctx, ctx,
759 SEC_RIGHTS_ENUM_SUBKEYS, &key);
760 if (!W_ERROR_IS_OK(werr)) {
764 if (smbconf_reg_key_has_values(key)) {
765 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
767 if (!W_ERROR_IS_OK(werr)) {
773 /* make sure "global" is always listed first */
774 if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
775 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
776 added_count, GLOBAL_NAME);
777 if (!W_ERROR_IS_OK(werr)) {
784 werr = reg_enumkey(tmp_ctx, key, count, &subkey_name, NULL),
788 if (strequal(subkey_name, GLOBAL_NAME)) {
792 werr = smbconf_add_string_to_array(tmp_ctx,
796 if (!W_ERROR_IS_OK(werr)) {
801 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
806 *num_shares = added_count;
807 if (added_count > 0) {
808 *share_names = talloc_move(mem_ctx, &tmp_share_names);
814 TALLOC_FREE(tmp_ctx);
819 * check if a share/service of a given name exists - registry version
821 static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
822 const char *servicename)
825 WERROR werr = WERR_OK;
826 TALLOC_CTX *mem_ctx = talloc_stackframe();
827 struct registry_key *key = NULL;
829 werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
831 if (W_ERROR_IS_OK(werr)) {
835 TALLOC_FREE(mem_ctx);
840 * Add a service if it does not already exist - registry version
842 static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
843 const char *servicename)
846 TALLOC_CTX *mem_ctx = talloc_stackframe();
847 struct registry_key *key = NULL;
849 if (servicename == NULL) {
850 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE,
853 werr = smbconf_reg_create_service_key(mem_ctx, ctx,
857 TALLOC_FREE(mem_ctx);
862 * get a definition of a share (service) from configuration.
864 static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
866 const char *servicename,
867 struct smbconf_service **service)
869 WERROR werr = WERR_OK;
870 struct registry_key *key = NULL;
871 struct smbconf_service *tmp_service = NULL;
872 TALLOC_CTX *tmp_ctx = talloc_stackframe();
874 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
876 if (!W_ERROR_IS_OK(werr)) {
880 tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);
881 if (tmp_service == NULL) {
886 if (servicename != NULL) {
887 tmp_service->name = talloc_strdup(tmp_service, servicename);
888 if (tmp_service->name == NULL) {
894 werr = smbconf_reg_get_values(tmp_service, key,
895 &(tmp_service->num_params),
896 &(tmp_service->param_names),
897 &(tmp_service->param_values));
899 if (W_ERROR_IS_OK(werr)) {
900 *service = talloc_move(mem_ctx, &tmp_service);
904 TALLOC_FREE(tmp_ctx);
909 * delete a service from configuration
911 static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
912 const char *servicename)
914 WERROR werr = WERR_OK;
915 struct registry_key *key = NULL;
916 TALLOC_CTX *mem_ctx = talloc_stackframe();
918 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key);
919 if (!W_ERROR_IS_OK(werr)) {
923 if (servicename != NULL) {
924 werr = reg_deletekey_recursive(key, key, servicename);
926 werr = smbconf_reg_delete_values(key);
930 TALLOC_FREE(mem_ctx);
935 * set a configuration parameter to the value provided.
937 static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
943 struct registry_key *key = NULL;
944 TALLOC_CTX *mem_ctx = talloc_stackframe();
946 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
947 REG_KEY_WRITE, &key);
948 if (!W_ERROR_IS_OK(werr)) {
952 werr = smbconf_reg_set_value(key, param, valstr);
955 TALLOC_FREE(mem_ctx);
960 * get the value of a configuration parameter as a string
962 static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
968 WERROR werr = WERR_OK;
969 struct registry_key *key = NULL;
970 struct registry_value *value = NULL;
972 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
974 if (!W_ERROR_IS_OK(werr)) {
978 if (!smbconf_reg_valname_valid(param)) {
979 werr = WERR_INVALID_PARAM;
983 if (!smbconf_value_exists(key, param)) {
984 werr = WERR_INVALID_PARAM;
988 werr = reg_queryvalue(mem_ctx, key, param, &value);
989 if (!W_ERROR_IS_OK(werr)) {
993 *valstr = smbconf_format_registry_value(mem_ctx, value);
995 if (*valstr == NULL) {
1006 * delete a parameter from configuration
1008 static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
1009 const char *service,
1012 struct registry_key *key = NULL;
1013 WERROR werr = WERR_OK;
1014 TALLOC_CTX *mem_ctx = talloc_stackframe();
1016 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
1018 if (!W_ERROR_IS_OK(werr)) {
1022 if (!smbconf_reg_valname_valid(param)) {
1023 werr = WERR_INVALID_PARAM;
1027 if (!smbconf_value_exists(key, param)) {
1028 werr = WERR_INVALID_PARAM;
1032 werr = reg_deletevalue(key, param);
1035 TALLOC_FREE(mem_ctx);
1039 static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx,
1040 TALLOC_CTX *mem_ctx,
1041 const char *service,
1042 uint32_t *num_includes,
1046 struct registry_key *key = NULL;
1047 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1049 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1050 REG_KEY_READ, &key);
1051 if (!W_ERROR_IS_OK(werr)) {
1055 werr = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
1059 TALLOC_FREE(tmp_ctx);
1063 static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
1064 const char *service,
1065 uint32_t num_includes,
1066 const char **includes)
1068 WERROR werr = WERR_OK;
1069 struct registry_key *key = NULL;
1070 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1072 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1074 if (!W_ERROR_IS_OK(werr)) {
1078 if (num_includes == 0) {
1079 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
1082 werr = reg_deletevalue(key, INCLUDES_VALNAME);
1084 werr = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
1085 num_includes, includes);
1089 TALLOC_FREE(tmp_ctx);
1093 static WERROR smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
1094 const char *service)
1096 WERROR werr = WERR_OK;
1097 struct registry_key *key = NULL;
1098 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1100 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1102 if (!W_ERROR_IS_OK(werr)) {
1106 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
1110 werr = reg_deletevalue(key, INCLUDES_VALNAME);
1114 TALLOC_FREE(tmp_ctx);
1118 struct smbconf_ops smbconf_ops_reg = {
1119 .init = smbconf_reg_init,
1120 .shutdown = smbconf_reg_shutdown,
1121 .open_conf = smbconf_reg_open,
1122 .close_conf = smbconf_reg_close,
1123 .get_csn = smbconf_reg_get_csn,
1124 .drop = smbconf_reg_drop,
1125 .get_share_names = smbconf_reg_get_share_names,
1126 .share_exists = smbconf_reg_share_exists,
1127 .create_share = smbconf_reg_create_share,
1128 .get_share = smbconf_reg_get_share,
1129 .delete_share = smbconf_reg_delete_share,
1130 .set_parameter = smbconf_reg_set_parameter,
1131 .get_parameter = smbconf_reg_get_parameter,
1132 .delete_parameter = smbconf_reg_delete_parameter,
1133 .get_includes = smbconf_reg_get_includes,
1134 .set_includes = smbconf_reg_set_includes,
1135 .delete_includes = smbconf_reg_delete_includes,
1140 * initialize the smbconf registry backend
1141 * the only function that is exported from this module
1143 WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
1146 return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);