]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Be consistent with most other helpers in how to manage spaces. If there
authorhno <>
Sat, 6 Oct 2001 03:54:03 +0000 (03:54 +0000)
committerhno <>
Sat, 6 Oct 2001 03:54:03 +0000 (03:54 +0000)
is space characters then assume these are from the password, not the login
name.

helpers/basic_auth/LDAP/squid_ldap_auth.c

index 474a5fd6f7a5f7ab53ade3f1ba5deb97f4a79dbe..e706f436b7a450fd4360680ea13500931b87f158 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * 
  * squid_ldap_auth: authentication via ldap for squid proxy server
  * 
  * Maintainer: Henrik Nordstrom <hno@squid-cache.org>
  * or (at your option) any later version.
  *
  * Changes:
+ * 2001-10-04: Henrik Nordstrom <hno@squid-cache.org>
+ *             - Be consistent with the other helpers in how
+ *              spaces are managed. If there is space characters
+ *              then these are assumed to be part of the password
  * 2001-05-02: Henrik Nordstrom <hno@squid-cache.org>
  *             - Support newer OpenLDAP 2.x libraries using the
  *               revised Internet Draft API which unfortunately
@@ -108,7 +111,7 @@ int
 main(int argc, char **argv)
 {
     char buf[256];
-    char *user, *passwd, *p;
+    char *user, *passwd;
     char *ldapServer;
     LDAP *ld = NULL;
     int tryagain;
@@ -211,17 +214,13 @@ main(int argc, char **argv)
     ldapServer = (char *) argv[1];
 
     while (fgets(buf, 256, stdin) != NULL) {
-       if ((p = strchr(buf, '\n')) != NULL)
-           *p = '\0';          /* strip \n */
-       if ((p = strchr(buf, '\r')) != NULL)
-           *p = '\0';          /* strip \r */
+       user = strtok(buf, " \r\n");
+       passwd = strtok(buf, "\r\n");
 
-       user = buf;
-       if ((passwd = strrchr(buf, ' ')) == NULL) {
+       if (!user || !passwd || !passwd[0]) {
            printf("ERR\n");
            continue;
        }
-       *passwd++ = '\0';       /* Cut in username,password */
        tryagain = 1;
       recover:
        if (ld == NULL) {