Remove the final regdb_close() from net_conf.c
[ira/wip.git] / source3 / utils / net_conf.c
1 /*
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
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 /*
22  * This is an interface to the configuration stored inside the
23  * samba registry. In the future there might be support for other
24  * configuration backends as well.
25  */
26
27 #include "includes.h"
28 #include "utils/net.h"
29 #include "libnet/libnet.h"
30
31 /*
32  * usage functions
33  */
34
35 static int net_conf_list_usage(int argc, const char **argv)
36 {
37         d_printf("USAGE: net conf list\n");
38         return -1;
39 }
40
41 static int net_conf_import_usage(int argc, const char**argv)
42 {
43         d_printf("USAGE: net conf import [--test|-T] <filename> "
44                  "[<servicename>]\n"
45                  "\t[--test|-T]    testmode - do not act, just print "
46                                    "what would be done\n"
47                  "\t<servicename>  only import service <servicename>, "
48                                    "ignore the rest\n");
49         return -1;
50 }
51
52 static int net_conf_listshares_usage(int argc, const char **argv)
53 {
54         d_printf("USAGE: net conf listshares\n");
55         return -1;
56 }
57
58 static int net_conf_drop_usage(int argc, const char **argv)
59 {
60         d_printf("USAGE: net conf drop\n");
61         return -1;
62 }
63
64 static int net_conf_showshare_usage(int argc, const char **argv)
65 {
66         d_printf("USAGE: net conf showshare <sharename>\n");
67         return -1;
68 }
69
70 static int net_conf_addshare_usage(int argc, const char **argv)
71 {
72         d_printf("USAGE: net conf addshare <sharename> <path> "
73                  "[writeable={y|N} [guest_ok={y|N} [<comment>]]\n"
74                  "\t<sharename>      the new share name.\n"
75                  "\t<path>           the path on the filesystem to export.\n"
76                  "\twriteable={y|N}  set \"writeable to \"yes\" or "
77                  "\"no\" (default) on this share.\n"
78                  "\tguest_ok={y|N}   set \"guest ok\" to \"yes\" or "
79                  "\"no\" (default)   on this share.\n"
80                  "\t<comment>        optional comment for the new share.\n");
81         return -1;
82 }
83
84 static int net_conf_delshare_usage(int argc, const char **argv)
85 {
86         d_printf("USAGE: net conf delshare <sharename>\n");
87         return -1;
88 }
89
90 static int net_conf_setparm_usage(int argc, const char **argv)
91 {
92         d_printf("USAGE: net conf setparm <section> <param> <value>\n");
93         return -1;
94 }
95
96 static int net_conf_getparm_usage(int argc, const char **argv)
97 {
98         d_printf("USAGE: net conf getparm <section> <param>\n");
99         return -1;
100 }
101
102 static int net_conf_delparm_usage(int argc, const char **argv)
103 {
104         d_printf("USAGE: net conf delparm <section> <param>\n");
105         return -1;
106 }
107
108
109 /*
110  * Helper functions
111  */
112
113 static char *parm_valstr(TALLOC_CTX *ctx, struct parm_struct *parm,
114                          struct share_params *share)
115 {
116         char *valstr = NULL;
117         int i = 0;
118         void *ptr = parm->ptr;
119
120         if (parm->p_class == P_LOCAL && share->service >= 0) {
121                 ptr = lp_local_ptr(share->service, ptr);
122         }
123
124         switch (parm->type) {
125         case P_CHAR:
126                 valstr = talloc_asprintf(ctx, "%c", *(char *)ptr);
127                 break;
128         case P_STRING:
129         case P_USTRING:
130                 valstr = talloc_asprintf(ctx, "%s", *(char **)ptr);
131                 break;
132         case P_BOOL:
133                 valstr = talloc_asprintf(ctx, "%s", BOOLSTR(*(bool *)ptr));
134                 break;
135         case P_BOOLREV:
136                 valstr = talloc_asprintf(ctx, "%s", BOOLSTR(!*(bool *)ptr));
137                 break;
138         case P_ENUM:
139                 for (i = 0; parm->enum_list[i].name; i++) {
140                         if (*(int *)ptr == parm->enum_list[i].value)
141                         {
142                                 valstr = talloc_asprintf(ctx, "%s",
143                                          parm->enum_list[i].name);
144                                 break;
145                         }
146                 }
147                 break;
148         case P_OCTAL: {
149                 char *o = octal_string(*(int *)ptr);
150                 valstr = talloc_move(ctx, &o);
151                 break;
152         }
153         case P_LIST:
154                 valstr = talloc_strdup(ctx, "");
155                 if ((char ***)ptr && *(char ***)ptr) {
156                         char **list = *(char ***)ptr;
157                         for (; *list; list++) {
158                                 /* surround strings with whitespace
159                                  * in double quotes */
160                                 if (strchr_m(*list, ' '))
161                                 {
162                                         valstr = talloc_asprintf_append(
163                                                 valstr, "\"%s\"%s",
164                                                 *list,
165                                                  ((*(list+1))?", ":""));
166                                 } else {
167                                         valstr = talloc_asprintf_append(
168                                                 valstr, "%s%s", *list,
169                                                  ((*(list+1))?", ":""));
170                                 }
171                         }
172                 }
173                 break;
174         case P_INTEGER:
175                 valstr = talloc_asprintf(ctx, "%d", *(int *)ptr);
176                 break;
177         case P_SEP:
178                 break;
179         default:
180                 valstr = talloc_asprintf(ctx, "<type unimplemented>\n");
181                 break;
182         }
183
184         return valstr;
185 }
186
187 static int import_process_service(TALLOC_CTX *ctx,
188                                   struct share_params *share)
189 {
190         int ret = -1;
191         struct parm_struct *parm;
192         int pnum = 0;
193         const char *servicename;
194         WERROR werr;
195         char *valstr = NULL;
196         TALLOC_CTX *tmp_ctx = NULL;
197
198         tmp_ctx = talloc_new(ctx);
199         if (tmp_ctx == NULL) {
200                 werr = WERR_NOMEM;
201                 goto done;
202         }
203
204         servicename = (share->service == GLOBAL_SECTION_SNUM)?
205                 GLOBAL_NAME : lp_servicename(share->service);
206
207         if (opt_testmode) {
208                 d_printf("[%s]\n", servicename);
209         } else {
210                 if (libnet_conf_share_exists(servicename)) {
211                         werr = libnet_conf_delete_share(servicename);
212                         if (!W_ERROR_IS_OK(werr)) {
213                                 goto done;
214                         }
215                 }
216         }
217
218         while ((parm = lp_next_parameter(share->service, &pnum, 0)))
219         {
220                 if ((share->service < 0) && (parm->p_class == P_LOCAL)
221                     && !(parm->flags & FLAG_GLOBAL))
222                 {
223                         continue;
224                 }
225
226                 valstr = parm_valstr(tmp_ctx, parm, share);
227
228                 if (parm->type != P_SEP) {
229                         if (opt_testmode) {
230                                 d_printf("\t%s = %s\n", parm->label, valstr);
231                         } else {
232                                 werr = libnet_conf_set_parameter(servicename,
233                                                                  parm->label,
234                                                                  valstr);
235                                 if (!W_ERROR_IS_OK(werr)) {
236                                         d_fprintf(stderr,
237                                                   "Error setting parameter '%s'"
238                                                   ": %s\n", parm->label,
239                                                    dos_errstr(werr));
240                                         goto done;
241                                 }
242                         }
243                 }
244         }
245
246         if (opt_testmode) {
247                 d_printf("\n");
248         }
249
250         ret = 0;
251
252 done:
253         TALLOC_FREE(tmp_ctx);
254         return ret;
255 }
256
257 /* return true iff there are nondefault globals */
258 static bool globals_exist(void)
259 {
260         int i = 0;
261         struct parm_struct *parm;
262
263         while ((parm = lp_next_parameter(GLOBAL_SECTION_SNUM, &i, 0)) != NULL) {
264                 if (parm->type != P_SEP) {
265                         return true;
266                 }
267         }
268         return false;
269 }
270
271 /*
272  * the conf functions
273  */
274
275 static int net_conf_list(int argc, const char **argv)
276 {
277         WERROR werr = WERR_OK;
278         int ret = -1;
279         TALLOC_CTX *ctx;
280         uint32_t num_shares;
281         char **share_names;
282         uint32_t *num_params;
283         char ***param_names;
284         char ***param_values;
285         uint32_t share_count, param_count;
286
287         ctx = talloc_init("list");
288
289         if (argc != 0) {
290                 net_conf_list_usage(argc, argv);
291                 goto done;
292         }
293
294         werr = libnet_conf_get_config(ctx, &num_shares, &share_names,
295                                       &num_params, &param_names,
296                                       &param_values);
297         if (!W_ERROR_IS_OK(werr)) {
298                 d_fprintf(stderr, "Error getting config: %s\n",
299                           dos_errstr(werr));
300                 goto done;
301         }
302
303         for (share_count = 0; share_count < num_shares; share_count++) {
304                 d_printf("[%s]\n", share_names[share_count]);
305                 for (param_count = 0; param_count < num_params[share_count];
306                      param_count++)
307                 {
308                         d_printf("\t%s = %s\n",
309                                  param_names[share_count][param_count],
310                                  param_values[share_count][param_count]);
311                 }
312                 d_printf("\n");
313         }
314
315         ret = 0;
316
317 done:
318         TALLOC_FREE(ctx);
319         return ret;
320 }
321
322 static int net_conf_import(int argc, const char **argv)
323 {
324         int ret = -1;
325         const char *filename = NULL;
326         const char *servicename = NULL;
327         bool service_found = false;
328         TALLOC_CTX *ctx;
329         struct share_iterator *shares;
330         struct share_params *share;
331         struct share_params global_share = { GLOBAL_SECTION_SNUM };
332
333         ctx = talloc_init("net_conf_import");
334
335         switch (argc) {
336                 case 0:
337                 default:
338                         net_conf_import_usage(argc, argv);
339                         goto done;
340                 case 2:
341                         servicename = argv[1];
342                 case 1:
343                         filename = argv[0];
344                         break;
345         }
346
347         DEBUG(3,("net_conf_import: reading configuration from file %s.\n",
348                 filename));
349
350         if (!lp_load(filename,
351                      false,     /* global_only */
352                      true,      /* save_defaults */
353                      false,     /* add_ipc */
354                      true))     /* initialize_globals */
355         {
356                 d_fprintf(stderr, "Error parsing configuration file.\n");
357                 goto done;
358         }
359
360         if (opt_testmode) {
361                 d_printf("\nTEST MODE - "
362                          "would import the following configuration:\n\n");
363         }
364
365         if (((servicename == NULL) && globals_exist()) ||
366             strequal(servicename, GLOBAL_NAME))
367         {
368                 service_found = true;
369                 if (import_process_service(ctx, &global_share) != 0) {
370                         goto done;
371                 }
372         }
373
374         if (service_found && (servicename != NULL)) {
375                 ret = 0;
376                 goto done;
377         }
378
379         if (!(shares = share_list_all(ctx))) {
380                 d_fprintf(stderr, "Could not list shares...\n");
381                 goto done;
382         }
383         while ((share = next_share(shares)) != NULL) {
384                 if ((servicename == NULL)
385                     || strequal(servicename, lp_servicename(share->service)))
386                 {
387                         service_found = true;
388                         if (import_process_service(ctx, share)!= 0) {
389                                 goto done;
390                         }
391                 }
392         }
393
394         if ((servicename != NULL) && !service_found) {
395                 d_printf("Share %s not found in file %s\n",
396                          servicename, filename);
397                 goto done;
398
399         }
400
401         ret = 0;
402
403 done:
404         TALLOC_FREE(ctx);
405         return ret;
406 }
407
408 static int net_conf_listshares(int argc, const char **argv)
409 {
410         WERROR werr = WERR_OK;
411         int ret = -1;
412         uint32_t count, num_shares = 0;
413         char **share_names = NULL;
414         TALLOC_CTX *ctx;
415
416         ctx = talloc_init("listshares");
417
418         if (argc != 0) {
419                 net_conf_listshares_usage(argc, argv);
420                 goto done;
421         }
422
423         werr = libnet_conf_get_share_names(ctx, &num_shares, &share_names);
424         if (!W_ERROR_IS_OK(werr)) {
425                 goto done;
426         }
427
428         for (count = 0; count < num_shares; count++)
429         {
430                 d_printf("%s\n", share_names[count]);
431         }
432
433         ret = 0;
434
435 done:
436         TALLOC_FREE(ctx);
437         return ret;
438 }
439
440 static int net_conf_drop(int argc, const char **argv)
441 {
442         int ret = -1;
443         WERROR werr;
444
445         if (argc != 0) {
446                 net_conf_drop_usage(argc, argv);
447                 goto done;
448         }
449
450         werr = libnet_conf_drop();
451         if (!W_ERROR_IS_OK(werr)) {
452                 d_fprintf(stderr, "Error deleting configuration: %s\n",
453                           dos_errstr(werr));
454                 goto done;
455         }
456
457         ret = 0;
458
459 done:
460         return ret;
461 }
462
463 static int net_conf_showshare(int argc, const char **argv)
464 {
465         int ret = -1;
466         WERROR werr = WERR_OK;
467         const char *sharename = NULL;
468         TALLOC_CTX *ctx;
469         uint32_t num_params;
470         uint32_t count;
471         char **param_names;
472         char **param_values;
473
474         ctx = talloc_init("showshare");
475
476         if (argc != 1) {
477                 net_conf_showshare_usage(argc, argv);
478                 goto done;
479         }
480
481         sharename = argv[0];
482
483         werr = libnet_conf_get_share(ctx, sharename, &num_params,
484                                      &param_names, &param_values);
485         if (!W_ERROR_IS_OK(werr)) {
486                 d_printf("error getting share parameters: %s\n",
487                          dos_errstr(werr));
488                 goto done;
489         }
490
491         d_printf("[%s]\n", sharename);
492
493         for (count = 0; count < num_params; count++) {
494                 d_printf("\t%s = %s\n", param_names[count],
495                          param_values[count]);
496         }
497
498         ret = 0;
499
500 done:
501         TALLOC_FREE(ctx);
502         return ret;
503 }
504
505 /**
506  * Add a share, with a couple of standard parameters, partly optional.
507  *
508  * This is a high level utility function of the net conf utility,
509  * not a direct frontend to the libnet_conf API.
510  */
511 static int net_conf_addshare(int argc, const char **argv)
512 {
513         int ret = -1;
514         WERROR werr = WERR_OK;
515         char *sharename = NULL;
516         const char *path = NULL;
517         const char *comment = NULL;
518         const char *guest_ok = "no";
519         const char *writeable = "no";
520         SMB_STRUCT_STAT sbuf;
521
522         switch (argc) {
523                 case 0:
524                 case 1:
525                 default:
526                         net_conf_addshare_usage(argc, argv);
527                         goto done;
528                 case 5:
529                         comment = argv[4];
530                 case 4:
531                         if (!strnequal(argv[3], "guest_ok=", 9)) {
532                                 net_conf_addshare_usage(argc, argv);
533                                 goto done;
534                         }
535                         switch (argv[3][9]) {
536                                 case 'y':
537                                 case 'Y':
538                                         guest_ok = "yes";
539                                         break;
540                                 case 'n':
541                                 case 'N':
542                                         guest_ok = "no";
543                                         break;
544                                 default:
545                                         net_conf_addshare_usage(argc, argv);
546                                         goto done;
547                         }
548                 case 3:
549                         if (!strnequal(argv[2], "writeable=", 10)) {
550                                 net_conf_addshare_usage(argc, argv);
551                                 goto done;
552                         }
553                         switch (argv[2][10]) {
554                                 case 'y':
555                                 case 'Y':
556                                         writeable = "yes";
557                                         break;
558                                 case 'n':
559                                 case 'N':
560                                         writeable = "no";
561                                         break;
562                                 default:
563                                         net_conf_addshare_usage(argc, argv);
564                                         goto done;
565                         }
566                 case 2:
567                         path = argv[1];
568                         sharename = strdup_lower(argv[0]);
569                         break;
570         }
571
572         /*
573          * validate arguments
574          */
575
576         /* validate share name */
577
578         if (!validate_net_name(sharename, INVALID_SHARENAME_CHARS,
579                                strlen(sharename)))
580         {
581                 d_fprintf(stderr, "ERROR: share name %s contains "
582                         "invalid characters (any of %s)\n",
583                         sharename, INVALID_SHARENAME_CHARS);
584                 goto done;
585         }
586
587         if (getpwnam(sharename)) {
588                 d_fprintf(stderr, "ERROR: share name %s is already a valid "
589                           "system user name.\n", sharename);
590                 goto done;
591         }
592
593         if (strequal(sharename, GLOBAL_NAME)) {
594                 d_fprintf(stderr,
595                           "ERROR: 'global' is not a valid share name.\n");
596                 goto done;
597         }
598
599         if (libnet_conf_share_exists(sharename)) {
600                 d_fprintf(stderr, "ERROR: share %s already exists.\n",
601                           sharename);
602                 goto done;
603         }
604
605         /* validate path */
606
607         if (path[0] != '/') {
608                 d_fprintf(stderr,
609                           "Error: path '%s' is not an absolute path.\n",
610                           path);
611                 goto done;
612         }
613
614         if (sys_stat(path, &sbuf) != 0) {
615                 d_fprintf(stderr,
616                           "ERROR: cannot stat path '%s' to ensure "
617                           "this is a directory.\n"
618                           "Error was '%s'.\n",
619                           path, strerror(errno));
620                 goto done;
621         }
622
623         if (!S_ISDIR(sbuf.st_mode)) {
624                 d_fprintf(stderr,
625                           "ERROR: path '%s' is not a directory.\n",
626                           path);
627                 goto done;
628         }
629
630         /*
631          * create the share
632          */
633
634         werr = libnet_conf_create_share(sharename);
635         if (!W_ERROR_IS_OK(werr)) {
636                 d_fprintf(stderr, "Error creating share %s: %s\n",
637                           sharename, dos_errstr(werr));
638                 goto done;
639         }
640
641         /*
642          * fill the share with parameters
643          */
644
645         werr = libnet_conf_set_parameter(sharename, "path", path);
646         if (!W_ERROR_IS_OK(werr)) {
647                 d_fprintf(stderr, "Error setting parameter %s: %s\n",
648                           "path", dos_errstr(werr));
649                 goto done;
650         }
651
652         if (comment != NULL) {
653                 werr = libnet_conf_set_parameter(sharename, "comment", comment);
654                 if (!W_ERROR_IS_OK(werr)) {
655                         d_fprintf(stderr, "Error setting parameter %s: %s\n",
656                                   "comment", dos_errstr(werr));
657                         goto done;
658                 }
659         }
660
661         werr = libnet_conf_set_parameter(sharename, "guest ok", guest_ok);
662         if (!W_ERROR_IS_OK(werr)) {
663                 d_fprintf(stderr, "Error setting parameter %s: %s\n",
664                           "'guest ok'", dos_errstr(werr));
665                 goto done;
666         }
667
668         werr = libnet_conf_set_parameter(sharename, "writeable", writeable);
669         if (!W_ERROR_IS_OK(werr)) {
670                 d_fprintf(stderr, "Error setting parameter %s: %s\n",
671                           "writeable", dos_errstr(werr));
672                 goto done;
673         }
674
675         ret = 0;
676
677 done:
678         SAFE_FREE(sharename);
679         return ret;
680 }
681
682 static int net_conf_delshare(int argc, const char **argv)
683 {
684         int ret = -1;
685         const char *sharename = NULL;
686         WERROR werr = WERR_OK;
687
688         if (argc != 1) {
689                 net_conf_delshare_usage(argc, argv);
690                 goto done;
691         }
692         sharename = argv[0];
693
694         werr = libnet_conf_delete_share(sharename);
695         if (!W_ERROR_IS_OK(werr)) {
696                 d_fprintf(stderr, "Error deleting share %s: %s\n",
697                           sharename, dos_errstr(werr));
698                 goto done;
699         }
700
701         ret = 0;
702 done:
703         return ret;
704 }
705
706 static int net_conf_setparm(int argc, const char **argv)
707 {
708         int ret = -1;
709         WERROR werr = WERR_OK;
710         char *service = NULL;
711         char *param = NULL;
712         const char *value_str = NULL;
713
714         if (argc != 3) {
715                 net_conf_setparm_usage(argc, argv);
716                 goto done;
717         }
718         service = strdup_lower(argv[0]);
719         param = strdup_lower(argv[1]);
720         value_str = argv[2];
721
722         if (!libnet_conf_share_exists(service)) {
723                 werr = libnet_conf_create_share(service);
724                 if (!W_ERROR_IS_OK(werr)) {
725                         d_fprintf(stderr, "Error creating share '%s': %s\n",
726                                   service, dos_errstr(werr));
727                         goto done;
728                 }
729         }
730
731         werr = libnet_conf_set_parameter(service, param, value_str);
732
733         if (!W_ERROR_IS_OK(werr)) {
734                 d_fprintf(stderr, "Error setting value '%s': %s\n",
735                           param, dos_errstr(werr));
736                 goto done;
737         }
738
739         ret = 0;
740
741 done:
742         SAFE_FREE(service);
743         SAFE_FREE(param);
744         return ret;
745 }
746
747 static int net_conf_getparm(int argc, const char **argv)
748 {
749         int ret = -1;
750         WERROR werr = WERR_OK;
751         char *service = NULL;
752         char *param = NULL;
753         char *valstr = NULL;
754         TALLOC_CTX *ctx;
755
756         ctx = talloc_init("getparm");
757
758         if (argc != 2) {
759                 net_conf_getparm_usage(argc, argv);
760                 goto done;
761         }
762         service = strdup_lower(argv[0]);
763         param = strdup_lower(argv[1]);
764
765         werr = libnet_conf_get_parameter(ctx, service, param, &valstr);
766
767         if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
768                 d_fprintf(stderr,
769                           "Error: given service '%s' does not exist.\n",
770                           service);
771                 goto done;
772         } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
773                 d_fprintf(stderr,
774                           "Error: given parameter '%s' is not set.\n",
775                           param);
776                 goto done;
777         } else if (!W_ERROR_IS_OK(werr)) {
778                 d_fprintf(stderr, "Error getting value '%s': %s.\n",
779                           param, dos_errstr(werr));
780                 goto done;
781         }
782
783         d_printf("%s\n", valstr);
784
785         ret = 0;
786 done:
787         SAFE_FREE(service);
788         SAFE_FREE(param);
789         TALLOC_FREE(ctx);
790         return ret;
791 }
792
793 static int net_conf_delparm(int argc, const char **argv)
794 {
795         int ret = -1;
796         WERROR werr = WERR_OK;
797         char *service = NULL;
798         char *param = NULL;
799
800         if (argc != 2) {
801                 net_conf_delparm_usage(argc, argv);
802                 goto done;
803         }
804         service = strdup_lower(argv[0]);
805         param = strdup_lower(argv[1]);
806
807         werr = libnet_conf_delete_parameter(service, param);
808
809         if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
810                 d_fprintf(stderr,
811                           "Error: given service '%s' does not exist.\n",
812                           service);
813                 goto done;
814         } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
815                 d_fprintf(stderr,
816                           "Error: given parameter '%s' is not set.\n",
817                           param);
818                 goto done;
819         } else if (!W_ERROR_IS_OK(werr)) {
820                 d_fprintf(stderr, "Error deleting value '%s': %s.\n",
821                           param, dos_errstr(werr));
822                 goto done;
823         }
824
825         ret = 0;
826
827 done:
828         SAFE_FREE(service);
829         SAFE_FREE(param);
830         return ret;
831 }
832
833 /*
834  * Entry-point for all the CONF functions.
835  */
836
837 int net_conf(int argc, const char **argv)
838 {
839         int ret = -1;
840         struct functable2 func[] = {
841                 {"list", net_conf_list,
842                  "Dump the complete configuration in smb.conf like format."},
843                 {"import", net_conf_import,
844                  "Import configuration from file in smb.conf format."},
845                 {"listshares", net_conf_listshares,
846                  "List the registry shares."},
847                 {"drop", net_conf_drop,
848                  "Delete the complete configuration from registry."},
849                 {"showshare", net_conf_showshare,
850                  "Show the definition of a registry share."},
851                 {"addshare", net_conf_addshare,
852                  "Create a new registry share."},
853                 {"delshare", net_conf_delshare,
854                  "Delete a registry share."},
855                 {"setparm", net_conf_setparm,
856                  "Store a parameter."},
857                 {"getparm", net_conf_getparm,
858                  "Retrieve the value of a parameter."},
859                 {"delparm", net_conf_delparm,
860                  "Delete a parameter."},
861                 {NULL, NULL, NULL}
862         };
863
864         ret = net_run_function2(argc, argv, "net conf", func);
865
866         return ret;
867 }
868