Squid-2.2.STABLE3: proxy_auth and spaces in username or password This patch adds support for spaces in the username or password by encoding unsafe characters before calling the authenticator. Please note that this patch breaks compability with any existing authenticator modules and you need to URL unescape the username and password prior to processing or authentication will fail if unsafe characters is used in the username or password. Index: squid/auth_modules/NCSA/ncsa_auth.c diff -u squid/auth_modules/NCSA/ncsa_auth.c:1.1.1.5.32.2 squid/auth_modules/NCSA/ncsa_auth.c:1.1.1.5.32.3 --- squid/auth_modules/NCSA/ncsa_auth.c:1.1.1.5.32.2 Tue Jun 22 22:41:53 1999 +++ squid/auth_modules/NCSA/ncsa_auth.c Tue Jun 22 22:56:15 1999 @@ -130,6 +130,8 @@ printf("ERR\n"); continue; } + rfc1738_unescape(user); + rfc1738_unescape(passwd); u = hash_lookup(hash, user); if (u == NULL) { printf("ERR\n"); Index: squid/auth_modules/SMB/Makefile diff -u squid/auth_modules/SMB/Makefile:1.1.1.1.14.2 squid/auth_modules/SMB/Makefile:1.1.1.1.14.3 --- squid/auth_modules/SMB/Makefile:1.1.1.1.14.2 Tue Jun 22 22:41:56 1999 +++ squid/auth_modules/SMB/Makefile Tue Jun 22 22:56:18 1999 @@ -20,10 +20,11 @@ CC = gcc CFLAGS = -O2 -Wall \ - -DSAMBAPREFIX=\"$(SAMBAPREFIX)\" -DHELPERSCRIPT=\"$(INSTALLBIN)/$(SCRIPT)\" + -DSAMBAPREFIX=\"$(SAMBAPREFIX)\" -DHELPERSCRIPT=\"$(INSTALLBIN)/$(SCRIPT)\" \ + -I../../include smb_auth: $(OBJECTS) - $(CC) -o smb_auth $(OBJECTS) + $(CC) -o smb_auth $(OBJECTS) -L../../lib -lmiscutil -lm install: smb_auth install smb_auth $(SCRIPT) $(INSTALLBIN) Index: squid/auth_modules/SMB/smb_auth.c diff -u squid/auth_modules/SMB/smb_auth.c:1.1.1.1.14.2 squid/auth_modules/SMB/smb_auth.c:1.1.1.1.14.3 --- squid/auth_modules/SMB/smb_auth.c:1.1.1.1.14.2 Tue Jun 22 22:41:56 1999 +++ squid/auth_modules/SMB/smb_auth.c Tue Jun 22 22:56:18 1999 @@ -21,6 +21,8 @@ #include #include +#include "util.h" + #define BUFSIZE 256 #define NMB_UNICAST 1 #define NMB_BROADCAST 2 @@ -154,6 +156,9 @@ (void) printf("ERR\n"); continue; } + + rfc1738_unescape(user); + rfc1738_unescape(pass); (void) fprintf(p, "%s\n", SAMBAPREFIX); (void) fprintf(p, "%s\n", dom->name); Index: squid/auth_modules/getpwnam/getpwnam_auth.c diff -u squid/auth_modules/getpwnam/getpwnam_auth.c:1.1.1.1.10.2 squid/auth_modules/getpwnam/getpwnam_auth.c:1.1.1.1.10.3 --- squid/auth_modules/getpwnam/getpwnam_auth.c:1.1.1.1.10.2 Tue Jun 22 22:41:56 1999 +++ squid/auth_modules/getpwnam/getpwnam_auth.c Tue Jun 22 22:56:19 1999 @@ -40,6 +40,7 @@ #include #endif +#include "util.h" #define ERR "ERR\n" #define OK "OK\n" @@ -65,6 +66,8 @@ printf(ERR); continue; } + rfc1738_unescape(user); + rfc1738_unescape(passwd); pwd = getpwnam(user); if (pwd == NULL) { printf(ERR); Index: squid/src/authenticate.c diff -u squid/src/authenticate.c:1.1.1.7.14.3 squid/src/authenticate.c:1.1.1.7.14.4 --- squid/src/authenticate.c:1.1.1.7.14.3 Tue Jun 22 22:41:57 1999 +++ squid/src/authenticate.c Tue Jun 22 22:56:20 1999 @@ -37,6 +37,8 @@ typedef struct { void *data; + char user[256]; + char passwd[256]; acl_proxy_auth_user *auth_user; RH *handler; } authenticateStateData; @@ -96,11 +98,13 @@ } r = xcalloc(1, sizeof(authenticateStateData)); cbdataAdd(r, cbdataXfree, 0); + xstrncpy(r->user, rfc1738_escape(auth_user->user), sizeof(r->user)); + xstrncpy(r->passwd, rfc1738_escape(auth_user->passwd), sizeof(r->passwd)); r->handler = handler; cbdataLock(data); r->data = data; r->auth_user = auth_user; - snprintf(buf, 8192, "%s %s\n", r->auth_user->user, r->auth_user->passwd); + snprintf(buf, 8192, "%s %s\n", r->user, r->passwd); helperSubmit(authenticators, buf, authenticateHandleReply, r); }