[Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools/ldclt ldapfct.c, 1.3, 1.4 ldclt.c, 1.4, 1.5 ldclt.h, 1.3, 1.4 ldcltU.c, 1.3, 1.4 threadMain.c, 1.2, 1.3

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Thu Jul 5 23:53:44 UTC 2007


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17002

Modified Files:
	ldapfct.c ldclt.c ldclt.h ldcltU.c threadMain.c 
Log Message:
Resolves: #246690
Summary: feature request for ldclt: add randomauthid for testing
Description: Adding randomauthid options: -e "randomauthid" -e "randomauthidlow=<low>" -e "randomauthidhigh=<high>"



Index: ldapfct.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/ldapfct.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ldapfct.c	8 Jun 2007 23:19:19 -0000	1.3
+++ ldapfct.c	5 Jul 2007 23:53:41 -0000	1.4
@@ -807,6 +807,7 @@
                                           (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 @@
       }
     }
 
+  /*
+   * 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 );


Index: ldclt.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/ldclt.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ldclt.c	8 Jun 2007 23:19:20 -0000	1.4
+++ ldclt.c	5 Jul 2007 23:53:41 -0000	1.5
@@ -1496,7 +1496,7 @@
     }								/*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 @@
   }
 
   /*
-   * Maybe random base DN to prepear ?
+   * Maybe random base DN to prepare ?
    */
   if (mctx.mode & RANDOM_BASE)
   {
@@ -1523,7 +1523,7 @@
   }
 
   /*
-   * 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 @@
   }								/*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 @@
     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 @@
 	"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 @@
 	}							/*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 @@
     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 @@
       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*/


Index: ldclt.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/ldclt.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ldclt.h	8 Jun 2007 23:19:20 -0000	1.3
+++ ldclt.h	5 Jul 2007 23:53:41 -0000	1.4
@@ -283,6 +283,7 @@
 #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 @@
 	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 @@
 	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 @@
 	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;


Index: ldcltU.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/ldcltU.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ldcltU.c	8 Jun 2007 23:19:20 -0000	1.3
+++ ldcltU.c	5 Jul 2007 23:53:41 -0000	1.4
@@ -201,6 +201,9 @@
   (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");


Index: threadMain.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/ldclt/threadMain.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- threadMain.c	10 Nov 2006 23:45:50 -0000	1.2
+++ threadMain.c	5 Jul 2007 23:53:41 -0000	1.3
@@ -1073,6 +1073,29 @@
     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
    */




More information about the Fedora-directory-commits mailing list