Re: gethostbyname in 3.8 returns error -1
Otto Moerbeek wrote: On Tue, 6 Dec 2005, Federico Giannici wrote: Since I upgraded an OpenBSD/amd64 3.7 to 3.8 (following instructions in the Upgrade Guide) sometimes gethostbyname() returns NULL with h_errno equal to -1 (Resolver internal error). What is the value of errno? errno is 2. The program (OpenSER 1.0.0) had no problems under 3.7. The domain string is correct. The error seems to appear the SECOND time the gethostbyname() function is called by the same process. What could be the problem? Check the usual suspect: /etc/resolv.conf It is the same of 3.7, simply the following: lookup file bind nameserver 195.120.250.10 May it be relevant that the program is run chrootted??? I'm going to make some tests, as soon as I have the time... Bye. -- ___ __ |- [EMAIL PROTECTED] |ederico Giannici http://www.neomedia.it ___
Re: gethostbyname in 3.8 returns error -1
Federico Giannici wrote: Otto Moerbeek wrote: On Tue, 6 Dec 2005, Federico Giannici wrote: Since I upgraded an OpenBSD/amd64 3.7 to 3.8 (following instructions in the Upgrade Guide) sometimes gethostbyname() returns NULL with h_errno equal to -1 (Resolver internal error). What is the value of errno? errno is 2. The program (OpenSER 1.0.0) had no problems under 3.7. The domain string is correct. The error seems to appear the SECOND time the gethostbyname() function is called by the same process. What could be the problem? Check the usual suspect: /etc/resolv.conf It is the same of 3.7, simply the following: lookup file bind nameserver 195.120.250.10 May it be relevant that the program is run chrootted??? I'm going to make some tests, as soon as I have the time... Got it! I simply copied /etc/resolv.conf to the chrootted path and the problem disappeared. So something changed beetween 3.7 and 3.8 in the way /etc/resolv.conf is accessed... Thank you. -- ___ __ |- [EMAIL PROTECTED] |ederico Giannici http://www.neomedia.it ___
Re: gethostbyname in 3.8 returns error -1
On 12/7/05, Federico Giannici [EMAIL PROTECTED] wrote: May it be relevant that the program is run chrootted??? I'm going to make some tests, as soon as I have the time... Got it! I simply copied /etc/resolv.conf to the chrootted path and the problem disappeared. So something changed beetween 3.7 and 3.8 in the way /etc/resolv.conf is accessed... i made some changes to the resolver, though they should deal with this situation (unless there's a bug).
Re: gethostbyname in 3.8 returns error -1
On Wed, 7 Dec 2005, Ted Unangst wrote: On 12/7/05, Federico Giannici [EMAIL PROTECTED] wrote: May it be relevant that the program is run chrootted??? I'm going to make some tests, as soon as I have the time... Got it! I simply copied /etc/resolv.conf to the chrootted path and the problem disappeared. So something changed beetween 3.7 and 3.8 in the way /etc/resolv.conf is accessed... i made some changes to the resolver, though they should deal with this situation (unless there's a bug). I only grepped through the code of openser briefly, but this scenario seems likely. 1. App calls res_init() which calls _res_init(1); _resp-restimespe does not get set 2. App calls gethostbyname(), all is fine. 3. App does chroot. 4. App calls gethostbyname(), which calls _res_init(0). Let's assume the recheck is done. The stat() will fail, but since _resp-restimespec is not set, it will fall through and try to read /etc/resolv.conf from within the chroot. -Otto
Re: gethostbyname in 3.8 returns error -1
On 12/7/05, Otto Moerbeek [EMAIL PROTECTED] wrote: i made some changes to the resolver, though they should deal with this situation (unless there's a bug). I only grepped through the code of openser briefly, but this scenario seems likely. 1. App calls res_init() which calls _res_init(1); _resp-restimespe does not get set 2. App calls gethostbyname(), all is fine. 3. App does chroot. 4. App calls gethostbyname(), which calls _res_init(0). Let's assume the recheck is done. The stat() will fail, but since _resp-restimespec is not set, it will fall through and try to read /etc/resolv.conf from within the chroot. yes, i think making it set restimespec to now (long ago?) would be a good fix.
Re: gethostbyname in 3.8 returns error -1
try this, i think it covers the chroot case better. Index: res_init.c === RCS file: /cvs/src/lib/libc/net/res_init.c,v retrieving revision 1.33 diff -u -r1.33 res_init.c --- res_init.c 2005/08/06 20:30:04 1.33 +++ res_init.c 2005/12/08 05:42:29 @@ -178,27 +178,24 @@ int dots; #endif - if (usercall == 0) { - if (_resp-options RES_INIT - _resp-reschktime = time(NULL)) + if (!usercall _resp-options RES_INIT + _resp-reschktime = time(NULL)) + return (0); + _resp-reschktime = time(NULL) + __res_chktime; + if (stat(_PATH_RESCONF, sb) != -1) { + if (!usercall timespeccmp(sb.st_mtimespec, + _resp-restimespec, ==)) return (0); - _resp-reschktime = time(NULL) + __res_chktime; - if (stat(_PATH_RESCONF, sb) != -1) { - if (timespeccmp(sb.st_mtimespec, - _resp-restimespec, ==)) - return (0); - else - _resp-restimespec = sb.st_mtimespec; - } else { - /* -* Lost the file, in chroot? -* Don' trash settings -*/ - if (timespecisset(_resp-restimespec)) - return (0); - } - } else - _resp-reschktime = time(NULL) + __res_chktime; + else + _resp-restimespec = sb.st_mtimespec; + } else { + /* +* Lost the file, in chroot? +* Don't trash settings +*/ + if (!usercall timespecisset(_resp-restimespec)) + return (0); + } /* -- die energie aus fleisch und blutdeine sprache und die ganze wut deine gefuehle die du lebst und dein herz fuehl wie es bebt zeitbombe! sie tickt in dirzeitbombe! sie explodiert in deinem kopf - girls under glass
gethostbyname in 3.8 returns error -1
Since I upgraded an OpenBSD/amd64 3.7 to 3.8 (following instructions in the Upgrade Guide) sometimes gethostbyname() returns NULL with h_errno equal to -1 (Resolver internal error). The program (OpenSER 1.0.0) had no problems under 3.7. The domain string is correct. The error seems to appear the SECOND time the gethostbyname() function is called by the same process. What could be the problem? Thanks. -- ___ __ |- [EMAIL PROTECTED] |ederico Giannici http://www.neomedia.it ___
Re: gethostbyname in 3.8 returns error -1
On Tue, 6 Dec 2005, Federico Giannici wrote: Since I upgraded an OpenBSD/amd64 3.7 to 3.8 (following instructions in the Upgrade Guide) sometimes gethostbyname() returns NULL with h_errno equal to -1 (Resolver internal error). What is the value of errno? The program (OpenSER 1.0.0) had no problems under 3.7. The domain string is correct. The error seems to appear the SECOND time the gethostbyname() function is called by the same process. What could be the problem? Check the usual suspect: /etc/resolv.conf If that does not help: there have been changes to the resolver code between 3.7 and 3.8 as well. One thing is does is checking if /etc/resolv.conf has been changed and then reload things. We need more info to see what is going on. OB Compiling the resolver code with -DDEBUG and enabling debug by including options debug in resolv.conf can give a clue. Or ktrace the process. -Otto