2 * Samba Unix/Linux SMB client library
3 * Distributed SMB/CIFS Server Management Utility
4 * Local configuration interface
5 * Copyright (C) Michael Adam 2007-2008
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, see <http://www.gnu.org/licenses/>.
22 * This is an interface to Samba's configuration as made available
23 * by the libsmbconf interface (source/lib/smbconf/smbconf.c).
25 * This currently supports local interaction with the configuration
26 * stored in the registry. But other backends and remote access via
27 * rpc might get implemented in the future.
31 #include "utils/net.h"
33 /**********************************************************************
37 **********************************************************************/
39 static int net_conf_list_usage(struct net_context *c, int argc,
42 d_printf(_("USAGE: net conf list\n"));
46 static int net_conf_import_usage(struct net_context *c, int argc,
49 d_printf(_("USAGE: net conf import [--test|-T] <filename> "
51 "\t[--test|-T] testmode - do not act, just print "
52 "what would be done\n"
53 "\t<servicename> only import service <servicename>, "
54 "ignore the rest\n"));
58 static int net_conf_listshares_usage(struct net_context *c, int argc,
61 d_printf(_("USAGE: net conf listshares\n"));
65 static int net_conf_drop_usage(struct net_context *c, int argc,
68 d_printf(_("USAGE: net conf drop\n"));
72 static int net_conf_showshare_usage(struct net_context *c, int argc,
75 d_printf(_("USAGE: net conf showshare <sharename>\n"));
79 static int net_conf_addshare_usage(struct net_context *c, int argc,
82 d_printf(_("USAGE: net conf addshare <sharename> <path> "
83 "[writeable={y|N} [guest_ok={y|N} [<comment>]]\n"
84 "\t<sharename> the new share name.\n"
85 "\t<path> the path on the filesystem to export.\n"
86 "\twriteable={y|N} set \"writeable to \"yes\" or "
87 "\"no\" (default) on this share.\n"
88 "\tguest_ok={y|N} set \"guest ok\" to \"yes\" or "
89 "\"no\" (default) on this share.\n"
90 "\t<comment> optional comment for the new share.\n"));
94 static int net_conf_delshare_usage(struct net_context *c, int argc,
97 d_printf(_("USAGE: net conf delshare <sharename>\n"));
101 static int net_conf_setparm_usage(struct net_context *c, int argc,
104 d_printf(_("USAGE: net conf setparm <section> <param> <value>\n"));
108 static int net_conf_getparm_usage(struct net_context *c, int argc,
111 d_printf(_("USAGE: net conf getparm <section> <param>\n"));
115 static int net_conf_delparm_usage(struct net_context *c, int argc,
118 d_printf(_("USAGE: net conf delparm <section> <param>\n"));
122 static int net_conf_getincludes_usage(struct net_context *c, int argc,
125 d_printf(_("USAGE: net conf getincludes <section>\n"));
129 static int net_conf_setincludes_usage(struct net_context *c, int argc,
132 d_printf(_("USAGE: net conf setincludes <section> [<filename>]*\n"));
136 static int net_conf_delincludes_usage(struct net_context *c, int argc,
139 d_printf(_("USAGE: net conf delincludes <section>\n"));
144 /**********************************************************************
148 **********************************************************************/
151 * This functions process a service previously loaded with libsmbconf.
153 static WERROR import_process_service(struct net_context *c,
154 struct smbconf_ctx *conf_ctx,
155 struct smbconf_service *service)
158 WERROR werr = WERR_OK;
159 uint32_t num_includes = 0;
160 char **includes = NULL;
161 TALLOC_CTX *mem_ctx = talloc_stackframe();
163 if (c->opt_testmode) {
164 const char *indent = "";
165 if (service->name != NULL) {
166 d_printf("[%s]\n", service->name);
169 for (idx = 0; idx < service->num_params; idx++) {
170 d_printf("%s%s = %s\n", indent,
171 service->param_names[idx],
172 service->param_values[idx]);
178 if (smbconf_share_exists(conf_ctx, service->name)) {
179 werr = smbconf_delete_share(conf_ctx, service->name);
180 if (!W_ERROR_IS_OK(werr)) {
184 werr = smbconf_create_share(conf_ctx, service->name);
185 if (!W_ERROR_IS_OK(werr)) {
189 for (idx = 0; idx < service->num_params; idx ++) {
190 if (strequal(service->param_names[idx], "include")) {
191 includes = TALLOC_REALLOC_ARRAY(mem_ctx,
195 if (includes == NULL) {
199 includes[num_includes] = talloc_strdup(includes,
200 service->param_values[idx]);
201 if (includes[num_includes] == NULL) {
207 werr = smbconf_set_parameter(conf_ctx,
209 service->param_names[idx],
210 service->param_values[idx]);
211 if (!W_ERROR_IS_OK(werr)) {
217 werr = smbconf_set_includes(conf_ctx, service->name, num_includes,
218 (const char **)includes);
221 TALLOC_FREE(mem_ctx);
226 /**********************************************************************
228 * the main conf functions
230 **********************************************************************/
232 static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
233 int argc, const char **argv)
235 WERROR werr = WERR_OK;
239 uint32_t share_count, param_count;
240 struct smbconf_service **shares = NULL;
242 mem_ctx = talloc_stackframe();
244 if (argc != 0 || c->display_usage) {
245 net_conf_list_usage(c, argc, argv);
249 werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
250 if (!W_ERROR_IS_OK(werr)) {
251 d_fprintf(stderr, _("Error getting config: %s\n"),
256 for (share_count = 0; share_count < num_shares; share_count++) {
257 const char *indent = "";
258 if (shares[share_count]->name != NULL) {
259 d_printf("[%s]\n", shares[share_count]->name);
262 for (param_count = 0;
263 param_count < shares[share_count]->num_params;
266 d_printf("%s%s = %s\n",
268 shares[share_count]->param_names[param_count],
269 shares[share_count]->param_values[param_count]);
277 TALLOC_FREE(mem_ctx);
281 static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
282 int argc, const char **argv)
285 const char *filename = NULL;
286 const char *servicename = NULL;
287 char *conf_source = NULL;
289 struct smbconf_ctx *txt_ctx;
292 if (c->display_usage)
293 return net_conf_import_usage(c, argc, argv);
295 mem_ctx = talloc_stackframe();
300 net_conf_import_usage(c, argc, argv);
303 servicename = talloc_strdup(mem_ctx, argv[1]);
304 if (servicename == NULL) {
305 d_printf(_("error: out of memory!\n"));
313 DEBUG(3,("net_conf_import: reading configuration from file %s.\n",
316 conf_source = talloc_asprintf(mem_ctx, "file:%s", filename);
317 if (conf_source == NULL) {
318 d_printf(_("error: out of memory!\n"));
322 werr = smbconf_init(mem_ctx, &txt_ctx, conf_source);
323 if (!W_ERROR_IS_OK(werr)) {
324 d_printf(_("error loading file '%s': %s\n"), filename,
329 if (c->opt_testmode) {
330 d_printf(_("\nTEST MODE - "
331 "would import the following configuration:\n\n"));
334 if (servicename != NULL) {
335 struct smbconf_service *service = NULL;
337 werr = smbconf_get_share(txt_ctx, mem_ctx,
340 if (!W_ERROR_IS_OK(werr)) {
344 werr = smbconf_transaction_start(conf_ctx);
345 if (!W_ERROR_IS_OK(werr)) {
346 d_printf(_("error starting transaction: %s\n"),
351 werr = import_process_service(c, conf_ctx, service);
352 if (!W_ERROR_IS_OK(werr)) {
356 struct smbconf_service **services = NULL;
357 uint32_t num_shares, sidx;
359 werr = smbconf_get_config(txt_ctx, mem_ctx,
362 if (!W_ERROR_IS_OK(werr)) {
365 if (!c->opt_testmode) {
366 werr = smbconf_drop(conf_ctx);
367 if (!W_ERROR_IS_OK(werr)) {
373 * Wrap the importing of shares into a transaction,
374 * but only 100 at a time, in order to serve memory.
375 * The allocated memory accumulates across the actions
376 * within the transaction, and for me, some 1500
377 * imported shares, the MAX_TALLOC_SIZE of 256 MB
380 werr = smbconf_transaction_start(conf_ctx);
381 if (!W_ERROR_IS_OK(werr)) {
382 d_printf(_("error starting transaction: %s\n"),
387 for (sidx = 0; sidx < num_shares; sidx++) {
388 werr = import_process_service(c, conf_ctx,
390 if (!W_ERROR_IS_OK(werr)) {
398 werr = smbconf_transaction_commit(conf_ctx);
399 if (!W_ERROR_IS_OK(werr)) {
400 d_printf(_("error committing transaction: "
405 werr = smbconf_transaction_start(conf_ctx);
406 if (!W_ERROR_IS_OK(werr)) {
407 d_printf(_("error starting transaction: %s\n"),
414 werr = smbconf_transaction_commit(conf_ctx);
415 if (!W_ERROR_IS_OK(werr)) {
416 d_printf(_("error committing transaction: %s\n"),
425 werr = smbconf_transaction_cancel(conf_ctx);
426 if (!W_ERROR_IS_OK(werr)) {
427 d_printf(_("error cancelling transaction: %s\n"),
432 TALLOC_FREE(mem_ctx);
436 static int net_conf_listshares(struct net_context *c,
437 struct smbconf_ctx *conf_ctx, int argc,
440 WERROR werr = WERR_OK;
442 uint32_t count, num_shares = 0;
443 char **share_names = NULL;
446 mem_ctx = talloc_stackframe();
448 if (argc != 0 || c->display_usage) {
449 net_conf_listshares_usage(c, argc, argv);
453 werr = smbconf_get_share_names(conf_ctx, mem_ctx, &num_shares,
455 if (!W_ERROR_IS_OK(werr)) {
459 for (count = 0; count < num_shares; count++)
461 d_printf("%s\n", share_names[count]);
467 TALLOC_FREE(mem_ctx);
471 static int net_conf_drop(struct net_context *c, struct smbconf_ctx *conf_ctx,
472 int argc, const char **argv)
477 if (argc != 0 || c->display_usage) {
478 net_conf_drop_usage(c, argc, argv);
482 werr = smbconf_drop(conf_ctx);
483 if (!W_ERROR_IS_OK(werr)) {
484 d_fprintf(stderr, _("Error deleting configuration: %s\n"),
495 static int net_conf_showshare(struct net_context *c,
496 struct smbconf_ctx *conf_ctx, int argc,
500 WERROR werr = WERR_OK;
501 const char *sharename = NULL;
504 struct smbconf_service *service = NULL;
506 mem_ctx = talloc_stackframe();
508 if (argc != 1 || c->display_usage) {
509 net_conf_showshare_usage(c, argc, argv);
513 sharename = talloc_strdup(mem_ctx, argv[0]);
514 if (sharename == NULL) {
515 d_printf("error: out of memory!\n");
519 werr = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
520 if (!W_ERROR_IS_OK(werr)) {
521 d_printf(_("error getting share parameters: %s\n"),
526 d_printf("[%s]\n", service->name);
528 for (count = 0; count < service->num_params; count++) {
529 d_printf("\t%s = %s\n", service->param_names[count],
530 service->param_values[count]);
536 TALLOC_FREE(mem_ctx);
541 * Add a share, with a couple of standard parameters, partly optional.
543 * This is a high level utility function of the net conf utility,
544 * not a direct frontend to the smbconf API.
546 static int net_conf_addshare(struct net_context *c,
547 struct smbconf_ctx *conf_ctx, int argc,
551 WERROR werr = WERR_OK;
552 char *sharename = NULL;
553 const char *path = NULL;
554 const char *comment = NULL;
555 const char *guest_ok = "no";
556 const char *writeable = "no";
557 SMB_STRUCT_STAT sbuf;
558 TALLOC_CTX *mem_ctx = talloc_stackframe();
560 if (c->display_usage) {
561 net_conf_addshare_usage(c, argc, argv);
570 net_conf_addshare_usage(c, argc, argv);
575 if (!strnequal(argv[3], "guest_ok=", 9)) {
576 net_conf_addshare_usage(c, argc, argv);
579 switch (argv[3][9]) {
589 net_conf_addshare_usage(c, argc, argv);
593 if (!strnequal(argv[2], "writeable=", 10)) {
594 net_conf_addshare_usage(c, argc, argv);
597 switch (argv[2][10]) {
607 net_conf_addshare_usage(c, argc, argv);
612 sharename = talloc_strdup(mem_ctx, argv[0]);
613 if (sharename == NULL) {
614 d_printf(_("error: out of memory!\n"));
625 /* validate share name */
627 if (!validate_net_name(sharename, INVALID_SHARENAME_CHARS,
630 d_fprintf(stderr, _("ERROR: share name %s contains "
631 "invalid characters (any of %s)\n"),
632 sharename, INVALID_SHARENAME_CHARS);
636 if (strequal(sharename, GLOBAL_NAME)) {
638 _("ERROR: 'global' is not a valid share name.\n"));
642 if (smbconf_share_exists(conf_ctx, sharename)) {
643 d_fprintf(stderr, _("ERROR: share %s already exists.\n"),
650 if (path[0] != '/') {
652 _("Error: path '%s' is not an absolute path.\n"),
657 if (sys_stat(path, &sbuf) != 0) {
659 _("ERROR: cannot stat path '%s' to ensure "
660 "this is a directory.\n"
661 "Error was '%s'.\n"),
662 path, strerror(errno));
666 if (!S_ISDIR(sbuf.st_ex_mode)) {
668 _("ERROR: path '%s' is not a directory.\n"),
677 werr = smbconf_create_share(conf_ctx, sharename);
678 if (!W_ERROR_IS_OK(werr)) {
679 d_fprintf(stderr, _("Error creating share %s: %s\n"),
680 sharename, win_errstr(werr));
685 * fill the share with parameters
688 werr = smbconf_set_parameter(conf_ctx, sharename, "path", path);
689 if (!W_ERROR_IS_OK(werr)) {
690 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
691 "path", win_errstr(werr));
695 if (comment != NULL) {
696 werr = smbconf_set_parameter(conf_ctx, sharename, "comment",
698 if (!W_ERROR_IS_OK(werr)) {
699 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
700 "comment", win_errstr(werr));
705 werr = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
706 if (!W_ERROR_IS_OK(werr)) {
707 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
708 "'guest ok'", win_errstr(werr));
712 werr = smbconf_set_parameter(conf_ctx, sharename, "writeable",
714 if (!W_ERROR_IS_OK(werr)) {
715 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
716 "writeable", win_errstr(werr));
723 TALLOC_FREE(mem_ctx);
727 static int net_conf_delshare(struct net_context *c,
728 struct smbconf_ctx *conf_ctx, int argc,
732 const char *sharename = NULL;
733 WERROR werr = WERR_OK;
734 TALLOC_CTX *mem_ctx = talloc_stackframe();
736 if (argc != 1 || c->display_usage) {
737 net_conf_delshare_usage(c, argc, argv);
740 sharename = talloc_strdup(mem_ctx, argv[0]);
741 if (sharename == NULL) {
742 d_printf(_("error: out of memory!\n"));
746 werr = smbconf_delete_share(conf_ctx, sharename);
747 if (!W_ERROR_IS_OK(werr)) {
748 d_fprintf(stderr, _("Error deleting share %s: %s\n"),
749 sharename, win_errstr(werr));
755 TALLOC_FREE(mem_ctx);
759 static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
760 int argc, const char **argv)
763 WERROR werr = WERR_OK;
764 char *service = NULL;
766 const char *value_str = NULL;
767 TALLOC_CTX *mem_ctx = talloc_stackframe();
769 if (argc != 3 || c->display_usage) {
770 net_conf_setparm_usage(c, argc, argv);
774 * NULL service name means "dangling parameters" to libsmbconf.
775 * We use the empty string from the command line for this purpose.
777 if (strlen(argv[0]) != 0) {
778 service = talloc_strdup(mem_ctx, argv[0]);
779 if (service == NULL) {
780 d_printf(_("error: out of memory!\n"));
784 param = strlower_talloc(mem_ctx, argv[1]);
786 d_printf(_("error: out of memory!\n"));
791 werr = smbconf_transaction_start(conf_ctx);
792 if (!W_ERROR_IS_OK(werr)) {
793 d_printf(_("error starting transaction: %s\n"),
798 if (!smbconf_share_exists(conf_ctx, service)) {
799 werr = smbconf_create_share(conf_ctx, service);
800 if (!W_ERROR_IS_OK(werr)) {
801 d_fprintf(stderr, _("Error creating share '%s': %s\n"),
802 service, win_errstr(werr));
807 werr = smbconf_set_parameter(conf_ctx, service, param, value_str);
809 if (!W_ERROR_IS_OK(werr)) {
810 d_fprintf(stderr, _("Error setting value '%s': %s\n"),
811 param, win_errstr(werr));
815 werr = smbconf_transaction_commit(conf_ctx);
816 if (!W_ERROR_IS_OK(werr)) {
817 d_printf(_("error committing transaction: %s\n"),
826 werr = smbconf_transaction_cancel(conf_ctx);
827 if (!W_ERROR_IS_OK(werr)) {
828 d_printf(_("error cancelling transaction: %s\n"),
833 TALLOC_FREE(mem_ctx);
837 static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
838 int argc, const char **argv)
841 WERROR werr = WERR_OK;
842 char *service = NULL;
847 mem_ctx = talloc_stackframe();
849 if (argc != 2 || c->display_usage) {
850 net_conf_getparm_usage(c, argc, argv);
854 * NULL service name means "dangling parameters" to libsmbconf.
855 * We use the empty string from the command line for this purpose.
857 if (strlen(argv[0]) != 0) {
858 service = talloc_strdup(mem_ctx, argv[0]);
859 if (service == NULL) {
860 d_printf(_("error: out of memory!\n"));
864 param = strlower_talloc(mem_ctx, argv[1]);
866 d_printf(_("error: out of memory!\n"));
870 werr = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
872 if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
874 _("Error: given service '%s' does not exist.\n"),
877 } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
879 _("Error: given parameter '%s' is not set.\n"),
882 } else if (!W_ERROR_IS_OK(werr)) {
883 d_fprintf(stderr, _("Error getting value '%s': %s.\n"),
884 param, win_errstr(werr));
888 d_printf("%s\n", valstr);
892 TALLOC_FREE(mem_ctx);
896 static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
897 int argc, const char **argv)
900 WERROR werr = WERR_OK;
901 char *service = NULL;
903 TALLOC_CTX *mem_ctx = talloc_stackframe();
905 if (argc != 2 || c->display_usage) {
906 net_conf_delparm_usage(c, argc, argv);
910 * NULL service name means "dangling parameters" to libsmbconf.
911 * We use the empty string from the command line for this purpose.
913 if (strlen(argv[0]) != 0) {
914 service = talloc_strdup(mem_ctx, argv[0]);
915 if (service == NULL) {
916 d_printf(_("error: out of memory!\n"));
920 param = strlower_talloc(mem_ctx, argv[1]);
922 d_printf("error: out of memory!\n");
926 werr = smbconf_delete_parameter(conf_ctx, service, param);
928 if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
930 _("Error: given service '%s' does not exist.\n"),
933 } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
935 _("Error: given parameter '%s' is not set.\n"),
938 } else if (!W_ERROR_IS_OK(werr)) {
939 d_fprintf(stderr, _("Error deleting value '%s': %s.\n"),
940 param, win_errstr(werr));
947 TALLOC_FREE(mem_ctx);
951 static int net_conf_getincludes(struct net_context *c,
952 struct smbconf_ctx *conf_ctx,
953 int argc, const char **argv)
956 uint32_t num_includes;
959 char **includes = NULL;
961 TALLOC_CTX *mem_ctx = talloc_stackframe();
963 if (argc != 1 || c->display_usage) {
964 net_conf_getincludes_usage(c, argc, argv);
968 service = talloc_strdup(mem_ctx, argv[0]);
969 if (service == NULL) {
970 d_printf(_("error: out of memory!\n"));
974 werr = smbconf_get_includes(conf_ctx, mem_ctx, service,
975 &num_includes, &includes);
976 if (!W_ERROR_IS_OK(werr)) {
977 d_printf(_("error getting includes: %s\n"), win_errstr(werr));
981 for (count = 0; count < num_includes; count++) {
982 d_printf("include = %s\n", includes[count]);
988 TALLOC_FREE(mem_ctx);
992 static int net_conf_setincludes(struct net_context *c,
993 struct smbconf_ctx *conf_ctx,
994 int argc, const char **argv)
998 uint32_t num_includes;
999 const char **includes;
1001 TALLOC_CTX *mem_ctx = talloc_stackframe();
1003 if (argc < 1 || c->display_usage) {
1004 net_conf_setincludes_usage(c, argc, argv);
1008 service = talloc_strdup(mem_ctx, argv[0]);
1009 if (service == NULL) {
1010 d_printf(_("error: out of memory!\n"));
1014 num_includes = argc - 1;
1015 if (num_includes == 0) {
1018 includes = argv + 1;
1021 werr = smbconf_set_includes(conf_ctx, service, num_includes, includes);
1022 if (!W_ERROR_IS_OK(werr)) {
1023 d_printf(_("error setting includes: %s\n"), win_errstr(werr));
1030 TALLOC_FREE(mem_ctx);
1034 static int net_conf_delincludes(struct net_context *c,
1035 struct smbconf_ctx *conf_ctx,
1036 int argc, const char **argv)
1041 TALLOC_CTX *mem_ctx = talloc_stackframe();
1043 if (argc != 1 || c->display_usage) {
1044 net_conf_delincludes_usage(c, argc, argv);
1048 service = talloc_strdup(mem_ctx, argv[0]);
1049 if (service == NULL) {
1050 d_printf(_("error: out of memory!\n"));
1054 werr = smbconf_delete_includes(conf_ctx, service);
1055 if (!W_ERROR_IS_OK(werr)) {
1056 d_printf(_("error deleting includes: %s\n"), win_errstr(werr));
1063 TALLOC_FREE(mem_ctx);
1068 /**********************************************************************
1070 * Wrapper and net_conf_run_function mechanism.
1072 **********************************************************************/
1075 * Wrapper function to call the main conf functions.
1076 * The wrapper calls handles opening and closing of the
1079 static int net_conf_wrap_function(struct net_context *c,
1080 int (*fn)(struct net_context *,
1081 struct smbconf_ctx *,
1082 int, const char **),
1083 int argc, const char **argv)
1086 TALLOC_CTX *mem_ctx = talloc_stackframe();
1087 struct smbconf_ctx *conf_ctx;
1090 werr = smbconf_init(mem_ctx, &conf_ctx, "registry:");
1092 if (!W_ERROR_IS_OK(werr)) {
1096 ret = fn(c, conf_ctx, argc, argv);
1098 smbconf_shutdown(conf_ctx);
1104 * We need a functable struct of our own, because the
1105 * functions are called through a wrapper that handles
1106 * the opening and closing of the configuration, and so on.
1108 struct conf_functable {
1109 const char *funcname;
1110 int (*fn)(struct net_context *c, struct smbconf_ctx *ctx, int argc,
1112 int valid_transports;
1113 const char *description;
1118 * This imitates net_run_function but calls the main functions
1119 * through the wrapper net_conf_wrap_function().
1121 static int net_conf_run_function(struct net_context *c, int argc,
1122 const char **argv, const char *whoami,
1123 struct conf_functable *table)
1128 for (i=0; table[i].funcname; i++) {
1129 if (StrCaseCmp(argv[0], table[i].funcname) == 0)
1130 return net_conf_wrap_function(c, table[i].fn,
1136 d_printf(_("Usage:\n"));
1137 for (i=0; table[i].funcname; i++) {
1138 if (c->display_usage == false)
1139 d_printf("%s %-15s %s\n", whoami, table[i].funcname,
1140 table[i].description);
1142 d_printf("%s\n", table[i].usage);
1145 return c->display_usage?0:-1;
1149 * Entry-point for all the CONF functions.
1152 int net_conf(struct net_context *c, int argc, const char **argv)
1155 struct conf_functable func_table[] = {
1159 NET_TRANSPORT_LOCAL,
1160 N_("Dump the complete configuration in smb.conf like "
1162 N_("net conf list\n"
1163 " Dump the complete configuration in smb.conf "
1170 NET_TRANSPORT_LOCAL,
1171 N_("Import configuration from file in smb.conf "
1173 N_("net conf import\n"
1174 " Import configuration from file in smb.conf "
1179 net_conf_listshares,
1180 NET_TRANSPORT_LOCAL,
1181 N_("List the share names."),
1182 N_("net conf listshares\n"
1183 " List the share names.")
1188 NET_TRANSPORT_LOCAL,
1189 N_("Delete the complete configuration."),
1190 N_("net conf drop\n"
1191 " Delete the complete configuration.")
1196 NET_TRANSPORT_LOCAL,
1197 N_("Show the definition of a share."),
1198 N_("net conf showshare\n"
1199 " Show the definition of a share.")
1204 NET_TRANSPORT_LOCAL,
1205 N_("Create a new share."),
1206 N_("net conf addshare\n"
1207 " Create a new share.")
1212 NET_TRANSPORT_LOCAL,
1213 N_("Delete a share."),
1214 N_("net conf delshare\n"
1220 NET_TRANSPORT_LOCAL,
1221 N_("Store a parameter."),
1222 N_("net conf setparm\n"
1223 " Store a parameter.")
1228 NET_TRANSPORT_LOCAL,
1229 N_("Retrieve the value of a parameter."),
1230 N_("net conf getparm\n"
1231 " Retrieve the value of a parameter.")
1236 NET_TRANSPORT_LOCAL,
1237 N_("Delete a parameter."),
1238 N_("net conf delparm\n"
1239 " Delete a parameter.")
1243 net_conf_getincludes,
1244 NET_TRANSPORT_LOCAL,
1245 N_("Show the includes of a share definition."),
1246 N_("net conf getincludes\n"
1247 " Show the includes of a share definition.")
1251 net_conf_setincludes,
1252 NET_TRANSPORT_LOCAL,
1253 N_("Set includes for a share."),
1254 N_("net conf setincludes\n"
1255 " Set includes for a share.")
1259 net_conf_delincludes,
1260 NET_TRANSPORT_LOCAL,
1261 N_("Delete includes from a share definition."),
1262 N_("net conf setincludes\n"
1263 " Delete includes from a share definition.")
1265 {NULL, NULL, 0, NULL, NULL}
1268 ret = net_conf_run_function(c, argc, argv, "net conf", func_table);