[Fedora-directory-commits] dsgw dosearch.c, 1.3, 1.4 dsgwutil.c, 1.7, 1.8 entrydisplay.c, 1.4, 1.5

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Fri Feb 1 17:04:24 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/dsgw
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv5375/dsgw

Modified Files:
	dosearch.c dsgwutil.c entrydisplay.c 
Log Message:
remove the hp host:port cgi parameter


Index: dosearch.c
===================================================================
RCS file: /cvs/dirsec/dsgw/dosearch.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- dosearch.c	14 Jan 2008 23:34:27 -0000	1.3
+++ dosearch.c	1 Feb 2008 17:04:22 -0000	1.4
@@ -41,7 +41,7 @@
 
 #include "dsgw.h"
 
-static void get_request(char* hostport, char *dn, char *ldapquery);
+static void get_request(char *dn, char *ldapquery);
 static void post_request();
 
 
@@ -54,7 +54,6 @@
 {
     int		reqmethod;
     char       *dn = NULL;
-    char       *hostport = NULL;
     char       *ldapquery = NULL;
     int     index = 0;
     char    *varname = NULL;
@@ -70,7 +69,6 @@
 
     reqmethod = dsgw_init( argc, argv,  DSGW_METHOD_POST | DSGW_METHOD_GET );
 
-    hostport = dsgw_get_cgi_var("hp", DSGW_CGIVAR_OPTIONAL);
     ldapquery = dsgw_get_cgi_var("ldq", DSGW_CGIVAR_OPTIONAL);
     dn = dsgw_get_cgi_var("dn", DSGW_CGIVAR_OPTIONAL);
     /* 
@@ -78,8 +76,8 @@
      * tack it onto the end of ldapquery.
      */
     while ( (varname = dsgw_next_cgi_var( &index, &val )) != NULL) {
-	if (!strcmp(varname, "hp") || !strcmp(varname, "ldq") ||
-	    !strcmp(varname, "dn") || !strcmp(varname, "context")) {
+	if (!strcmp(varname, "context") || !strcmp(varname, "ldq") ||
+	    !strcmp(varname, "dn")) {
 	    continue;
 	}
 	if (ldapquery != NULL) {
@@ -106,7 +104,7 @@
 #endif
 
     if ( reqmethod == DSGW_METHOD_GET ) {
-	get_request(hostport, dn, ldapquery);
+	get_request(dn, ldapquery);
     } else {
 	post_request();
     }
@@ -116,7 +114,7 @@
 
 
 static void
-get_request(char* hostport, char *dn, char *ldapquery)
+get_request(char *dn, char *ldapquery)
 {
     int    urllen  = 0;
     int    argslen = 0;
@@ -147,55 +145,23 @@
      * .../dosearch?context=BLAH[&hp=host[:port]][&dn=baseDN][&ldq=LDAPquery]]  
      *   -RJP
      */
-    argslen = 0;
-
-    /* get the length of all the args (dn, hostport, ldapquery)*/
-    if (hostport != NULL) {
-      argslen += strlen(hostport);
-    }
-
-    if (dn != NULL) {
-      argslen += strlen(dn);
-    }
-
-    if (ldapquery != NULL) {
-      argslen += strlen(ldapquery);
-    }
-
-    /* If nothing was supplied, exit*/
-    if ( argslen == 0 ) {
-	dsgw_error( DSGW_ERR_MISSINGINPUT, NULL, DSGW_ERROPT_EXIT, 0, NULL );
-    }
-
-    /* Malloc the ldapurl*/
-    urllen = LDAP_URL_PREFIX_LEN + argslen + 3;
-    p = ldapurl = (char *)dsgw_ch_malloc( urllen );
-    
-    /*Slap on ldap:// */
-    strcpy( p, LDAP_URL_PREFIX );
-    p += LDAP_URL_PREFIX_LEN;
-
-    /*Slap on host:port if there is one*/
-    if ( hostport != NULL ) {
-	strcpy( p, hostport );
-    }
-
-    strcat( ldapurl, "/" );
-
-    /*Slap on /dn, if there is a dn */
-    if ( dn != NULL ) {
-	strcat( ldapurl, dn );
-    }
-    
-    /*Slap on ?ldapquery */
-    if ( ldapquery != NULL ) {
-	sprintf( ldapurl + strlen( ldapurl ), "?%s", ldapquery );
-    }
+    /* richm 20080201
+     * removed the hp argument - we will now just construct the ldap url
+     * based on the dsgw config parameters
+     */
+    ldapurl = PR_smprintf("ldap%s://%s:%d/%s%s%s",
+			  (gc->gc_ldapssl ? "s" : ""),
+			  gc->gc_ldapserver, gc->gc_ldapport,
+			  (dn ? dn : ""),
+			  (ldapquery ? "?" : ""),
+			  (ldapquery ? ldapquery : ""));
 
 #ifdef DSGW_DEBUG
     dsgw_log( "get_request: processing LDAP URL \"%s\"\n", ldapurl );
 #endif
     dsgw_ldapurl_search( NULL, ldapurl);
+
+    PR_smprintf_free(ldapurl);
 }
 
 


Index: dsgwutil.c
===================================================================
RCS file: /cvs/dirsec/dsgw/dsgwutil.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- dsgwutil.c	30 Jan 2008 02:22:46 -0000	1.7
+++ dsgwutil.c	1 Feb 2008 17:04:22 -0000	1.8
@@ -677,16 +677,9 @@
 dsgw_build_urlprefix()
 {
     char	*prefix = dsgw_getvp( DSGW_CGINUM_DOSEARCH );
-    char	*p, *urlprefix;
+    char	*urlprefix;
 
-    p = ( gc->gc_ldapserver == NULL ? "" : gc->gc_ldapserver );
-    urlprefix = dsgw_ch_malloc( 16 /* room for "?:port#&dn=" + zero-term. */
-            + strlen( prefix ) + strlen( p ) +strlen(context) + 9);
-    sprintf( urlprefix, "%s?context=%s&hp=%s", prefix, context, p );
-    if ( gc->gc_ldapport != 0 && gc->gc_ldapport != LDAP_PORT ) {
-        sprintf( urlprefix + strlen( urlprefix ), ":%d", gc->gc_ldapport );
-    }
-    strcat( urlprefix,"&dn=" );
+    urlprefix = PR_smprintf("%s?context=%s&dn=", prefix, context);
     return( urlprefix );
 }
 


Index: entrydisplay.c
===================================================================
RCS file: /cvs/dirsec/dsgw/entrydisplay.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- entrydisplay.c	30 Jan 2008 17:16:45 -0000	1.4
+++ entrydisplay.c	1 Feb 2008 17:04:22 -0000	1.5
@@ -1023,6 +1023,9 @@
 	 * Now, thanks to me, they look like:
 	 *   .../dosearch?context=<blah>&hp=<host>:<port>&dn=<encodeddn>&ldq=<the rest>
 	 *     - RJP
+	 *
+	 * richm 20080201 - removed hp - search will always use the configured LDAP server
+	 * instead of passing the host:port to use
 	 */
 	char    *urlprefix, *escapeddn, *mimetype, *prefix, *suffix;
 




More information about the Fedora-directory-commits mailing list