summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2007-07-05 23:53:41 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2007-07-05 23:53:41 +0000
commitaf7e04a6b3f9eaa0994298de3ccb79a1a0cda114 (patch)
treefbb4a53bcd700f029de55ffcfe9f79f66188e3f0
parentaf10ba6ae36a6f50ff55be43da77fac0c38542a5 (diff)
downloadds-af7e04a6b3f9eaa0994298de3ccb79a1a0cda114.tar.gz
ds-af7e04a6b3f9eaa0994298de3ccb79a1a0cda114.tar.xz
ds-af7e04a6b3f9eaa0994298de3ccb79a1a0cda114.zip
Resolves: #246690
Summary: feature request for ldclt: add randomauthid for testing Description: Adding randomauthid options: -e "randomauthid" -e "randomauthidlow=<low>" -e "randomauthidhigh=<high>"
-rw-r--r--ldap/servers/slapd/tools/ldclt/ldapfct.c24
-rw-r--r--ldap/servers/slapd/tools/ldclt/ldclt.c65
-rw-r--r--ldap/servers/slapd/tools/ldclt/ldclt.h8
-rw-r--r--ldap/servers/slapd/tools/ldclt/ldcltU.c3
-rw-r--r--ldap/servers/slapd/tools/ldclt/threadMain.c23
5 files changed, 117 insertions, 6 deletions
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 4ba5965d..ada9bc00 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -807,6 +807,7 @@ connectToServer (
(mctx.mode & BIND_EACH_OPER))) {
void *defaults;
LDAPControl **rctrls = NULL;
+ char *my_saslauthid = NULL;
if ( mctx.sasl_mech == NULL) {
fprintf( stderr, "Please specify the SASL mechanism name when "
@@ -825,13 +826,32 @@ connectToServer (
}
}
+ /*
+ * Generate the random authid if set up so
+ */
+ if (mctx.mod2 & M2_RANDOM_SASLAUTHID)
+ {
+ rnd (tttctx->buf2, mctx.sasl_authid_low, mctx.sasl_authid_high,
+ mctx.sasl_authid_nbdigit);
+ strncpy (&(tttctx->bufSaslAuthid[tttctx->startSaslAuthid]),
+ tttctx->buf2, mctx.sasl_authid_nbdigit);
+ my_saslauthid = tttctx->bufSaslAuthid;
+ if (mctx.mode & VERY_VERBOSE)
+ printf ("ldclt[%d]: T%03d: Sasl Authid=\"%s\"\n",
+ mctx.pid, tttctx->thrdNum, tttctx->bufSaslAuthid);
+ }
+ else
+ {
+ my_saslauthid = mctx.sasl_authid;
+ }
+
defaults = ldaptool_set_sasl_defaults( tttctx->ldapCtx, mctx.sasl_flags, mctx.sasl_mech,
- mctx.sasl_authid, mctx.sasl_username, mctx.passwd, mctx.sasl_realm );
+ my_saslauthid, mctx.sasl_username, mctx.passwd, mctx.sasl_realm );
if (defaults == NULL) {
perror ("malloc");
exit (LDAP_NO_MEMORY);
}
-
+
ret = ldap_sasl_interactive_bind_ext_s( tttctx->ldapCtx, mctx.bindDN, mctx.sasl_mech,
NULL, NULL, mctx.sasl_flags,
ldaptool_sasl_interact, defaults, NULL );
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
index c4292467..e4991b45 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -1496,7 +1496,7 @@ basicInit (void)
} /*JLS 19-03-01*/
/*
- * Maybe random filter to prepear ?
+ * Maybe random filter to prepare ?
*/
if ((mctx.mode & (RANDOM | INCREMENTAL)) &&
(!(mctx.mod2 & M2_RDN_VALUE))) /*JLS 23-03-01*/
@@ -1510,7 +1510,7 @@ basicInit (void)
}
/*
- * Maybe random base DN to prepear ?
+ * Maybe random base DN to prepare ?
*/
if (mctx.mode & RANDOM_BASE)
{
@@ -1523,7 +1523,7 @@ basicInit (void)
}
/*
- * Maybe random bind DN to prepear ?
+ * Maybe random bind DN to prepare ?
*/
if (mctx.mode & RANDOM_BINDDN) /*JLS 05-01-01*/
{ /*JLS 05-01-01*/
@@ -1542,7 +1542,20 @@ basicInit (void)
} /*JLS 05-01-01*/
/*
- * Maybe an attribute replacement to prepear ?
+ * Maybe random authid to prepare ?
+ */
+ if (mctx.mod2 & M2_RANDOM_SASLAUTHID)
+ {
+ if (parseFilter (mctx.sasl_authid, &(mctx.sasl_authid_head),
+ &(mctx.sasl_authid_tail), &(mctx.sasl_authid_nbdigit)) < 0)
+ {
+ printf ("Error: cannot parse bind DN...\n");
+ return (-1);
+ }
+ }
+
+ /*
+ * Maybe an attribute replacement to prepare ?
*/
if (mctx.mode & ATTR_REPLACE) /*JLS 21-11-00*/
{ /*JLS 21-11-00*/
@@ -1753,6 +1766,8 @@ dumpModeValues (void)
printf (" ssl_with_client_authentication"); /* BK 23-11-00*/
if (mctx.mod2 & M2_SASLAUTH)
printf (" saslauth");
+ if (mctx.mod2 & M2_RANDOM_SASLAUTHID)
+ printf (" randomauthid");
if (mctx.mode & SMOOTHSHUTDOWN) /*JLS 17-11-00*/
printf (" smoothshutdown"); /*JLS 17-11-00*/
if (mctx.mode & DONT_SLEEP_DOWN) /*JLS 14-03-01*/
@@ -2206,6 +2221,12 @@ char *execParams[] = {
"randombinddnfromfile", /*JLS 03-05-01*/
#define EP_BINDONLY 45 /*JLS 04-05-01*/
"bindonly", /*JLS 04-05-01*/
+#define EP_RANDOMSASLAUTHID 46
+ "randomauthid",
+#define EP_RANDOMSASLAUTHIDHIGH 47
+ "randomauthidhigh",
+#define EP_RANDOMSASLAUTHIDLOW 48
+ "randomauthidlow",
NULL
};
@@ -2416,6 +2437,27 @@ decodeExecParams (
} /*JLS 12-01-01*/
mctx.bindDNLow = atoi (subvalue); /*JLS 05-01-01*/
break; /*JLS 05-01-01*/
+ case EP_RANDOMSASLAUTHID:
+ mctx.mod2 |= M2_RANDOM_SASLAUTHID;
+ break;
+ case EP_RANDOMSASLAUTHIDHIGH:
+ mctx.mod2 |= M2_RANDOM_SASLAUTHID;
+ if (subvalue == NULL)
+ {
+ fprintf(stderr,"Error: missing arg randomauthidhigh\n");
+ return (-1);
+ }
+ mctx.sasl_authid_high = atoi (subvalue);
+ break;
+ case EP_RANDOMSASLAUTHIDLOW:
+ mctx.mod2 |= M2_RANDOM_SASLAUTHID;
+ if (subvalue == NULL)
+ {
+ fprintf(stderr, "Error: missing arg randomauthidlow\n");
+ return (-1);
+ }
+ mctx.sasl_authid_low = atoi (subvalue);
+ break;
case EP_RDN: /*JLS 23-03-01*/
if (decodeRdnParam (subvalue) < 0) /*JLS 23-03-01*/
return (-1); /*JLS 23-03-01*/
@@ -2931,6 +2973,14 @@ main (
fprintf(stderr,"Error: use option -e randombinddnhigh=\n"); /*JLS 05-01-01*/
ldcltExit (EXIT_PARAMS); /*JLS 05-01-01*/
} /*JLS 05-01-01*/
+ if ((mctx.mod2 & M2_RANDOM_SASLAUTHID) &&
+ ((mctx.sasl_authid_low < 0) || (mctx.sasl_authid_high < 0)))
+ {
+ fprintf(stderr,"Error: missing ranges for randomauthid.\n");
+ fprintf(stderr,"Error: use option -e randomauthidlow=\n");
+ fprintf(stderr,"Error: use option -e randomauthidhigh=\n");
+ ldcltExit (EXIT_PARAMS); /*JLS 05-01-01*/
+ } /*JLS 05-01-01*/
if (mctx.mode & CLTAUTH) /* BK 23-11-00*/
{ /* BK 23-11-00*/
if (!(mctx.mode & SSL)) /* BK 23-11-00*/
@@ -3136,6 +3186,13 @@ main (
printf ("Bind passwd's head = \"%s\"\n", mctx.passwdHead);/*JLS 05-01-01*/
printf ("Bind passwd's tail = \"%s\"\n", mctx.passwdTail);/*JLS 05-01-01*/
} /*JLS 05-01-01*/
+ if (mctx.mod2 & M2_RANDOM_SASLAUTHID)
+ { /*JLS 05-01-01*/
+ printf ("Bind Authid's head = \"%s\"\n", mctx.sasl_authid_head);
+ printf ("Bind Authid's tail = \"%s\"\n", mctx.sasl_authid_tail);
+ printf ("Bind Authid's range = [%d , %d]\n",
+ mctx.sasl_authid_low, mctx.sasl_authid_high);
+ } /*JLS 05-01-01*/
if (mctx.mode & ATTR_REPLACE) /*JLS 21-11-00*/
{ /*JLS 21-11-00*/
printf ("Attribute's head = \"%s\"\n", mctx.attrplHead);/*JLS 21-11-00*/
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.h b/ldap/servers/slapd/tools/ldclt/ldclt.h
index 3b7a05cb..db2eb824 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.h
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.h
@@ -283,6 +283,7 @@ dd/mm/yy | Author | Comments
#define M2_RNDBINDFILE 0x00000010 /* -e randombinddnfromfile *//*JLS 03-05-01*/
#define M2_BINDONLY 0x00000020 /* -e bindonly */ /*JLS 04-05-01*/
#define M2_SASLAUTH 0x00000040 /* -o : SASL authentication */
+#define M2_RANDOM_SASLAUTHID 0x00000080 /* -e randomauthid */
/*
* Combinatory defines
@@ -563,6 +564,11 @@ typedef struct main_context {
int referral; /* Referral followed */ /*JLS 08-03-01*/
int sampling; /* Sampling frequency */
char *sasl_authid;
+ int sasl_authid_low; /* authid's low val */
+ int sasl_authid_high; /* authid's high val */
+ int sasl_authid_nbdigit; /* authid's ndigits */
+ char *sasl_authid_head; /* authid's head */
+ char *sasl_authid_tail; /* authid's tail */
unsigned sasl_flags;
char *sasl_mech;
char *sasl_realm;
@@ -636,6 +642,7 @@ typedef struct thread_context {
char *bufBindDN; /* Bind DN to use */ /*JLS 05-01-01*/
char *bufFilter; /* Filter to use */
char *bufPasswd; /* Bind passwd to use *//*JLS 05-01-01*/
+ char *bufSaslAuthid; /* Sasl Authid to use */
/*
* Note about matcheddnp management. This pointer is managed by the
* function dnFromMessage() that need it to free or remember the string
@@ -647,6 +654,7 @@ typedef struct thread_context {
int startBindDN; /* Insert random here *//*JLS 05-01-01*/
int startPasswd; /* Insert random here *//*JLS 05-01-01*/
int startRandom; /* Insert random here */
+ int startSaslAuthid; /* Insert random here */
msgid_cell *firstMsgId; /* pending messages */
msgid_cell *lastMsgId; /* last one */
} thread_context;
diff --git a/ldap/servers/slapd/tools/ldclt/ldcltU.c b/ldap/servers/slapd/tools/ldclt/ldcltU.c
index a91c74a5..c4ec8892 100644
--- a/ldap/servers/slapd/tools/ldclt/ldcltU.c
+++ b/ldap/servers/slapd/tools/ldclt/ldcltU.c
@@ -201,6 +201,9 @@ void usage ()
(void) printf (" string : create random strings rather than random numbers.\n");
(void) printf (" v2 : ldap v2.\n");
(void) printf (" withnewparent : rename with newparent specified as argument.\n");
+ (void) printf (" randomauthid : random SASL Authid.\n");
+ (void) printf (" randomauthidlow=value : low value for random SASL Authid.\n");
+ (void) printf (" randomauthidhigh=value : high value for random SASL Authid.\n");
(void) printf (" -f Filter for searches.\n");
(void) printf (" -h Host to connect. Default \"localhost\".\n");
(void) printf (" -i Number of times inactivity allowed. Default 3 (30 seconds)\n");
diff --git a/ldap/servers/slapd/tools/ldclt/threadMain.c b/ldap/servers/slapd/tools/ldclt/threadMain.c
index bdba2af9..f5af4bf7 100644
--- a/ldap/servers/slapd/tools/ldclt/threadMain.c
+++ b/ldap/servers/slapd/tools/ldclt/threadMain.c
@@ -1073,6 +1073,29 @@ threadMain (
mctx.passwd = "foo bar"; /* trick... */ /*JLS 03-05-01*/
} /*JLS 03-05-01*/
+ /*
+ * Variable Authid ?
+ */
+ if (mctx.sasl_authid != NULL)
+ {
+ tttctx->bufSaslAuthid = (char *) malloc (strlen (mctx.sasl_authid) + 1);
+ if (tttctx->bufSaslAuthid == NULL)
+ {
+ printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufSaslAuthid), error=%d (%s)\n",
+ mctx.pid, tttctx->thrdNum, errno, strerror (errno));
+ ldcltExit (EXIT_INIT);
+ }
+ if (!(mctx.mod2 & M2_RANDOM_SASLAUTHID))
+ strcpy (tttctx->bufSaslAuthid, mctx.sasl_authid);
+ else
+ {
+ tttctx->startSaslAuthid = strlen (mctx.sasl_authid_head);
+ strcpy (tttctx->bufSaslAuthid, mctx.sasl_authid_head);
+ strcpy (&(tttctx->bufSaslAuthid[tttctx->startSaslAuthid+mctx.sasl_authid_nbdigit]),
+ mctx.sasl_authid_tail);
+ }
+ }
+
/*
* Initiates the attribute replace buffers
*/