[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Wed Mar 24 23:23:34 MDT 2010


The branch, master has been updated
       via  6199ae4... s4-ldb: fixed command line parsing in oLschema2ldif
       via  3b29f9c... s4-ldb: removed unused command line options -I and -O
       via  8e1d947... s4-drs: If we are a RODC then do not send DSReplicaSync messages
      from  088096d... python: use '#!/usr/bin/env python' to cope with varying install locations

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6199ae474589f24180002a22f9c197ab973447b7
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Mar 25 15:45:08 2010 +1100

    s4-ldb: fixed command line parsing in oLschema2ldif
    
    It really doesn't make sense to use the ldb command line code

commit 3b29f9c66e68abff8c49390d97b71b4762d28417
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Mar 25 15:06:40 2010 +1100

    s4-ldb: removed unused command line options -I and -O
    
    These are not used anywehere, so they just confuse people
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 8e1d94778702ac2ab18983abac630957d8782cf6
Author: Fernando J V da Silva <fernandojvsilva at yahoo.com.br>
Date:   Wed Mar 24 13:02:36 2010 -0300

    s4-drs: If we are a RODC then do not send DSReplicaSync messages

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/repl/drepl_service.c |   19 ++++++----
 source4/lib/ldb/tools/cmdline.c   |    2 -
 source4/lib/ldb/tools/cmdline.h   |    2 -
 source4/utils/oLschema2ldif.c     |   70 +++++++++++++++++++++++++++----------
 4 files changed, 62 insertions(+), 31 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c
index 3ed5885..4196f94 100644
--- a/source4/dsdb/repl/drepl_service.c
+++ b/source4/dsdb/repl/drepl_service.c
@@ -193,14 +193,17 @@ static void dreplsrv_task_init(struct task_server *task)
 		return;
 	}
 
-	service->notify.interval = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", 
-					       "notify_interval", 5); /* in seconds */
-	status = dreplsrv_notify_schedule(service, service->notify.interval);
-	if (!W_ERROR_IS_OK(status)) {
-		task_server_terminate(task, talloc_asprintf(task,
-				      "dreplsrv: Failed to setup notify schedule: %s\n",
-							    win_errstr(status)), true);
-		return;
+	/* if we are a RODC then we do not send DSReplicaSync*/
+	if (!samdb_rodc(service->samdb)) {
+		service->notify.interval = lp_parm_int(task->lp_ctx, NULL, "dreplsrv",
+							   "notify_interval", 5); /* in seconds */
+		status = dreplsrv_notify_schedule(service, service->notify.interval);
+		if (!W_ERROR_IS_OK(status)) {
+			task_server_terminate(task, talloc_asprintf(task,
+						  "dreplsrv: Failed to setup notify schedule: %s\n",
+									win_errstr(status)), true);
+			return;
+		}
 	}
 
 	irpc_add_name(task->msg_ctx, "dreplsrv");
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index 869d5ca..180923f 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -56,8 +56,6 @@ static struct poptOption popt_options[] = {
 	{ "all", 'a',    POPT_ARG_NONE, &options.all_records, 0, "(|(objectClass=*)(distinguishedName=*))", NULL },
 	{ "nosync", 0,   POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL },
 	{ "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL },
-	{ "input", 'I', POPT_ARG_STRING, &options.input, 0, "Input File", "Input" },
-	{ "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" },
 	{ NULL,    'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" },
 	{ "controls", 0, POPT_ARG_STRING, NULL, 'c', "controls", NULL },
 	{ "show-binary", 0, POPT_ARG_NONE, &options.show_binary, 0, "display binary LDIF", NULL },
diff --git a/source4/lib/ldb/tools/cmdline.h b/source4/lib/ldb/tools/cmdline.h
index 52e7ece..e82b2ee 100644
--- a/source4/lib/ldb/tools/cmdline.h
+++ b/source4/lib/ldb/tools/cmdline.h
@@ -41,8 +41,6 @@ struct ldb_cmdline {
 	int num_records;
 	int num_searches;
 	const char *sasl_mechanism;
-	const char *input;
-	const char *output;
 	const char **controls;
 	int show_binary;
 	int tracing;
diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c
index 077987a..29ed3bd 100644
--- a/source4/utils/oLschema2ldif.c
+++ b/source4/utils/oLschema2ldif.c
@@ -37,6 +37,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "../lib/crypto/sha256.h"
 #include "../librpc/gen_ndr/ndr_misc.h"
+#include "lib/cmdline/popt_common.h"
 
 #define SCHEMA_UNKNOWN 0
 #define SCHEMA_NAME 1
@@ -583,55 +584,86 @@ static struct schema_conv process_file(FILE *in, FILE *out)
 	return ret;
 }
 
+static struct options {
+	const char *basedn;
+	const char *input;
+	const char *output;
+} options;
+
+static struct poptOption popt_options[] = {
+	POPT_AUTOHELP
+	{ "basedn",    'b', POPT_ARG_STRING, &options.basedn, 0, "base DN", "DN" },
+	{ "input", 'I', POPT_ARG_STRING, &options.input, 0, 
+	  "inputfile of OpenLDAP style schema otherwise STDIN", "inputfile"},
+	{ "output", 'O', POPT_ARG_STRING, &options.output, 0, 
+	  "outputfile otherwise STDOUT", "outputfile"},
+	POPT_COMMON_VERSION
+	{ NULL }
+};
+
+
 static void usage(void)
 {
-	printf("Usage: oLschema2ldif -H NONE <options>\n");
+	poptContext pc;
+	printf("Usage: oLschema2ldif <options>\n");
 	printf("\nConvert OpenLDAP schema to AD-like LDIF format\n\n");
-	printf("Options:\n");
-	printf("  -I inputfile     inputfile of OpenLDAP style schema otherwise STDIN\n");
-	printf("  -O outputfile    outputfile otherwise STDOUT\n");
-	printf("  -o options       pass options like modules to activate\n");
-	printf("              e.g: -o modules:timestamps\n");
-	printf("\n");
 	printf("Converts records from an openLdap formatted schema to an ldif schema\n\n");
+	pc = poptGetContext("oLschema2ldif", 0, NULL, popt_options, 
+			    POPT_CONTEXT_KEEP_FIRST);
+	poptPrintHelp(pc, stdout, 0);
 	exit(1);
 }
 
+
  int main(int argc, const char **argv)
 {
 	TALLOC_CTX *ctx;
 	struct schema_conv ret;
-	struct ldb_cmdline *options;
 	FILE *in = stdin;
 	FILE *out = stdout;
+	poptContext pc;
+	int opt;
+
 	ctx = talloc_new(NULL);
 	ldb_ctx = ldb_init(ctx, NULL);
 
 	setenv("LDB_URL", "NONE", 1);
-	options = ldb_cmdline_process(ldb_ctx, argc, argv, usage);
 
-	if (options->basedn == NULL) {
-		perror("Base DN not specified");
+	pc = poptGetContext(argv[0], argc, argv, popt_options, 
+			    POPT_CONTEXT_KEEP_FIRST);
+
+	while((opt = poptGetNextOpt(pc)) != -1) {
+		fprintf(stderr, "Invalid option %s: %s\n", 
+			poptBadOption(pc, 0), poptStrerror(opt));
+		usage();
+	}
+
+	if (options.basedn == NULL) {		
+		printf("Base DN not specified\n");
+		usage();
 		exit(1);
 	} else {
-		basedn = ldb_dn_new(ctx, ldb_ctx, options->basedn);
+		basedn = ldb_dn_new(ctx, ldb_ctx, options.basedn);
 		if ( ! ldb_dn_validate(basedn)) {
-			perror("Malformed Base DN");
+			printf("Malformed Base DN\n");
+			usage();
 			exit(1);
 		}
 	}
 
-	if (options->input) {
-		in = fopen(options->input, "r");
+	if (options.input) {
+		in = fopen(options.input, "r");
 		if (!in) {
-			perror(options->input);
+			perror(options.input);
+			usage();
 			exit(1);
 		}
 	}
-	if (options->output) {
-		out = fopen(options->output, "w");
+	if (options.output) {
+		out = fopen(options.output, "w");
 		if (!out) {
-			perror(options->output);
+			perror(options.output);
+			usage();
 			exit(1);
 		}
 	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list