[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#5919) URI syntaxe (ldap:///dc=my%2cdc=domaine)



This is a multi-part message in MIME format.

------=_NextPart_000_00C2_01C98DEA.AA80EF10
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

As I leave one week for a security formation ISO 27001 (and in case it would
persuade me to make never more programming ;), here is the current state
(not finished) of the patch (only the modified function - cf "Followup 19").
In fact, 2 more options must be validated there :
1/- ... // if (x-dnssrv == ".") then $hostname is (must be) the search
SRV-domain (or the default domain, if $hostname=="") ...
2/- // in all cases, if (*port != '\0') then : result = $(grep "$port" $(the
result of the SRV search)) ...
--
PE

------=_NextPart_000_00C2_01C98DEA.AA80EF10
Content-Type: application/octet-stream;
	name="open.c.url_expand.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="open.c.url_expand.patch"

--- openldap-2.4.13/libraries/libldap/open.c	2008-10-31 =
23:23:58.000000000 +0000=0A=
+++ openldap-2.4.13/libraries/libldap/open.c	2009-02-14 =
00:31:27.000000000 +0000=0A=
@@ -212,19 +212,164 @@=0A=
 	return( ld );=0A=
 }=0A=
 =0A=
+int=0A=
+url_expand_on_srv_search ( char ***result, LDAP_CONST char *url_in, =
char *domain )=0A=
+{	int	rc =3D 0;=0A=
+	char	*scheme, *hostname, *port, *opt;=0A=
+=0A=
+	// Syntax validation ...=0A=
+	if ( (scheme =3D (char *)LDAP_STRDUP( url_in )) =3D=3D NULL )=0A=
+		return -1;	// memory error ...=0A=
+=0A=
+	hostname =3D (char *)strchrnul( scheme, '/' ); *hostname++ =3D '\0';=0A=
+	if ( *hostname++ !=3D '/' )=0A=
+		return -1;	// syntax error ...=0A=
+	=0A=
+	opt  =3D (char *)strchrnul( hostname, '/' ); if ( *opt  )	*opt++ =3D =
'\0';=0A=
+	port =3D (char *)strchrnul( hostname, ':' ); if ( *port )	*port++ =3D =
'\0';=0A=
+=0A=
+	if ( *hostname && !strcmp ( domain, "." )=3D=3D0 )	// if (x-dnssrv =
=3D=3D ".") then $hostname is the search SRV-domain (or default domain, =
if $hostname=3D=3D"") ...=0A=
+		return -1;	// syntax error ...=0A=
+=0A=
+	// So now, we can search the server name(s) of the _ldap._tcp.$domain =
service ...=0A=
+	// if ( *port !=3D '\0') then : grep the result of SRV RR search with =
$port ...=0A=
+=0A=
+	// Coming soon ...=0A=
+if ( (*result =3D ldap_str2charray( "ldap1.gov.pf ldap2.gov.pf =
ldap3.gov.pf", " " )) !=3D NULL ) rc =3D 3; // line to delete ...=0A=
+=0A=
+	// Search is finished : so now, add initial scheme and opt to result =
hostport(s) ...=0A=
+	if ( *result !=3D NULL ) {=0A=
+		size_t plus =3D strlen( scheme ) + strlen ( opt ) + 4;=0A=
+		for ( rc=3D0; (char *)((*result)[rc]) !=3D NULL; ) {=0A=
+			(*result)[rc] =3D (char *)LDAP_REALLOC ( (char *)((*result)[rc]), =
strlen ( (char *)((*result)[rc]) ) + plus );	=0A=
+			{	// do a : memcpy ( &((char *)((*result)[rc]))[strlen( scheme ) + =
2], *result[rc], strlen( (char *)((*result)[rc]) ) + 1 );=0A=
+				char *n =3D &((char *)((*result)[rc]))[strlen( scheme ) + 2];=0A=
+				char *s =3D (char *)((*result)[rc]);=0A=
+				char *e =3D s + (strlen( (char *)((*result)[rc]) ) + 1);=0A=
+				for ( n +=3D e - s; e >=3D s; ) *n-- =3D *e--;=0A=
+			}=0A=
+			memcpy ( &((char *)((*result)[rc]))[strlen( scheme )], "//", 2 );=0A=
+			memcpy ( (char *)((*result)[rc]), scheme, strlen( scheme ) );=0A=
+			strcat ( (char *)((*result)[rc]), "?" ); strcat ( (char =
*)((*result)[rc]), opt );=0A=
+			rc++;=0A=
+		}=0A=
+	} else	rc =3D 0;=0A=
+=0A=
+	LDAP_FREE ( scheme );=0A=
+	return rc;=0A=
+}=0A=
+=0A=
+char *=0A=
+expand_dnssrv_definitions ( LDAP_CONST char *url_in )=0A=
+{=0A=
...=0A=
=0A=

------=_NextPart_000_00C2_01C98DEA.AA80EF10--