Rev 5315: introduce logic for extended commandline for import
subcommand: in http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/
Michael Adam
ma at sernet.de
Sat Mar 31 23:24:33 GMT 2007
At http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/
------------------------------------------------------------
revno: 5315
revision-id: ma at sernet.de-20070331232431-88e5233d98a5e30f
parent: ma at sernet.de-20070331220356-a5fa313509d186b0
committer: Michael Adam <ma at sernet.de>
branch nick: SAMBA_3_0-registry.bzr
timestamp: Sun 2007-04-01 01:24:31 +0200
message:
introduce logic for extended commandline for import subcommand:
optional -t parameter for testmode.
optional servicename after filename to select one service of
input file instead of everything.
modified:
source/utils/net_conf.c net_conf.c-20070228210606-uywdn1acd043wgvt-1
=== modified file 'source/utils/net_conf.c'
--- a/source/utils/net_conf.c 2007-03-27 21:54:46 +0000
+++ b/source/utils/net_conf.c 2007-03-31 23:24:31 +0000
@@ -52,7 +52,11 @@
static int net_conf_import_usage(int argc, const char**argv)
{
- d_printf("USAGE: net conf import <filename>\n");
+ d_printf("USAGE: net conf import [-t] <filename> [<servicename>]\n"
+ "\t-t testmode - do not act, just print "
+ "what would be done\n"
+ "\t<servicename> only import service <servicename>, "
+ "ignore the rest\n");
return -1;
}
@@ -74,10 +78,10 @@
"[writeable={y|N} [guest_ok={y|N} [<comment>]]\n"
"\t<sharename> the new share name.\n"
"\t<path> the path on the filesystem to export.\n"
- "\twriteable={y|N} set \"writeable to \"yes\" or "
- "\"no\" (default) on this share.\n"
- "\tguest_ok={y|N} set \"guest ok\" to \"yes\" or "
- "\"no\" (default) on this share.\n"
+ "\twriteable={y|N} set \"writeable to \"yes\" or "
+ "\"no\" (default) on this share.\n"
+ "\tguest_ok={y|N} set \"guest ok\" to \"yes\" or "
+ "\"no\" (default) on this share.\n"
"\t<comment> optional comment for the new share.\n");
return -1;
}
@@ -280,7 +284,7 @@
return werr;
}
-static int import_process_service(struct share_params *share)
+static int import_process_service(struct share_params *share, BOOL testmode)
{
int ret = -1;
struct parm_struct *parm;
@@ -444,19 +448,48 @@
{
int ret = -1;
const char *filename = NULL;
+ const char *servicename = NULL;
+ BOOL service_found = False;
TALLOC_CTX *ctx;
struct share_iterator *shares;
struct share_params *share;
struct share_params global_share = { GLOBAL_SECTION_SNUM };
+ BOOL testmode = False;
ctx = talloc_init("net_conf_import");
- if (argc != 1) {
- net_conf_import_usage(argc, argv);
- goto done;
+ switch (argc) {
+ case 0:
+ default:
+ net_conf_import_usage(argc, argv);
+ goto done;
+ case 1:
+ filename = argv[0];
+ break;
+ case 2:
+ if (strequal(argv[0], "-t")) {
+ testmode = True;
+ filename = argv[1];
+ }
+ else {
+ filename = argv[0];
+ servicename = argv[1];
+ }
+ break;
+ case 3:
+ servicename = argv[2];
+ filename = argv[1];
+ if (strequal(argv[0], "-t")) {
+ testmode = True;
+ filename = argv[1];
+ }
+ else {
+ net_conf_import_usage(argc, argv);
+ goto done;
+ }
+ break;
}
- filename = argv[0];
DEBUG(3,("net_conf_import: reading configuration from file %s.\n",
filename));
@@ -472,7 +505,15 @@
goto done;
}
- if (import_process_service(&global_share) != 0) {
+ if ((servicename == NULL) || strequal(servicename, GLOBAL_NAME)) {
+ service_found = True;
+ if (import_process_service(&global_share, testmode) != 0) {
+ goto done;
+ }
+ }
+
+ if (service_found && (servicename != NULL)) {
+ ret = 0;
goto done;
}
@@ -481,10 +522,22 @@
goto done;
}
while ((share = next_share(shares)) != NULL) {
- if (import_process_service(share)!= 0) {
- goto done;
+ if ((servicename == NULL)
+ || strequal(servicename, lp_servicename(share->service)))
+ {
+ service_found = True;
+ if (import_process_service(share, testmode)!= 0) {
+ goto done;
+ }
}
}
+
+ if ((servicename != NULL) && !service_found) {
+ d_printf("Share %s not found in file %s\n",
+ servicename, filename);
+ goto done;
+
+ }
ret = 0;
More information about the samba-cvs
mailing list