ldap/servers/slapd/tools/ldclt/ldapfct.c | 37 +++++-- ldap/servers/slapd/tools/ldclt/ldclt.c | 44 ++++++++- ldap/servers/slapd/tools/ldclt/ldclt.h | 15 ++- ldap/servers/slapd/tools/ldclt/threadMain.c | 6 - ldap/servers/slapd/tools/ldclt/utils.c | 4 ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in | 92 +++++++++---------- 6 files changed, 130 insertions(+), 68 deletions(-)
New commits: commit 09efabfbf2be9da9e02150782bcad1a7e8d96e79 Author: Rich Megginson rmeggins@redhat.com Date: Fri Jan 11 17:34:28 2013 -0700
Ticket #613 - ldclt: add timestamp, interval, nozeropad, other improvements
https://fedorahosted.org/389/ticket/613 Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: add new timestamp, interval, nozeropad options - fix interval added timestamp and sampinterval options -e timestamp[=strftime format] - add timestamp "|" to the beginning of every ldclt status update line -e sampinterval=SECS - print the status update line every SECS seconds allow specifying the value to use for the increment instead of 1 in incremental mode, rather than just incrementing the value by 1, allow specifying -e incr=value and use the value for the increment also wrap the lastVal number instead of just resetting to randomLow if the lastVal is > randomHigh. added -e nozeropad option ldclt will usually generate random numbers used in RDNs and values padded with 0 e.g. uid=XXXXX is uid=00001 - with the -e nozeropad option, this will turn uid=X or XX or .. into uid=1 - no zero padding increment based on low value was incorrectly computing wrap-around value Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: Yes
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c index 3f74fd0..f83a456 100644 --- a/ldap/servers/slapd/tools/ldclt/ldapfct.c +++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c @@ -442,7 +442,7 @@ buildNewBindDN ( if (mctx.mode & STRING) (void) randomString (tttctx, mctx.bindDNNbDigit); else - rnd (tttctx->buf2, mctx.bindDNLow, mctx.bindDNHigh, mctx.bindDNNbDigit); + rnd (tttctx->buf2, mctx.bindDNLow, mctx.bindDNHigh, (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.bindDNNbDigit);
/* * First, randomize the bind DN. @@ -991,7 +991,7 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPass */ if ((mod2 & M2_RANDOM_SASLAUTHID) && tttctx) { rnd (tttctx->buf2, mctx.sasl_authid_low, mctx.sasl_authid_high, - mctx.sasl_authid_nbdigit); + (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.sasl_authid_nbdigit); strncpy (&(tttctx->bufSaslAuthid[tttctx->startSaslAuthid]), tttctx->buf2, mctx.sasl_authid_nbdigit); my_saslauthid = tttctx->bufSaslAuthid; @@ -1324,7 +1324,7 @@ buildVersatileAttribute ( num = field->cnt; field->cnt++; /* Next value for next loop */ } - sprintf (tttctx->buf2, "%0*d", field->nb, num); + sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : field->nb, num); strcat (attrib->buf, tttctx->buf2); if (field->var != -1) strcpy (object->var[field->var], tttctx->buf2); @@ -1347,7 +1347,7 @@ buildVersatileAttribute ( num = field->cnt; field->cnt++; /* Next value for next loop */ } - sprintf (tttctx->buf2, "%0*d", field->nb, num); + sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : field->nb, num); strcat (attrib->buf, tttctx->buf2); if (field->var != -1) strcpy (object->var[field->var], tttctx->buf2); @@ -1359,7 +1359,7 @@ buildVersatileAttribute ( strcpy (object->var[field->var], field->dlf->str[num]); break; case HOW_RND_NUMBER: - rnd (tttctx->buf2, field->low, field->high, field->nb); + rnd (tttctx->buf2, field->low, field->high, (mctx.mod2 & M2_NOZEROPAD) ? 0 : field->nb); strcat (attrib->buf, tttctx->buf2); if (field->var != -1) strcpy (object->var[field->var], tttctx->buf2); @@ -1430,7 +1430,7 @@ buildRandomRdnOrFilter ( (void) randomString (tttctx, mctx.baseDNNbDigit); else rnd (tttctx->buf2, mctx.baseDNLow, mctx.baseDNHigh, /*JLS 14-11-00*/ - mctx.baseDNNbDigit); /*JLS 14-11-00*/ + (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.baseDNNbDigit); /*JLS 14-11-00*/ strncpy (&(tttctx->bufBaseDN[tttctx->startBaseDN]), tttctx->buf2, mctx.baseDNNbDigit); if (mctx.mode & VERY_VERBOSE) @@ -1481,9 +1481,12 @@ buildRandomRdnOrFilter ( (void) randomString (tttctx, mctx.randomNbDigit); else rnd (tttctx->buf2, mctx.randomLow, mctx.randomHigh, /*JLS 14-11-00*/ - mctx.randomNbDigit); /*JLS 14-11-00*/ + (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.randomNbDigit); /*JLS 14-11-00*/ strncpy (&(tttctx->bufFilter[tttctx->startRandom]), - tttctx->buf2, mctx.randomNbDigit); + tttctx->buf2, mctx.randomNbDigit); + if ((mctx.mod2 & M2_NOZEROPAD) && mctx.randomTail) { + strcat(tttctx->bufFilter, mctx.randomTail); + } if (mctx.mode & VERY_VERBOSE) printf ("ldclt[%d]: %s: random mode:filter="%s"\n", mctx.pid, tttctx->thrdId, tttctx->bufFilter); @@ -1496,11 +1499,11 @@ buildRandomRdnOrFilter ( val = incrementCommonCounter (tttctx); /*JLS 14-03-01*/ if (val == -1) /*JLS 14-03-01*/ return (-1); /*JLS 14-03-01*/ - sprintf (tttctx->buf2, "%0*d", mctx.randomNbDigit, val);/*JLS 14-03-01*/ + sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.randomNbDigit, val);/*JLS 14-03-01*/ } /*JLS 14-03-01*/ else /*JLS 14-03-01*/ { /*JLS 14-03-01*/ - tttctx->lastVal++; + tttctx->lastVal += mctx.incr; if (tttctx->lastVal > mctx.randomHigh) { if (!(mctx.mode & NOLOOP)) @@ -1511,16 +1514,19 @@ buildRandomRdnOrFilter ( * Well, there is no clean way to exit. Let's use the error * condition and hope all will be ok. */ - printf ("ldclt[%d]: %s: Hit top incrementeal value\n", + printf ("ldclt[%d]: %s: Hit top incremental value\n", mctx.pid, tttctx->thrdId); return (-1); } } - sprintf (tttctx->buf2, "%0*d", mctx.randomNbDigit, tttctx->lastVal); + sprintf (tttctx->buf2, "%0*d", (mctx.mod2 & M2_NOZEROPAD) ? 0 : mctx.randomNbDigit, tttctx->lastVal); } /*JLS 14-03-01*/
strncpy (&(tttctx->bufFilter[tttctx->startRandom]), tttctx->buf2, mctx.randomNbDigit); + if ((mctx.mod2 & M2_NOZEROPAD) && mctx.randomTail) { + strcat(tttctx->bufFilter, mctx.randomTail); + } if (mctx.mode & VERY_VERBOSE) printf ("ldclt[%d]: %s: incremental mode:filter="%s"\n", mctx.pid, tttctx->thrdId, tttctx->bufFilter); @@ -3919,6 +3925,7 @@ doExactSearch ( } else { /* if search success & we are in verbose mode */ + int nentries = 0; if (mctx.mode & VERBOSE) { for (e = ldap_first_message (tttctx->ldapCtx, res); e != NULL ; e = ldap_next_message (tttctx->ldapCtx, e) ) @@ -3928,6 +3935,7 @@ doExactSearch ( { /* if this is an entry that returned */ case LDAP_RES_SEARCH_ENTRY: + nentries++; /* get dereferenced value into resctrls: deref parsing */ parse_rc = ldap_get_entry_controls ( tttctx->ldapCtx, e, &resctrls ); if ( resctrls != NULL ) @@ -3975,6 +3983,11 @@ doExactSearch ( } /*end of message retriving */ } /* end of verbose mode */
+ if ((mctx.srch_nentries > -1) && (mctx.srch_nentries != nentries)) { + printf ("Error: search returned %d entries not the requested %d entries\n", nentries, mctx.srch_nentries); + goto bail; + } + if (incrementNbOpers (tttctx) < 0)/* Memorize operation */ { goto bail; diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c index 27a2412..ecad6b5 100644 --- a/ldap/servers/slapd/tools/ldclt/ldclt.c +++ b/ldap/servers/slapd/tools/ldclt/ldclt.c @@ -777,10 +777,21 @@ monitorThem (void) int nbOpersTot; /* Total nb of operations */ int allDead = 0; /* All threads are dead */ int status; /* Thread's status */ /*JLS 17-11-00*/ + time_t t; + struct tm *tmstr; + char timestamp[128];
while (!allDead) { ldclt_sleep (mctx.sampling); + if (mctx.tsfmt) { + t = time(NULL); + tmstr = localtime(&t); + strftime(timestamp, sizeof(timestamp), mctx.tsfmt, tmstr); + } else { + timestamp[0] = '\0'; + } + nbOpersTot = 0; allDead = 1; /* Assume all threads are dead */
@@ -853,7 +864,8 @@ monitorThem (void) /* * Summary of operations */ - printf ("ldclt[%d]: Average rate: %7.2f/thr (%7.2f/sec), total: %6d\n", + printf ("%s%sldclt[%d]: Average rate: %7.2f/thr (%7.2f/sec), total: %6d\n", + timestamp, mctx.tsfmt ? "|" : "", mctx.pid, (float)nbOpersTot/(float)mctx.nbThreads, (float)nbOpersTot/(float)mctx.sampling, nbOpersTot); fflush (stdout); @@ -1355,7 +1367,7 @@ basicInit (void) fflush (stderr); /*JLS 14-03-01*/ return (-1); /*JLS 14-03-01*/ } /*JLS 14-03-01*/ - mctx.lastVal = mctx.randomLow-1; /*JLS 14-03-01*/ + mctx.lastVal = mctx.randomLow-mctx.incr; /*JLS 14-03-01*/ } /*JLS 14-03-01*/
/* @@ -2251,6 +2263,14 @@ char *execParams[] = { "deref", #define EP_ATT_REPLACE_FILE 51 "attreplacefile", +#define EP_SRCH_NENTRIES 52 /* number of entries that must be returned by each search */ + "srchnentries", +#define EP_SAMP_INTERVAL 53 /* sampling interval */ + "sampinterval", +#define EP_TIMESTAMP 54 /* show timestamp when reporting progress */ + "timestamp", +#define EP_NOZEROPAD 55 /* do not zero pad numbers created by XXX patterns in values and RDNs */ + "nozeropad", NULL };
@@ -2357,6 +2377,8 @@ decodeExecParams ( break; /*JLS 16-11-00*/ case EP_INCREMENTAL: mctx.mode |= INCREMENTAL; + if (subvalue) + mctx.incr = atoi (subvalue); break; case EP_KEYDB_FILE: /* BK 23-11-00*/ mctx.mode |= CLTAUTH; /* BK 23-11-00*/ @@ -2385,6 +2407,9 @@ decodeExecParams ( case EP_NOLOOP: mctx.mode |= NOLOOP; break; + case EP_NOZEROPAD: + mctx.mod2 |= M2_NOZEROPAD; + break; case EP_OBJECT: /*JLS 19-03-01*/ mctx.mod2 |= M2_OBJECT; /*JLS 19-03-01*/ if (subvalue == NULL) /*JLS 19-03-01*/ @@ -2554,6 +2579,19 @@ decodeExecParams ( mctx.attrpl = NULL; } break; + case EP_SRCH_NENTRIES: + mctx.srch_nentries = atoi (subvalue); + break; + case EP_SAMP_INTERVAL: + mctx.sampling = atoi (subvalue); + break; + case EP_TIMESTAMP: + if (subvalue) { + mctx.tsfmt = strdup (subvalue); + } else { + mctx.tsfmt = strdup (DEFAULT_TIMESTAMP_FMT); + } + break; default: fprintf (stderr, "Error: illegal option -e %s\n", subvalue); return (-1); @@ -2683,6 +2721,7 @@ main ( mctx.images = NULL; /*JLS 17-11-00*/ mctx.imagesDir = DEF_IMAGES_PATH; /*JLS 16-11-00*/ mctx.inactivMax = DEF_INACTIV_MAX; + mctx.incr = 1; mctx.maxErrors = DEF_MAX_ERRORS; mctx.mode = NOTHING; mctx.mod2 = NOTHING; @@ -2706,6 +2745,7 @@ main ( mctx.scope = DEF_SCOPE; mctx.slaveConn = 0; mctx.slavesNb = 0; + mctx.srch_nentries = -1; mctx.timeout = DEF_TIMEOUT; mctx.totalReq = -1; mctx.waitSec = 0; diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.h b/ldap/servers/slapd/tools/ldclt/ldclt.h index 0426a1a..71ff06d 100644 --- a/ldap/servers/slapd/tools/ldclt/ldclt.h +++ b/ldap/servers/slapd/tools/ldclt/ldclt.h @@ -277,9 +277,10 @@ dd/mm/yy | Author | Comments #define M2_BINDONLY 0x00000020 /* -e bindonly */ /*JLS 04-05-01*/ #define M2_SASLAUTH 0x00000040 /* -o : SASL authentication */ #define M2_RANDOM_SASLAUTHID 0x00000080 /* -e randomauthid */ -#define M2_ABANDON 0x00000100 /* -e abandon */ -#define M2_DEREF 0x00000200 /* -e deref */ +#define M2_ABANDON 0x00000100 /* -e abandon */ +#define M2_DEREF 0x00000200 /* -e deref */ #define M2_ATTR_REPLACE_FILE 0x00000400 /* -e attreplacefile */ +#define M2_NOZEROPAD 0x00000800 /* -e nozeropad */
/* * Combinatory defines @@ -511,7 +512,7 @@ typedef struct main_context { char *attrpl; /* Attrib argument */ /*JLS 21-11-00*/ char *attrplFile; /* Attrib file to get value from */ char *attrplFileContent; /* Attrib file content */ - int attrplFileSize; /* Attrib file size*/ + int attrplFileSize; /* Attrib file size*/ char *attrplHead; /* Attrib value head */ /*JLS 21-11-00*/ char *attrplName; /* Attrib name */ /*JLS 21-11-00*/ int attrplNbDigit; /* Attrib nb digits */ /*JLS 21-11-00*/ @@ -549,8 +550,9 @@ typedef struct main_context { int imagesLast; /* Last selected image */ ldclt_mutex_t imagesLast_mutex; /* Protect imagesLast */ int inactivMax; /* Allowed inactivity */ - char *keydbfile; /* key DB file */ /* BK 23-11-00*/ - char *keydbpin; /* key DB password */ /* BK 23-11-00*/ + int incr; /* in incremental mode, number to use to increment (default 1) */ + char *keydbfile; /* key DB file */ /* BK 23-11-00*/ + char *keydbpin; /* key DB password */ /* BK 23-11-00*/ int lastVal; /* To build filters */ /*JLS 14-03-01*/ ldclt_mutex_t lastVal_mutex; /* Protect lastVal */ /*JLS 14-03-01*/ int ldapauth; /* Used to indicate auth type */ @@ -593,12 +595,15 @@ typedef struct main_context { int slaveConn; /* Slave has connected */ char *slaves[MAX_SLAVES]; /* Slaves list */ int slavesNb; /* Number of slaves */ + int srch_nentries; /* number of entries that must be returned by each search op */ int timeout; /* LDAP op. t.o. */ struct timeval timeval; /* Timeval structure */ struct timeval timevalZero; /* Timeout of zero */ int totalReq; /* Total requested */ int totNbOpers; /* Total opers number */ int totNbSamples; /* Total samples nb */ +#define DEFAULT_TIMESTAMP_FMT "%s" + char *tsfmt; /* if non-null, use this strftime format to print timestamps for status updates */ int waitSec; /* Wait between two operations */ } main_context;
diff --git a/ldap/servers/slapd/tools/ldclt/threadMain.c b/ldap/servers/slapd/tools/ldclt/threadMain.c index a335b19..3b53a62 100644 --- a/ldap/servers/slapd/tools/ldclt/threadMain.c +++ b/ldap/servers/slapd/tools/ldclt/threadMain.c @@ -343,17 +343,17 @@ incrementCommonCounter ( /* * Compute next value */ - if ((mctx.mode & NOLOOP) && (mctx.lastVal == mctx.randomHigh)) + if ((mctx.mode & NOLOOP) && (mctx.lastVal >= mctx.randomHigh)) val = -1; else { - mctx.lastVal++; + mctx.lastVal += mctx.incr; if (mctx.lastVal > mctx.randomHigh) { if (mctx.mode & NOLOOP) val = -1; else - mctx.lastVal = mctx.randomLow; + mctx.lastVal -= (mctx.randomHigh-mctx.incr) + mctx.randomLow; } val = mctx.lastVal; } diff --git a/ldap/servers/slapd/tools/ldclt/utils.c b/ldap/servers/slapd/tools/ldclt/utils.c index 26ae85c..3e3d60b 100644 --- a/ldap/servers/slapd/tools/ldclt/utils.c +++ b/ldap/servers/slapd/tools/ldclt/utils.c @@ -199,10 +199,10 @@ rndlim ( arguments. The string is returned in the buffer. INPUT : low = low limit high = high limit - ndigits = number of digits + ndigits = number of digits - 0 means no zero pad OUTPUT : buf = buffer to write the random string. Note that it is generated with fixed number of digits, - completed with leading '0'. + completed with leading '0', if ndigits > 0 RETURN : None. DESCRIPTION : *****************************************************************************/
commit ee20c8fbf0b36bd42b0b601aa7effec402da5113 Author: Rich Megginson rmeggins@redhat.com Date: Fri Jan 11 17:33:07 2013 -0700
Ticket #612 - improve dbgen rdn generation, output
https://fedorahosted.org/389/ticket/612 Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: added ability to create rdn values as sequential numbers - output to stdout added the -b flag which not only specifies the beginning number but makes the RDN values increasing numbers with optional 0 padding (as used by ldclt) using -o - will output to stdout if not using verbose, will only print out ldif Platforms tested: RHEL6 x86_64 Flag Day: no Doc impact: Yes
diff --git a/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in b/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in index e500abe..ce18f7c 100755 --- a/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in +++ b/ldap/servers/slapd/tools/rsearch/scripts/dbgen.pl.in @@ -60,8 +60,14 @@ sub PrintUsage { print STDERR "Usage: $0 [options] -o output_file -n number\n", "\t Where options are:\n", + "\t -o filename output file\n", "\t -s suffix, default is 'dc=example,dc=com'\n", "\t -c for CN naming style RDN's : default is UID\n", + "\t -z extra objectclasses to add to base used in -O - should be AUXILIARY or SUB\n", + "\t -j 0 pad numbers used in RDN to this many digits e.g. with 4 1 becomes 0001\n", + "\t -m naming attribute for RDN\n", + "\t -n number of entries to generate\n", + "\t -b beginning number for RDN (default 1 - ending number is -n value)\n", "\t -O for organizationalPersons, default is inetOrgPerson\n", "\t -p for piranha style aci's, default is barracuda\n", "\t -r seed---seed number for random number generator\n", @@ -529,7 +535,7 @@ my $mycert =
require "flush.pl"; require "getopts.pl"; -&Getopts('n:o:s:r:cOvpqgxyl:'); +&Getopts('n:o:s:r:cOvpqgxyl:z:m:b:j:');
$Number_To_Generate = $opt_n; $Verbose = $opt_v; @@ -541,9 +547,16 @@ $debug = $opt_d; $Suffix = $opt_s || 'dc=example,dc=com'; $NamingType = "cn" if ($opt_c); $NamingType = "uid" if (!$opt_c); +$NamingType = $opt_m if ($opt_m); $inetOrgPerson = "objectClass: inetOrgPerson\n" if (!$opt_O); $PrintOrgChartDat = $opt_g; $DataDir = $opt_l || "@templatedir@"; +$ExtraObjClasses = ""; +if ($opt_z) { + $ExtraObjClasses = join "\n", map { "objectClass: $_" } split(/ /, $opt_z); + $ExtraObjClasses .= "\n"; +} +$BeginNum = $opt_b || 0; $printpreamble = 1; if ("" != $opt_x) { @@ -554,6 +567,7 @@ if ("" != $opt_y) { $printorgunit = 0; } +$ZeroPad = $opt_j;
if ($Suffix =~ /o=/) { ($Organization) = $Suffix =~ /o=([^,]+)/; @@ -580,6 +594,13 @@ if ( (!$Number_To_Generate) || (!$Output_File_Name)) { &PrintUsage; }
+if ($Output_File_Name eq '-') { + *OUTPUT_FILE = *STDOUT; +} else { + open (OUTPUT_FILE, ">>$Output_File_Name") || + die "Error---Can't open output file $Output_File_Name\n"; +} + srand($Random_Seed);
print "Loading Name Data...\n" if $Verbose; @@ -604,9 +625,6 @@ if ($printpreamble) } }
-open (OUTPUT_FILE, ">>$Output_File_Name") || - die "Error---Can't open output file $Output_File_Name\n"; - if ($printorgunit) { &PrintOrganizationalUnits; @@ -655,9 +673,9 @@ if ($PrintOrgChartDat) } }
-print "Generating $Number_To_Generate entries, please wait\n"; +print "Generating $Number_To_Generate entries, please wait\n" if $Verbose;
-print "Progress: "; +print "Progress: " if $Verbose; # We don't want people with duplicate names, so for each name generated, # add it to "TheMap", which is an associative array with the # name as the key. If there's a duplicate, throw the name out and @@ -670,7 +688,7 @@ $dups = 0;
# CHANGED: updated to allow for uid naming style or cn style. Check the RDN for uniqueness -for ($x= 0; $x < $Number_To_Generate; $x++) { +for ($x= $BeginNum; $x < ($Number_To_Generate+$BeginNum); $x++) {
($givenName, $sn, $cn, $uid, $rdn,) = &MakeRandomName; if (&AddAndCheck($rdn)) { @@ -729,10 +747,10 @@ for ($x= 0; $x < $Number_To_Generate; $x++) { $userPassword = "$uid\n"; }
- if ($PrintOrgChartDat) { - $dnstr = "dn: $NamingType=$rdn, ou=People, $Suffix\n", + if ($PrintOrgChartDat or !$printorgunit) { + $dnstr = "dn: $NamingType=$rdn,ou=People,$Suffix\n", } else { - $dnstr = "dn: $NamingType=$rdn, ou=$OrgUnit, $Suffix\n"; + $dnstr = "dn: $NamingType=$rdn,ou=$OrgUnit,$Suffix\n"; }
print OUTPUT_FILE @@ -740,7 +758,7 @@ for ($x= 0; $x < $Number_To_Generate; $x++) { "objectClass: top\n", "objectClass: person\n", "objectClass: organizationalPerson\n", - $inetOrgPerson, + $inetOrgPerson, $ExtraObjClasses, "cn: $cn\n", "sn: $sn\n", "uid: $uid\n", @@ -769,15 +787,15 @@ for ($x= 0; $x < $Number_To_Generate; $x++) {
if (!$Quiet) { if ($x % 1000 == 0) { - print "."; + print "." if $Verbose; &flush(STDOUT); } }
}
-print "\n"; -print "Generated $x entries\n"; +print "\n" if $Verbose; +print "Generated $x entries\n" if $Verbose;
if ($Verbose) { print "$dups duplicates skipped\n"; @@ -825,7 +843,6 @@ sub ReadFamilyNames { sub PrintPreAmblePiranha { local($output_file) = @_;
- open (OUTPUT_FILE, ">$output_file") || die "Can't open $output_file for writing $!\n"; print OUTPUT_FILE<<End_Of_File dn: $Suffix objectClass: top @@ -836,17 +853,12 @@ subtreeaci: +(privilege=compare) subtreeaci: +(|(privilege=search)(privilege=read))
End_Of_File - ; - - close (OUTPUT_FILE); - + ; }
sub PrintPreAmbleBarracuda { local($output_file) = @_;
- open (OUTPUT_FILE, ">$output_file") || die "Can't open $output_file for writing $!\n"; - print OUTPUT_FILE<<End_Of_File dn: $Suffix objectClass: top @@ -858,14 +870,11 @@ aci: (target=ldap:///$Suffix)(targetattr=*)(version 3.0; acl "acl3"; allow(read,
End_Of_File ; - close (OUTPUT_FILE); }
sub PrintPreAmbleNoACI { local($output_file) = @_;
- open (OUTPUT_FILE, ">$output_file") || die "Can't open $output_file for writing $!\n"; - print OUTPUT_FILE<<End_Of_File dn: $Suffix objectClass: top @@ -874,8 +883,6 @@ o: $Organization
End_Of_File ; - close (OUTPUT_FILE); - }
@@ -883,14 +890,14 @@ End_Of_File sub PrintOrganizationalUnits { foreach $ou (@OrganizationalUnits) { print OUTPUT_FILE - "dn: ou=$ou, $Suffix\n", + "dn: ou=$ou,$Suffix\n", "objectClass: top\n", "objectClass: organizationalUnit\n", "ou: $ou\n\n"; } if ($PrintOrgChartDat) { print OUTPUT_FILE - "dn: ou=People, $Suffix\n", + "dn: ou=People,$Suffix\n", "objectClass: top\n", "objectClass: organizationalUnit\n", "ou: People\n\n"; @@ -938,7 +945,7 @@ sub PrintManagers { $userPassword = "$uid\n"; }
- $dnstr = "dn: $NamingType=$rdn, ou=People, $Suffix\n"; + $dnstr = "dn: $NamingType=$rdn,ou=People,$Suffix\n"; if ("" ne $orgUnit) { $oustr = "ou: $orgUnit\n"; } @@ -997,22 +1004,22 @@ sub MakeRandomName { $Given_Name = $given_names[rand @given_names]; $Surname = $family_names[rand @family_names]; $Full_Name = "$Given_Name $Surname"; + $first = substr($Given_Name, 0,1); + $last = substr($Surname, 0,8); + $UID = $first . $last . "$uniq";
# Create the uid based on the DN naming type defined - if ($NamingType eq "uid") { - $first = substr($Given_Name, 0,1); - $last = substr($Surname, 0,8); - $UID = $first . $last . "$uniq"; + if ($opt_b) { # use a uniquenumber for the RDN value + if ($ZeroPad) { + $RDN = sprintf "%0.${ZeroPad}d", $x; + } else { + $RDN = $x; + } + } elsif ($NamingType eq "uid") { $RDN = $UID; + } else { + $RDN = $Full_Name; } - else - { - $first = substr($Given_Name, 0,1); - $last = substr($Surname, 0,8); - $UID = $first . $last . "$uniq"; - $RDN = $Full_Name; - } -
return ($Given_Name, $Surname, $Full_Name, $UID, $RDN); } @@ -1098,6 +1105,3 @@ sub MakeInitials { ($last) = $sn =~ /^(\w).*/; return "$first" . ". " . "$last" . "."; } - - -
389-commits@lists.fedoraproject.org