Subject: lib/32454: dbopen(3) creates temp file in CWD instead of $TMPDIR
To: None <,,>
From: Jeff Rizzo <>
List: netbsd-bugs
Date: 01/04/2006 23:35:00
>Number:         32454
>Category:       lib
>Synopsis:       dbopen(3) creates temp file in CWD instead of $TMPDIR
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 04 23:35:00 +0000 2006
>Originator:     Jeff Rizzo
>Release:        NetBSD 3.0_STABLE

System: NetBSD 3.0_STABLE NetBSD 3.0_STABLE (TYAN251X.MP) #3: Mon Jan 2 14:38:32 PST 2006 i386
Architecture: i386
Machine: i386
	When calling dbopen() with a NULL file pointer ("files never intended
	to be preserved on disk"),  the temp file is created in the current
	working directory, rather than in $TMPDIR.  Thus, if $CWD is
	read-only, it will fail unexpectedly.

	I discovered this using tsort(1):

	$ mkdir /tmp/foo
	$ chmod -w /tmp/foo
	$ cd /tmp/foo
	$ tsort /usr/share/dict/words
	tsort: db: acronical: Permission denied

	(I would expect this to work, since output should be on stdout).

	Looking into the tsort source code, I discovered it's the dbopen()
	call which creates the tempfile...

	I confirmed this is still an issue in -current.
	None supplied.  I glanced through the libc db code, but quickly
	got lost...