Subject: root vs. /etc/pwd.db vs. /etc/spwd.db.
To: None <tech-userlevel@NetBSD.ORG>
From: matthew green <mrg@eterna.com.au>
List: tech-userlevel
Date: 09/05/1997 14:55:35
so, our libc code only looks at /etc/spwd.db if we are running as root,
which is annoying if running under a chroot environment where we only
care about the uid <-> name mapping, and thus only provide a /etc/pwd.db
in the chroot area. the patch below fixes this problem for me.
do people think this should go in ?
.mrg.
Index: getpwent.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/getpwent.c,v
retrieving revision 1.23
diff -c -r1.23 getpwent.c
*** getpwent.c 1997/07/21 14:07:13 1.23
--- getpwent.c 1997/09/05 04:52:32
***************
*** 911,918 ****
#ifdef YP
__ypmode = YPMODE_NONE;
#endif
! p = (geteuid()) ? _PATH_MP_DB : _PATH_SMP_DB;
! _pw_db = dbopen(p, O_RDONLY, 0, DB_HASH, NULL);
if (_pw_db)
return(1);
if (!warned)
--- 911,922 ----
#ifdef YP
__ypmode = YPMODE_NONE;
#endif
! if (geteuid()) {
! _pw_db = dbopen((p = _PATH_SMP_DB), O_RDONLY, 0, DB_HASH, NULL);
! if (_pw_db)
! return(1);
! }
! _pw_db = dbopen((p = _PATH_MP_DB), O_RDONLY, 0, DB_HASH, NULL);
if (_pw_db)
return(1);
if (!warned)