NetBSD Problem Report #1328
From gnats Thu Aug 10 18:50:26 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id SAA06586 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Thu, 10 Aug 1995 18:50:26 -0400
Message-Id: <199508102241.SAA12540@duality.gnu.ai.mit.edu>
Date: Thu, 10 Aug 1995 18:41:29 -0400
From: Daniel Hagerty <hag@gnu.ai.mit.edu>
Reply-To: Daniel Hagerty <hag@gnu.ai.mit.edu>
To: netbsd-gnats@gnu.ai.mit.edu
Subject: pwdb_mkdb doesn't do any error checking for things like disk space!
X-Send-Pr-Version: 3.2
>Number: 1328
>Category: bin
>Synopsis: pwdb_mkdb doesn't do any error checking for things like disk space!
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 10 19:05:02 +0000 1995
>Closed-Date: Mon Apr 13 23:09:41 +0000 1998
>Last-Modified: Mon Apr 13 23:10:16 +0000 1998
>Originator: Daniel Hagerty
>Release: gnats-3.2
>Organization:
Free Software Foundation
>Environment:
System: NetBSD duality.gnu.ai.mit.edu 1.0A NetBSD 1.0A (DUALITY) #1: Sat Aug 5 22:08:26 EDT 1995 mycroft@duality.gnu.ai.mit.edu:/build/src/sys/arch/hp300/compile/DUALITY hp300
>Description:
pwd_mkdb doesn't check for successful writes. Running pwd_mkdb
on a full file system results in trashed *.db and master.passwd
files. This is a severe bug.
>How-To-Repeat:
Pretty damn trivial. Fill up your disk, build a new passwd
file. Poof! You're screwed.
>Fix:
After a quick look at the code, it seems that there is error
checking being done for db put operations. Could the problem be in
libdb?
>Release-Note:
>Audit-Trail:
From: The Grey Wolf <greywolf@defender.VAS.viewlogic.com>
To: gnats-bugs@netbsd.org
Cc: Subject: Re: bin/1328
Date: Tue, 14 May 96 13:36:25 PDT
/* Fix for pwd_mkdb enclosed. I wonder if the other *_mkdb programs have
* this problem.. */
*** pwd_mkdb.c Tue May 14 10:46:15 1996
--- pwd_mkdb.c.orig Mon May 13 17:18:57 1996
***************
*** 86,92 ****
void mv __P((char *, char *));
int scan __P((FILE *, struct passwd *, int *));
void usage __P((void));
- char errbuf[BUFSIZ];
int
main(argc, argv)
--- 86,91 ----
***************
*** 234,246 ****
/* Create original format password file entry */
if (makeold)
! if (fprintf(oldfp, "%s:*:%d:%d:%s:%s:%s\n",
pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_gecos,
! pwd.pw_dir, pwd.pw_shell) < 0) {
! (void) snprintf (errbuf, sizeof(errbuf),
! "Cannot write %s", pname);
! error(errbuf);
! }
}
/* Store YP token, if needed. */
--- 233,241 ----
/* Create original format password file entry */
if (makeold)
! (void)fprintf(oldfp, "%s:*:%d:%d:%s:%s:%s\n",
pwd.pw_name, pwd.pw_uid, pwd.pw_gid, pwd.pw_gecos,
! pwd.pw_dir, pwd.pw_shell);
}
/* Store YP token, if needed. */
***************
*** 254,271 ****
error("put");
}
! if ((dp->close)(dp) < 0) {
! (void)snprintf(errbuf, sizeof(errbuf), "Could not write %s",
! _PATH_MP_DB);
! error(errbuf);
! }
if (makeold) {
(void)fflush(oldfp);
! if (fclose(oldfp) == EOF) {
! (void)snprintf(errbuf, sizeof(errbuf),
! "Could not write %s", pname);
! error(errbuf);
! }
}
/* Open the temporary encrypted password database. */
--- 249,258 ----
error("put");
}
! (void)(dp->close)(dp);
if (makeold) {
(void)fflush(oldfp);
! (void)fclose(oldfp);
}
/* Open the temporary encrypted password database. */
***************
*** 333,351 ****
error("put");
}
! if ((edp->close)(edp) < 0) {
! (void) snprintf(errbuf, sizeof(errbuf),
! "Cannot write %s", _PATH_SMP_DB);
! error(errbuf);
! }
/* Set master.passwd permissions, in case caller forgot. */
(void)fchmod(fileno(fp), S_IRUSR|S_IWUSR);
! if (fclose(fp) < 0) {
! (void) snprintf(errbuf, sizeof(errbuf),
! "Cannot write %s", pname);
! error(errbuf);
! }
/* Install as the real password files. */
(void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_MP_DB);
--- 320,330 ----
error("put");
}
! (void)(edp->close)(edp);
/* Set master.passwd permissions, in case caller forgot. */
(void)fchmod(fileno(fp), S_IRUSR|S_IWUSR);
! (void)fclose(fp);
/* Install as the real password files. */
(void)snprintf(buf, sizeof(buf), "%s.tmp", _PATH_MP_DB);
***************
*** 420,429 ****
warn(name);
cleanup();
- fprintf(stderr, "%s %s\n%s\n",
- "NOTE: possible inconsistencies between text files",
- "and databases;",
- "re-run pwd_mkdb when you have fixed the problem.");
exit(1);
}
--- 399,404 ----
State-Changed-From-To: open->closed
State-Changed-By: fair
State-Changed-When: Mon Apr 13 16:09:41 PDT 1998
State-Changed-Why:
This program has been modified to check for I/O errors, and properly
report them.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.