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[] = {
55 "includes", /* this has a special meaning internally */
58 const char **forbidden = NULL;
60 for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) {
61 if (strwicmp(valname, *forbidden) == 0) {
68 static bool smbconf_reg_valname_valid(const char *valname)
70 return (!smbconf_reg_valname_forbidden(valname) &&
71 lp_parameter_is_valid(valname));
75 * Open a registry key specified by "path"
77 static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
78 struct smbconf_ctx *ctx,
80 uint32 desired_access,
81 struct registry_key **key)
83 WERROR werr = WERR_OK;
86 DEBUG(1, ("Error: configuration is not open!\n"));
87 werr = WERR_INVALID_PARAM;
91 if (rpd(ctx)->token == NULL) {
92 DEBUG(1, ("Error: token missing from smbconf_ctx. "
93 "was smbconf_init() called?\n"));
94 werr = WERR_INVALID_PARAM;
98 werr = ctx->ops->open_conf(ctx);
99 if (!W_ERROR_IS_OK(werr)) {
100 DEBUG(1, ("Error opening the registry.\n"));
105 DEBUG(1, ("Error: NULL path string given\n"));
106 werr = WERR_INVALID_PARAM;
110 werr = reg_open_path(mem_ctx, path, desired_access, rpd(ctx)->token,
113 if (!W_ERROR_IS_OK(werr)) {
114 DEBUG(5, ("Error opening registry path '%s': %s\n",
115 path, dos_errstr(werr)));
123 * Open a subkey of the base key (i.e a service)
125 static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
126 struct smbconf_ctx *ctx,
127 const char *servicename,
128 uint32 desired_access,
129 struct registry_key **key)
131 WERROR werr = WERR_OK;
134 if (servicename == NULL) {
135 path = talloc_strdup(mem_ctx, ctx->path);
137 path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path,
145 werr = smbconf_reg_open_path(mem_ctx, ctx, path, desired_access, key);
155 static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx,
156 struct smbconf_ctx *ctx,
157 uint32 desired_access,
158 struct registry_key **key)
160 return smbconf_reg_open_path(mem_ctx, ctx, ctx->path, desired_access,
165 * check if a value exists in a given registry key
167 static bool smbconf_value_exists(struct registry_key *key, const char *param)
170 WERROR werr = WERR_OK;
171 TALLOC_CTX *ctx = talloc_stackframe();
172 struct registry_value *value = NULL;
174 werr = reg_queryvalue(ctx, key, param, &value);
175 if (W_ERROR_IS_OK(werr)) {
184 * create a subkey of the base key (i.e. a service...)
186 static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
187 struct smbconf_ctx *ctx,
188 const char * subkeyname,
189 struct registry_key **newkey)
191 WERROR werr = WERR_OK;
192 struct registry_key *create_parent = NULL;
193 TALLOC_CTX *create_ctx;
194 enum winreg_CreateAction action = REG_ACTION_NONE;
196 /* create a new talloc ctx for creation. it will hold
197 * the intermediate parent key (SMBCONF) for creation
198 * and will be destroyed when leaving this function... */
199 create_ctx = talloc_stackframe();
201 werr = smbconf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE,
203 if (!W_ERROR_IS_OK(werr)) {
207 werr = reg_createkey(mem_ctx, create_parent, subkeyname,
208 REG_KEY_WRITE, newkey, &action);
209 if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
210 DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
211 werr = WERR_FILE_EXISTS;
213 if (!W_ERROR_IS_OK(werr)) {
214 DEBUG(5, ("Error creating key %s: %s\n",
215 subkeyname, dos_errstr(werr)));
219 TALLOC_FREE(create_ctx);
224 * add a value to a key.
226 static WERROR smbconf_reg_set_value(struct registry_key *key,
230 struct registry_value val;
231 WERROR werr = WERR_OK;
233 const char *canon_valname;
234 const char *canon_valstr;
236 if (!lp_canonicalize_parameter_with_value(valname, valstr,
240 if (canon_valname == NULL) {
241 DEBUG(5, ("invalid parameter '%s' given\n",
244 DEBUG(5, ("invalid value '%s' given for "
245 "parameter '%s'\n", valstr, valname));
247 werr = WERR_INVALID_PARAM;
251 if (smbconf_reg_valname_forbidden(canon_valname)) {
252 DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
254 werr = WERR_INVALID_PARAM;
258 subkeyname = strrchr_m(key->key->name, '\\');
259 if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
260 DEBUG(5, ("Invalid registry key '%s' given as "
261 "smbconf section.\n", key->key->name));
262 werr = WERR_INVALID_PARAM;
266 if (!strequal(subkeyname, GLOBAL_NAME) &&
267 lp_parameter_is_global(valname))
269 DEBUG(5, ("Global paramter '%s' not allowed in "
270 "service definition ('%s').\n", canon_valname,
272 werr = WERR_INVALID_PARAM;
279 val.v.sz.str = CONST_DISCARD(char *, canon_valstr);
280 val.v.sz.len = strlen(canon_valstr) + 1;
282 werr = reg_setvalue(key, canon_valname, &val);
283 if (!W_ERROR_IS_OK(werr)) {
284 DEBUG(5, ("Error adding value '%s' to "
286 canon_valname, key->key->name, dos_errstr(werr)));
293 static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
295 const uint32_t num_strings,
296 const char **strings)
299 struct registry_value *value;
301 TALLOC_CTX *tmp_ctx = talloc_stackframe();
303 if (strings == NULL) {
304 werr = WERR_INVALID_PARAM;
308 value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
310 value->type = REG_MULTI_SZ;
311 value->v.multi_sz.num_strings = num_strings;
312 value->v.multi_sz.strings = TALLOC_ARRAY(tmp_ctx, char *, num_strings);
313 if (value->v.multi_sz.strings == NULL) {
317 for (count = 0; count < num_strings; count++) {
318 value->v.multi_sz.strings[count] =
319 talloc_strdup(value->v.multi_sz.strings,
321 if (value->v.multi_sz.strings[count] == NULL) {
327 werr = reg_setvalue(key, valname, value);
328 if (!W_ERROR_IS_OK(werr)) {
329 DEBUG(5, ("Error adding value '%s' to key '%s': %s\n",
330 valname, key->key->name, dos_errstr(werr)));
334 TALLOC_FREE(tmp_ctx);
339 * format a registry_value into a string.
341 * This is intended to be used for smbconf registry values,
342 * which are ar stored as REG_SZ values, so the incomplete
343 * handling should be ok.
345 static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
346 struct registry_value *value)
350 /* alternatively, create a new talloc context? */
351 if (mem_ctx == NULL) {
355 switch (value->type) {
357 result = talloc_asprintf(mem_ctx, "%d", value->v.dword);
361 result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str);
365 for (j = 0; j < value->v.multi_sz.num_strings; j++) {
366 result = talloc_asprintf(mem_ctx, "%s\"%s\" ",
367 result ? result : "" ,
368 value->v.multi_sz.strings[j]);
369 if (result == NULL) {
376 result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
377 (int)value->v.binary.length);
380 result = talloc_asprintf(mem_ctx, "<unprintable>");
386 static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
387 struct registry_key *key,
388 uint32_t *num_includes,
393 struct registry_value *value = NULL;
394 char **tmp_includes = NULL;
395 TALLOC_CTX *tmp_ctx = talloc_stackframe();
397 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
405 werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value);
406 if (!W_ERROR_IS_OK(werr)) {
410 if (value->type != REG_MULTI_SZ) {
411 /* wront type -- ignore */
415 for (count = 0; count < value->v.multi_sz.num_strings; count++)
417 werr = smbconf_add_string_to_array(tmp_ctx,
420 value->v.multi_sz.strings[count]);
421 if (!W_ERROR_IS_OK(werr)) {
427 *includes = talloc_move(mem_ctx, &tmp_includes);
428 if (*includes == NULL) {
432 *num_includes = count;
439 TALLOC_FREE(tmp_ctx);
444 * Get the values of a key as a list of value names
445 * and a list of value strings (ordered)
447 static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
448 struct registry_key *key,
449 uint32_t *num_values,
451 char ***value_strings)
453 TALLOC_CTX *tmp_ctx = NULL;
454 WERROR werr = WERR_OK;
456 struct registry_value *valvalue = NULL;
457 char *valname = NULL;
458 uint32_t tmp_num_values = 0;
459 char **tmp_valnames = NULL;
460 char **tmp_valstrings = NULL;
461 uint32_t num_includes = 0;
462 char **includes = NULL;
464 if ((num_values == NULL) || (value_names == NULL) ||
465 (value_strings == NULL))
467 werr = WERR_INVALID_PARAM;
471 tmp_ctx = talloc_stackframe();
474 werr = reg_enumvalue(tmp_ctx, key, count, &valname, &valvalue),
480 if (!smbconf_reg_valname_valid(valname)) {
484 werr = smbconf_add_string_to_array(tmp_ctx,
486 tmp_num_values, valname);
487 if (!W_ERROR_IS_OK(werr)) {
491 valstring = smbconf_format_registry_value(tmp_ctx, valvalue);
492 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
493 tmp_num_values, valstring);
494 if (!W_ERROR_IS_OK(werr)) {
499 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
503 /* now add the includes at the end */
504 werr = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
506 if (!W_ERROR_IS_OK(werr)) {
509 for (count = 0; count < num_includes; count++) {
510 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valnames,
511 tmp_num_values, "include");
512 if (!W_ERROR_IS_OK(werr)) {
516 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
519 if (!W_ERROR_IS_OK(werr)) {
526 *num_values = tmp_num_values;
527 if (tmp_num_values > 0) {
528 *value_names = talloc_move(mem_ctx, &tmp_valnames);
529 *value_strings = talloc_move(mem_ctx, &tmp_valstrings);
532 *value_strings = NULL;
536 TALLOC_FREE(tmp_ctx);
540 static bool smbconf_reg_key_has_values(struct registry_key *key)
543 uint32_t num_subkeys;
544 uint32_t max_subkeylen;
545 uint32_t max_subkeysize;
547 uint32_t max_valnamelen;
548 uint32_t max_valbufsize;
549 uint32_t secdescsize;
550 NTTIME last_changed_time;
552 werr = reg_queryinfokey(key, &num_subkeys, &max_subkeylen,
553 &max_subkeysize, &num_values, &max_valnamelen,
554 &max_valbufsize, &secdescsize,
556 if (!W_ERROR_IS_OK(werr)) {
560 return (num_values != 0);
564 * delete all values from a key
566 static WERROR smbconf_reg_delete_values(struct registry_key *key)
570 struct registry_value *valvalue;
572 TALLOC_CTX *mem_ctx = talloc_stackframe();
575 werr = reg_enumvalue(mem_ctx, key, count, &valname, &valvalue),
579 werr = reg_deletevalue(key, valname);
580 if (!W_ERROR_IS_OK(werr)) {
584 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
585 DEBUG(1, ("smbconf_reg_delete_values: "
586 "Error enumerating values of %s: %s\n",
595 TALLOC_FREE(mem_ctx);
599 /**********************************************************************
601 * smbconf operations: registry implementations
603 **********************************************************************/
606 * initialize the registry smbconf backend
608 static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
610 WERROR werr = WERR_OK;
615 ctx->path = talloc_strdup(ctx, path);
616 if (ctx->path == NULL) {
621 ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
623 werr = ntstatus_to_werror(registry_create_admin_token(ctx,
624 &(rpd(ctx)->token)));
625 if (!W_ERROR_IS_OK(werr)) {
626 DEBUG(1, ("Error creating admin token\n"));
629 rpd(ctx)->open = false;
631 werr = registry_init_smbconf(path);
632 if (!W_ERROR_IS_OK(werr)) {
640 static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
642 return ctx->ops->close_conf(ctx);
645 static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx)
647 #ifdef CLUSTER_SUPPORT
648 if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) {
655 static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
659 if (rpd(ctx)->open) {
664 if (W_ERROR_IS_OK(werr)) {
665 rpd(ctx)->open = true;
670 static int smbconf_reg_close(struct smbconf_ctx *ctx)
674 if (!rpd(ctx)->open) {
680 rpd(ctx)->open = false;
686 * Get the change sequence number of the given service/parameter.
687 * service and parameter strings may be NULL.
689 static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
690 struct smbconf_csn *csn,
691 const char *service, const char *param)
697 if (!W_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
701 csn->csn = (uint64_t)regdb_get_seqnum();
705 * Drop the whole configuration (restarting empty) - registry version
707 static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
710 WERROR werr = WERR_OK;
711 struct registry_key *parent_key = NULL;
712 struct registry_key *new_key = NULL;
713 TALLOC_CTX* mem_ctx = talloc_stackframe();
714 enum winreg_CreateAction action;
716 path = talloc_strdup(mem_ctx, ctx->path);
721 p = strrchr(path, '\\');
723 werr = smbconf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE,
726 if (!W_ERROR_IS_OK(werr)) {
730 werr = reg_deletekey_recursive(mem_ctx, parent_key, p+1);
732 if (!W_ERROR_IS_OK(werr)) {
736 werr = reg_createkey(mem_ctx, parent_key, p+1, REG_KEY_WRITE,
740 TALLOC_FREE(mem_ctx);
745 * get the list of share names defined in the configuration.
748 static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
750 uint32_t *num_shares,
754 uint32_t added_count = 0;
755 TALLOC_CTX *tmp_ctx = NULL;
756 WERROR werr = WERR_OK;
757 struct registry_key *key = NULL;
758 char *subkey_name = NULL;
759 char **tmp_share_names = NULL;
761 if ((num_shares == NULL) || (share_names == NULL)) {
762 werr = WERR_INVALID_PARAM;
766 tmp_ctx = talloc_stackframe();
768 /* if there are values in the base key, return NULL as share name */
769 werr = smbconf_reg_open_base_key(tmp_ctx, ctx,
770 SEC_RIGHTS_ENUM_SUBKEYS, &key);
771 if (!W_ERROR_IS_OK(werr)) {
775 if (smbconf_reg_key_has_values(key)) {
776 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
778 if (!W_ERROR_IS_OK(werr)) {
784 /* make sure "global" is always listed first */
785 if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
786 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
787 added_count, GLOBAL_NAME);
788 if (!W_ERROR_IS_OK(werr)) {
795 werr = reg_enumkey(tmp_ctx, key, count, &subkey_name, NULL),
799 if (strequal(subkey_name, GLOBAL_NAME)) {
803 werr = smbconf_add_string_to_array(tmp_ctx,
807 if (!W_ERROR_IS_OK(werr)) {
812 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
817 *num_shares = added_count;
818 if (added_count > 0) {
819 *share_names = talloc_move(mem_ctx, &tmp_share_names);
825 TALLOC_FREE(tmp_ctx);
830 * check if a share/service of a given name exists - registry version
832 static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
833 const char *servicename)
836 WERROR werr = WERR_OK;
837 TALLOC_CTX *mem_ctx = talloc_stackframe();
838 struct registry_key *key = NULL;
840 werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
842 if (W_ERROR_IS_OK(werr)) {
846 TALLOC_FREE(mem_ctx);
851 * Add a service if it does not already exist - registry version
853 static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
854 const char *servicename)
857 TALLOC_CTX *mem_ctx = talloc_stackframe();
858 struct registry_key *key = NULL;
860 if (servicename == NULL) {
861 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE,
864 werr = smbconf_reg_create_service_key(mem_ctx, ctx,
868 TALLOC_FREE(mem_ctx);
873 * get a definition of a share (service) from configuration.
875 static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
877 const char *servicename,
878 struct smbconf_service **service)
880 WERROR werr = WERR_OK;
881 struct registry_key *key = NULL;
882 struct smbconf_service *tmp_service = NULL;
883 TALLOC_CTX *tmp_ctx = talloc_stackframe();
885 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
887 if (!W_ERROR_IS_OK(werr)) {
891 tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);
892 if (tmp_service == NULL) {
897 if (servicename != NULL) {
898 tmp_service->name = talloc_strdup(tmp_service, servicename);
899 if (tmp_service->name == NULL) {
905 werr = smbconf_reg_get_values(tmp_service, key,
906 &(tmp_service->num_params),
907 &(tmp_service->param_names),
908 &(tmp_service->param_values));
910 if (W_ERROR_IS_OK(werr)) {
911 *service = talloc_move(mem_ctx, &tmp_service);
915 TALLOC_FREE(tmp_ctx);
920 * delete a service from configuration
922 static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
923 const char *servicename)
925 WERROR werr = WERR_OK;
926 struct registry_key *key = NULL;
927 TALLOC_CTX *mem_ctx = talloc_stackframe();
929 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key);
930 if (!W_ERROR_IS_OK(werr)) {
934 if (servicename != NULL) {
935 werr = reg_deletekey_recursive(key, key, servicename);
937 werr = smbconf_reg_delete_values(key);
941 TALLOC_FREE(mem_ctx);
946 * set a configuration parameter to the value provided.
948 static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
954 struct registry_key *key = NULL;
955 TALLOC_CTX *mem_ctx = talloc_stackframe();
957 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
958 REG_KEY_WRITE, &key);
959 if (!W_ERROR_IS_OK(werr)) {
963 werr = smbconf_reg_set_value(key, param, valstr);
966 TALLOC_FREE(mem_ctx);
971 * get the value of a configuration parameter as a string
973 static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
979 WERROR werr = WERR_OK;
980 struct registry_key *key = NULL;
981 struct registry_value *value = NULL;
983 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
985 if (!W_ERROR_IS_OK(werr)) {
989 if (!smbconf_reg_valname_valid(param)) {
990 werr = WERR_INVALID_PARAM;
994 if (!smbconf_value_exists(key, param)) {
995 werr = WERR_INVALID_PARAM;
999 werr = reg_queryvalue(mem_ctx, key, param, &value);
1000 if (!W_ERROR_IS_OK(werr)) {
1004 *valstr = smbconf_format_registry_value(mem_ctx, value);
1006 if (*valstr == NULL) {
1017 * delete a parameter from configuration
1019 static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
1020 const char *service,
1023 struct registry_key *key = NULL;
1024 WERROR werr = WERR_OK;
1025 TALLOC_CTX *mem_ctx = talloc_stackframe();
1027 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
1029 if (!W_ERROR_IS_OK(werr)) {
1033 if (!smbconf_reg_valname_valid(param)) {
1034 werr = WERR_INVALID_PARAM;
1038 if (!smbconf_value_exists(key, param)) {
1039 werr = WERR_INVALID_PARAM;
1043 werr = reg_deletevalue(key, param);
1046 TALLOC_FREE(mem_ctx);
1050 static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx,
1051 TALLOC_CTX *mem_ctx,
1052 const char *service,
1053 uint32_t *num_includes,
1057 struct registry_key *key = NULL;
1058 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1060 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1061 REG_KEY_READ, &key);
1062 if (!W_ERROR_IS_OK(werr)) {
1066 werr = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
1070 TALLOC_FREE(tmp_ctx);
1074 static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
1075 const char *service,
1076 uint32_t num_includes,
1077 const char **includes)
1079 WERROR werr = WERR_OK;
1080 struct registry_key *key = NULL;
1081 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1083 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1085 if (!W_ERROR_IS_OK(werr)) {
1089 if (num_includes == 0) {
1090 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
1093 werr = reg_deletevalue(key, INCLUDES_VALNAME);
1095 werr = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
1096 num_includes, includes);
1100 TALLOC_FREE(tmp_ctx);
1104 static WERROR smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
1105 const char *service)
1107 WERROR werr = WERR_OK;
1108 struct registry_key *key = NULL;
1109 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1111 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1113 if (!W_ERROR_IS_OK(werr)) {
1117 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
1121 werr = reg_deletevalue(key, INCLUDES_VALNAME);
1125 TALLOC_FREE(tmp_ctx);
1129 struct smbconf_ops smbconf_ops_reg = {
1130 .init = smbconf_reg_init,
1131 .shutdown = smbconf_reg_shutdown,
1132 .requires_messaging = smbconf_reg_requires_messaging,
1133 .open_conf = smbconf_reg_open,
1134 .close_conf = smbconf_reg_close,
1135 .get_csn = smbconf_reg_get_csn,
1136 .drop = smbconf_reg_drop,
1137 .get_share_names = smbconf_reg_get_share_names,
1138 .share_exists = smbconf_reg_share_exists,
1139 .create_share = smbconf_reg_create_share,
1140 .get_share = smbconf_reg_get_share,
1141 .delete_share = smbconf_reg_delete_share,
1142 .set_parameter = smbconf_reg_set_parameter,
1143 .get_parameter = smbconf_reg_get_parameter,
1144 .delete_parameter = smbconf_reg_delete_parameter,
1145 .get_includes = smbconf_reg_get_includes,
1146 .set_includes = smbconf_reg_set_includes,
1147 .delete_includes = smbconf_reg_delete_includes,
1152 * initialize the smbconf registry backend
1153 * the only function that is exported from this module
1155 WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
1158 return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);