roxen.lists.pike.general

Subject Author Date
Re: Protocol.LDAP not working in 7.8? Martin Stjernholm <mast[at]lysator[dot]liu[dot]se> 24-08-2009
Dan Nelson <<dnelson[at]allantgroup.com>> wrote:

> Error in attributeTypes when querying schema: Term identifier expected at pos
22: "( id-at-DominoClntBld1$IP NAME 'ClntBld1$IP' SYNTAX
1.3.6.1.4.1.1466.115.121.1.15 )"

Now it's the '$' in "id-at-DominoClntBld1$IP". According to the
standard it should be a numeric oid, i.e. only 0-9 and ".", but I've
already relaxed it to handle symbolic oid's. Now even that doesn't
seem to be enough.. :(

I've no idea what the de-facto character set for symbolic oids might
be, but they're used in several places so it's not entirely trivial to
make it ultra-liberal. I'll try adding "$" only and see how far it
goes.


--- lib/modules/Protocols.pmod/LDAP.pmod/client.pike	29 Oct 2008 14:19:08
-0000	1.117
+++ lib/modules/Protocols.pmod/LDAP.pmod/client.pike	24 Aug 2009 16:06:48 -0000
@@ -2096,15 +2096,16 @@
 {
   string orig_str = str, oid;
 
-  // RFC 2252 mandates a dotted decimal oid here, but some servers
+  // RFC 4512 mandates a dotted decimal oid here, but some servers
   // (e.g. iPlanet) might use symbolic strings so we have to do a lax
-  // syntax check.
+  // syntax check. Also include '$' in symbolic oids since some Domino
+  // schema is known to contain that char.. :P
   //
   // Note: Maybe it would be convenient to lowercase the noncompliant
   // oids in such cases, to make later lookups easier. However there
   // are no docs saying that it's ok to do so, and I prefer to play
   // safe. /mast
-  if (!sscanf (str, "(%*[ ]%[-;a-zA-Z0-9.]%*[ ]%s", oid, str))
+  if (!sscanf (str, "(%*[ ]%[-;$a-zA-Z0-9.]%*[ ]%s", oid, str))
     ERROR ("%sExpected '(' at beginning: %O\n",
 	   errmsg_prefix, orig_str);
   if (!sizeof (oid))
@@ -2116,9 +2117,9 @@
   do {
     int pos = sizeof (str);
 
-    // Note: RFC 2252 is not clear on what chars are allowed in term
+    // Note: RFC 4512 is not clear on what chars are allowed in term
     // identifier. We assume the same set as for attribute names.
-    sscanf (str, "%[-;a-zA-Z0-9]%*[ ]%s", string term_id, str);
+    sscanf (str, "%[-;$a-zA-Z0-9]%*[ ]%s", string term_id, str);
     if (!sizeof (term_id))
       ERROR ("%sTerm identifier expected at pos %d: %O\n",
 	     errmsg_prefix, sizeof (orig_str) - pos, orig_str);
@@ -2135,7 +2136,7 @@
 
       case "oid": {		// Numeric oid or name.
 	// No strict syntax check here.
-	sscanf (str, "%[-;a-zA-Z0-9.]%*[ ]%s", string oid, str);
+	sscanf (str, "%[-;$a-zA-Z0-9.]%*[ ]%s", string oid, str);
 	if (!sizeof (oid))
 	  ERROR ("%sExpected oid after term %O at pos %d: %O\n",
 		 errmsg_prefix, term_id, sizeof (orig_str) - pos, orig_str);
@@ -2153,7 +2154,7 @@
 	if (has_prefix (str, "'")) {
 	  ms_kludge = 1;
 	  // No strict syntax check here.
-	  sscanf (str, "'%[-;a-zA-Z0-9.]%s", oid, str);
+	  sscanf (str, "'%[-;$a-zA-Z0-9.]%s", oid, str);
 	}
 	else {
 	  // No strict syntax check here.
@@ -2216,8 +2217,10 @@
 	string parse_qdescr (string what)
 	{
 	  string name;
-	  // No strict syntax check here.
-	  switch (sscanf (str, "'%[-;a-zA-Z0-9]'%*[ ]%s", name, str)) {
+	  // RFC 4512 restricts this to a letter followed by letters,
+	  // digits or hyphens. However, real world cases shows that
+	  // other chars can occur here ('.', at least), so let's be lax.
+	  switch (sscanf (str, "'%[^']'%*[ ]%s", name, str)) {
 	    case 0:
 	      ERROR ("%sExpected %s after term %O at pos %d: %O\n",
 		     errmsg_prefix, what, term_id, sizeof (orig_str) - pos, orig_str);
@@ -2248,7 +2251,7 @@
       default:
 	if (multisetp (term_syntax) || mappingp (term_syntax)) {
 	  // One of a set.
-	  sscanf (str, "%[-;a-zA-Z0-9.]%*[ ]%s", string choice, str);
+	  sscanf (str, "%[-;$a-zA-Z0-9.]%*[ ]%s", string choice, str);
 	  if (!sizeof (choice))
 	    ERROR ("%sExpected keyword after term %O at pos %d: %O\n",
 		   errmsg_prefix, term_id, sizeof (orig_str) - pos, orig_str);