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 "system/filesys.h"
32 #include "utils/net.h"
33 #include "utils/net_conf_util.h"
34 #include "lib/smbconf/smbconf.h"
35 #include "lib/smbconf/smbconf_init.h"
36 #include "lib/smbconf/smbconf_reg.h"
37 #include "lib/param/loadparm.h"
39 /**********************************************************************
43 **********************************************************************/
45 static int net_conf_list_usage(struct net_context *c, int argc,
48 d_printf("%s net conf list\n", _("Usage:"));
52 static int net_conf_import_usage(struct net_context *c, int argc,
57 _(" net conf import [--test|-T] <filename> "
59 "\t[--test|-T] testmode - do not act, just print "
60 "what would be done\n"
61 "\t<servicename> only import service <servicename>, "
62 "ignore the rest\n"));
66 static int net_conf_listshares_usage(struct net_context *c, int argc,
69 d_printf("%s\nnet conf listshares\n", _("Usage:"));
73 static int net_conf_drop_usage(struct net_context *c, int argc,
76 d_printf("%s\nnet conf drop\n", _("Usage:"));
80 static int net_conf_showshare_usage(struct net_context *c, int argc,
85 _("net conf showshare <sharename>\n"));
89 static int net_conf_addshare_usage(struct net_context *c, int argc,
94 _(" net conf addshare <sharename> <path> "
95 "[writeable={y|N} [guest_ok={y|N} [<comment>]]]\n"
96 "\t<sharename> the new share name.\n"
97 "\t<path> the path on the filesystem to export.\n"
98 "\twriteable={y|N} set \"writeable to \"yes\" or "
99 "\"no\" (default) on this share.\n"
100 "\tguest_ok={y|N} set \"guest ok\" to \"yes\" or "
101 "\"no\" (default) on this share.\n"
102 "\t<comment> optional comment for the new share.\n"));
106 static int net_conf_delshare_usage(struct net_context *c, int argc,
111 _("net conf delshare <sharename>\n"));
115 static int net_conf_setparm_usage(struct net_context *c, int argc,
120 _(" net conf setparm <section> <param> <value>\n"));
124 static int net_conf_getparm_usage(struct net_context *c, int argc,
129 _(" net conf getparm <section> <param>\n"));
133 static int net_conf_delparm_usage(struct net_context *c, int argc,
138 _(" net conf delparm <section> <param>\n"));
142 static int net_conf_getincludes_usage(struct net_context *c, int argc,
147 _(" net conf getincludes <section>\n"));
151 static int net_conf_setincludes_usage(struct net_context *c, int argc,
156 _(" net conf setincludes <section> [<filename>]*\n"));
160 static int net_conf_delincludes_usage(struct net_context *c, int argc,
165 _(" net conf delincludes <section>\n"));
170 /**********************************************************************
174 **********************************************************************/
177 * This functions process a service previously loaded with libsmbconf.
179 static sbcErr import_process_service(struct net_context *c,
180 struct smbconf_ctx *conf_ctx,
181 struct smbconf_service *service)
183 sbcErr err = SBC_ERR_OK;
185 if (c->opt_testmode) {
187 const char *indent = "";
188 if (service->name != NULL) {
189 d_printf("[%s]\n", service->name);
192 for (idx = 0; idx < service->num_params; idx++) {
193 d_printf("%s%s = %s\n", indent,
194 service->param_names[idx],
195 service->param_values[idx]);
201 if (smbconf_share_exists(conf_ctx, service->name)) {
202 err = smbconf_delete_share(conf_ctx, service->name);
203 if (!SBC_ERROR_IS_OK(err)) {
208 err = smbconf_create_set_share(conf_ctx, service);
215 /**********************************************************************
217 * the main conf functions
219 **********************************************************************/
221 static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
222 int argc, const char **argv)
228 uint32_t share_count, param_count;
229 struct smbconf_service **shares = NULL;
231 mem_ctx = talloc_stackframe();
233 if (argc != 0 || c->display_usage) {
234 net_conf_list_usage(c, argc, argv);
238 err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
239 if (!SBC_ERROR_IS_OK(err)) {
240 d_fprintf(stderr, _("Error getting config: %s\n"),
241 sbcErrorString(err));
245 for (share_count = 0; share_count < num_shares; share_count++) {
246 const char *indent = "";
247 if (shares[share_count]->name != NULL) {
248 d_printf("[%s]\n", shares[share_count]->name);
251 for (param_count = 0;
252 param_count < shares[share_count]->num_params;
255 d_printf("%s%s = %s\n",
257 shares[share_count]->param_names[param_count],
258 shares[share_count]->param_values[param_count]);
266 TALLOC_FREE(mem_ctx);
270 static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
271 int argc, const char **argv)
274 const char *filename = NULL;
275 const char *servicename = NULL;
276 char *conf_source = NULL;
278 struct smbconf_ctx *txt_ctx;
281 if (c->display_usage)
282 return net_conf_import_usage(c, argc, argv);
284 mem_ctx = talloc_stackframe();
289 net_conf_import_usage(c, argc, argv);
292 servicename = talloc_strdup(mem_ctx, argv[1]);
293 if (servicename == NULL) {
294 d_printf(_("error: out of memory!\n"));
302 DEBUG(3,("net_conf_import: reading configuration from file %s.\n",
305 conf_source = talloc_asprintf(mem_ctx, "file:%s", filename);
306 if (conf_source == NULL) {
307 d_printf(_("error: out of memory!\n"));
311 err = smbconf_init(mem_ctx, &txt_ctx, conf_source);
312 if (!SBC_ERROR_IS_OK(err)) {
313 d_printf(_("error loading file '%s': %s\n"), filename,
314 sbcErrorString(err));
318 if (c->opt_testmode) {
319 d_printf(_("\nTEST MODE - "
320 "would import the following configuration:\n\n"));
323 if (servicename != NULL) {
324 struct smbconf_service *service = NULL;
326 err = smbconf_get_share(txt_ctx, mem_ctx,
329 if (!SBC_ERROR_IS_OK(err)) {
333 err = smbconf_transaction_start(conf_ctx);
334 if (!SBC_ERROR_IS_OK(err)) {
335 d_printf(_("error starting transaction: %s\n"),
336 sbcErrorString(err));
340 err = import_process_service(c, conf_ctx, service);
341 if (!SBC_ERROR_IS_OK(err)) {
345 struct smbconf_service **services = NULL;
346 uint32_t num_shares, sidx;
348 err = smbconf_get_config(txt_ctx, mem_ctx,
351 if (!SBC_ERROR_IS_OK(err)) {
354 if (!c->opt_testmode) {
355 if (!SBC_ERROR_IS_OK(smbconf_drop(conf_ctx))) {
361 * Wrap the importing of shares into a transaction,
362 * but only 100 at a time, in order to save memory.
363 * The allocated memory accumulates across the actions
364 * within the transaction, and for me, some 1500
365 * imported shares, the MAX_TALLOC_SIZE of 256 MB
368 err = smbconf_transaction_start(conf_ctx);
369 if (!SBC_ERROR_IS_OK(err)) {
370 d_printf(_("error starting transaction: %s\n"),
371 sbcErrorString(err));
375 for (sidx = 0; sidx < num_shares; sidx++) {
376 err = import_process_service(c, conf_ctx,
378 if (!SBC_ERROR_IS_OK(err)) {
386 err = smbconf_transaction_commit(conf_ctx);
387 if (!SBC_ERROR_IS_OK(err)) {
388 d_printf(_("error committing transaction: "
390 sbcErrorString(err));
393 err = smbconf_transaction_start(conf_ctx);
394 if (!SBC_ERROR_IS_OK(err)) {
395 d_printf(_("error starting transaction: %s\n"),
396 sbcErrorString(err));
402 err = smbconf_transaction_commit(conf_ctx);
403 if (!SBC_ERROR_IS_OK(err)) {
404 d_printf(_("error committing transaction: %s\n"),
405 sbcErrorString(err));
413 err = smbconf_transaction_cancel(conf_ctx);
414 if (!SBC_ERROR_IS_OK(err)) {
415 d_printf(_("error cancelling transaction: %s\n"),
416 sbcErrorString(err));
420 TALLOC_FREE(mem_ctx);
424 static int net_conf_listshares(struct net_context *c,
425 struct smbconf_ctx *conf_ctx, int argc,
430 uint32_t count, num_shares = 0;
431 char **share_names = NULL;
434 mem_ctx = talloc_stackframe();
436 if (argc != 0 || c->display_usage) {
437 net_conf_listshares_usage(c, argc, argv);
441 err = smbconf_get_share_names(conf_ctx, mem_ctx, &num_shares,
443 if (!SBC_ERROR_IS_OK(err)) {
447 for (count = 0; count < num_shares; count++)
449 d_printf("%s\n", share_names[count]);
455 TALLOC_FREE(mem_ctx);
459 static int net_conf_drop(struct net_context *c, struct smbconf_ctx *conf_ctx,
460 int argc, const char **argv)
465 if (argc != 0 || c->display_usage) {
466 net_conf_drop_usage(c, argc, argv);
470 err = smbconf_drop(conf_ctx);
471 if (!SBC_ERROR_IS_OK(err)) {
472 d_fprintf(stderr, _("Error deleting configuration: %s\n"),
473 sbcErrorString(err));
483 static int net_conf_showshare(struct net_context *c,
484 struct smbconf_ctx *conf_ctx, int argc,
489 const char *sharename = NULL;
492 struct smbconf_service *service = NULL;
494 mem_ctx = talloc_stackframe();
496 if (argc != 1 || c->display_usage) {
497 net_conf_showshare_usage(c, argc, argv);
501 sharename = talloc_strdup(mem_ctx, argv[0]);
502 if (sharename == NULL) {
503 d_printf("error: out of memory!\n");
507 err = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
508 if (!SBC_ERROR_IS_OK(err)) {
509 d_printf(_("error getting share parameters: %s\n"),
510 sbcErrorString(err));
514 d_printf("[%s]\n", service->name);
516 for (count = 0; count < service->num_params; count++) {
517 d_printf("\t%s = %s\n", service->param_names[count],
518 service->param_values[count]);
524 TALLOC_FREE(mem_ctx);
529 * Add a share, with a couple of standard parameters, partly optional.
531 * This is a high level utility function of the net conf utility,
532 * not a direct frontend to the smbconf API.
534 static int net_conf_addshare(struct net_context *c,
535 struct smbconf_ctx *conf_ctx, int argc,
540 char *sharename = NULL;
541 const char *path = NULL;
542 const char *comment = NULL;
543 const char *guest_ok = "no";
544 const char *writeable = "no";
545 TALLOC_CTX *mem_ctx = talloc_stackframe();
547 if (c->display_usage) {
548 net_conf_addshare_usage(c, argc, argv);
557 net_conf_addshare_usage(c, argc, argv);
562 if (!strnequal(argv[3], "guest_ok=", 9)) {
563 net_conf_addshare_usage(c, argc, argv);
566 switch (argv[3][9]) {
576 net_conf_addshare_usage(c, argc, argv);
580 if (!strnequal(argv[2], "writeable=", 10)) {
581 net_conf_addshare_usage(c, argc, argv);
584 switch (argv[2][10]) {
594 net_conf_addshare_usage(c, argc, argv);
599 sharename = talloc_strdup(mem_ctx, argv[0]);
600 if (sharename == NULL) {
601 d_printf(_("error: out of memory!\n"));
612 /* validate share name */
614 if (!validate_net_name(sharename, INVALID_SHARENAME_CHARS,
617 d_fprintf(stderr, _("ERROR: share name %s contains "
618 "invalid characters (any of %s)\n"),
619 sharename, INVALID_SHARENAME_CHARS);
623 if (strequal(sharename, GLOBAL_NAME)) {
625 _("ERROR: 'global' is not a valid share name.\n"));
629 if (smbconf_share_exists(conf_ctx, sharename)) {
630 d_fprintf(stderr, _("ERROR: share %s already exists.\n"),
637 if (path[0] != '/') {
639 _("Error: path '%s' is not an absolute path.\n"),
645 * start a transaction
648 err = smbconf_transaction_start(conf_ctx);
649 if (!SBC_ERROR_IS_OK(err)) {
650 d_printf("error starting transaction: %s\n",
651 sbcErrorString(err));
659 err = smbconf_create_share(conf_ctx, sharename);
660 if (!SBC_ERROR_IS_OK(err)) {
661 d_fprintf(stderr, _("Error creating share %s: %s\n"),
662 sharename, sbcErrorString(err));
667 * fill the share with parameters
670 err = smbconf_set_parameter(conf_ctx, sharename, "path", path);
671 if (!SBC_ERROR_IS_OK(err)) {
672 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
673 "path", sbcErrorString(err));
677 if (comment != NULL) {
678 err = smbconf_set_parameter(conf_ctx, sharename, "comment",
680 if (!SBC_ERROR_IS_OK(err)) {
681 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
682 "comment", sbcErrorString(err));
687 err = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
688 if (!SBC_ERROR_IS_OK(err)) {
689 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
690 "'guest ok'", sbcErrorString(err));
694 err = smbconf_set_parameter(conf_ctx, sharename, "writeable",
696 if (!SBC_ERROR_IS_OK(err)) {
697 d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
698 "writeable", sbcErrorString(err));
703 * commit the whole thing
706 err = smbconf_transaction_commit(conf_ctx);
707 if (!SBC_ERROR_IS_OK(err)) {
708 d_printf("error committing transaction: %s\n",
709 sbcErrorString(err));
717 err = smbconf_transaction_cancel(conf_ctx);
718 if (!SBC_ERROR_IS_OK(err)) {
719 d_printf("error cancelling transaction: %s\n",
720 sbcErrorString(err));
724 TALLOC_FREE(mem_ctx);
728 static int net_conf_delshare(struct net_context *c,
729 struct smbconf_ctx *conf_ctx, int argc,
733 const char *sharename = NULL;
735 TALLOC_CTX *mem_ctx = talloc_stackframe();
737 if (argc != 1 || c->display_usage) {
738 net_conf_delshare_usage(c, argc, argv);
741 sharename = talloc_strdup(mem_ctx, argv[0]);
742 if (sharename == NULL) {
743 d_printf(_("error: out of memory!\n"));
747 err = smbconf_delete_share(conf_ctx, sharename);
748 if (!SBC_ERROR_IS_OK(err)) {
749 d_fprintf(stderr, _("Error deleting share %s: %s\n"),
750 sharename, sbcErrorString(err));
756 TALLOC_FREE(mem_ctx);
760 static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
761 int argc, const char **argv)
765 char *service = NULL;
767 const char *value_str = NULL;
768 TALLOC_CTX *mem_ctx = talloc_stackframe();
770 if (argc != 3 || c->display_usage) {
771 net_conf_setparm_usage(c, argc, argv);
775 * NULL service name means "dangling parameters" to libsmbconf.
776 * We use the empty string from the command line for this purpose.
778 if (strlen(argv[0]) != 0) {
779 service = talloc_strdup(mem_ctx, argv[0]);
780 if (service == NULL) {
781 d_printf(_("error: out of memory!\n"));
785 param = strlower_talloc(mem_ctx, argv[1]);
787 d_printf(_("error: out of memory!\n"));
792 if (!net_conf_param_valid(service,param, value_str)) {
796 err = smbconf_transaction_start(conf_ctx);
797 if (!SBC_ERROR_IS_OK(err)) {
798 d_printf(_("error starting transaction: %s\n"),
799 sbcErrorString(err));
803 if (!smbconf_share_exists(conf_ctx, service)) {
804 err = smbconf_create_share(conf_ctx, service);
805 if (!SBC_ERROR_IS_OK(err)) {
806 d_fprintf(stderr, _("Error creating share '%s': %s\n"),
807 service, sbcErrorString(err));
812 err = smbconf_set_parameter(conf_ctx, service, param, value_str);
813 if (!SBC_ERROR_IS_OK(err)) {
814 d_fprintf(stderr, _("Error setting value '%s': %s\n"),
815 param, sbcErrorString(err));
819 err = smbconf_transaction_commit(conf_ctx);
820 if (!SBC_ERROR_IS_OK(err)) {
821 d_printf(_("error committing transaction: %s\n"),
822 sbcErrorString(err));
830 err = smbconf_transaction_cancel(conf_ctx);
831 if (!SBC_ERROR_IS_OK(err)) {
832 d_printf(_("error cancelling transaction: %s\n"),
833 sbcErrorString(err));
837 TALLOC_FREE(mem_ctx);
841 static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
842 int argc, const char **argv)
846 char *service = NULL;
851 mem_ctx = talloc_stackframe();
853 if (argc != 2 || c->display_usage) {
854 net_conf_getparm_usage(c, argc, argv);
858 * NULL service name means "dangling parameters" to libsmbconf.
859 * We use the empty string from the command line for this purpose.
861 if (strlen(argv[0]) != 0) {
862 service = talloc_strdup(mem_ctx, argv[0]);
863 if (service == NULL) {
864 d_printf(_("error: out of memory!\n"));
868 param = strlower_talloc(mem_ctx, argv[1]);
870 d_printf(_("error: out of memory!\n"));
874 err = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
875 if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) {
877 _("Error: given service '%s' does not exist.\n"),
880 } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) {
882 _("Error: given parameter '%s' is not set.\n"),
885 } else if (!SBC_ERROR_IS_OK(err)) {
886 d_fprintf(stderr, _("Error getting value '%s': %s.\n"),
887 param, sbcErrorString(err));
891 d_printf("%s\n", valstr);
895 TALLOC_FREE(mem_ctx);
899 static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
900 int argc, const char **argv)
904 char *service = NULL;
906 TALLOC_CTX *mem_ctx = talloc_stackframe();
908 if (argc != 2 || c->display_usage) {
909 net_conf_delparm_usage(c, argc, argv);
913 * NULL service name means "dangling parameters" to libsmbconf.
914 * We use the empty string from the command line for this purpose.
916 if (strlen(argv[0]) != 0) {
917 service = talloc_strdup(mem_ctx, argv[0]);
918 if (service == NULL) {
919 d_printf(_("error: out of memory!\n"));
923 param = strlower_talloc(mem_ctx, argv[1]);
925 d_printf("error: out of memory!\n");
929 err = smbconf_delete_parameter(conf_ctx, service, param);
930 if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) {
932 _("Error: given service '%s' does not exist.\n"),
935 } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) {
937 _("Error: given parameter '%s' is not set.\n"),
940 } else if (!SBC_ERROR_IS_OK(err)) {
941 d_fprintf(stderr, _("Error deleting value '%s': %s.\n"),
942 param, sbcErrorString(err));
949 TALLOC_FREE(mem_ctx);
953 static int net_conf_getincludes(struct net_context *c,
954 struct smbconf_ctx *conf_ctx,
955 int argc, const char **argv)
958 uint32_t num_includes;
961 char **includes = NULL;
963 TALLOC_CTX *mem_ctx = talloc_stackframe();
965 if (argc != 1 || c->display_usage) {
966 net_conf_getincludes_usage(c, argc, argv);
970 service = talloc_strdup(mem_ctx, argv[0]);
971 if (service == NULL) {
972 d_printf(_("error: out of memory!\n"));
976 err = smbconf_get_includes(conf_ctx, mem_ctx, service,
977 &num_includes, &includes);
978 if (!SBC_ERROR_IS_OK(err)) {
979 d_printf(_("error getting includes: %s\n"), sbcErrorString(err));
983 for (count = 0; count < num_includes; count++) {
984 d_printf("include = %s\n", includes[count]);
990 TALLOC_FREE(mem_ctx);
994 static int net_conf_setincludes(struct net_context *c,
995 struct smbconf_ctx *conf_ctx,
996 int argc, const char **argv)
1000 uint32_t num_includes;
1001 const char **includes;
1003 TALLOC_CTX *mem_ctx = talloc_stackframe();
1005 if (argc < 1 || c->display_usage) {
1006 net_conf_setincludes_usage(c, argc, argv);
1010 service = talloc_strdup(mem_ctx, argv[0]);
1011 if (service == NULL) {
1012 d_printf(_("error: out of memory!\n"));
1016 num_includes = argc - 1;
1017 if (num_includes == 0) {
1020 includes = argv + 1;
1023 err = smbconf_set_includes(conf_ctx, service, num_includes, includes);
1024 if (!SBC_ERROR_IS_OK(err)) {
1025 d_printf(_("error setting includes: %s\n"), sbcErrorString(err));
1032 TALLOC_FREE(mem_ctx);
1036 static int net_conf_delincludes(struct net_context *c,
1037 struct smbconf_ctx *conf_ctx,
1038 int argc, const char **argv)
1043 TALLOC_CTX *mem_ctx = talloc_stackframe();
1045 if (argc != 1 || c->display_usage) {
1046 net_conf_delincludes_usage(c, argc, argv);
1050 service = talloc_strdup(mem_ctx, argv[0]);
1051 if (service == NULL) {
1052 d_printf(_("error: out of memory!\n"));
1056 err = smbconf_delete_includes(conf_ctx, service);
1057 if (!SBC_ERROR_IS_OK(err)) {
1058 d_printf(_("error deleting includes: %s\n"), sbcErrorString(err));
1065 TALLOC_FREE(mem_ctx);
1070 /**********************************************************************
1072 * Wrapper and net_conf_run_function mechanism.
1074 **********************************************************************/
1077 * Wrapper function to call the main conf functions.
1078 * The wrapper calls handles opening and closing of the
1081 static int net_conf_wrap_function(struct net_context *c,
1082 int (*fn)(struct net_context *,
1083 struct smbconf_ctx *,
1084 int, const char **),
1085 int argc, const char **argv)
1088 TALLOC_CTX *mem_ctx = talloc_stackframe();
1089 struct smbconf_ctx *conf_ctx;
1092 err = smbconf_init(mem_ctx, &conf_ctx, "registry:");
1093 if (!SBC_ERROR_IS_OK(err)) {
1094 talloc_free(mem_ctx);
1098 ret = fn(c, conf_ctx, argc, argv);
1100 smbconf_shutdown(conf_ctx);
1102 talloc_free(mem_ctx);
1107 * We need a functable struct of our own, because the
1108 * functions are called through a wrapper that handles
1109 * the opening and closing of the configuration, and so on.
1111 struct conf_functable {
1112 const char *funcname;
1113 int (*fn)(struct net_context *c, struct smbconf_ctx *ctx, int argc,
1115 int valid_transports;
1116 const char *description;
1121 * This imitates net_run_function but calls the main functions
1122 * through the wrapper net_conf_wrap_function().
1124 static int net_conf_run_function(struct net_context *c, int argc,
1125 const char **argv, const char *whoami,
1126 struct conf_functable *table)
1131 for (i=0; table[i].funcname; i++) {
1132 if (strcasecmp_m(argv[0], table[i].funcname) == 0)
1133 return net_conf_wrap_function(c, table[i].fn,
1139 d_printf(_("Usage:\n"));
1140 for (i=0; table[i].funcname; i++) {
1141 if (c->display_usage == false)
1142 d_printf("%s %-15s %s\n", whoami, table[i].funcname,
1143 table[i].description);
1145 d_printf("%s\n", table[i].usage);
1148 return c->display_usage?0:-1;
1152 * Entry-point for all the CONF functions.
1155 int net_conf(struct net_context *c, int argc, const char **argv)
1158 struct conf_functable func_table[] = {
1162 NET_TRANSPORT_LOCAL,
1163 N_("Dump the complete configuration in smb.conf like "
1165 N_("net conf list\n"
1166 " Dump the complete configuration in smb.conf "
1173 NET_TRANSPORT_LOCAL,
1174 N_("Import configuration from file in smb.conf "
1176 N_("net conf import\n"
1177 " Import configuration from file in smb.conf "
1182 net_conf_listshares,
1183 NET_TRANSPORT_LOCAL,
1184 N_("List the share names."),
1185 N_("net conf listshares\n"
1186 " List the share names.")
1191 NET_TRANSPORT_LOCAL,
1192 N_("Delete the complete configuration."),
1193 N_("net conf drop\n"
1194 " Delete the complete configuration.")
1199 NET_TRANSPORT_LOCAL,
1200 N_("Show the definition of a share."),
1201 N_("net conf showshare\n"
1202 " Show the definition of a share.")
1207 NET_TRANSPORT_LOCAL,
1208 N_("Create a new share."),
1209 N_("net conf addshare\n"
1210 " Create a new share.")
1215 NET_TRANSPORT_LOCAL,
1216 N_("Delete a share."),
1217 N_("net conf delshare\n"
1223 NET_TRANSPORT_LOCAL,
1224 N_("Store a parameter."),
1225 N_("net conf setparm\n"
1226 " Store a parameter.")
1231 NET_TRANSPORT_LOCAL,
1232 N_("Retrieve the value of a parameter."),
1233 N_("net conf getparm\n"
1234 " Retrieve the value of a parameter.")
1239 NET_TRANSPORT_LOCAL,
1240 N_("Delete a parameter."),
1241 N_("net conf delparm\n"
1242 " Delete a parameter.")
1246 net_conf_getincludes,
1247 NET_TRANSPORT_LOCAL,
1248 N_("Show the includes of a share definition."),
1249 N_("net conf getincludes\n"
1250 " Show the includes of a share definition.")
1254 net_conf_setincludes,
1255 NET_TRANSPORT_LOCAL,
1256 N_("Set includes for a share."),
1257 N_("net conf setincludes\n"
1258 " Set includes for a share.")
1262 net_conf_delincludes,
1263 NET_TRANSPORT_LOCAL,
1264 N_("Delete includes from a share definition."),
1265 N_("net conf delincludes\n"
1266 " Delete includes from a share definition.")
1268 {NULL, NULL, 0, NULL, NULL}
1271 ret = net_conf_run_function(c, argc, argv, "net conf", func_table);