Subject: lib/27222: mislay dlerror status in nsdispatch.c cause error check in some application to fail +FIX
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <shigeya@shigeya.org>
List: netbsd-bugs
Date: 10/11/2004 10:14:14
>Number: 27222
>Category: lib
>Synopsis: mislay dlerror status in nsdispatch.c cause error check in some application to fail +FIX
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 11 01:26:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Shigeya Suzuki
>Release: NetBSD 2.99.9
>Organization:
shigeya.org
>Environment:
System: NetBSD pooh.shigeya.org 2.99.9 NetBSD 2.99.9 (GENERIC) #8: Fri Oct 8 16:35:44 JST 2004 root@pooh.shigeya.org:/usr/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
In nsdispatch.c:_nsloadmod, since there are no external module
ready yet, call to dlopen is always failing(*1). There are
other problem exists - the routine does not clear dlopen
result status.
Call to this routine may be side-effect of other library
call. Application developer might not know underlining
condition. Thus, call to dlerror() may return status of
dynamic load of nss library, instead of what application
developer expected. Samba 3 module is one of such example.
(*1) This also is a problem. every run of dynamically linked
executable cause call to dlopen one to three times
*ALWAYS*.
>How-To-Repeat:
Install/Configure samba-3.0.7.
Configure smb.conf to use vfs cap module. adding
vfs = cap
do this. This cause cap module (cap.so) to be dynamically loaded.
According to this bug, samba module loader
(lib/module.c:do_smb_load_module) misinterpret status, so cap
module load treated as failure even it really is succeeded.
sample samba log follows:
------------------------------
[2004/10/11 07:28:34, 0] lib/module.c:do_smb_load_module(57)
Error trying to resolve symbol 'init_module' in /usr/pkg/lib/samba/vfs/cap.so: Shared object "nss_dns.so.0" not found
[2004/10/11 07:28:34, 0] smbd/vfs.c:vfs_init_custom(256)
Can't find a vfs module [cap]
[2004/10/11 07:28:34, 0] smbd/vfs.c:smbd_vfs_init(319)
smbd_vfs_init: vfs_init_custom failed for cap
[2004/10/11 07:28:34, 0] smbd/service.c:make_connection_snum(517)
vfs_init failed for service shigeya
------------------------------
>Fix:
Clearing dlerror status solved this problem.
There must be better implemetation.
Index: nsdispatch.c
===================================================================
RCS file: /cvsroot/src/lib/libc/net/nsdispatch.c,v
retrieving revision 1.27
diff -c -r1.27 nsdispatch.c
*** nsdispatch.c 4 Oct 2004 04:02:27 -0000 1.27
--- nsdispatch.c 11 Oct 2004 00:38:51 -0000
***************
*** 79,84 ****
--- 79,85 ----
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/queue.h>
+ #include <syslog.h>
#include <assert.h>
#ifdef __ELF__
***************
*** 301,306 ****
--- 302,311 ----
* sources are not yet modules.
*/
/* XXX log some error? */
+ syslog(LOG_ERR, "_nsloadmod: file '%s' not found: %s",
+ mod.name, dlerror());
+ #else
+ dlerror(); /* CLEAR dlerror here anyway */
#endif
goto out;
}
>Release-Note:
>Audit-Trail:
>Unformatted:
cvs'ed on Oct 7 22:49 (JST)