*** rlm_sql.c.orig      Fri Feb 21 06:53:52 2003

--- rlm_sql.c     Fri Feb 21 06:54:02 2003

***************

*** 224,229 ****

--- 224,283 ----

      *out = '\0';

      return len;

  }

+

+ /*

+  *  strip and translate usernames.

+  */

+ static int stripMSdomain_escape_func(char *out, int outlen, const char *in)

+ {

+     int len = 0;

+         int lentmp=0;

+     char tmp[MAX_STRING_LEN];

+

+         tmp[0]=0;

+         if (strrchr(in, '\\')) {

+            strcpy(tmp, strrchr(in, '\\') + 1);

+         } else {

+            strcpy(tmp, in);

+         }

+    

+

+         while (tmp[lentmp]) {

+           /*

+            *  Only one byte left.

+            */

+           if (outlen <= 1) {

+                 break;

+           }

+          

+           /*

+            *    Non-printable characters get replaced with their

+            *    mime-encoded equivalents.

+            */

+           if ((tmp[lentmp] < 32) ||

+               strchr("@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: =/", tmp[lentmp]) == NULL) {

+                 snprintf(out, outlen, "=%02X", (unsigned char) tmp[lentmp]);

+                 out += 3;

+                 outlen -= 3;

+                 len += 3;

+                         lentmp++;

+                 continue;

+           }

+          

+           /*

+            *    Else it's a nice character.

+            */

+           *out = tmp[lentmp];

+           out++;

+           outlen--;

+           len++;

+                 lentmp++;

+     }

+

+     *out = '\0';

+     return len;

+ }

+

  /*

   *  Set the SQl user name.

   */

***************

*** 240,246 ****

      if (username != NULL) {

            strNcpy(tmpuser, username, MAX_STRING_LEN);

      } else if (strlen(inst->config->query_user)) {

!           radius_xlat(tmpuser, sizeof(tmpuser), inst->config->query_user, request, sql_escape_func);

      } else {

            return 0;

      }

--- 294,300 ----

      if (username != NULL) {

            strNcpy(tmpuser, username, MAX_STRING_LEN);

      } else if (strlen(inst->config->query_user)) {

!           radius_xlat(tmpuser, sizeof(tmpuser), inst->config->query_user, request, stripMSdomain_escape_func);

      } else {

            return 0;

      }

Reply via email to