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