Case-insensitive usernames

From: Chemolli Francesco (USI) <ChemolliF@dont-contact.us>
Date: Thu, 20 Jul 2000 11:51:17 +0200

There is a slight problem with the patch I
previously submitted for this same topic.

This is version 2 of the case-insensitive-usernames patch:

--- acl.c 2000/07/20 09:11:56 1.1.1.3.12.8
+++ acl.c 2000/07/20 09:32:16
@@ -1041,6 +1041,7 @@
 static int
 aclMatchUser(wordlist * data, const char *user)
 {
+ int cis=0;
     if (user == NULL)
    return 0;
     debug(28, 3) ("aclMatchUser: checking '%s'\n", user);
@@ -1048,8 +1049,17 @@
    debug(28, 3) ("aclMatchUser: looking for '%s'\n", data->key);
    if (strcmp(data->key, "REQUIRED") == 0 && *user != '\0' && strcmp(user,
"-") != 0)
        return 1;
- if (strcmp(data->key, user) == 0)
+ if (strcmp(data->key,"-i") == 0) {
+ debug(28, 3) ("aclMatchUser: going case-insensitive\n");
+ cis=1;
+ }
+ if (cis) {
+ if (strcasecmp(data->key,user) == 0)
+ return 1;
+ } else {
+ if (strcmp(data->key, user) == 0)
        return 1;
+ }
    data = data->next;
     }
     return 0;

The previous patch was mostly functional, but flawed:
the condition line used to be:

+ if ((!cis && strcmp(data->key, user) == 0) ||
+ strcasecmp(data->key,user) == 0)

if cis==0 and the user didn't match, it went on
to compare case-insensitively.
Result: inefficiceny (double strcmp - ugh!) and broken
behavior. All this for me not wanting to explicitly
code in a condition...
This should fix it up.

The patched code compiles, but, as usual, should you decide
to accept it, I don't guarrantee that it won't blow up
on your face.

        ing. Francesco Chemolli
Received on Thu Jul 20 2000 - 03:48:31 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:54:34 MST