2 * Samba Unix/Linux SMB client library
3 * Distributed SMB/CIFS Server Management Utility
4 * Local configuration interface
5 * Copyright (C) Michael Adam 2007
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * This is an interface to the configuration stored inside the
24 * samba registry. In the future there might be support for other
25 * configuration backends as well.
29 #include "utils/net.h"
35 static int net_conf_list_usage(int argc, const char **argv)
37 d_printf("USAGE: net conf list\n");
41 static int net_conf_import_usage(int argc, const char**argv)
43 d_printf("USAGE: net conf import [--test|-T] <filename> [<servicename>]\n"
44 "\t[--test|-T] testmode - do not act, just print "
45 "what would be done\n"
46 "\t<servicename> only import service <servicename>, "
51 static int net_conf_listshares_usage(int argc, const char **argv)
53 d_printf("USAGE: net conf listshares\n");
57 static int net_conf_drop_usage(int argc, const char **argv)
59 d_printf("USAGE: net conf drop\n");
63 static int net_conf_showshare_usage(int argc, const char **argv)
65 d_printf("USAGE: net conf showshare <sharename>\n");
69 static int net_conf_addshare_usage(int argc, const char **argv)
71 d_printf("USAGE: net conf addshare <sharename> <path> "
72 "[writeable={y|N} [guest_ok={y|N} [<comment>]]\n"
73 "\t<sharename> the new share name.\n"
74 "\t<path> the path on the filesystem to export.\n"
75 "\twriteable={y|N} set \"writeable to \"yes\" or "
76 "\"no\" (default) on this share.\n"
77 "\tguest_ok={y|N} set \"guest ok\" to \"yes\" or "
78 "\"no\" (default) on this share.\n"
79 "\t<comment> optional comment for the new share.\n");
83 static int net_conf_delshare_usage(int argc, const char **argv)
85 d_printf("USAGE: net conf delshare <sharename>\n");
89 static int net_conf_setparm_usage(int argc, const char **argv)
91 d_printf("USAGE: net conf setparm <section> <param> <value>\n");
95 static int net_conf_getparm_usage(int argc, const char **argv)
97 d_printf("USAGE: net conf getparm <section> <param>\n");
101 static int net_conf_delparm_usage(int argc, const char **argv)
103 d_printf("USAGE: net conf delparm <section> <param>\n");
112 static char *format_value(TALLOC_CTX *mem_ctx, struct registry_value *value)
116 /* what if mem_ctx = NULL? */
118 switch (value->type) {
120 result = talloc_asprintf(mem_ctx, "%d", value->v.dword);
124 result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str);
128 for (j = 0; j < value->v.multi_sz.num_strings; j++) {
129 result = talloc_asprintf(mem_ctx, "\"%s\" ",
130 value->v.multi_sz.strings[j]);
135 result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
136 (int)value->v.binary.length);
139 result = talloc_asprintf(mem_ctx, "<unprintable>");
146 * add a value to a key.
148 static WERROR reg_setvalue_internal(struct registry_key *key,
152 struct registry_value val;
153 WERROR werr = WERR_OK;
159 val.v.sz.str = CONST_DISCARD(char *, valstr);
160 val.v.sz.len = strlen(valstr) + 1;
162 if (!lp_parameter_is_valid(valname)) {
163 d_fprintf(stderr, "Invalid parameter '%s' given.\n", valname);
164 werr = WERR_INVALID_PARAM;
168 if (registry_smbconf_valname_forbidden(valname)) {
169 d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n",
171 werr = WERR_INVALID_PARAM;
175 subkeyname = strrchr_m(key->key->name, '\\');
176 if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) {
177 d_fprintf(stderr, "Invalid registry key '%s' given as "
178 "smbconf section.\n", key->key->name);
179 werr = WERR_INVALID_PARAM;
183 if (!strequal(subkeyname, GLOBAL_NAME) &&
184 lp_parameter_is_global(valname))
186 d_fprintf(stderr, "Global paramter '%s' not allowed in "
187 "service definition ('%s').\n", valname,
189 werr = WERR_INVALID_PARAM;
193 werr = reg_setvalue(key, valname, &val);
194 if (!W_ERROR_IS_OK(werr)) {
196 "Error adding value '%s' to "
198 valname, key->key->name, dos_errstr(werr));
206 * Open a subkey of KEY_SMBCONF (i.e a service)
207 * - variant without error output (q = quiet)-
209 static WERROR smbconf_open_path_q(TALLOC_CTX *ctx, const char *subkeyname,
210 uint32 desired_access,
211 struct registry_key **key)
213 WERROR werr = WERR_OK;
215 NT_USER_TOKEN *token;
217 if (!(token = registry_create_admin_token(ctx))) {
218 DEBUG(1, ("Error creating admin token\n"));
222 if (subkeyname == NULL) {
223 path = talloc_strdup(ctx, KEY_SMBCONF);
226 path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, subkeyname);
229 werr = reg_open_path(ctx, path, desired_access,
238 * Open a subkey of KEY_SMBCONF (i.e a service)
239 * - variant with error output -
241 static WERROR smbconf_open_path(TALLOC_CTX *ctx, const char *subkeyname,
242 uint32 desired_access,
243 struct registry_key **key)
245 WERROR werr = WERR_OK;
247 werr = smbconf_open_path_q(ctx, subkeyname, desired_access, key);
248 if (!W_ERROR_IS_OK(werr)) {
249 d_fprintf(stderr, "Error opening registry path '%s\\%s': %s\n",
251 (subkeyname == NULL) ? "" : subkeyname,
259 * open the base key KEY_SMBCONF
261 static WERROR smbconf_open_basepath(TALLOC_CTX *ctx, uint32 desired_access,
262 struct registry_key **key)
264 return smbconf_open_path(ctx, NULL, desired_access, key);
268 * delete a subkey of KEY_SMBCONF
270 static WERROR reg_delkey_internal(TALLOC_CTX *ctx, const char *keyname)
272 WERROR werr = WERR_OK;
273 struct registry_key *key = NULL;
275 werr = smbconf_open_basepath(ctx, REG_KEY_WRITE, &key);
276 if (!W_ERROR_IS_OK(werr)) {
280 werr = reg_deletekey_recursive(key, key, keyname);
281 if (!W_ERROR_IS_OK(werr)) {
282 d_fprintf(stderr, "Error deleting registry key %s\\%s: %s\n",
283 KEY_SMBCONF, keyname, dos_errstr(werr));
292 * create a subkey of KEY_SMBCONF
294 static WERROR reg_createkey_internal(TALLOC_CTX *ctx,
295 const char * subkeyname,
296 struct registry_key **newkey)
298 WERROR werr = WERR_OK;
299 struct registry_key *create_parent = NULL;
300 TALLOC_CTX *create_ctx;
301 enum winreg_CreateAction action = REG_ACTION_NONE;
303 /* create a new talloc ctx for creation. it will hold
304 * the intermediate parent key (SMBCONF) for creation
305 * and will be destroyed when leaving this function... */
306 if (!(create_ctx = talloc_new(ctx))) {
311 werr = smbconf_open_basepath(create_ctx, REG_KEY_WRITE, &create_parent);
312 if (!W_ERROR_IS_OK(werr)) {
316 werr = reg_createkey(ctx, create_parent, subkeyname,
317 REG_KEY_WRITE, newkey, &action);
318 if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
319 d_fprintf(stderr, "Key '%s' already exists.\n", subkeyname);
320 werr = WERR_ALREADY_EXISTS;
322 if (!W_ERROR_IS_OK(werr)) {
323 d_fprintf(stderr, "Error creating key %s: %s\n",
324 subkeyname, dos_errstr(werr));
328 TALLOC_FREE(create_ctx);
333 * check if a subkey of KEY_SMBCONF of a given name exists
335 static BOOL smbconf_key_exists(TALLOC_CTX *ctx, const char *subkeyname)
338 WERROR werr = WERR_OK;
340 struct registry_key *key;
342 if (!(mem_ctx = talloc_new(ctx))) {
343 d_fprintf(stderr, "ERROR: Out of memory...!\n");
347 werr = smbconf_open_path_q(mem_ctx, subkeyname, REG_KEY_READ, &key);
348 if (W_ERROR_IS_OK(werr)) {
353 TALLOC_FREE(mem_ctx);
357 static BOOL smbconf_value_exists(TALLOC_CTX *ctx, struct registry_key *key,
361 WERROR werr = WERR_OK;
362 struct registry_value *value = NULL;
364 werr = reg_queryvalue(ctx, key, param, &value);
365 if (W_ERROR_IS_OK(werr)) {
373 static WERROR list_values(TALLOC_CTX *ctx, struct registry_key *key)
375 WERROR werr = WERR_OK;
377 struct registry_value *valvalue = NULL;
378 char *valname = NULL;
381 W_ERROR_IS_OK(werr = reg_enumvalue(ctx, key, idx, &valname,
385 d_printf("\t%s = %s\n", valname, format_value(ctx, valvalue));
387 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
388 d_fprintf(stderr, "Error enumerating values: %s\n",
398 static WERROR drop_smbconf_internal(TALLOC_CTX *ctx)
401 WERROR werr = WERR_OK;
402 NT_USER_TOKEN *token;
403 struct registry_key *parent_key = NULL;
404 struct registry_key *new_key = NULL;
405 TALLOC_CTX* tmp_ctx = NULL;
406 enum winreg_CreateAction action;
408 tmp_ctx = talloc_new(ctx);
409 if (tmp_ctx == NULL) {
414 if (!(token = registry_create_admin_token(tmp_ctx))) {
415 /* what is the appropriate error code here? */
416 werr = WERR_CAN_NOT_COMPLETE;
420 path = talloc_strdup(tmp_ctx, KEY_SMBCONF);
422 d_fprintf(stderr, "ERROR: out of memory!\n");
426 p = strrchr(path, '\\');
428 werr = reg_open_path(tmp_ctx, path, REG_KEY_WRITE, token, &parent_key);
430 if (!W_ERROR_IS_OK(werr)) {
434 werr = reg_deletekey_recursive(tmp_ctx, parent_key, p+1);
436 if (!W_ERROR_IS_OK(werr)) {
440 werr = reg_createkey(tmp_ctx, parent_key, p+1, REG_KEY_WRITE,
444 TALLOC_FREE(tmp_ctx);
448 static char *parm_valstr(TALLOC_CTX *ctx, struct parm_struct *parm,
449 struct share_params *share)
453 void *ptr = parm->ptr;
455 if (parm->p_class == P_LOCAL && share->service >= 0) {
456 ptr = lp_local_ptr(share->service, ptr);
459 switch (parm->type) {
461 valstr = talloc_asprintf(ctx, "%c", *(char *)ptr);
465 valstr = talloc_asprintf(ctx, "%s", *(char **)ptr);
469 valstr = talloc_asprintf(ctx, "%s", (char *)ptr);
472 valstr = talloc_asprintf(ctx, "%s", BOOLSTR(*(BOOL *)ptr));
475 valstr = talloc_asprintf(ctx, "%s", BOOLSTR(!*(BOOL *)ptr));
478 for (i = 0; parm->enum_list[i].name; i++) {
479 if (*(int *)ptr == parm->enum_list[i].value)
481 valstr = talloc_asprintf(ctx, "%s",
482 parm->enum_list[i].name);
488 valstr = talloc_asprintf(ctx, "%s", octal_string(*(int *)ptr));
491 valstr = talloc_strdup(ctx, "");
492 if ((char ***)ptr && *(char ***)ptr) {
493 char **list = *(char ***)ptr;
494 for (; *list; list++) {
495 /* surround strings with whitespace
496 * in double quotes */
497 if (strchr_m(*list, ' '))
499 valstr = talloc_asprintf_append(
502 ((*(list+1))?", ":""));
505 valstr = talloc_asprintf_append(
506 valstr, "%s%s", *list,
507 ((*(list+1))?", ":""));
513 valstr = talloc_asprintf(ctx, "%d", *(int *)ptr);
518 valstr = talloc_asprintf(ctx, "<type unimplemented>\n");
525 static int import_process_service(TALLOC_CTX *ctx,
526 struct share_params *share)
529 struct parm_struct *parm;
531 const char *servicename;
532 struct registry_key *key;
535 TALLOC_CTX *tmp_ctx = NULL;
537 tmp_ctx = talloc_new(ctx);
538 if (tmp_ctx == NULL) {
543 servicename = (share->service == GLOBAL_SECTION_SNUM)?
544 GLOBAL_NAME : lp_servicename(share->service);
547 d_printf("[%s]\n", servicename);
550 if (smbconf_key_exists(tmp_ctx, servicename)) {
551 werr = reg_delkey_internal(tmp_ctx, servicename);
552 if (!W_ERROR_IS_OK(werr)) {
556 werr = reg_createkey_internal(tmp_ctx, servicename, &key);
557 if (!W_ERROR_IS_OK(werr)) {
562 while ((parm = lp_next_parameter(share->service, &pnum, 0)))
564 if ((share->service < 0 && parm->p_class == P_LOCAL)
565 && !(parm->flags & FLAG_GLOBAL))
568 valstr = parm_valstr(tmp_ctx, parm, share);
570 if (parm->type != P_SEP) {
572 d_printf("\t%s = %s\n", parm->label, valstr);
575 werr = reg_setvalue_internal(key, parm->label,
577 if (!W_ERROR_IS_OK(werr)) {
591 TALLOC_FREE(tmp_ctx);
595 /* return True iff there are nondefault globals */
596 static BOOL globals_exist(void)
599 struct parm_struct *parm;
601 while ((parm = lp_next_parameter(GLOBAL_SECTION_SNUM, &i, 0)) != NULL) {
602 if (parm->type != P_SEP) {
613 int net_conf_list(int argc, const char **argv)
615 WERROR werr = WERR_OK;
618 struct registry_key *base_key = NULL;
619 struct registry_key *sub_key = NULL;
621 char *subkey_name = NULL;
623 ctx = talloc_init("list");
626 net_conf_list_usage(argc, argv);
630 werr = smbconf_open_basepath(ctx, REG_KEY_READ, &base_key);
631 if (!W_ERROR_IS_OK(werr)) {
635 if (smbconf_key_exists(ctx, GLOBAL_NAME)) {
636 werr = reg_openkey(ctx, base_key, GLOBAL_NAME,
637 REG_KEY_READ, &sub_key);
638 if (!W_ERROR_IS_OK(werr)) {
639 d_fprintf(stderr, "Error opening subkey '%s' : %s\n",
640 subkey_name, dos_errstr(werr));
643 d_printf("[%s]\n", GLOBAL_NAME);
644 if (!W_ERROR_IS_OK(list_values(ctx, sub_key))) {
651 W_ERROR_IS_OK(werr = reg_enumkey(ctx, base_key, idx_key,
652 &subkey_name, NULL));
655 if (strequal(subkey_name, GLOBAL_NAME)) {
658 d_printf("[%s]\n", subkey_name);
660 werr = reg_openkey(ctx, base_key, subkey_name,
661 REG_KEY_READ, &sub_key);
662 if (!W_ERROR_IS_OK(werr)) {
664 "Error opening subkey '%s': %s\n",
665 subkey_name, dos_errstr(werr));
668 if (!W_ERROR_IS_OK(list_values(ctx, sub_key))) {
673 if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
674 d_fprintf(stderr, "Error enumerating subkeys: %s\n",
686 int net_conf_import(int argc, const char **argv)
689 const char *filename = NULL;
690 const char *servicename = NULL;
691 BOOL service_found = False;
693 struct share_iterator *shares;
694 struct share_params *share;
695 struct share_params global_share = { GLOBAL_SECTION_SNUM };
697 ctx = talloc_init("net_conf_import");
702 net_conf_import_usage(argc, argv);
705 servicename = argv[1];
711 DEBUG(3,("net_conf_import: reading configuration from file %s.\n",
714 if (!lp_load(filename,
715 False, /* global_only */
716 True, /* save_defaults */
718 True)) /* initialize_globals */
720 d_fprintf(stderr, "Error parsing configuration file.\n");
725 d_printf("\nTEST MODE - "
726 "would import the following configuration:\n\n");
729 if (((servicename == NULL) && globals_exist()) ||
730 strequal(servicename, GLOBAL_NAME))
732 service_found = True;
733 if (import_process_service(ctx, &global_share) != 0) {
738 if (service_found && (servicename != NULL)) {
743 if (!(shares = share_list_all(ctx))) {
744 d_fprintf(stderr, "Could not list shares...\n");
747 while ((share = next_share(shares)) != NULL) {
748 if ((servicename == NULL)
749 || strequal(servicename, lp_servicename(share->service)))
751 service_found = True;
752 if (import_process_service(ctx, share)!= 0) {
758 if ((servicename != NULL) && !service_found) {
759 d_printf("Share %s not found in file %s\n",
760 servicename, filename);
772 int net_conf_listshares(int argc, const char **argv)
774 WERROR werr = WERR_OK;
776 struct registry_key *key;
778 char *subkey_name = NULL;
781 ctx = talloc_init("listshares");
784 net_conf_listshares_usage(argc, argv);
788 werr = smbconf_open_basepath(ctx, SEC_RIGHTS_ENUM_SUBKEYS, &key);
789 if (!W_ERROR_IS_OK(werr)) {
794 W_ERROR_IS_OK(werr = reg_enumkey(ctx, key, idx,
795 &subkey_name, NULL));
798 d_printf("%s\n", subkey_name);
800 if (! W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
801 d_fprintf(stderr, "Error enumerating subkeys: %s\n",
813 int net_conf_drop(int argc, const char **argv)
819 net_conf_drop_usage(argc, argv);
823 werr = drop_smbconf_internal(NULL);
824 if (!W_ERROR_IS_OK(werr)) {
825 d_fprintf(stderr, "Error deleting configuration: %s\n",
836 int net_conf_showshare(int argc, const char **argv)
839 WERROR werr = WERR_OK;
840 struct registry_key *key = NULL;
843 ctx = talloc_init("showshare");
846 net_conf_showshare_usage(argc, argv);
850 werr = smbconf_open_path(ctx, argv[0], REG_KEY_READ, &key);
851 if (!W_ERROR_IS_OK(werr)) {
855 d_printf("[%s]\n", argv[0]);
857 if (!W_ERROR_IS_OK(list_values(ctx, key))) {
868 int net_conf_addshare(int argc, const char **argv)
871 WERROR werr = WERR_OK;
872 struct registry_key *newkey = NULL;
873 char *sharename = NULL;
874 const char *path = NULL;
875 const char *comment = NULL;
876 const char *guest_ok = "no";
877 const char *writeable = "no";
878 SMB_STRUCT_STAT sbuf;
884 net_conf_addshare_usage(argc, argv);
889 if (!strnequal(argv[3], "guest_ok=", 9)) {
890 net_conf_addshare_usage(argc, argv);
893 switch (argv[3][9]) {
903 net_conf_addshare_usage(argc, argv);
907 if (!strnequal(argv[2], "writeable=", 10)) {
908 net_conf_addshare_usage(argc, argv);
911 switch (argv[2][10]) {
921 net_conf_addshare_usage(argc, argv);
927 sharename = strdup_lower(argv[0]);
935 /* validate share name */
937 if (!validate_net_name(sharename, INVALID_SHARENAME_CHARS,
940 d_fprintf(stderr, "ERROR: share name %s contains "
941 "invalid characters (any of %s)\n",
942 sharename, INVALID_SHARENAME_CHARS);
946 if (getpwnam(sharename)) {
947 d_fprintf(stderr, "ERROR: share name %s is already a valid "
948 "system user name.\n", sharename);
952 if (strequal(sharename, GLOBAL_NAME)) {
954 "ERROR: 'global' is not a valid share name.\n");
960 if (path[0] != '/') {
962 "Error: path '%s' is not an absolute path.\n",
967 if (sys_stat(path, &sbuf) != 0) {
969 "ERROR: cannot stat path '%s' to ensure "
970 "this is a directory.\n"
972 path, strerror(errno));
976 if (!S_ISDIR(sbuf.st_mode)) {
978 "ERROR: path '%s' is not a directory.\n",
987 werr = reg_createkey_internal(NULL, argv[0], &newkey);
988 if (!W_ERROR_IS_OK(werr)) {
992 /* add config params as values */
994 werr = reg_setvalue_internal(newkey, "path", path);
995 if (!W_ERROR_IS_OK(werr))
998 if (comment != NULL) {
999 werr = reg_setvalue_internal(newkey, "comment", comment);
1000 if (!W_ERROR_IS_OK(werr))
1004 werr = reg_setvalue_internal(newkey, "guest ok", guest_ok);
1005 if (!W_ERROR_IS_OK(werr))
1008 werr = reg_setvalue_internal(newkey, "writeable", writeable);
1009 if (!W_ERROR_IS_OK(werr))
1015 TALLOC_FREE(newkey);
1016 SAFE_FREE(sharename);
1020 int net_conf_delshare(int argc, const char **argv)
1023 const char *sharename = NULL;
1026 net_conf_delshare_usage(argc, argv);
1029 sharename = argv[0];
1031 if (W_ERROR_IS_OK(reg_delkey_internal(NULL, sharename))) {
1038 static int net_conf_setparm(int argc, const char **argv)
1041 WERROR werr = WERR_OK;
1042 struct registry_key *key = NULL;
1043 char *service = NULL;
1045 const char *value_str = NULL;
1048 ctx = talloc_init("setparm");
1051 net_conf_setparm_usage(argc, argv);
1054 service = strdup_lower(argv[0]);
1055 param = strdup_lower(argv[1]);
1056 value_str = argv[2];
1058 if (!smbconf_key_exists(ctx, service)) {
1059 werr = reg_createkey_internal(ctx, service, &key);
1062 werr = smbconf_open_path(ctx, service, REG_KEY_READ, &key);
1064 if (!W_ERROR_IS_OK(werr)) {
1068 werr = reg_setvalue_internal(key, param, value_str);
1069 if (!W_ERROR_IS_OK(werr)) {
1070 d_fprintf(stderr, "Error setting value '%s': %s\n",
1071 param, dos_errstr(werr));
1084 static int net_conf_getparm(int argc, const char **argv)
1087 WERROR werr = WERR_OK;
1088 struct registry_key *key = NULL;
1089 char *service = NULL;
1091 struct registry_value *value = NULL;
1094 ctx = talloc_init("getparm");
1097 net_conf_getparm_usage(argc, argv);
1100 service = strdup_lower(argv[0]);
1101 param = strdup_lower(argv[1]);
1103 if (!smbconf_key_exists(ctx, service)) {
1105 "ERROR: given service '%s' does not exist.\n",
1110 werr = smbconf_open_path(ctx, service, REG_KEY_READ, &key);
1111 if (!W_ERROR_IS_OK(werr)) {
1115 werr = reg_queryvalue(ctx, key, param, &value);
1116 if (!W_ERROR_IS_OK(werr)) {
1117 d_fprintf(stderr, "Error querying value '%s': %s.\n",
1118 param, dos_errstr(werr));
1122 d_printf("%s\n", format_value(ctx, value));
1132 static int net_conf_delparm(int argc, const char **argv)
1135 WERROR werr = WERR_OK;
1136 struct registry_key *key = NULL;
1137 char *service = NULL;
1141 ctx = talloc_init("delparm");
1144 net_conf_delparm_usage(argc, argv);
1147 service = strdup_lower(argv[0]);
1148 param = strdup_lower(argv[1]);
1150 if (!smbconf_key_exists(ctx, service)) {
1152 "Error: given service '%s' does not exist.\n",
1157 werr = smbconf_open_path(ctx, service, REG_KEY_READ, &key);
1158 if (!W_ERROR_IS_OK(werr)) {
1162 if (!smbconf_value_exists(ctx, key, param)) {
1164 "Error: given parameter '%s' is not set.\n",
1168 werr = reg_deletevalue(key, param);
1169 if (!W_ERROR_IS_OK(werr)) {
1170 d_fprintf(stderr, "Error deleting value '%s': %s.\n",
1171 param, dos_errstr(werr));
1182 * Entry-point for all the CONF functions.
1185 int net_conf(int argc, const char **argv)
1188 struct functable2 func[] = {
1189 {"list", net_conf_list,
1190 "Dump the complete configuration in smb.conf like format."},
1191 {"import", net_conf_import,
1192 "Import configuration from file in smb.conf format."},
1193 {"listshares", net_conf_listshares,
1194 "List the registry shares."},
1195 {"drop", net_conf_drop,
1196 "Delete the complete configuration from registry."},
1197 {"showshare", net_conf_showshare,
1198 "Show the definition of a registry share."},
1199 {"addshare", net_conf_addshare,
1200 "Create a new registry share."},
1201 {"delshare", net_conf_delshare,
1202 "Delete a registry share."},
1203 {"setparm", net_conf_setparm,
1204 "Store a parameter."},
1205 {"getparm", net_conf_getparm,
1206 "Retrieve the value of a parameter."},
1207 {"delparm", net_conf_delparm,
1208 "Delete a parameter."},
1212 if (!registry_init_regdb()) {
1213 d_fprintf(stderr, "Error initializing the registry!\n");
1217 ret = net_run_function2(argc, argv, "net conf", func);