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 "lib/smbconf/smbconf_private.h"
23 #include "registry/reg_api.h"
24 #include "registry/reg_backend_db.h"
25 #include "registry/reg_util_token.h"
26 #include "registry/reg_api_util.h"
27 #include "registry/reg_init_smbconf.h"
28 #include "lib/smbconf/smbconf_init.h"
29 #include "lib/smbconf/smbconf_reg.h"
30 #include "../libcli/registry/util_reg.h"
32 #define INCLUDES_VALNAME "includes"
34 struct reg_private_data {
35 struct registry_key *base_key;
36 bool open; /* did _we_ open the registry? */
39 /**********************************************************************
43 **********************************************************************/
46 * a convenience helper to cast the private data structure
48 static struct reg_private_data *rpd(struct smbconf_ctx *ctx)
50 return (struct reg_private_data *)(ctx->data);
54 * check whether a given value name is forbidden in registry (smbconf)
56 static bool smbconf_reg_valname_forbidden(const char *valname)
58 /* hard code the list of forbidden names here for now */
59 const char *forbidden_valnames[] = {
64 "includes", /* this has a special meaning internally */
67 const char **forbidden = NULL;
69 for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) {
70 if (strwicmp(valname, *forbidden) == 0) {
77 static bool smbconf_reg_valname_valid(const char *valname)
79 return (!smbconf_reg_valname_forbidden(valname) &&
80 lp_parameter_is_valid(valname));
84 * Open a subkey of the base key (i.e a service)
86 static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
87 struct smbconf_ctx *ctx,
88 const char *servicename,
89 uint32 desired_access,
90 struct registry_key **key)
94 if (servicename == NULL) {
95 *key = rpd(ctx)->base_key;
98 werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
101 if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
102 werr = WERR_NO_SUCH_SERVICE;
109 * check if a value exists in a given registry key
111 static bool smbconf_value_exists(struct registry_key *key, const char *param)
114 WERROR werr = WERR_OK;
115 TALLOC_CTX *ctx = talloc_stackframe();
116 struct registry_value *value = NULL;
118 werr = reg_queryvalue(ctx, key, param, &value);
119 if (W_ERROR_IS_OK(werr)) {
128 * create a subkey of the base key (i.e. a service...)
130 static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
131 struct smbconf_ctx *ctx,
132 const char * subkeyname,
133 struct registry_key **newkey)
135 WERROR werr = WERR_OK;
136 TALLOC_CTX *create_ctx;
137 enum winreg_CreateAction action = REG_ACTION_NONE;
139 /* create a new talloc ctx for creation. it will hold
140 * the intermediate parent key (SMBCONF) for creation
141 * and will be destroyed when leaving this function... */
142 create_ctx = talloc_stackframe();
144 werr = reg_createkey(mem_ctx, rpd(ctx)->base_key, subkeyname,
145 REG_KEY_WRITE, newkey, &action);
146 if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
147 DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
148 werr = WERR_FILE_EXISTS;
150 if (!W_ERROR_IS_OK(werr)) {
151 DEBUG(5, ("Error creating key %s: %s\n",
152 subkeyname, win_errstr(werr)));
155 talloc_free(create_ctx);
160 * add a value to a key.
162 static WERROR smbconf_reg_set_value(struct registry_key *key,
166 struct registry_value val;
167 WERROR werr = WERR_OK;
169 const char *canon_valname;
170 const char *canon_valstr;
172 if (!lp_canonicalize_parameter_with_value(valname, valstr,
176 if (canon_valname == NULL) {
177 DEBUG(5, ("invalid parameter '%s' given\n",
180 DEBUG(5, ("invalid value '%s' given for "
181 "parameter '%s'\n", valstr, valname));
183 werr = WERR_INVALID_PARAM;
187 if (smbconf_reg_valname_forbidden(canon_valname)) {
188 DEBUG(5, ("Parameter '%s' not allowed in registry.\n",
190 werr = WERR_INVALID_PARAM;
194 subkeyname = strrchr_m(key->key->name, '\\');
195 if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
196 DEBUG(5, ("Invalid registry key '%s' given as "
197 "smbconf section.\n", key->key->name));
198 werr = WERR_INVALID_PARAM;
202 if (!strequal(subkeyname, GLOBAL_NAME) &&
203 lp_parameter_is_global(valname))
205 DEBUG(5, ("Global parameter '%s' not allowed in "
206 "service definition ('%s').\n", canon_valname,
208 werr = WERR_INVALID_PARAM;
215 if (!push_reg_sz(talloc_tos(), &val.data, canon_valstr)) {
220 werr = reg_setvalue(key, canon_valname, &val);
221 if (!W_ERROR_IS_OK(werr)) {
222 DEBUG(5, ("Error adding value '%s' to "
224 canon_valname, key->key->name, win_errstr(werr)));
231 static WERROR smbconf_reg_set_multi_sz_value(struct registry_key *key,
233 const uint32_t num_strings,
234 const char **strings)
237 struct registry_value *value;
239 TALLOC_CTX *tmp_ctx = talloc_stackframe();
242 if (strings == NULL) {
243 werr = WERR_INVALID_PARAM;
247 array = talloc_zero_array(tmp_ctx, const char *, num_strings + 1);
253 value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
259 value->type = REG_MULTI_SZ;
261 for (count = 0; count < num_strings; count++) {
262 array[count] = talloc_strdup(value, strings[count]);
263 if (array[count] == NULL) {
269 if (!push_reg_multi_sz(value, &value->data, array)) {
274 werr = reg_setvalue(key, valname, value);
275 if (!W_ERROR_IS_OK(werr)) {
276 DEBUG(5, ("Error adding value '%s' to key '%s': %s\n",
277 valname, key->key->name, win_errstr(werr)));
281 talloc_free(tmp_ctx);
286 * format a registry_value into a string.
288 * This is intended to be used for smbconf registry values,
289 * which are ar stored as REG_SZ values, so the incomplete
290 * handling should be ok.
292 static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx,
293 struct registry_value *value)
297 /* alternatively, create a new talloc context? */
298 if (mem_ctx == NULL) {
302 switch (value->type) {
304 if (value->data.length >= 4) {
305 uint32_t v = IVAL(value->data.data, 0);
306 result = talloc_asprintf(mem_ctx, "%d", v);
310 case REG_EXPAND_SZ: {
312 if (!pull_reg_sz(mem_ctx, &value->data, &s)) {
315 result = talloc_strdup(mem_ctx, s);
320 const char **a = NULL;
321 if (!pull_reg_multi_sz(mem_ctx, &value->data, &a)) {
324 for (j = 0; a[j] != NULL; j++) {
325 result = talloc_asprintf(mem_ctx, "%s\"%s\" ",
326 result ? result : "" ,
328 if (result == NULL) {
335 result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
336 (int)value->data.length);
339 result = talloc_asprintf(mem_ctx, "<unprintable>");
345 static WERROR smbconf_reg_get_includes_internal(TALLOC_CTX *mem_ctx,
346 struct registry_key *key,
347 uint32_t *num_includes,
353 struct registry_value *value = NULL;
354 char **tmp_includes = NULL;
355 const char **array = NULL;
356 TALLOC_CTX *tmp_ctx = talloc_stackframe();
358 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
366 werr = reg_queryvalue(tmp_ctx, key, INCLUDES_VALNAME, &value);
367 if (!W_ERROR_IS_OK(werr)) {
371 if (value->type != REG_MULTI_SZ) {
372 /* wrong type -- ignore */
376 if (!pull_reg_multi_sz(tmp_ctx, &value->data, &array)) {
381 for (count = 0; array[count] != NULL; count++) {
382 err = smbconf_add_string_to_array(tmp_ctx,
386 if (!SBC_ERROR_IS_OK(err)) {
393 *includes = talloc_move(mem_ctx, &tmp_includes);
394 if (*includes == NULL) {
398 *num_includes = count;
405 talloc_free(tmp_ctx);
410 * Get the values of a key as a list of value names
411 * and a list of value strings (ordered)
413 static WERROR smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
414 struct registry_key *key,
415 uint32_t *num_values,
417 char ***value_strings)
419 TALLOC_CTX *tmp_ctx = NULL;
420 WERROR werr = WERR_OK;
423 struct registry_value *valvalue = NULL;
424 char *valname = NULL;
425 uint32_t tmp_num_values = 0;
426 char **tmp_valnames = NULL;
427 char **tmp_valstrings = NULL;
428 uint32_t num_includes = 0;
429 char **includes = NULL;
431 if ((num_values == NULL) || (value_names == NULL) ||
432 (value_strings == NULL))
434 werr = WERR_INVALID_PARAM;
438 tmp_ctx = talloc_stackframe();
441 werr = reg_enumvalue(tmp_ctx, key, count, &valname, &valvalue),
447 if (!smbconf_reg_valname_valid(valname)) {
451 err = smbconf_add_string_to_array(tmp_ctx,
453 tmp_num_values, valname);
454 if (!SBC_ERROR_IS_OK(err)) {
459 valstring = smbconf_format_registry_value(tmp_ctx, valvalue);
460 err = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
461 tmp_num_values, valstring);
462 if (!SBC_ERROR_IS_OK(err)) {
468 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
472 /* now add the includes at the end */
473 werr = smbconf_reg_get_includes_internal(tmp_ctx, key, &num_includes,
475 if (!W_ERROR_IS_OK(werr)) {
478 for (count = 0; count < num_includes; count++) {
479 err = smbconf_add_string_to_array(tmp_ctx, &tmp_valnames,
480 tmp_num_values, "include");
481 if (!SBC_ERROR_IS_OK(err)) {
486 err = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings,
489 if (!SBC_ERROR_IS_OK(err)) {
497 *num_values = tmp_num_values;
498 if (tmp_num_values > 0) {
499 *value_names = talloc_move(mem_ctx, &tmp_valnames);
500 *value_strings = talloc_move(mem_ctx, &tmp_valstrings);
503 *value_strings = NULL;
507 talloc_free(tmp_ctx);
511 static bool smbconf_reg_key_has_values(struct registry_key *key)
514 uint32_t num_subkeys;
515 uint32_t max_subkeylen;
516 uint32_t max_subkeysize;
518 uint32_t max_valnamelen;
519 uint32_t max_valbufsize;
520 uint32_t secdescsize;
521 NTTIME last_changed_time;
523 werr = reg_queryinfokey(key, &num_subkeys, &max_subkeylen,
524 &max_subkeysize, &num_values, &max_valnamelen,
525 &max_valbufsize, &secdescsize,
527 if (!W_ERROR_IS_OK(werr)) {
531 return (num_values != 0);
535 * delete all values from a key
537 static WERROR smbconf_reg_delete_values(struct registry_key *key)
541 struct registry_value *valvalue;
543 TALLOC_CTX *mem_ctx = talloc_stackframe();
546 werr = reg_enumvalue(mem_ctx, key, count, &valname, &valvalue),
550 werr = reg_deletevalue(key, valname);
551 if (!W_ERROR_IS_OK(werr)) {
555 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
556 DEBUG(1, ("smbconf_reg_delete_values: "
557 "Error enumerating values of %s: %s\n",
566 talloc_free(mem_ctx);
570 /**********************************************************************
572 * smbconf operations: registry implementations
574 **********************************************************************/
577 * initialize the registry smbconf backend
579 static sbcErr smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
581 WERROR werr = WERR_OK;
583 struct security_token *token;
588 ctx->path = talloc_strdup(ctx, path);
589 if (ctx->path == NULL) {
594 ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
596 werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
597 if (!W_ERROR_IS_OK(werr)) {
598 DEBUG(1, ("Error creating admin token\n"));
599 err = SBC_ERR_UNKNOWN_FAILURE;
602 rpd(ctx)->open = false;
604 werr = registry_init_smbconf(path);
605 if (!W_ERROR_IS_OK(werr)) {
606 err = SBC_ERR_BADFILE;
610 err = ctx->ops->open_conf(ctx);
611 if (!SBC_ERROR_IS_OK(err)) {
612 DEBUG(1, ("Error opening the registry.\n"));
616 werr = reg_open_path(ctx, ctx->path,
617 KEY_ENUMERATE_SUB_KEYS | REG_KEY_WRITE,
618 token, &rpd(ctx)->base_key);
619 if (!W_ERROR_IS_OK(werr)) {
620 err = SBC_ERR_UNKNOWN_FAILURE;
628 static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
630 return ctx->ops->close_conf(ctx);
633 static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx)
635 #ifdef CLUSTER_SUPPORT
636 if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) {
643 static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx)
646 * The backend has write support.
648 * TODO: add access checks whether the concrete
649 * config source is really writeable by the calling user.
654 static sbcErr smbconf_reg_open(struct smbconf_ctx *ctx)
658 if (rpd(ctx)->open) {
663 if (!W_ERROR_IS_OK(werr)) {
664 return SBC_ERR_BADFILE;
667 rpd(ctx)->open = true;
671 static int smbconf_reg_close(struct smbconf_ctx *ctx)
675 if (!rpd(ctx)->open) {
681 rpd(ctx)->open = false;
687 * Get the change sequence number of the given service/parameter.
688 * service and parameter strings may be NULL.
690 static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
691 struct smbconf_csn *csn,
692 const char *service, const char *param)
698 if (!SBC_ERROR_IS_OK(ctx->ops->open_conf(ctx))) {
702 csn->csn = (uint64_t)regdb_get_seqnum();
706 * Drop the whole configuration (restarting empty) - registry version
708 static sbcErr smbconf_reg_drop(struct smbconf_ctx *ctx)
711 WERROR werr = WERR_OK;
712 sbcErr err = SBC_ERR_OK;
713 struct registry_key *parent_key = NULL;
714 struct registry_key *new_key = NULL;
715 TALLOC_CTX* mem_ctx = talloc_stackframe();
716 enum winreg_CreateAction action;
717 struct security_token *token;
719 werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
720 if (!W_ERROR_IS_OK(werr)) {
721 DEBUG(1, ("Error creating admin token\n"));
722 err = SBC_ERR_UNKNOWN_FAILURE;
726 path = talloc_strdup(mem_ctx, ctx->path);
731 p = strrchr(path, '\\');
733 err = SBC_ERR_INVALID_PARAM;
737 werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token,
739 if (!W_ERROR_IS_OK(werr)) {
740 err = SBC_ERR_IO_FAILURE;
744 werr = reg_deletekey_recursive(parent_key, p+1);
745 if (!W_ERROR_IS_OK(werr)) {
746 err = SBC_ERR_IO_FAILURE;
750 werr = reg_createkey(mem_ctx, parent_key, p+1, REG_KEY_WRITE,
752 if (!W_ERROR_IS_OK(werr)) {
753 err = SBC_ERR_IO_FAILURE;
758 talloc_free(mem_ctx);
763 * get the list of share names defined in the configuration.
766 static sbcErr smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
768 uint32_t *num_shares,
772 uint32_t added_count = 0;
773 TALLOC_CTX *tmp_ctx = NULL;
775 sbcErr err = SBC_ERR_OK;
776 char *subkey_name = NULL;
777 char **tmp_share_names = NULL;
779 if ((num_shares == NULL) || (share_names == NULL)) {
780 return SBC_ERR_INVALID_PARAM;
783 tmp_ctx = talloc_stackframe();
785 /* if there are values in the base key, return NULL as share name */
787 if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) {
788 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
790 if (!SBC_ERROR_IS_OK(err)) {
796 /* make sure "global" is always listed first */
797 if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
798 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
799 added_count, GLOBAL_NAME);
800 if (!SBC_ERROR_IS_OK(err)) {
807 werr = reg_enumkey(tmp_ctx, rpd(ctx)->base_key, count,
812 if (strequal(subkey_name, GLOBAL_NAME)) {
816 err = smbconf_add_string_to_array(tmp_ctx,
820 if (!SBC_ERROR_IS_OK(err)) {
825 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
826 err = SBC_ERR_NO_MORE_ITEMS;
831 *num_shares = added_count;
832 if (added_count > 0) {
833 *share_names = talloc_move(mem_ctx, &tmp_share_names);
839 talloc_free(tmp_ctx);
844 * check if a share/service of a given name exists - registry version
846 static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
847 const char *servicename)
850 WERROR werr = WERR_OK;
851 TALLOC_CTX *mem_ctx = talloc_stackframe();
852 struct registry_key *key = NULL;
854 werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename,
856 if (W_ERROR_IS_OK(werr)) {
860 talloc_free(mem_ctx);
865 * Add a service if it does not already exist - registry version
867 static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
868 const char *servicename)
871 struct registry_key *key = NULL;
873 if (servicename == NULL) {
877 werr = smbconf_reg_create_service_key(talloc_tos(), ctx,
885 * get a definition of a share (service) from configuration.
887 static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
889 const char *servicename,
890 struct smbconf_service **service)
892 WERROR werr = WERR_OK;
893 struct registry_key *key = NULL;
894 struct smbconf_service *tmp_service = NULL;
895 TALLOC_CTX *tmp_ctx = talloc_stackframe();
897 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename,
899 if (!W_ERROR_IS_OK(werr)) {
903 tmp_service = TALLOC_ZERO_P(tmp_ctx, struct smbconf_service);
904 if (tmp_service == NULL) {
909 if (servicename != NULL) {
910 tmp_service->name = talloc_strdup(tmp_service, servicename);
911 if (tmp_service->name == NULL) {
917 werr = smbconf_reg_get_values(tmp_service, key,
918 &(tmp_service->num_params),
919 &(tmp_service->param_names),
920 &(tmp_service->param_values));
922 if (W_ERROR_IS_OK(werr)) {
923 *service = talloc_move(mem_ctx, &tmp_service);
927 talloc_free(tmp_ctx);
932 * delete a service from configuration
934 static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
935 const char *servicename)
937 WERROR werr = WERR_OK;
938 TALLOC_CTX *mem_ctx = talloc_stackframe();
940 if (servicename != NULL) {
941 werr = reg_deletekey_recursive(rpd(ctx)->base_key, servicename);
943 werr = smbconf_reg_delete_values(rpd(ctx)->base_key);
946 talloc_free(mem_ctx);
951 * set a configuration parameter to the value provided.
953 static WERROR smbconf_reg_set_parameter(struct smbconf_ctx *ctx,
959 struct registry_key *key = NULL;
960 TALLOC_CTX *mem_ctx = talloc_stackframe();
962 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
963 REG_KEY_WRITE, &key);
964 if (!W_ERROR_IS_OK(werr)) {
968 werr = smbconf_reg_set_value(key, param, valstr);
971 talloc_free(mem_ctx);
976 * get the value of a configuration parameter as a string
978 static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
984 WERROR werr = WERR_OK;
985 struct registry_key *key = NULL;
986 struct registry_value *value = NULL;
988 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
990 if (!W_ERROR_IS_OK(werr)) {
994 if (!smbconf_reg_valname_valid(param)) {
995 werr = WERR_INVALID_PARAM;
999 if (!smbconf_value_exists(key, param)) {
1000 werr = WERR_INVALID_PARAM;
1004 werr = reg_queryvalue(mem_ctx, key, param, &value);
1005 if (!W_ERROR_IS_OK(werr)) {
1009 *valstr = smbconf_format_registry_value(mem_ctx, value);
1011 if (*valstr == NULL) {
1022 * delete a parameter from configuration
1024 static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
1025 const char *service,
1028 struct registry_key *key = NULL;
1029 WERROR werr = WERR_OK;
1030 TALLOC_CTX *mem_ctx = talloc_stackframe();
1032 werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
1034 if (!W_ERROR_IS_OK(werr)) {
1038 if (!smbconf_reg_valname_valid(param)) {
1039 werr = WERR_INVALID_PARAM;
1043 if (!smbconf_value_exists(key, param)) {
1044 werr = WERR_INVALID_PARAM;
1048 werr = reg_deletevalue(key, param);
1051 talloc_free(mem_ctx);
1055 static WERROR smbconf_reg_get_includes(struct smbconf_ctx *ctx,
1056 TALLOC_CTX *mem_ctx,
1057 const char *service,
1058 uint32_t *num_includes,
1062 struct registry_key *key = NULL;
1063 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1065 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1066 REG_KEY_READ, &key);
1067 if (!W_ERROR_IS_OK(werr)) {
1071 werr = smbconf_reg_get_includes_internal(mem_ctx, key, num_includes,
1075 talloc_free(tmp_ctx);
1079 static WERROR smbconf_reg_set_includes(struct smbconf_ctx *ctx,
1080 const char *service,
1081 uint32_t num_includes,
1082 const char **includes)
1084 WERROR werr = WERR_OK;
1085 struct registry_key *key = NULL;
1086 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1088 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1090 if (!W_ERROR_IS_OK(werr)) {
1094 if (num_includes == 0) {
1095 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
1098 werr = reg_deletevalue(key, INCLUDES_VALNAME);
1100 werr = smbconf_reg_set_multi_sz_value(key, INCLUDES_VALNAME,
1101 num_includes, includes);
1105 talloc_free(tmp_ctx);
1109 static WERROR smbconf_reg_delete_includes(struct smbconf_ctx *ctx,
1110 const char *service)
1112 WERROR werr = WERR_OK;
1113 struct registry_key *key = NULL;
1114 TALLOC_CTX *tmp_ctx = talloc_stackframe();
1116 werr = smbconf_reg_open_service_key(tmp_ctx, ctx, service,
1118 if (!W_ERROR_IS_OK(werr)) {
1122 if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
1126 werr = reg_deletevalue(key, INCLUDES_VALNAME);
1130 talloc_free(tmp_ctx);
1134 static WERROR smbconf_reg_transaction_start(struct smbconf_ctx *ctx)
1136 return regdb_transaction_start();
1139 static WERROR smbconf_reg_transaction_commit(struct smbconf_ctx *ctx)
1141 return regdb_transaction_commit();
1144 static WERROR smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx)
1146 return regdb_transaction_cancel();
1149 struct smbconf_ops smbconf_ops_reg = {
1150 .init = smbconf_reg_init,
1151 .shutdown = smbconf_reg_shutdown,
1152 .requires_messaging = smbconf_reg_requires_messaging,
1153 .is_writeable = smbconf_reg_is_writeable,
1154 .open_conf = smbconf_reg_open,
1155 .close_conf = smbconf_reg_close,
1156 .get_csn = smbconf_reg_get_csn,
1157 .drop = smbconf_reg_drop,
1158 .get_share_names = smbconf_reg_get_share_names,
1159 .share_exists = smbconf_reg_share_exists,
1160 .create_share = smbconf_reg_create_share,
1161 .get_share = smbconf_reg_get_share,
1162 .delete_share = smbconf_reg_delete_share,
1163 .set_parameter = smbconf_reg_set_parameter,
1164 .get_parameter = smbconf_reg_get_parameter,
1165 .delete_parameter = smbconf_reg_delete_parameter,
1166 .get_includes = smbconf_reg_get_includes,
1167 .set_includes = smbconf_reg_set_includes,
1168 .delete_includes = smbconf_reg_delete_includes,
1169 .transaction_start = smbconf_reg_transaction_start,
1170 .transaction_commit = smbconf_reg_transaction_commit,
1171 .transaction_cancel = smbconf_reg_transaction_cancel,
1176 * initialize the smbconf registry backend
1177 * the only function that is exported from this module
1179 sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
1182 return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);