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>, "
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_lower(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 werr
= smbconf_transaction_start(conf_ctx
);
335 if (!W_ERROR_IS_OK(werr
)) {
336 d_printf("error starting transaction: %s\n", win_errstr(werr
));
340 if (servicename
!= NULL
) {
341 struct smbconf_service
*service
= NULL
;
343 werr
= smbconf_get_share(txt_ctx
, mem_ctx
,
346 if (!W_ERROR_IS_OK(werr
)) {
349 werr
= import_process_service(c
, conf_ctx
, service
);
350 if (!W_ERROR_IS_OK(werr
)) {
354 struct smbconf_service
**services
= NULL
;
355 uint32_t num_shares
, sidx
;
357 werr
= smbconf_get_config(txt_ctx
, mem_ctx
,
360 if (!W_ERROR_IS_OK(werr
)) {
363 if (!c
->opt_testmode
) {
364 werr
= smbconf_drop(conf_ctx
);
365 if (!W_ERROR_IS_OK(werr
)) {
369 for (sidx
= 0; sidx
< num_shares
; sidx
++) {
370 werr
= import_process_service(c
, conf_ctx
,
372 if (!W_ERROR_IS_OK(werr
)) {
378 werr
= smbconf_transaction_commit(conf_ctx
);
379 if (!W_ERROR_IS_OK(werr
)) {
380 d_printf("error committing transaction: %s\n",
389 werr
= smbconf_transaction_cancel(conf_ctx
);
390 if (!W_ERROR_IS_OK(werr
)) {
391 d_printf("error cancelling transaction: %s\n",
396 TALLOC_FREE(mem_ctx
);
400 static int net_conf_listshares(struct net_context
*c
,
401 struct smbconf_ctx
*conf_ctx
, int argc
,
404 WERROR werr
= WERR_OK
;
406 uint32_t count
, num_shares
= 0;
407 char **share_names
= NULL
;
410 mem_ctx
= talloc_stackframe();
412 if (argc
!= 0 || c
->display_usage
) {
413 net_conf_listshares_usage(c
, argc
, argv
);
417 werr
= smbconf_get_share_names(conf_ctx
, mem_ctx
, &num_shares
,
419 if (!W_ERROR_IS_OK(werr
)) {
423 for (count
= 0; count
< num_shares
; count
++)
425 d_printf("%s\n", share_names
[count
]);
431 TALLOC_FREE(mem_ctx
);
435 static int net_conf_drop(struct net_context
*c
, struct smbconf_ctx
*conf_ctx
,
436 int argc
, const char **argv
)
441 if (argc
!= 0 || c
->display_usage
) {
442 net_conf_drop_usage(c
, argc
, argv
);
446 werr
= smbconf_drop(conf_ctx
);
447 if (!W_ERROR_IS_OK(werr
)) {
448 d_fprintf(stderr
, "Error deleting configuration: %s\n",
459 static int net_conf_showshare(struct net_context
*c
,
460 struct smbconf_ctx
*conf_ctx
, int argc
,
464 WERROR werr
= WERR_OK
;
465 const char *sharename
= NULL
;
468 struct smbconf_service
*service
= NULL
;
470 mem_ctx
= talloc_stackframe();
472 if (argc
!= 1 || c
->display_usage
) {
473 net_conf_showshare_usage(c
, argc
, argv
);
477 sharename
= talloc_strdup_lower(mem_ctx
, argv
[0]);
478 if (sharename
== NULL
) {
479 d_printf("error: out of memory!\n");
483 werr
= smbconf_get_share(conf_ctx
, mem_ctx
, sharename
, &service
);
484 if (!W_ERROR_IS_OK(werr
)) {
485 d_printf("error getting share parameters: %s\n",
490 d_printf("[%s]\n", sharename
);
492 for (count
= 0; count
< service
->num_params
; count
++) {
493 d_printf("\t%s = %s\n", service
->param_names
[count
],
494 service
->param_values
[count
]);
500 TALLOC_FREE(mem_ctx
);
505 * Add a share, with a couple of standard parameters, partly optional.
507 * This is a high level utility function of the net conf utility,
508 * not a direct frontend to the smbconf API.
510 static int net_conf_addshare(struct net_context
*c
,
511 struct smbconf_ctx
*conf_ctx
, int argc
,
515 WERROR werr
= WERR_OK
;
516 char *sharename
= NULL
;
517 const char *path
= NULL
;
518 const char *comment
= NULL
;
519 const char *guest_ok
= "no";
520 const char *writeable
= "no";
521 SMB_STRUCT_STAT sbuf
;
522 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
524 if (c
->display_usage
) {
525 net_conf_addshare_usage(c
, argc
, argv
);
534 net_conf_addshare_usage(c
, argc
, argv
);
539 if (!strnequal(argv
[3], "guest_ok=", 9)) {
540 net_conf_addshare_usage(c
, argc
, argv
);
543 switch (argv
[3][9]) {
553 net_conf_addshare_usage(c
, argc
, argv
);
557 if (!strnequal(argv
[2], "writeable=", 10)) {
558 net_conf_addshare_usage(c
, argc
, argv
);
561 switch (argv
[2][10]) {
571 net_conf_addshare_usage(c
, argc
, argv
);
576 sharename
= talloc_strdup_lower(mem_ctx
, argv
[0]);
577 if (sharename
== NULL
) {
578 d_printf("error: out of memory!\n");
589 /* validate share name */
591 if (!validate_net_name(sharename
, INVALID_SHARENAME_CHARS
,
594 d_fprintf(stderr
, "ERROR: share name %s contains "
595 "invalid characters (any of %s)\n",
596 sharename
, INVALID_SHARENAME_CHARS
);
600 if (strequal(sharename
, GLOBAL_NAME
)) {
602 "ERROR: 'global' is not a valid share name.\n");
606 if (smbconf_share_exists(conf_ctx
, sharename
)) {
607 d_fprintf(stderr
, "ERROR: share %s already exists.\n",
614 if (path
[0] != '/') {
616 "Error: path '%s' is not an absolute path.\n",
621 if (sys_stat(path
, &sbuf
) != 0) {
623 "ERROR: cannot stat path '%s' to ensure "
624 "this is a directory.\n"
626 path
, strerror(errno
));
630 if (!S_ISDIR(sbuf
.st_mode
)) {
632 "ERROR: path '%s' is not a directory.\n",
641 werr
= smbconf_create_share(conf_ctx
, sharename
);
642 if (!W_ERROR_IS_OK(werr
)) {
643 d_fprintf(stderr
, "Error creating share %s: %s\n",
644 sharename
, dos_errstr(werr
));
649 * fill the share with parameters
652 werr
= smbconf_set_parameter(conf_ctx
, sharename
, "path", path
);
653 if (!W_ERROR_IS_OK(werr
)) {
654 d_fprintf(stderr
, "Error setting parameter %s: %s\n",
655 "path", dos_errstr(werr
));
659 if (comment
!= NULL
) {
660 werr
= smbconf_set_parameter(conf_ctx
, sharename
, "comment",
662 if (!W_ERROR_IS_OK(werr
)) {
663 d_fprintf(stderr
, "Error setting parameter %s: %s\n",
664 "comment", dos_errstr(werr
));
669 werr
= smbconf_set_parameter(conf_ctx
, sharename
, "guest ok", guest_ok
);
670 if (!W_ERROR_IS_OK(werr
)) {
671 d_fprintf(stderr
, "Error setting parameter %s: %s\n",
672 "'guest ok'", dos_errstr(werr
));
676 werr
= smbconf_set_parameter(conf_ctx
, sharename
, "writeable",
678 if (!W_ERROR_IS_OK(werr
)) {
679 d_fprintf(stderr
, "Error setting parameter %s: %s\n",
680 "writeable", dos_errstr(werr
));
687 TALLOC_FREE(mem_ctx
);
691 static int net_conf_delshare(struct net_context
*c
,
692 struct smbconf_ctx
*conf_ctx
, int argc
,
696 const char *sharename
= NULL
;
697 WERROR werr
= WERR_OK
;
698 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
700 if (argc
!= 1 || c
->display_usage
) {
701 net_conf_delshare_usage(c
, argc
, argv
);
704 sharename
= talloc_strdup_lower(mem_ctx
, argv
[0]);
705 if (sharename
== NULL
) {
706 d_printf("error: out of memory!\n");
710 werr
= smbconf_delete_share(conf_ctx
, sharename
);
711 if (!W_ERROR_IS_OK(werr
)) {
712 d_fprintf(stderr
, "Error deleting share %s: %s\n",
713 sharename
, dos_errstr(werr
));
719 TALLOC_FREE(mem_ctx
);
723 static int net_conf_setparm(struct net_context
*c
, struct smbconf_ctx
*conf_ctx
,
724 int argc
, const char **argv
)
727 WERROR werr
= WERR_OK
;
728 char *service
= NULL
;
730 const char *value_str
= NULL
;
731 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
733 if (argc
!= 3 || c
->display_usage
) {
734 net_conf_setparm_usage(c
, argc
, argv
);
737 service
= talloc_strdup_lower(mem_ctx
, argv
[0]);
738 if (service
== NULL
) {
739 d_printf("error: out of memory!\n");
742 param
= talloc_strdup_lower(mem_ctx
, argv
[1]);
744 d_printf("error: out of memory!\n");
749 if (!smbconf_share_exists(conf_ctx
, service
)) {
750 werr
= smbconf_create_share(conf_ctx
, service
);
751 if (!W_ERROR_IS_OK(werr
)) {
752 d_fprintf(stderr
, "Error creating share '%s': %s\n",
753 service
, dos_errstr(werr
));
758 werr
= smbconf_set_parameter(conf_ctx
, service
, param
, value_str
);
760 if (!W_ERROR_IS_OK(werr
)) {
761 d_fprintf(stderr
, "Error setting value '%s': %s\n",
762 param
, dos_errstr(werr
));
769 TALLOC_FREE(mem_ctx
);
773 static int net_conf_getparm(struct net_context
*c
, struct smbconf_ctx
*conf_ctx
,
774 int argc
, const char **argv
)
777 WERROR werr
= WERR_OK
;
778 char *service
= NULL
;
783 mem_ctx
= talloc_stackframe();
785 if (argc
!= 2 || c
->display_usage
) {
786 net_conf_getparm_usage(c
, argc
, argv
);
789 service
= talloc_strdup_lower(mem_ctx
, argv
[0]);
790 if (service
== NULL
) {
791 d_printf("error: out of memory!\n");
794 param
= talloc_strdup_lower(mem_ctx
, argv
[1]);
796 d_printf("error: out of memory!\n");
800 werr
= smbconf_get_parameter(conf_ctx
, mem_ctx
, service
, param
, &valstr
);
802 if (W_ERROR_EQUAL(werr
, WERR_NO_SUCH_SERVICE
)) {
804 "Error: given service '%s' does not exist.\n",
807 } else if (W_ERROR_EQUAL(werr
, WERR_INVALID_PARAM
)) {
809 "Error: given parameter '%s' is not set.\n",
812 } else if (!W_ERROR_IS_OK(werr
)) {
813 d_fprintf(stderr
, "Error getting value '%s': %s.\n",
814 param
, dos_errstr(werr
));
818 d_printf("%s\n", valstr
);
822 TALLOC_FREE(mem_ctx
);
826 static int net_conf_delparm(struct net_context
*c
, struct smbconf_ctx
*conf_ctx
,
827 int argc
, const char **argv
)
830 WERROR werr
= WERR_OK
;
831 char *service
= NULL
;
833 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
835 if (argc
!= 2 || c
->display_usage
) {
836 net_conf_delparm_usage(c
, argc
, argv
);
839 service
= talloc_strdup_lower(mem_ctx
, argv
[0]);
840 if (service
== NULL
) {
841 d_printf("error: out of memory!\n");
844 param
= talloc_strdup_lower(mem_ctx
, argv
[1]);
846 d_printf("error: out of memory!\n");
850 werr
= smbconf_delete_parameter(conf_ctx
, service
, param
);
852 if (W_ERROR_EQUAL(werr
, WERR_NO_SUCH_SERVICE
)) {
854 "Error: given service '%s' does not exist.\n",
857 } else if (W_ERROR_EQUAL(werr
, WERR_INVALID_PARAM
)) {
859 "Error: given parameter '%s' is not set.\n",
862 } else if (!W_ERROR_IS_OK(werr
)) {
863 d_fprintf(stderr
, "Error deleting value '%s': %s.\n",
864 param
, dos_errstr(werr
));
871 TALLOC_FREE(mem_ctx
);
875 static int net_conf_getincludes(struct net_context
*c
,
876 struct smbconf_ctx
*conf_ctx
,
877 int argc
, const char **argv
)
880 uint32_t num_includes
;
883 char **includes
= NULL
;
885 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
887 if (argc
!= 1 || c
->display_usage
) {
888 net_conf_getincludes_usage(c
, argc
, argv
);
892 service
= talloc_strdup_lower(mem_ctx
, argv
[0]);
893 if (service
== NULL
) {
894 d_printf("error: out of memory!\n");
898 werr
= smbconf_get_includes(conf_ctx
, mem_ctx
, service
,
899 &num_includes
, &includes
);
900 if (!W_ERROR_IS_OK(werr
)) {
901 d_printf("error getting includes: %s\n", dos_errstr(werr
));
905 for (count
= 0; count
< num_includes
; count
++) {
906 d_printf("include = %s\n", includes
[count
]);
912 TALLOC_FREE(mem_ctx
);
916 static int net_conf_setincludes(struct net_context
*c
,
917 struct smbconf_ctx
*conf_ctx
,
918 int argc
, const char **argv
)
922 uint32_t num_includes
;
923 const char **includes
;
925 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
927 if (argc
< 1 || c
->display_usage
) {
928 net_conf_setincludes_usage(c
, argc
, argv
);
932 service
= talloc_strdup_lower(mem_ctx
, argv
[0]);
933 if (service
== NULL
) {
934 d_printf("error: out of memory!\n");
938 num_includes
= argc
- 1;
939 if (num_includes
== 0) {
945 werr
= smbconf_set_includes(conf_ctx
, service
, num_includes
, includes
);
946 if (!W_ERROR_IS_OK(werr
)) {
947 d_printf("error setting includes: %s\n", dos_errstr(werr
));
954 TALLOC_FREE(mem_ctx
);
958 static int net_conf_delincludes(struct net_context
*c
,
959 struct smbconf_ctx
*conf_ctx
,
960 int argc
, const char **argv
)
965 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
967 if (argc
!= 1 || c
->display_usage
) {
968 net_conf_delincludes_usage(c
, argc
, argv
);
972 service
= talloc_strdup_lower(mem_ctx
, argv
[0]);
973 if (service
== NULL
) {
974 d_printf("error: out of memory!\n");
978 werr
= smbconf_delete_includes(conf_ctx
, service
);
979 if (!W_ERROR_IS_OK(werr
)) {
980 d_printf("error deleting includes: %s\n", dos_errstr(werr
));
987 TALLOC_FREE(mem_ctx
);
992 /**********************************************************************
994 * Wrapper and net_conf_run_function mechanism.
996 **********************************************************************/
999 * Wrapper function to call the main conf functions.
1000 * The wrapper calls handles opening and closing of the
1003 static int net_conf_wrap_function(struct net_context
*c
,
1004 int (*fn
)(struct net_context
*,
1005 struct smbconf_ctx
*,
1006 int, const char **),
1007 int argc
, const char **argv
)
1010 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
1011 struct smbconf_ctx
*conf_ctx
;
1014 werr
= smbconf_init(mem_ctx
, &conf_ctx
, "registry:");
1016 if (!W_ERROR_IS_OK(werr
)) {
1020 ret
= fn(c
, conf_ctx
, argc
, argv
);
1022 smbconf_shutdown(conf_ctx
);
1028 * We need a functable struct of our own, because the
1029 * functions are called through a wrapper that handles
1030 * the opening and closing of the configuration, and so on.
1032 struct conf_functable
{
1033 const char *funcname
;
1034 int (*fn
)(struct net_context
*c
, struct smbconf_ctx
*ctx
, int argc
,
1036 int valid_transports
;
1037 const char *description
;
1042 * This imitates net_run_function but calls the main functions
1043 * through the wrapper net_conf_wrap_function().
1045 static int net_conf_run_function(struct net_context
*c
, int argc
,
1046 const char **argv
, const char *whoami
,
1047 struct conf_functable
*table
)
1052 for (i
=0; table
[i
].funcname
; i
++) {
1053 if (StrCaseCmp(argv
[0], table
[i
].funcname
) == 0)
1054 return net_conf_wrap_function(c
, table
[i
].fn
,
1060 d_printf("Usage:\n");
1061 for (i
=0; table
[i
].funcname
; i
++) {
1062 if (c
->display_usage
== false)
1063 d_printf("%s %-15s %s\n", whoami
, table
[i
].funcname
,
1064 table
[i
].description
);
1066 d_printf("%s\n", table
[i
].usage
);
1069 return c
->display_usage
?0:-1;
1073 * Entry-point for all the CONF functions.
1076 int net_conf(struct net_context
*c
, int argc
, const char **argv
)
1079 struct conf_functable func_table
[] = {
1083 NET_TRANSPORT_LOCAL
,
1084 "Dump the complete configuration in smb.conf like "
1087 " Dump the complete configuration in smb.conf like "
1094 NET_TRANSPORT_LOCAL
,
1095 "Import configuration from file in smb.conf format.",
1097 " Import configuration from file in smb.conf format."
1101 net_conf_listshares
,
1102 NET_TRANSPORT_LOCAL
,
1103 "List the share names.",
1104 "net conf listshares\n"
1105 " List the share names."
1110 NET_TRANSPORT_LOCAL
,
1111 "Delete the complete configuration.",
1113 " Delete the complete configuration."
1118 NET_TRANSPORT_LOCAL
,
1119 "Show the definition of a share.",
1120 "net conf showshare\n"
1121 " Show the definition of a share."
1126 NET_TRANSPORT_LOCAL
,
1127 "Create a new share.",
1128 "net conf addshare\n"
1129 " Create a new share."
1134 NET_TRANSPORT_LOCAL
,
1136 "net conf delshare\n"
1142 NET_TRANSPORT_LOCAL
,
1143 "Store a parameter.",
1144 "net conf setparm\n"
1145 " Store a parameter."
1150 NET_TRANSPORT_LOCAL
,
1151 "Retrieve the value of a parameter.",
1152 "net conf getparm\n"
1153 " Retrieve the value of a parameter."
1158 NET_TRANSPORT_LOCAL
,
1159 "Delete a parameter.",
1160 "net conf delparm\n"
1161 " Delete a parameter."
1165 net_conf_getincludes
,
1166 NET_TRANSPORT_LOCAL
,
1167 "Show the includes of a share definition.",
1168 "net conf getincludes\n"
1169 " Show the includes of a share definition."
1173 net_conf_setincludes
,
1174 NET_TRANSPORT_LOCAL
,
1175 "Set includes for a share.",
1176 "net conf setincludes\n"
1177 " Set includes for a share."
1181 net_conf_delincludes
,
1182 NET_TRANSPORT_LOCAL
,
1183 "Delete includes from a share definition.",
1184 "net conf setincludes\n"
1185 " Delete includes from a share definition."
1187 {NULL
, NULL
, 0, NULL
, NULL
}
1190 ret
= net_conf_run_function(c
, argc
, argv
, "net conf", func_table
);