--------------------- PatchSet 2751 Date: 2001/08/13 17:09:16 Author: serassio Branch: nt-2_3 Tag: (none) Log: Added full command line support running as a Windows service Members: doc/WIN32-ChangeLog.txt:1.1.2.2->1.1.2.3 doc/readme.txt:1.1.2.2->1.1.2.3 include/autoconf.h:1.1.2.6->1.1.2.7 lib/heap.c:1.1.1.1.4.1.2.1->1.1.1.1.4.1.2.2 src/access_log.c:1.1.1.3.4.1.2.3->1.1.1.3.4.1.2.4 src/acl.c:1.1.1.3.4.3.2.3->1.1.1.3.4.3.2.4 src/cf.data.pre:1.1.1.3.4.3.2.2->1.1.1.3.4.3.2.3 src/client_side.c:1.1.1.3.4.6.2.4->1.1.1.3.4.6.2.5 src/comm.c:1.1.1.3.4.1.2.5->1.1.1.3.4.1.2.6 src/dns_internal.c:1.1.1.1.4.6.2.3->1.1.1.1.4.6.2.4 src/forward.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 src/ftp.c:1.1.1.3.4.3.2.1->1.1.1.3.4.3.2.2 src/globals.h:1.1.1.3.4.2.2.4->1.1.1.3.4.2.2.5 src/htcp.c:1.1.1.2.4.1.2.2->1.1.1.2.4.1.2.3 src/icp_v2.c:1.1.1.3.4.1.2.2->1.1.1.3.4.1.2.3 src/ident.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 src/ipc.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 src/main.c:1.1.1.3.4.2.2.9->1.1.1.3.4.2.2.10 src/protos.h:1.1.1.3.4.1.2.6->1.1.1.3.4.1.2.7 src/snmp_agent.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 src/snmp_core.c:1.1.1.3.4.1.2.3->1.1.1.3.4.1.2.4 src/ssl.c:1.1.1.3.4.1.2.1->1.1.1.3.4.1.2.2 src/structs.h:1.1.1.3.4.2.2.3->1.1.1.3.4.2.2.4 src/tools.c:1.1.1.3.4.1.2.6->1.1.1.3.4.1.2.7 src/wccp.c:1.1.1.1.4.2.2.1->1.1.1.1.4.2.2.2 src/win32.c:1.1.2.3->1.1.2.4 Index: squid/doc/WIN32-ChangeLog.txt =================================================================== RCS file: /cvsroot/squid-sf//squid/doc/Attic/WIN32-ChangeLog.txt,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/doc/WIN32-ChangeLog.txt 15 Jul 2001 16:58:37 -0000 1.1.2.2 +++ squid/doc/WIN32-ChangeLog.txt 13 Aug 2001 17:09:16 -0000 1.1.2.3 @@ -1,4 +1,4 @@ -Squid 2.3 Stable 4 for WIN32 Change Log +Squid 2.3 Stable 5 for WIN32 Change Log Plese note, that ALL the Windows NT source addition are encapsulated between #ifdef _SQUID_MSWIN_ - #endif sections. @@ -40,3 +40,5 @@ 07 Jul 2001 - Fixed a "non caching" bug - (Guido Serassio) 09 Jul 2001 - Enabled full "Process Filedescriptor Allocation" cachemgr features - (Guido Serassio) 15 Jul 2001 - Enabled SNMP functionality - (Guido Serassio) +31 Jul 2001 - Merged code enhancement from Andrey Shorin - (Guido Serassio) +13 Aug 2001 - Added support for Service command line with -O switch - (Guido Serassio) Index: squid/doc/readme.txt =================================================================== RCS file: /cvsroot/squid-sf//squid/doc/Attic/readme.txt,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/doc/readme.txt 15 Jul 2001 16:58:37 -0000 1.1.2.2 +++ squid/doc/readme.txt 13 Aug 2001 17:09:16 -0000 1.1.2.3 @@ -6,12 +6,13 @@ Run as a native Windows NT Service (No CygWin Unix emulation, compiled with MS VC++ 6.0) Multiple Squid service instances are allowed + Full Command line support when running as a service Use PSAPI.LIB for full getrusage emulation Internal DNS looks in registry for configured DNS, resolv.conf no more needed External DNS helper run as a DLL plug-in and use internal NT DNS resolver, so hosts file if used. All squid -k switches (check, debug, interrupt, kill, parse, reconfigure, rotate, shutdown) works - Native Windows NT Authenticator working as DLL plug-in, is possible to authenticante against a single NT - Server, a single or a trusted NT Domain. User access allowed by NT User Group membership + Native Windows NT Authenticator working as DLL plug-in, is possible to authenticante against a single NT Server, a + single or a trusted NT Domain. User access allowed by NT User Group membership NCSA Authenticator working as DLL plug-in Working htpasswd and chhpasswd.cgi for NCSA password support LDAP Authenticator working as DLL plug-in (NOT YET TESTED !!!) @@ -26,14 +27,16 @@ Read the CompileOptions.txt file Edit the squid.conf and change if needed the c:/squid path (use path with '/' char, NOT '\') Manually create ALL the directories specified in squid.conf, except the contents of the cache directory - squid -i [-f configfile] [-n servicename] (installs the servicename Squid service using the configfile - configuration file, default configfile is "c:/squid/etc/squid.conf", default servicename is "SquidNT2.3") + squid -i [-f configfile] [-n servicename] (installs the servicename Squid service using the configfile configuration + file, default configfile is "c:/squid/etc/squid.conf", default servicename is "SquidNT2.3") squid -z [-f configfile] (creates the cache directories) + squid -O servicecommandline [-n servicename] (Set in Windows Registry the Squid servicename service + command line) Authenticators configuration: Edit the squid.conf - Specify the FULL DLL path (with .dll suffix) in the authenticate_program directive plus the correct - parameter - See the original authenticator documentation + Specify the FULL DLL path (with .dll suffix) in the authenticate_program directive plus the correct parameter - + See the original authenticator documentation External DNS Helper Plug-in configuration (Only if compiled with internal DNS disabled): Edit the squid.conf @@ -49,17 +52,16 @@ squid -h Print help message. squid -n servicename [-f configfile] -k reconfigure | rotate | shutdown | interrupt | kill | debug | check Send signal to running copy and exit. + squid -O servicecommandline [-n servicename] Set Windows Service Command line options in Registry. squid -v Print version. - The results of the rest of the (original) cmdline switches when running as a Service is undeterminate (for the - moment). + The rest of the (original) cmdline switches when running as a Service must be used with the -O switch. This Squid build can support multiple Squid service instances running from the same executable. - Every instance must have a different service name, use different TCP ports and use a different configuration - file. - So, when installing the service, if don't using the default settings (c:/squid, SquidNT2.3 Service Name), the - service name and the associated config file MUST be specified. - The same when removing or running squid -k commands. + Every instance must have a different service name, use different TCP ports and use a different configuration file. + So, when installing the service, if don't using the default settings (c:/squid, SquidNT2.3 Service Name), the service + name and the associated config file MUST be specified. + The same when removing or running squid -k or -O commands. Command Line mode: All Squid cmdline switches are available, except the -N (no daemon mode) @@ -69,8 +71,7 @@ MS Visual Studio C++ 6.0 Native perl, sed and patch for NT PSAPI files from MS SDK - Download the latest Squid 2.3 STABLE 5 tarball, the squid-2.3.STABLE5-NT patch from - squid.sourceforge.net + Download the latest Squid 2.3 STABLE 5 tarball, the squid-2.3.STABLE5-NT patch from squid.sourceforge.net Apply squid-2.3.STABLE5-NT patch Verify the Squid options defined in autoconf.h Check default parameters on cf.data.mak file @@ -81,7 +82,10 @@ Squid features not operationals: WCCP, Transparent Proxy and Async I/O. Some code sections can make blocking calls. +At this time Windows is a platform unsupported from Squid Community. No warranties of any kind. No time for support, sorry. Use at your own risk. +SquidNT BUG Reports: squidnt@serassio.it + Original Port and some enhancements by Romeo Anghelache (see the ChangeLog) Index: squid/include/autoconf.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/Attic/autoconf.h,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid/include/autoconf.h 28 Jul 2001 10:18:13 -0000 1.1.2.6 +++ squid/include/autoconf.h 13 Aug 2001 17:09:16 -0000 1.1.2.7 @@ -93,7 +93,7 @@ * Traffic management via "delay pools". */ #undef DELAY_POOLS -#define DELAY_POOLS 1 +//#define DELAY_POOLS 1 /* * If you want to log User-Agent request header values, define this. Index: squid/lib/heap.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/heap.c,v retrieving revision 1.1.1.1.4.1.2.1 retrieving revision 1.1.1.1.4.1.2.2 diff -u -r1.1.1.1.4.1.2.1 -r1.1.1.1.4.1.2.2 --- squid/lib/heap.c 6 Jan 2001 12:40:10 -0000 1.1.1.1.4.1.2.1 +++ squid/lib/heap.c 13 Aug 2001 17:09:16 -0000 1.1.1.1.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: heap.c,v 1.1.1.1.4.1.2.1 2001/01/06 12:40:10 hno Exp $ + * $Id: heap.c,v 1.1.1.1.4.1.2.2 2001/08/13 17:09:16 serassio Exp $ * * AUTHOR: John Dilley, Hewlett Packard * @@ -449,7 +449,7 @@ int newSize; if (hp->size > Threshold) - newSize = hp->size * SlowRate; + newSize = (int) (hp->size * SlowRate); else newSize = hp->size * NormalRate; Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/access_log.c,v retrieving revision 1.1.1.3.4.1.2.3 retrieving revision 1.1.1.3.4.1.2.4 diff -u -r1.1.1.3.4.1.2.3 -r1.1.1.3.4.1.2.4 --- squid/src/access_log.c 15 Jul 2001 16:58:38 -0000 1.1.1.3.4.1.2.3 +++ squid/src/access_log.c 13 Aug 2001 17:09:16 -0000 1.1.1.3.4.1.2.4 @@ -1,7 +1,7 @@ /* - * $Id: access_log.c,v 1.1.1.3.4.1.2.3 2001/07/15 16:58:38 serassio Exp $ + * $Id: access_log.c,v 1.1.1.3.4.1.2.4 2001/08/13 17:09:16 serassio Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -402,11 +402,7 @@ mcast_miss_to.sin_port = htons(Config.mcast_miss.port); mcast_miss_to.sin_addr.s_addr = Config.mcast_miss.addr.s_addr; mcast_miss_fd = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ - IPPROTO_UDP, -#else - 0, -#endif + IPPROTO_UDP, Config.Addrs.udp_incoming, Config.mcast_miss.port, COMM_NONBLOCKING, Index: squid/src/acl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/acl.c,v retrieving revision 1.1.1.3.4.3.2.3 retrieving revision 1.1.1.3.4.3.2.4 diff -u -r1.1.1.3.4.3.2.3 -r1.1.1.3.4.3.2.4 --- squid/src/acl.c 17 Jun 2001 12:39:53 -0000 1.1.1.3.4.3.2.3 +++ squid/src/acl.c 13 Aug 2001 17:09:16 -0000 1.1.1.3.4.3.2.4 @@ -1,6 +1,6 @@ /* - * $Id: acl.c,v 1.1.1.3.4.3.2.3 2001/06/17 12:39:53 serassio Exp $ + * $Id: acl.c,v 1.1.1.3.4.3.2.4 2001/08/13 17:09:16 serassio Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -1758,7 +1758,7 @@ } void -aclNBCheck(aclCheck_t * checklist, PF callback, void *callback_data) +aclNBCheck(aclCheck_t * checklist, PF *callback, void *callback_data) { checklist->callback = callback; checklist->callback_data = callback_data; Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf.data.pre,v retrieving revision 1.1.1.3.4.3.2.2 retrieving revision 1.1.1.3.4.3.2.3 diff -u -r1.1.1.3.4.3.2.2 -r1.1.1.3.4.3.2.3 --- squid/src/cf.data.pre 3 Jun 2001 19:41:48 -0000 1.1.1.3.4.3.2.2 +++ squid/src/cf.data.pre 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.3.2.3 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.1.1.3.4.3.2.2 2001/06/03 19:41:48 serassio Exp $ +# $Id: cf.data.pre,v 1.1.1.3.4.3.2.3 2001/08/13 17:09:17 serassio Exp $ # # # SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -788,6 +788,21 @@ DOC_END +NAME: log_redirected_url +COMMENT: on|off +TYPE: onoff +LOC: Config.onoff.log_redirected_url +DEFAULT: off +DOC_START + The Cache logs original URL requested by clients to access_log. + This options allows to log URL like it looks after redirector + processed it. May be usable when you are concerned about traffic + volumes. By default this is off. + +log_redirected_url off +DOC_END + + NAME: pid_filename TYPE: string DEFAULT: @DEFAULT_PID_FILE@ @@ -2254,6 +2269,20 @@ DOC_END +NAME: source_ping +COMMENT: on|off +TYPE: onoff +IFDEF: ALLOW_SOURCE_PING +DEFAULT: off +LOC: Config.onoff.source_ping +DOC_START + If using the ICMP pinging stuff, ping source server each time + url is retrieved from it. + +source_ping off +DOC_END + + NAME: cachemgr_passwd TYPE: cachemgrpasswd DEFAULT: none Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.3.4.6.2.4 retrieving revision 1.1.1.3.4.6.2.5 diff -u -r1.1.1.3.4.6.2.4 -r1.1.1.3.4.6.2.5 --- squid/src/client_side.c 10 Jul 2001 19:42:13 -0000 1.1.1.3.4.6.2.4 +++ squid/src/client_side.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.6.2.5 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.6.2.4 2001/07/10 19:42:13 serassio Exp $ + * $Id: client_side.c,v 1.1.1.3.4.6.2.5 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -112,6 +112,10 @@ static int clientReplyBodyTooLarge(int clen); static int clientRequestBodyTooLarge(int clen); +#ifdef _SQUID_MSWIN_ +#define xstrerror() wsastrerror(errno) +#endif + static int checkAccelOnly(clientHttpRequest * http) { @@ -661,6 +665,8 @@ if (http->out.size || http->log_type) { http->al.icp.opcode = ICP_INVALID; http->al.url = http->log_uri; + if ( Config.onoff.log_redirected_url ) + http->al.url = http->uri; debug(33, 9) ("httpRequestFree: al.url='%s'\n", http->al.url); if (mem) { http->al.http.code = mem->reply->sline.status; @@ -2859,11 +2865,7 @@ } enter_suid(); fd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, -#else - 0, -#endif s->s.sin_addr, ntohs(s->s.sin_port), COMM_NONBLOCKING, Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.1.1.3.4.1.2.5 retrieving revision 1.1.1.3.4.1.2.6 diff -u -r1.1.1.3.4.1.2.5 -r1.1.1.3.4.1.2.6 --- squid/src/comm.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.1.2.5 +++ squid/src/comm.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.1.1.3.4.1.2.5 2001/07/29 16:06:05 serassio Exp $ + * $Id: comm.c,v 1.1.1.3.4.1.2.6 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -897,7 +897,6 @@ int commSetNonBlocking(int fd) { - int flags; int dummy = 0; #ifdef _SQUID_MSWIN_ int nonblocking = TRUE; @@ -907,6 +906,7 @@ } sd_table[fd].flags.nonblocking = 1; #else + int flags; if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { debug(50, 0) ("FD %d: fcntl F_GETFL: %s\n", fd, xstrerror()); return COMM_ERROR; @@ -923,7 +923,6 @@ int commUnsetNonBlocking(int fd) { - int flags; int dummy = 0; #ifdef _SQUID_MSWIN_ int nonblocking=0; @@ -933,6 +932,7 @@ } sd_table[fd].flags.nonblocking = 0; #else + int flags; if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { debug(50, 0) ("FD %d: fcntl F_GETFL: %s\n", fd, xstrerror()); return COMM_ERROR; Index: squid/src/dns_internal.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/dns_internal.c,v retrieving revision 1.1.1.1.4.6.2.3 retrieving revision 1.1.1.1.4.6.2.4 diff -u -r1.1.1.1.4.6.2.3 -r1.1.1.1.4.6.2.4 --- squid/src/dns_internal.c 29 Jul 2001 09:10:28 -0000 1.1.1.1.4.6.2.3 +++ squid/src/dns_internal.c 13 Aug 2001 17:09:17 -0000 1.1.1.1.4.6.2.4 @@ -1,6 +1,6 @@ /* - * $Id: dns_internal.c,v 1.1.1.1.4.6.2.3 2001/07/29 09:10:28 serassio Exp $ + * $Id: dns_internal.c,v 1.1.1.1.4.6.2.4 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c * AUTHOR: Duane Wessels @@ -593,11 +593,7 @@ static int init = 0; if (DnsSocket < 0) { DnsSocket = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Addrs.udp_outgoing, 0, COMM_NONBLOCKING, Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.1.1.3.4.1.2.2 retrieving revision 1.1.1.3.4.1.2.3 diff -u -r1.1.1.3.4.1.2.2 -r1.1.1.3.4.1.2.3 --- squid/src/forward.c 14 Jun 2001 21:34:24 -0000 1.1.1.3.4.1.2.2 +++ squid/src/forward.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.1.1.3.4.1.2.2 2001/06/14 21:34:24 serassio Exp $ + * $Id: forward.c,v 1.1.1.3.4.1.2.3 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -247,11 +247,7 @@ return; } fd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ - IPPROTO_TCP, -#else - 0, -#endif + IPPROTO_TCP, Config.Addrs.tcp_outgoing, 0, COMM_NONBLOCKING, Index: squid/src/ftp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v retrieving revision 1.1.1.3.4.3.2.1 retrieving revision 1.1.1.3.4.3.2.2 diff -u -r1.1.1.3.4.3.2.1 -r1.1.1.3.4.3.2.2 --- squid/src/ftp.c 6 Jan 2001 12:40:14 -0000 1.1.1.3.4.3.2.1 +++ squid/src/ftp.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.3.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ftp.c,v 1.1.1.3.4.3.2.1 2001/01/06 12:40:14 hno Exp $ + * $Id: ftp.c,v 1.1.1.3.4.3.2.2 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1688,11 +1688,7 @@ } /* Open data channel with the same local address as control channel */ fd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, -#else - 0, -#endif addr.sin_addr, 0, COMM_NONBLOCKING, @@ -1825,11 +1821,7 @@ port = ntohs(addr.sin_port); } fd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, -#else - 0, -#endif addr.sin_addr, port, COMM_NONBLOCKING | (fallback ? COMM_REUSEADDR : 0), Index: squid/src/globals.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/globals.h,v retrieving revision 1.1.1.3.4.2.2.4 retrieving revision 1.1.1.3.4.2.2.5 diff -u -r1.1.1.3.4.2.2.4 -r1.1.1.3.4.2.2.5 --- squid/src/globals.h 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.2.2.4 +++ squid/src/globals.h 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.2.2.5 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.1.1.3.4.2.2.4 2001/07/29 16:06:05 serassio Exp $ + * $Id: globals.h,v 1.1.1.3.4.2.2.5 2001/08/13 17:09:17 serassio Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -159,8 +159,9 @@ extern const char *SwapDirType[]; #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) extern unsigned int WIN32_OS_version; /* 0 */ -extern char *WIN32_OS_string; +extern char *WIN32_OS_string; /* NULL */ extern char *WIN32_Service_name; /* NULL */ +extern char *WIN32_Command_Line; /* NULL */ extern unsigned int WIN32_run_mode; /* _WIN_SQUID_RUN_MODE_INTERACTIVE */ #if defined(_SQUID_MSWIN_) && defined(_DEBUG) extern int do_debug; /* 0 */ Index: squid/src/htcp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/htcp.c,v retrieving revision 1.1.1.2.4.1.2.2 retrieving revision 1.1.1.2.4.1.2.3 diff -u -r1.1.1.2.4.1.2.2 -r1.1.1.2.4.1.2.3 --- squid/src/htcp.c 14 Jun 2001 21:34:24 -0000 1.1.1.2.4.1.2.2 +++ squid/src/htcp.c 13 Aug 2001 17:09:17 -0000 1.1.1.2.4.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: htcp.c,v 1.1.1.2.4.1.2.2 2001/06/14 21:34:24 serassio Exp $ + * $Id: htcp.c,v 1.1.1.2.4.1.2.3 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -841,11 +841,7 @@ { enter_suid(); htcpInSocket = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Addrs.udp_incoming, Config.Port.htcp, COMM_NONBLOCKING, @@ -859,11 +855,7 @@ if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr) { enter_suid(); htcpOutSocket = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Addrs.udp_outgoing, Config.Port.htcp, COMM_NONBLOCKING, Index: squid/src/icp_v2.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/icp_v2.c,v retrieving revision 1.1.1.3.4.1.2.2 retrieving revision 1.1.1.3.4.1.2.3 diff -u -r1.1.1.3.4.1.2.2 -r1.1.1.3.4.1.2.3 --- squid/src/icp_v2.c 14 Jun 2001 21:34:24 -0000 1.1.1.3.4.1.2.2 +++ squid/src/icp_v2.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.c,v 1.1.1.3.4.1.2.2 2001/06/14 21:34:24 serassio Exp $ + * $Id: icp_v2.c,v 1.1.1.3.4.1.2.3 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -413,11 +413,7 @@ return; enter_suid(); theInIcpConnection = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Addrs.udp_incoming, port, COMM_NONBLOCKING, @@ -438,11 +434,7 @@ if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) { enter_suid(); theOutIcpConnection = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif addr, port, COMM_NONBLOCKING, Index: squid/src/ident.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ident.c,v retrieving revision 1.1.1.3.4.1.2.1 retrieving revision 1.1.1.3.4.1.2.2 diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2 --- squid/src/ident.c 6 Jan 2001 12:40:14 -0000 1.1.1.3.4.1.2.1 +++ squid/src/ident.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ident.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:14 hno Exp $ + * $Id: ident.c,v 1.1.1.3.4.1.2.2 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -208,11 +208,7 @@ return; } fd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, -#else - 0, -#endif me->sin_addr, 0, COMM_NONBLOCKING, Index: squid/src/ipc.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ipc.c,v retrieving revision 1.1.1.3.4.1.2.1 retrieving revision 1.1.1.3.4.1.2.2 diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2 --- squid/src/ipc.c 6 Jan 2001 12:40:14 -0000 1.1.1.3.4.1.2.1 +++ squid/src/ipc.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ipc.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:14 hno Exp $ + * $Id: ipc.c,v 1.1.1.3.4.1.2.2 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -85,42 +85,26 @@ *wfd = -1; if (type == IPC_TCP_SOCKET) { crfd = cwfd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, -#else - 0, -#endif local_addr, 0, COMM_NOCLOEXEC, name); prfd = pwfd = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, /* protocol */ -#else - 0, /* protocol */ -#endif local_addr, 0, /* port */ 0, /* blocking */ name); } else if (type == IPC_UDP_SOCKET) { crfd = cwfd = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif local_addr, 0, COMM_NOCLOEXEC, name); prfd = pwfd = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif local_addr, 0, 0, Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.1.1.3.4.2.2.9 retrieving revision 1.1.1.3.4.2.2.10 diff -u -r1.1.1.3.4.2.2.9 -r1.1.1.3.4.2.2.10 --- squid/src/main.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.2.2.9 +++ squid/src/main.c 13 Aug 2001 17:09:17 -0000 1.1.1.3.4.2.2.10 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.1.1.3.4.2.2.9 2001/07/29 16:06:05 serassio Exp $ + * $Id: main.c,v 1.1.1.3.4.2.2.10 2001/08/13 17:09:17 serassio Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -44,6 +44,7 @@ static int opt_install_service = FALSE; static int opt_remove_service = FALSE; static int opt_signal_service = FALSE; +static int opt_command_line = FALSE; extern void WIN32_svcstatusupdate(DWORD); void WINAPI WIN32_svcHandler(DWORD); #endif @@ -97,7 +98,7 @@ { fprintf(stderr, #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) - "Usage: %s [-dhirsvzCDFRVYX] [-f config-file] [-[au] port] [-k signal] [-n name]\n" + "Usage: %s [-dhirsvzCDFRVYX] [-f config-file] [-[au] port] [-k signal] [-n name] [-O CommandLine]\n" #else "Usage: %s [-dhsvzCDFNRVYX] [-f config-file] [-[au] port] [-k signal]\n" #endif @@ -126,6 +127,9 @@ " -F Don't serve any requests until store is rebuilt.\n" #if !(defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_))) " -N No daemon mode.\n" +#else + " -O options\n" + " Set Windows Service Command line options in Registry.\n" #endif " -R Do not set REUSEADDR on port.\n" " -V Virtual host httpd-accelerator.\n" @@ -142,7 +146,7 @@ int c; #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) - while ((c = getopt(argc, argv, "CDFRSVYXa:d:f:hik:m::n:rsu:vz?")) != -1) { + while ((c = getopt(argc, argv, "CDFO:RSVYXa:d:f:hik:m::n:rsu:vz?")) != -1) { #else while ((c = getopt(argc, argv, "CDFNRSVYXa:d:f:hk:m::su:vz?")) != -1) { #endif @@ -160,6 +164,11 @@ case 'N': opt_no_daemon = 1; break; +#else + case 'O': + opt_command_line = 1; + WIN32_Command_Line = xstrdup(optarg); + break; #endif case 'R': opt_reuseaddr = 0; @@ -637,7 +646,7 @@ #if defined(USE_WIN32_SERVICE) && (defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)) /* When USE_WIN32_SERVICE is defined, the main function is placed in win32.c */ -void WINAPI SquidMain(DWORD argc, char **argv) +void WINAPI SquidMain(int argc, char **argv) #else int main(int argc, char **argv) @@ -654,7 +663,7 @@ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) #ifdef USE_WIN32_SERVICE - if (WIN32_Subsystem_Init()) + if (WIN32_Subsystem_Init(&argc, &argv)) return; #else { @@ -717,6 +726,10 @@ WIN32_RemoveService(); return; } + if (opt_command_line) { + WIN32_SetServiceCommandLine(); + return; + } #endif /* parse configuration file * note: in "normal" case this used to be called from mainInitialize() */ @@ -1077,9 +1090,5 @@ version_string); if (debug_log) fclose(debug_log); -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) - WIN32_Exit(0); -#else exit(0); -#endif } Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.1.1.3.4.1.2.6 retrieving revision 1.1.1.3.4.1.2.7 diff -u -r1.1.1.3.4.1.2.6 -r1.1.1.3.4.1.2.7 --- squid/src/protos.h 29 Jul 2001 09:10:28 -0000 1.1.1.3.4.1.2.6 +++ squid/src/protos.h 13 Aug 2001 17:09:18 -0000 1.1.1.3.4.1.2.7 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.1.1.3.4.1.2.6 2001/07/29 09:10:28 serassio Exp $ + * $Id: protos.h,v 1.1.1.3.4.1.2.7 2001/08/13 17:09:18 serassio Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1230,9 +1230,15 @@ /* CygWin & Windows NT Port */ /* win32.c */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) -extern int WIN32_Subsystem_Init(); +#ifdef USE_WIN32_SERVICE +extern int WIN32_Subsystem_Init(int *, char ***); +#else +extern int WIN32_Subsystem_Init(void); +#endif extern void WIN32_sendSignal(int); -extern void WIN32_Exit(int); +extern void WIN32_Abort(int); +extern void WIN32_Exit(void); +extern void WIN32_SetServiceCommandLine(void); extern void WIN32_InstallService(void); extern void WIN32_RemoveService(void); #endif Index: squid/src/snmp_agent.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/snmp_agent.c,v retrieving revision 1.1.1.3.4.1.2.1 retrieving revision 1.1.1.3.4.1.2.2 diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2 --- squid/src/snmp_agent.c 6 Jan 2001 12:40:16 -0000 1.1.1.3.4.1.2.1 +++ squid/src/snmp_agent.c 13 Aug 2001 17:09:18 -0000 1.1.1.3.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: snmp_agent.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:16 hno Exp $ + * $Id: snmp_agent.c,v 1.1.1.3.4.1.2.2 2001/08/13 17:09:18 serassio Exp $ * * DEBUG: section 49 SNMP Interface * AUTHOR: Kostas Anagnostakis @@ -65,7 +65,7 @@ break; case SYS_UPTIME: Answer = snmp_var_new_integer(Var->name, Var->name_length, - tvSubDsec(squid_start, current_time) * 100, + (int) tvSubDsec(squid_start, current_time) * 100, SMI_TIMETICKS); break; default: Index: squid/src/snmp_core.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/snmp_core.c,v retrieving revision 1.1.1.3.4.1.2.3 retrieving revision 1.1.1.3.4.1.2.4 diff -u -r1.1.1.3.4.1.2.3 -r1.1.1.3.4.1.2.4 --- squid/src/snmp_core.c 15 Jul 2001 08:49:37 -0000 1.1.1.3.4.1.2.3 +++ squid/src/snmp_core.c 13 Aug 2001 17:09:18 -0000 1.1.1.3.4.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: snmp_core.c,v 1.1.1.3.4.1.2.3 2001/07/15 08:49:37 serassio Exp $ + * $Id: snmp_core.c,v 1.1.1.3.4.1.2.4 2001/08/13 17:09:18 serassio Exp $ * * DEBUG: section 49 SNMP support * AUTHOR: Glenn Chisholm @@ -348,11 +348,7 @@ if ((port = Config.Port.snmp) > (u_short) 0) { enter_suid(); theInSnmpConnection = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Addrs.snmp_incoming, port, COMM_NONBLOCKING, @@ -366,11 +362,7 @@ if (Config.Addrs.snmp_outgoing.s_addr != no_addr.s_addr) { enter_suid(); theOutSnmpConnection = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Addrs.snmp_outgoing, port, COMM_NONBLOCKING, Index: squid/src/ssl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ssl.c,v retrieving revision 1.1.1.3.4.1.2.1 retrieving revision 1.1.1.3.4.1.2.2 diff -u -r1.1.1.3.4.1.2.1 -r1.1.1.3.4.1.2.2 --- squid/src/ssl.c 6 Jan 2001 12:40:16 -0000 1.1.1.3.4.1.2.1 +++ squid/src/ssl.c 13 Aug 2001 17:09:18 -0000 1.1.1.3.4.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.1.1.3.4.1.2.1 2001/01/06 12:40:16 hno Exp $ + * $Id: ssl.c,v 1.1.1.3.4.1.2.2 2001/08/13 17:09:18 serassio Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -443,11 +443,7 @@ Counter.server.other.requests++; /* Create socket. */ sock = comm_open(SOCK_STREAM, -#ifdef _SQUID_MSWIN_ IPPROTO_TCP, -#else - 0, -#endif Config.Addrs.tcp_outgoing, 0, COMM_NONBLOCKING, Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.4.2.2.3 retrieving revision 1.1.1.3.4.2.2.4 diff -u -r1.1.1.3.4.2.2.3 -r1.1.1.3.4.2.2.4 --- squid/src/structs.h 14 Jun 2001 20:36:16 -0000 1.1.1.3.4.2.2.3 +++ squid/src/structs.h 13 Aug 2001 17:09:18 -0000 1.1.1.3.4.2.2.4 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.2.2.3 2001/06/14 20:36:16 serassio Exp $ + * $Id: structs.h,v 1.1.1.3.4.2.2.4 2001/08/13 17:09:18 serassio Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -417,6 +417,7 @@ #if USE_CACHE_DIGESTS int digest_generation; #endif + int log_redirected_url; int ie_refresh; } onoff; acl *aclList; Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.1.1.3.4.1.2.6 retrieving revision 1.1.1.3.4.1.2.7 diff -u -r1.1.1.3.4.1.2.6 -r1.1.1.3.4.1.2.7 --- squid/src/tools.c 29 Jul 2001 16:06:05 -0000 1.1.1.3.4.1.2.6 +++ squid/src/tools.c 13 Aug 2001 17:09:18 -0000 1.1.1.3.4.1.2.7 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.1.1.3.4.1.2.6 2001/07/29 16:06:05 serassio Exp $ + * $Id: tools.c,v 1.1.1.3.4.1.2.7 2001/08/13 17:09:18 serassio Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -396,11 +396,10 @@ if (0 == store_dirs_rebuilding) storeDirWriteCleanLogs(0); fatal_common(message); -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) - WIN32_Exit(shutting_down ? 0 : 1); -#else - exit(shutting_down ? 0 : 1); -#endif + if (shutting_down) + exit(0); + else + abort(); } /* printf-style interface for fatal */ Index: squid/src/wccp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/wccp.c,v retrieving revision 1.1.1.1.4.2.2.1 retrieving revision 1.1.1.1.4.2.2.2 diff -u -r1.1.1.1.4.2.2.1 -r1.1.1.1.4.2.2.2 --- squid/src/wccp.c 6 Jan 2001 12:40:17 -0000 1.1.1.1.4.2.2.1 +++ squid/src/wccp.c 13 Aug 2001 17:09:18 -0000 1.1.1.1.4.2.2.2 @@ -1,6 +1,6 @@ /* - * $Id: wccp.c,v 1.1.1.1.4.2.2.1 2001/01/06 12:40:17 hno Exp $ + * $Id: wccp.c,v 1.1.1.1.4.2.2.2 2001/08/13 17:09:18 serassio Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Glenn Chisholm @@ -126,11 +126,7 @@ return; } theInWccpConnection = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ IPPROTO_UDP, -#else - 0, -#endif Config.Wccp.incoming, port, COMM_NONBLOCKING, @@ -146,11 +142,7 @@ (int) port, theInWccpConnection); if (Config.Wccp.outgoing.s_addr != no_addr.s_addr) { theOutWccpConnection = comm_open(SOCK_DGRAM, -#ifdef _SQUID_MSWIN_ - IPPROTO_UDP, -#else - 0, -#endif + IPPROTO_UDP, Config.Wccp.outgoing, port, COMM_NONBLOCKING, Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid/src/win32.c 14 Jun 2001 20:36:16 -0000 1.1.2.3 +++ squid/src/win32.c 13 Aug 2001 17:09:18 -0000 1.1.2.4 @@ -32,7 +32,9 @@ void WINAPI WIN32_svcHandler(DWORD); static int WIN32_StoreKey(const char *, DWORD, unsigned char *, int); static int WIN32_create_key(void); -void WINAPI SquidMain(DWORD, char **); +static void WIN32_build_argv (char *); +void WINAPI SquidMain(int, char **); + /* The following code section is part of an EXPERIMENTAL native */ /* Windows NT/2000 Squid port - Compiles only on MS Visual C++ */ #if defined(_SQUID_MSWIN_) @@ -42,15 +44,28 @@ static SERVICE_STATUS svcStatus; static SERVICE_STATUS_HANDLE svcHandle; +static int WIN32_argc; +static char ** WIN32_argv; +static char * WIN32_module_name; #define VENDOR "GNU" #if defined(_SQUID_MSWIN_) -#define SOFTWARE "SquidNT" +#define SOFTWARENAME "SquidNT" #else -#define SOFTWARE "Squid" +#define SOFTWARENAME "Squid" #endif -#define VERSION "2.3-STABLE-4" -#define REGKEY "SOFTWARE\\" VENDOR "\\" SOFTWARE "\\" VERSION +#define VERSION "2.3-STABLE-5" +#define COMMANDLINE "CommandLine" +#define CONFIGFILE "ConfigFile" +static char REGKEY[256]="SOFTWARE\\"VENDOR"\\"SOFTWARENAME"\\"VERSION"\\"; +static char *keys[] = { + "SOFTWARE", /* key[0] */ + VENDOR, /* key[1] */ + SOFTWARENAME, /* key[2] */ + VERSION, /* key[3] */ + NULL, /* key[4] */ + NULL /* key[5] */ +}; /* ====================================================================== */ /* LOCAL FUNCTIONS */ @@ -59,12 +74,6 @@ static int WIN32_create_key(void) { - static char *keys[] = { "SOFTWARE", - VENDOR, - SOFTWARE, - VERSION, - NULL - }; int index; HKEY hKey; HKEY hKeyNext; @@ -216,43 +225,94 @@ return _WIN_OS_UNKNOWN; } +/* Build argv, argc from string passed from Windows. */ +static void WIN32_build_argv(char *cmd) +{ + int argvlen = 0; + char *word; + + WIN32_argc = 1; + WIN32_argv = (char **) xmalloc ((WIN32_argc+1) * sizeof (char *)); + WIN32_argv[0]=xstrdup(WIN32_module_name); +/* Scan command line until there is nothing left. */ + while (*cmd) { + /* Ignore spaces */ + if (xisspace(*cmd)) { + cmd++; + continue; + } + /* Found the beginning of an argument. */ + word = cmd; + while (*cmd) { + cmd++; /* Skip over this character */ + if (xisspace(*cmd)) /* End of argument if space */ + break; + } + if (*cmd) + *cmd++ = '\0'; /* Terminate `word' */ + /* See if we need to allocate more space for argv */ + if (WIN32_argc >= argvlen) { + argvlen = WIN32_argc + 1; + WIN32_argv = (char **) xrealloc (WIN32_argv, (1 + argvlen) * sizeof (char *)); + } + /* Add word to argv file. */ + WIN32_argv[WIN32_argc++] = word; + } + WIN32_argv[WIN32_argc] = NULL; +} + /* ====================================================================== */ /* PUBLIC FUNCTIONS */ /* ====================================================================== */ -VOID -WIN32_Exit(int ExitStatus) +void +WIN32_Abort(int sig) +{ +#ifdef USE_WIN32_SERVICE + svcStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; + svcStatus.dwServiceSpecificExitCode = 1; +#endif + WIN32_Exit(); +} + +void +WIN32_Exit() { #ifdef _SQUID_MSWIN_ Win32SockCleanup(); #endif #ifdef USE_WIN32_SERVICE - if (ExitStatus) { - svcStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; - svcStatus.dwServiceSpecificExitCode = 1; - } svcStatus.dwCurrentState = SERVICE_STOPPED; SetServiceStatus(svcHandle, &svcStatus); #endif - exit(0); + _exit(0); } -int -WIN32_Subsystem_Init() +#ifdef USE_WIN32_SERVICE +int WIN32_Subsystem_Init(int * argc, char *** argv) +#else +int WIN32_Subsystem_Init() +#endif { WIN32_OS_version = GetOSVersion(); + if (atexit(WIN32_Exit) != 0) + return 1; #ifdef USE_WIN32_SERVICE if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { char path[512]; HKEY hndKey; + char * CommandLine; + if (signal(SIGABRT, WIN32_Abort) == SIG_ERR) + return 1; /* Register the service Handler function */ svcHandle = RegisterServiceCtrlHandler(WIN32_Service_name, WIN32_svcHandler); if (svcHandle == 0) return 1; - /* Set Process work dir to directory cointaining squid.exe */ +/* Set Process work dir to directory cointaining squid.exe */ GetModuleFileName(NULL, path, 512); + WIN32_module_name=xstrdup(path); path[strlen(path) - 10] = '\0'; if (SetCurrentDirectory(path) == 0) return 1; @@ -263,17 +323,31 @@ DWORD Size = 0; LONG Result; Result = - RegQueryValueEx(hndKey, WIN32_Service_name, NULL, &Type, NULL, &Size); + RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, NULL, &Size); if (Result == ERROR_SUCCESS && Size) { ConfigFile = xmalloc(Size); - RegQueryValueEx(hndKey, WIN32_Service_name, NULL, &Type, ConfigFile, + RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, ConfigFile, &Size); } else ConfigFile = xstrdup(DefaultConfigFile); + Size = 0; + Type = 0; + Result = + RegQueryValueEx(hndKey, COMMANDLINE, NULL, &Type, NULL, &Size); + if (Result == ERROR_SUCCESS && Size) { + CommandLine = xmalloc(Size); + RegQueryValueEx(hndKey, COMMANDLINE, NULL, &Type, CommandLine, + &Size); + } else + CommandLine = xstrdup(""); RegCloseKey(hndKey); } else { ConfigFile = xstrdup(DefaultConfigFile); + CommandLine = xstrdup(""); } + WIN32_build_argv(CommandLine); + *argc = WIN32_argc; + *argv = WIN32_argv; /* Set Service Staus to SERVICE_START_PENDING */ svcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; svcStatus.dwCurrentState = SERVICE_START_PENDING; @@ -366,6 +440,8 @@ if (!WIN32_Service_name) WIN32_Service_name = xstrdup(_WIN_SQUID_DEFAULT_SERVICE_NAME); + strcat(REGKEY, WIN32_Service_name); + keys[4] = WIN32_Service_name; schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */ NULL, /* database (NULL == default) */ SC_MANAGER_ALL_ACCESS /* access required */ @@ -402,6 +478,17 @@ } void +WIN32_SetServiceCommandLine() +{ + if (!WIN32_Service_name) + WIN32_Service_name = xstrdup(_WIN_SQUID_DEFAULT_SERVICE_NAME); + strcat(REGKEY, WIN32_Service_name); + keys[4] = WIN32_Service_name; + /* Now store the Service Command Line in the registry */ + WIN32_StoreKey(COMMANDLINE, REG_SZ, (unsigned char *) WIN32_Command_Line, strlen(WIN32_Command_Line) + 1); +} + +void WIN32_InstallService() { SC_HANDLE schService; @@ -412,6 +499,8 @@ if (!WIN32_Service_name) WIN32_Service_name = xstrdup(_WIN_SQUID_DEFAULT_SERVICE_NAME); + strcat(REGKEY, WIN32_Service_name); + keys[4] = WIN32_Service_name; if ((lenpath = GetModuleFileName(NULL, ServicePath, 512)) == 0) { debug(1, 1) ("Can't get executable path"); exit(1); @@ -444,7 +533,7 @@ /* Now store the config file location in the registry */ if (!ConfigFile) ConfigFile = xstrdup(DefaultConfigFile); - WIN32_StoreKey(WIN32_Service_name, REG_SZ, (unsigned char *) ConfigFile, strlen(ConfigFile) + 1); + WIN32_StoreKey(CONFIGFILE, REG_SZ, (unsigned char *) ConfigFile, strlen(ConfigFile) + 1); printf("Squid Cache version %s for %s\n", version_string, CONFIG_HOST_TYPE); printf("installed successfully as %s Windows System Service.\n", @@ -557,6 +646,8 @@ } WIN32_Service_name = xstrdup(c+1); DispatchTable[0].lpServiceName=WIN32_Service_name; + strcat(REGKEY, WIN32_Service_name); + keys[4] = WIN32_Service_name; if (!StartServiceCtrlDispatcher(DispatchTable)) { fprintf(stderr, "StartServiceCtrlDispatcher error = %ld\n", GetLastError());