Proposal: case/nocase argument for realms file
Maurice Makaay <[email protected]> Mon, 3 Nov 2003 22:13:41 +0100
| Newsgroups | gmane.comp.gnu.radius.bugs |
|---|---|
| Organization | InterNLnet BV |
| Message-ID | <[email protected]> |
Hi, On our system, we handle usernames/realms in a case-insensitive way. We use the new rewrite builtin tolower() for this. This is working just fine. However, we are now trying to proxy accounting data to a central radius server, but realms currently can't be handled case insensitive. So now the accounting data for users that login using uppercase characters in their realm is logged only locally. Using the patch proposal I attached to this message, one can add the argument "nocase" to a realms entry to make the realm matching case insensitive. Regards, -- Maurice Makaay _______________________________________________ Bug-gnu-radius mailing list [email protected] http://mail.gnu.org/mailman/listinfo/bug-gnu-radius
realms.nocase.patch
(text/plain, 1.5 KB)
Index: include/radius.h
===================================================================
RCS file: /cvsroot/radius/radius/include/radius.h,v
retrieving revision 1.66
diff -u -r1.66 radius.h
--- include/radius.h 2 Nov 2003 21:44:28 -0000 1.66
+++ include/radius.h 3 Nov 2003 21:03:20 -0000
@@ -259,6 +259,7 @@
char realm[MAX_REALMNAME+1];
envar_t *args;
RADIUS_SERVER_QUEUE *queue;
+ int case_sensitive;
} REALM;
typedef struct radius_req {
Index: lib/realms.c
===================================================================
RCS file: /cvsroot/radius/radius/lib/realms.c,v
retrieving revision 1.12
diff -u -r1.12 realms.c
--- lib/realms.c 31 Oct 2003 13:09:31 -0000 1.12
+++ lib/realms.c 3 Nov 2003 21:03:20 -0000
@@ -141,6 +141,8 @@
rp->queue->retries = envar_lookup_int(rp->args,
"retries", 1);
}
+
+ rp->case_sensitive = envar_lookup_int(rp->args, "case", 1);
}
if (!realms)
realms = list_create();
@@ -186,9 +188,13 @@
if (!itr)
return NULL;
- for (p = iterator_first(itr); p; p = iterator_next(itr))
- if (strcmp(p->realm, realm) == 0)
+ for (p = iterator_first(itr); p; p = iterator_next(itr)) {
+ int cmp = p->case_sensitive
+ ? strcmp(p->realm, realm)
+ : strcasecmp(p->realm, realm);
+ if (cmp == 0)
break;
+ }
if (!p && strcmp(realm, "NOREALM")) {
for (p = iterator_first(itr); p; p = iterator_next(itr))
if (strcmp(p->realm, "DEFAULT") == 0)