httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Barrera A." <>
Subject Re: [users@httpd] case insensitive using basic authentication
Date Mon, 03 Jan 2005 20:46:23 GMT
> My first implementation used stricmp(), which like Ivan said, may not be a
> valid/popular C function too. I found from other apache websites that some
> times "mod_xxxx could not be loaded" can be caused by not finding the
> required library files. I thought strlen() was more popular than stricmp(),
> so I changed to the second implementation. The second one was still not
> working.
strlen is pretty common.

> This morning I changed to the third implementation, which copies the
> original user string into a temporary char[] of mine own and makes the
> temp_user to all lower case, then do the comparasion using strcmp(). This
> time it worked!
strcasecmp is faster.. but what you did is correct :)

> I am still confused about two things:
> 1. why didn't I get any compile/link error messages the first time (with
> stricmp()) ? I was only looking at the log messages as the screen flys by.
> And I found a newly built mod_auth under ~www/modules directory after the
> build. So I thought everything was fine. My question is: what place should I
> look for compile/build error messages?
Im not sure, but may be in someplace a directive that sets the linked to 
not look if a function exists.. so in runtime, it just segfaults.

> 2. what exactly went wrong with the second implementation? The only external
> function I used was strlen(), I don't expect it had any errors too. So...
You didnt post the exact error you got.. But i got your code working 
fine (in a little example below).
Also, remember to set both strings to lowercase, not just the first.
btw,you'll be better using ==0 for checking if a string is equal.

i did the following example.

#include "string.h"

int main() {
  int i;
  char str_in_the_file[50] = "testing some weird thing";
  char user_str[50] = "TeStIng sOME wEiRD ThinG";

  for (i=0;i<strlen(user_str);i++) {
    if (user_str[i] >='A' && user_str[i]<='Z') {
      user_str[i]  += ('a' - 'A');

  printf("\nTesting strings : \n\n%s\n%s\n",user_str,str_in_the_file);
  printf("\nBoth strings are : ");

  if (strcmp(user_str, str_in_the_file)==0) printf("the same\n\n");
  else                                      printf("different\n\n");



And it worked fine. ( the same )

> Thanks again in advance!
> Regards,
> Yanbin
> ----- Original Message ----- 
> From: "Ivan Barrera A." <>
> To: <>
> Sent: Monday, January 03, 2005 1:02 PM
> Subject: Re: [users@httpd] case insensitive using basic authentication
>>stricmp doesnt exists in c.
>>The correct function is strcasecmp.
>>        #include <string.h>
>>        int strcasecmp(const char *s1, const char *s2);
>>        int strncasecmp(const char *s1, const char *s2, size_t n);
>>Yanbin Ma wrote:
>>>It seems nobody is interested in my previous question. Can anybody tell
>>>me if I should address this to developer mail list? Thanks!
>>>    ----- Original Message -----
>>>    *From:* Yanbin Ma <>
>>>    *To:* <>
>>>    *Sent:* Sunday, January 02, 2005 11:05 PM
>>>    *Subject:* [users@httpd] case insensitive using basic authentication
>>>    Hi,
>>>    I have recently moved one of our server from a netscape suitespot
>>>    V3.5 to apache 2.0. Finishing this was a miracle, considering I am
>>>    new to apache and my tight schedule in the last month. However, I am
>>>    facing one (hopefully last) difficulty here:
>>>    The Netscape server uses a case insenstive DBM based basic
>>>    authentication. After I switched to apache, I chose to use file
>>>    based basic authentication. (again, because of the schedule,
>>>    otherwise, I would go a longer way and setup some database/dbm based
>>>    solution). However, I found mod_auth in apache 2.0 searches the
>>>    password file in a case sensitive way. So I thought since I have all
>>>    the apache source code, why don't I make a custom mod_auth to search
>>>    the file in case insensitive way.
>>>    So I changed mod_auth.c, it was a simple one line change ( from
>>>    strcmp() to stricmp()), then rebuilt the apache. However, the newly
>>>    built version cannot be started because "mod_auth cannot be loaded".
>>>    I thought maybe stricmp() is not a popular function, so I changed
>>>    the code again so that it does something like below:
>>>        int i;
>>>        ....
>>>        for (i=0;i<strlen(user_str);i++) {
>>>           if (user_str[i] >='A' && user_str[i]<='Z') {
>>>              user_str[i]  += ('a' - 'A');
>>>           }
>>>        }
>>>        if (!strcmp(user_str, str_in_the_file))
>>>    However, it still does not work. I am sure it's not syntax error,
>>>    otherwise I would have failed the build. But I can not figure out
>>>    what else I need to do in addition to change the code and rebuild.
>>>    Did anybody have experience in this?
>>>    Regards,
>>>    Yanbin Ma
>>The official User-To-User support forum of the Apache HTTP Server Project.
>>See <URL:> for more info.
>>To unsubscribe, e-mail:
>>   "   from the digest:
>>For additional commands, e-mail:
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:> for more info.
> To unsubscribe, e-mail:
>    "   from the digest:
> For additional commands, e-mail:

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message