From: Pierangelo Masarati Date: Tue, 28 Aug 2007 19:35:57 +0000 (+0000) Subject: add -S to slapadd to set desired SID in generated entryCSN/contextCSN X-Git-Tag: OPENLDAP_REL_ENG_2_4_MP~50 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a6fd7fa95a0e04653fe33f396909c7077fcc90c8;p=openldap add -S to slapadd to set desired SID in generated entryCSN/contextCSN --- diff --git a/doc/man/man8/slapadd.8 b/doc/man/man8/slapadd.8 index 48c418f4ac..7cecd3d527 100644 --- a/doc/man/man8/slapadd.8 +++ b/doc/man/man8/slapadd.8 @@ -18,6 +18,7 @@ slapadd \- Add entries to a SLAPD database .B [\-o name[=value] .B [\-q] .B [\-s] +.B [\-S SID] .B [\-u] .B [\-v] .B [\-w] @@ -119,6 +120,10 @@ databases containing special objects, such as fractional objects on a partial replica. Loading normal objects which do not conform to schema may result in unexpected and ill behavior. .TP +.B \-S " SID" +Server ID to use in generated entryCSN. Also used for contextCSN +if `\-w' is set as well. Defaults to 0. +.TP .B \-u enable dry-run (don't write to backend) mode. .TP diff --git a/servers/slapd/slapadd.c b/servers/slapd/slapadd.c index a758955224..5f8d6be364 100644 --- a/servers/slapd/slapadd.c +++ b/servers/slapd/slapadd.c @@ -67,6 +67,9 @@ slapadd( int argc, char **argv ) int rc = EXIT_SUCCESS; int manage = 0; + /* default "000" */ + csnsid = 0; + slap_tool_init( progname, SLAPADD, argc, argv ); memset( &opbuf, 0, sizeof(opbuf) ); @@ -220,7 +223,7 @@ slapadd( int argc, char **argv ) nvals[1].bv_len = 0; nvals[1].bv_val = NULL; - csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 ); + csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), csnsid, 0 ); csn.bv_val = csnbuf; timestamp.bv_val = timebuf; diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index 5df0045557..adf5a60323 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -241,7 +241,7 @@ slap_tool_init( switch( tool ) { case SLAPADD: - options = "b:cd:f:F:gj:l:n:o:qstuvw"; + options = "b:cd:f:F:gj:l:n:o:qsS:tuvw"; break; case SLAPCAT: @@ -384,6 +384,14 @@ slap_tool_init( realm = optarg; break; + case 'S': + if ( lutil_atoul( &csnsid, optarg ) + || csnsid > SLAP_SYNC_SID_MAX ) + { + usage( tool, progname ); + } + break; + case 's': /* dump subtree */ if ( tool == SLAPADD ) mode |= SLAP_TOOL_NO_SCHEMA_CHECK; diff --git a/servers/slapd/slapcommon.h b/servers/slapd/slapcommon.h index 0fc4f09e15..d48d217975 100644 --- a/servers/slapd/slapcommon.h +++ b/servers/slapd/slapcommon.h @@ -60,6 +60,7 @@ typedef struct tool_vars { slap_ssf_t tv_tls_ssf; slap_ssf_t tv_sasl_ssf; unsigned tv_dn_mode; + unsigned int tv_csnsid; } tool_vars; extern tool_vars tool_globals; @@ -91,6 +92,7 @@ extern tool_vars tool_globals; #define tls_ssf tool_globals.tv_tls_ssf #define sasl_ssf tool_globals.tv_sasl_ssf #define dn_mode tool_globals.tv_dn_mode +#define csnsid tool_globals.tv_csnsid #define SLAP_TOOL_LDAPDN_PRETTY SLAP_LDAPDN_PRETTY #define SLAP_TOOL_LDAPDN_NORMAL (SLAP_LDAPDN_PRETTY << 1)