--------------------- PatchSet 3981 Date: 2002/04/11 20:15:56 Author: serassio Branch: nt-2_5 Tag: (none) Log: WIN32 code cleanup Members: configure.in:1.42.2.5.4.3->1.42.2.5.4.4 lib/util.c:1.12.14.3->1.12.14.4 src/defines.h:1.15.10.2->1.15.10.3 src/protos.h:1.41.6.3.4.4->1.41.6.3.4.5 src/auth/basic/helpers/LDAP/squid_ldap_auth.c:1.15.14.1->1.15.14.2 src/auth/basic/helpers/win32_locallogon/NT_auth.c:1.1.38.1->1.1.38.2 src/auth/basic/helpers/win32_locallogon/valid.c:1.1.38.1->1.1.38.2 src/auth/basic/helpers/win32_locallogon/valid.h:1.1.38.1->1.1.38.2 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.42.2.5.4.3 retrieving revision 1.42.2.5.4.4 diff -u -r1.42.2.5.4.3 -r1.42.2.5.4.4 --- squid/configure.in 4 Apr 2002 19:52:55 -0000 1.42.2.5.4.3 +++ squid/configure.in 11 Apr 2002 20:15:56 -0000 1.42.2.5.4.4 @@ -3,7 +3,7 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.42.2.5.4.3 2002/04/04 19:52:55 serassio Exp $ +dnl $Id: configure.in,v 1.42.2.5.4.4 2002/04/11 20:15:56 serassio Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.5.PRE5-CVS) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.42.2.5.4.3 $)dnl +AC_REVISION($Revision: 1.42.2.5.4.4 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -68,6 +68,7 @@ dnl Can the CC program be asked to use the Win32 API? AC_API_WIN32 + AC_DEFINE_UNQUOTED(SQUID_CONFIGURE_OPTIONS, "$ac_configure_args") dnl Gerben Wierda @@ -813,6 +814,7 @@ fi ]) + dnl Select auth schemes modules to build AC_ARG_ENABLE(auth, [ --enable-auth=\"list of auth scheme modules\" @@ -2132,6 +2134,7 @@ icons/Makefile \ errors/Makefile \ src/fs/aufs/Makefile \ + src/fs/awin32/Makefile \ src/fs/coss/Makefile \ src/fs/diskd/Makefile \ src/fs/null/Makefile \ Index: squid/lib/util.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/util.c,v retrieving revision 1.12.14.3 retrieving revision 1.12.14.4 diff -u -r1.12.14.3 -r1.12.14.4 --- squid/lib/util.c 7 Apr 2002 13:23:40 -0000 1.12.14.3 +++ squid/lib/util.c 11 Apr 2002 20:15:56 -0000 1.12.14.4 @@ -1,6 +1,6 @@ /* - * $Id: util.c,v 1.12.14.3 2002/04/07 13:23:40 serassio Exp $ + * $Id: util.c,v 1.12.14.4 2002/04/11 20:15:56 serassio Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -32,8 +32,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ + +#ifndef UTIL_C #define UTIL_C - #define _etext etext #include "config.h" @@ -762,3 +763,4 @@ write(2, "\n", 1); abort(); } +#endif /* UTIL_C */ Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.15.10.2 retrieving revision 1.15.10.3 diff -u -r1.15.10.2 -r1.15.10.3 --- squid/src/defines.h 27 Mar 2002 21:01:17 -0000 1.15.10.2 +++ squid/src/defines.h 11 Apr 2002 20:15:56 -0000 1.15.10.3 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.15.10.2 2002/03/27 21:01:17 serassio Exp $ + * $Id: defines.h,v 1.15.10.3 2002/04/11 20:15:56 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -300,8 +300,6 @@ /* CygWin & Windows NT Port */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) -#define _WIN_HOSTS_FILENAME "\\hosts" -#define _WIN95_NETWORK_DB_HOSTS "%WINDIR%" #define _WIN_SQUID_SERVICE_CONTROL_STOP SERVICE_CONTROL_STOP #define _WIN_SQUID_SERVICE_CONTROL_SHUTDOWN SERVICE_CONTROL_SHUTDOWN #define _WIN_SQUID_SERVICE_CONTROL_INTERROGATE SERVICE_CONTROL_INTERROGATE Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.41.6.3.4.4 retrieving revision 1.41.6.3.4.5 diff -u -r1.41.6.3.4.4 -r1.41.6.3.4.5 --- squid/src/protos.h 4 Apr 2002 19:52:56 -0000 1.41.6.3.4.4 +++ squid/src/protos.h 11 Apr 2002 20:15:56 -0000 1.41.6.3.4.5 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.41.6.3.4.4 2002/04/04 19:52:56 serassio Exp $ + * $Id: protos.h,v 1.41.6.3.4.5 2002/04/11 20:15:56 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1343,7 +1343,6 @@ extern void WIN32_InstallService(void); extern void WIN32_RemoveService(void); extern int WIN32_getrusage(int, struct rusage *); -extern int WIN32_is_interface_down(const char *); #endif #endif /* SQUID_PROTOS_H */ Index: squid/src/auth/basic/helpers/LDAP/squid_ldap_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/basic/helpers/LDAP/Attic/squid_ldap_auth.c,v retrieving revision 1.15.14.1 retrieving revision 1.15.14.2 diff -u -r1.15.14.1 -r1.15.14.2 --- squid/src/auth/basic/helpers/LDAP/squid_ldap_auth.c 23 Mar 2002 10:35:26 -0000 1.15.14.1 +++ squid/src/auth/basic/helpers/LDAP/squid_ldap_auth.c 11 Apr 2002 20:15:56 -0000 1.15.14.2 @@ -50,14 +50,14 @@ #include #include #include -#ifdef _WIN32 -#define snprintf _snprintf -#include -#include -#else +#ifdef _WIN32 +#define snprintf _snprintf +#include +#include +#else #include #include -#endif +#endif /* Change this to your search base */ static char *basedn; Index: squid/src/auth/basic/helpers/win32_locallogon/NT_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/basic/helpers/win32_locallogon/Attic/NT_auth.c,v retrieving revision 1.1.38.1 retrieving revision 1.1.38.2 diff -u -r1.1.38.1 -r1.1.38.2 --- squid/src/auth/basic/helpers/win32_locallogon/NT_auth.c 18 Mar 2002 22:39:44 -0000 1.1.38.1 +++ squid/src/auth/basic/helpers/win32_locallogon/NT_auth.c 11 Apr 2002 20:15:56 -0000 1.1.38.2 @@ -1,96 +1,96 @@ -/* - NT_auth - Version 1.11 - - Modified to act as a Squid authenticator module. - Can run as dll on NT native port. - Removed all Pike stuff. - Returns OK for a successful authentication, or ERR upon error. - - Guido Serassio, Torino - Italy - Sun Jun 17 14:34:26 CST 2001 - - Uses code from - - Antonino Iannella 2000 - Andrew Tridgell 1997 - Richard Sharpe 1996 - Bill Welliver 1999 - - Released under GNU Public License - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "squid.h" - -/* Check if we try to compile on a Windows Platform */ -#if defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) - -#include "valid.h" - -/* Main program for simple authentication. - Scans and checks for Squid input, and attempts to validate the user. -*/ - -static char NTGroup[256]; -extern char Default_NTDomain[256]; - -int -main(int argc, char **argv) - -{ - char wstr[256]; - char username[256]; - char password[256]; - char *p; - - if ((argc < 2) || (argc > 3)) { - fprintf(stderr, "Usage: NT_auth []\n"); - exit(1); - } - strcpy(NTGroup, argv[1]); - if (argc == 3) - strcpy(Default_NTDomain, argv[2]); - while (1) { - /* Read whole line from standard input. Terminate on break. */ - if (fgets(wstr, 255, stdin) == NULL) - break; - if ((p = strchr(wstr, '\n')) != NULL) - *p = '\0'; /* strip \n */ - if ((p = strchr(wstr, '\r')) != NULL) - *p = '\0'; /* strip \r */ - /* Clear any current settings */ - username[0] = '\0'; - password[0] = '\0'; - sscanf(wstr, "%s %s", username, password); /* Extract parameters */ - /* Check for invalid or blank entries */ - if ((username[0] == '\0') || (password[0] == '\0')) { - puts("ERR"); - fflush(stdout); - continue; - } - if (Valid_User(username, password, NTGroup) == NTV_NO_ERROR) - puts("OK"); - else - puts("ERR"); - fflush(stdout); - } - return 0; -} - -#else /* NON Windows Platform !!! */ - -#error NON WINDOWS PLATFORM - -#endif +/* + NT_auth - Version 1.11 + + Modified to act as a Squid authenticator module. + Can run as dll on NT native port. + Removed all Pike stuff. + Returns OK for a successful authentication, or ERR upon error. + + Guido Serassio, Torino - Italy + Sun Jun 17 14:34:26 CST 2001 + + Uses code from - + Antonino Iannella 2000 + Andrew Tridgell 1997 + Richard Sharpe 1996 + Bill Welliver 1999 + + Released under GNU Public License + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "squid.h" + +/* Check if we try to compile on a Windows Platform */ +#if defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) + +#include "valid.h" + +/* Main program for simple authentication. + Scans and checks for Squid input, and attempts to validate the user. +*/ + +static char NTGroup[256]; +extern char Default_NTDomain[256]; + +int +main(int argc, char **argv) + +{ + char wstr[256]; + char username[256]; + char password[256]; + char *p; + + if ((argc < 2) || (argc > 3)) { + fprintf(stderr, "Usage: NT_auth []\n"); + exit(1); + } + strcpy(NTGroup, argv[1]); + if (argc == 3) + strcpy(Default_NTDomain, argv[2]); + while (1) { + /* Read whole line from standard input. Terminate on break. */ + if (fgets(wstr, 255, stdin) == NULL) + break; + if ((p = strchr(wstr, '\n')) != NULL) + *p = '\0'; /* strip \n */ + if ((p = strchr(wstr, '\r')) != NULL) + *p = '\0'; /* strip \r */ + /* Clear any current settings */ + username[0] = '\0'; + password[0] = '\0'; + sscanf(wstr, "%s %s", username, password); /* Extract parameters */ + /* Check for invalid or blank entries */ + if ((username[0] == '\0') || (password[0] == '\0')) { + puts("ERR"); + fflush(stdout); + continue; + } + if (Valid_User(username, password, NTGroup) == NTV_NO_ERROR) + puts("OK"); + else + puts("ERR"); + fflush(stdout); + } + return 0; +} + +#else /* NON Windows Platform !!! */ + +#error NON WINDOWS PLATFORM + +#endif Index: squid/src/auth/basic/helpers/win32_locallogon/valid.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/basic/helpers/win32_locallogon/Attic/valid.c,v retrieving revision 1.1.38.1 retrieving revision 1.1.38.2 diff -u -r1.1.38.1 -r1.1.38.2 --- squid/src/auth/basic/helpers/win32_locallogon/valid.c 18 Mar 2002 22:39:44 -0000 1.1.38.1 +++ squid/src/auth/basic/helpers/win32_locallogon/valid.c 11 Apr 2002 20:15:57 -0000 1.1.38.2 @@ -1,117 +1,117 @@ -#include "squid.h" - -/* Check if we try to compile on a Windows Platform */ -#if defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) - -#include -#if defined(_SQUID_CYGWIN_) -#include -#endif -#include -#include -#include "valid.h" - -char Default_NTDomain[256] = NTV_DEFAULT_DOMAIN; - -/* Valid_User return codes - - 0 - User authenticated successfully. - 1 - Server error. - 2 - Protocol error. - 3 - Logon error; Incorrect password or username given. -*/ - -int -Valid_User(char *UserName, char *Password, char *Group) -{ - HANDLE hToken = INVALID_HANDLE_VALUE; - int result = NTV_LOGON_ERROR; - int error; - char NTDomain[256]; - char *domain_qualify; - char DomainUser[256]; - WCHAR wszUserName[256]; // Unicode user name - WCHAR wszGroup[256]; // Unicode Group - - LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; - LPLOCALGROUP_USERS_INFO_0 pTmpBuf; - DWORD dwLevel = 0; - DWORD dwFlags = LG_INCLUDE_INDIRECT; - DWORD dwPrefMaxLen = -1; - DWORD dwEntriesRead = 0; - DWORD dwTotalEntries = 0; - NET_API_STATUS nStatus; - DWORD i; - DWORD dwTotalCount = 0; - -/* Convert ANSI User Name and Group to Unicode */ - - MultiByteToWideChar(CP_ACP, 0, UserName, - strlen(UserName) + 1, wszUserName, - sizeof(wszUserName) / sizeof(wszUserName[0])); - MultiByteToWideChar(CP_ACP, 0, Group, - strlen(Group) + 1, wszGroup, sizeof(wszGroup) / sizeof(wszGroup[0])); - strcpy(NTDomain, UserName); - if ((domain_qualify = strchr(NTDomain, '\\')) == NULL) { - strcpy(DomainUser, NTDomain); - strcpy(NTDomain, Default_NTDomain); - } else { - strcpy(DomainUser, domain_qualify + 1); - domain_qualify[0] = '\0'; - } - /* Log the client on to the local computer. */ - if (!LogonUser(DomainUser, - NTDomain, - Password, - LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hToken)) { - result = NTV_LOGON_ERROR; - error = GetLastError(); - } else { - /* - * Call the NetUserGetLocalGroups function - * specifying information level 0. - * - * The LG_INCLUDE_INDIRECT flag specifies that the - * function should also return the names of the local - * groups in which the user is indirectly a member. - */ - nStatus = NetUserGetLocalGroups(NULL, - wszUserName, - dwLevel, - dwFlags, - (LPBYTE *) & pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries); - /* - * If the call succeeds, - */ - if (nStatus == NERR_Success) { - if ((pTmpBuf = pBuf) != NULL) { - for (i = 0; i < dwEntriesRead; i++) { - assert(pTmpBuf != NULL); - if (pTmpBuf == NULL) { - result = NTV_SERVER_ERROR; - break; - } - if (wcscmp(pTmpBuf->lgrui0_name, wszGroup) == 0) { - result = NTV_NO_ERROR; - break; - } - pTmpBuf++; - dwTotalCount++; - } - } - } else - result = NTV_SERVER_ERROR; - /* - * Free the allocated memory. - */ - if (pBuf != NULL) - NetApiBufferFree(pBuf); - } - if (hToken != INVALID_HANDLE_VALUE) - CloseHandle(hToken); - return result; -} -#else /* NON Windows Platform !!! */ - -#error NON WINDOWS PLATFORM - -#endif +#include "squid.h" + +/* Check if we try to compile on a Windows Platform */ +#if defined(_SQUID_CYGWIN_) || defined(_SQUID_MSWIN_) + +#include +#if defined(_SQUID_CYGWIN_) +#include +#endif +#include +#include +#include "valid.h" + +char Default_NTDomain[256] = NTV_DEFAULT_DOMAIN; + +/* Valid_User return codes - + 0 - User authenticated successfully. + 1 - Server error. + 2 - Protocol error. + 3 - Logon error; Incorrect password or username given. +*/ + +int +Valid_User(char *UserName, char *Password, char *Group) +{ + HANDLE hToken = INVALID_HANDLE_VALUE; + int result = NTV_LOGON_ERROR; + int error; + char NTDomain[256]; + char *domain_qualify; + char DomainUser[256]; + WCHAR wszUserName[256]; // Unicode user name + WCHAR wszGroup[256]; // Unicode Group + + LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; + LPLOCALGROUP_USERS_INFO_0 pTmpBuf; + DWORD dwLevel = 0; + DWORD dwFlags = LG_INCLUDE_INDIRECT; + DWORD dwPrefMaxLen = -1; + DWORD dwEntriesRead = 0; + DWORD dwTotalEntries = 0; + NET_API_STATUS nStatus; + DWORD i; + DWORD dwTotalCount = 0; + +/* Convert ANSI User Name and Group to Unicode */ + + MultiByteToWideChar(CP_ACP, 0, UserName, + strlen(UserName) + 1, wszUserName, + sizeof(wszUserName) / sizeof(wszUserName[0])); + MultiByteToWideChar(CP_ACP, 0, Group, + strlen(Group) + 1, wszGroup, sizeof(wszGroup) / sizeof(wszGroup[0])); + strcpy(NTDomain, UserName); + if ((domain_qualify = strchr(NTDomain, '\\')) == NULL) { + strcpy(DomainUser, NTDomain); + strcpy(NTDomain, Default_NTDomain); + } else { + strcpy(DomainUser, domain_qualify + 1); + domain_qualify[0] = '\0'; + } + /* Log the client on to the local computer. */ + if (!LogonUser(DomainUser, + NTDomain, + Password, + LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hToken)) { + result = NTV_LOGON_ERROR; + error = GetLastError(); + } else { + /* + * Call the NetUserGetLocalGroups function + * specifying information level 0. + * + * The LG_INCLUDE_INDIRECT flag specifies that the + * function should also return the names of the local + * groups in which the user is indirectly a member. + */ + nStatus = NetUserGetLocalGroups(NULL, + wszUserName, + dwLevel, + dwFlags, + (LPBYTE *) & pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries); + /* + * If the call succeeds, + */ + if (nStatus == NERR_Success) { + if ((pTmpBuf = pBuf) != NULL) { + for (i = 0; i < dwEntriesRead; i++) { + assert(pTmpBuf != NULL); + if (pTmpBuf == NULL) { + result = NTV_SERVER_ERROR; + break; + } + if (wcscmp(pTmpBuf->lgrui0_name, wszGroup) == 0) { + result = NTV_NO_ERROR; + break; + } + pTmpBuf++; + dwTotalCount++; + } + } + } else + result = NTV_SERVER_ERROR; + /* + * Free the allocated memory. + */ + if (pBuf != NULL) + NetApiBufferFree(pBuf); + } + if (hToken != INVALID_HANDLE_VALUE) + CloseHandle(hToken); + return result; +} +#else /* NON Windows Platform !!! */ + +#error NON WINDOWS PLATFORM + +#endif Index: squid/src/auth/basic/helpers/win32_locallogon/valid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/basic/helpers/win32_locallogon/Attic/valid.h,v retrieving revision 1.1.38.1 retrieving revision 1.1.38.2 diff -u -r1.1.38.1 -r1.1.38.2 --- squid/src/auth/basic/helpers/win32_locallogon/valid.h 18 Mar 2002 22:39:44 -0000 1.1.38.1 +++ squid/src/auth/basic/helpers/win32_locallogon/valid.h 11 Apr 2002 20:15:57 -0000 1.1.38.2 @@ -1,18 +1,18 @@ -#ifndef _VALID_H_ -#define _VALID_H_ -/* SMB User verification function */ - -#define NTV_NO_ERROR 0 -#define NTV_SERVER_ERROR 1 -#define NTV_PROTOCOL_ERROR 2 -#define NTV_LOGON_ERROR 3 - -#ifndef LOGON32_LOGON_NETWORK -#define LOGON32_LOGON_NETWORK 3 -#endif - -#define NTV_DEFAULT_DOMAIN "." - -int Valid_User(char *,char *, char *); - -#endif +#ifndef _VALID_H_ +#define _VALID_H_ +/* SMB User verification function */ + +#define NTV_NO_ERROR 0 +#define NTV_SERVER_ERROR 1 +#define NTV_PROTOCOL_ERROR 2 +#define NTV_LOGON_ERROR 3 + +#ifndef LOGON32_LOGON_NETWORK +#define LOGON32_LOGON_NETWORK 3 +#endif + +#define NTV_DEFAULT_DOMAIN "." + +int Valid_User(char *,char *, char *); + +#endif