Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT cygwin DOT com Delivered-To: mailing list cygwin-developers AT cygwin DOT com Date: Mon, 24 Feb 2003 15:02:01 -0500 From: Jason Tishler Subject: exim 4.12-3 winsock problem (was Re: 1.3.21) In-reply-to: <20030221191209.GE1408@tishler.net> To: "Pierre A. Humblet" Cc: Cygwin , cygwin-developers AT cygwin DOT com Reply-to: Cygwin Mail-followup-to: "Pierre A. Humblet" , Cygwin , cygwin-developers AT cygwin DOT com Message-id: <20030224200201.GA2348@tishler.net> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_JJ+Yy7kOHv7EVew8Y0Y/pw)" User-Agent: Mutt/1.4i References: <20030221153741 DOT GA26756 AT redhat DOT com> <20030221180822 DOT GB1408 AT tishler DOT net> <3E566E49 DOT 53BE7CBE AT ieee DOT org> <20030221191209 DOT GE1408 AT tishler DOT net> --Boundary_(ID_JJ+Yy7kOHv7EVew8Y0Y/pw) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline Pierre, [I'm moving this thread to cygwin@, since it currently doesn't appear to be a cygwin-developers@ issue...] On Fri, Feb 21, 2003 at 02:12:09PM -0500, Jason Tishler wrote: > On Fri, Feb 21, 2003 at 01:22:01PM -0500, Pierre A. Humblet wrote: > > This reminds me of something similar, possibly last month. Look for > > "exim", "services", "gerritt" In the end it was because exim was > > running as a special user who didn't have permission on the whole > > tree under c:\winnt. First make sure Everybody has rx access to it. You may be onto something, see below... > I found some 770s, changed them to 775, but still no luck. > > The above doesn't explain why the attached works when run under the > exim account even with the "bad" permissions: > > $ ssh exim AT localhost /tmp/getservbyname > getservbyname(smtp, tcp) succeeded > port = 6400 > > It also doesn't explain with gdb and strace "fixed" the bad > permissions too. See below... On Fri, Feb 21, 2003 at 01:33:17PM -0500, Pierre A. Humblet wrote: > FYI here is some correspondence from the previous similar problem. I > had a private debugging conversation involving sending long straces > etc... > > It was a winsock error due to permission problem. winsock didn't init > properly, and cywin went ahead anyway! > > ******************* > Thanks. It's definitely a winsock error. > Looking into it. > > 627 272260 [main] exim-4.12-2 2816 wsock_init: res 10107 <==== SHOULD BE 0 Since the problem "goes away" with strace and in gdb, I have hacked my DLL with the attached patches. When I start exim under the LocalSystem and exim accounts, I get the following: $ exim -bdf -q15m wsock_init(): wsock_started = 0 wsock_init(): wsastartup = 0x7503d2c3 wsock_init(): wsastartup() returned 10107 getservbyname() failed with last error = 10093 Any further suggestions? Note this is very painful to debug because I can't use gdb and I can't send mail when trying to debug. Sigh... :,( Thanks, Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 --Boundary_(ID_JJ+Yy7kOHv7EVew8Y0Y/pw) Content-type: text/plain; charset=us-ascii; NAME=autoload.cc.diff Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=autoload.cc.diff Index: autoload.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/autoload.cc,v retrieving revision 1.62 diff -u -p -r1.62 autoload.cc --- autoload.cc 20 Feb 2003 11:12:44 -0000 1.62 +++ autoload.cc 24 Feb 2003 19:31:48 -0000 @@ -240,12 +240,15 @@ std_dll_init () return ret.ll; } +#include + /* Initialization function for winsock stuff. */ static long long wsock_init () __asm__ ("wsock_init") __attribute__ ((unused, regparm(1))); bool NO_COPY wsock_started = 0; static long long wsock_init () { + printf("wsock_init(): wsock_started = %ld\n", wsock_started); static LONG NO_COPY here = -1L; struct func_info *func = (struct func_info *) __builtin_return_address (0); struct dll_info *dll = func->dll; @@ -273,9 +276,14 @@ wsock_init () wsastartup = (int (*)(int, WSADATA *)) GetProcAddress ((HMODULE) (dll->handle), "WSAStartup"); + printf("wsock_init(): wsastartup = %p\n", wsastartup); if (wsastartup) { int res = wsastartup ((2<<8) | 2, &wsadata); + printf("wsock_init(): wsastartup() returned %d\n", res); + if (res == 0) + printf("winsock_active = %ld, winsock2_active = %ld\n", + winsock_active, winsock2_active); debug_printf ("res %d", res); debug_printf ("wVersion %d", wsadata.wVersion); --Boundary_(ID_JJ+Yy7kOHv7EVew8Y0Y/pw) Content-type: text/plain; charset=us-ascii; NAME=net.cc.diff Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=net.cc.diff Index: net.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/net.cc,v retrieving revision 1.140 diff -u -p -r1.140 net.cc --- net.cc 20 Feb 2003 14:14:37 -0000 1.140 +++ net.cc 24 Feb 2003 19:31:14 -0000 @@ -849,6 +849,8 @@ out: static struct servent *servent_buf = NULL; #endif +#include + /* exported as getservbyname: standards? */ extern "C" struct servent * cygwin_getservbyname (const char *name, const char *proto) @@ -863,6 +865,9 @@ cygwin_getservbyname (const char *name, servent_buf = dup_servent_ptr (getservbyname (name, proto)); if (!servent_buf) set_winsock_errno (); + + if (!servent_buf) + printf("getservbyname() failed with last error = %ld\n", GetLastError ()); syscall_printf ("%x = getservbyname (%s, %s)", servent_buf, name, proto); return servent_buf; --Boundary_(ID_JJ+Yy7kOHv7EVew8Y0Y/pw)--