Subject: bin/11454: getpwuid() does not work with cross-compiled /etc/pwd.db (spwd.db?)
To: None <gnats-bugs@gnats.netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-bugs
Date: 11/08/2000 20:16:12
>Number:         11454
>Category:       bin
>Synopsis:       getpwuid() does not work with cross-compiled /etc/pwd.db (spwd.db?)
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 08 20:16:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     TheMan
>Release:        -current from 2000-10-31
>Organization:
nope
>Environment:
	
NetBSD this 1.5H NetBSD 1.5H (THAT) #17: Tue Oct 31 11:05:19 GMT 2000     root@this:/usr/src/sys/arch/i386/compile/THAT i386

>Description:

in a sparc installation built via a cross-compilation environment,
/etc/pwd.db as installed in $DESTDIR has uids stored with local
endianness, instead of target endianness.  the db files are, i'm led
to believe, architecture independant, but the keys and data are not.

>How-To-Repeat:

build and install the cross pkg called cross-sparc-netbsdelf-1.3.0.0.
use it to build a sparc installation somewhere.  mount the sparc set
via nfs and notice that cu refuses to work.  look at the owner of
/dev/[dt]ty[a-d] (ls -l) and notice that it does say "uucp" for the
owner, but rather 1107296256.  think for a second and then feed that
number to bc (with obase=16) and see 42000000.

>Fix:

pwd_mkdb has an endianness flag, so it should use it.  note that my
fix is for src/etc/Makefile, but that this endianess thing could just
as easily be stuff in each of the src/etc/etc.<arch>/Makefile.inc
files.

Index: etc/Makefile
===================================================================
RCS file: /cvsroot/basesrc/etc/Makefile,v
retrieving revision 1.169
diff -u -r1.169 Makefile
--- Makefile	2000/10/30 21:48:20	1.169
+++ Makefile	2000/11/09 04:01:38
@@ -118,6 +118,17 @@
 NAMEDB=	127 root.cache named.conf localhost loopback.v6
 PCS=	pcs750.bin
 
+TARGET_ENDIANNESS!= awk '/_BYTE_ORDER/{print $$3}' \
+	${DESTDIR}/usr/include/machine/endian_machdep.h
+
+.if ${TARGET_ENDIANNESS} == "_LITTLE_ENDIAN"
+TARGET_ENDIANNESS= -L
+.elif ${TARGET_ENDIANNESS} == "_BIG_ENDIAN"
+TARGET_ENDIANNESS= -B
+.else
+TARGET_ENDIANNESS=
+.endif
+
 all clean cleandir depend distclean etc includes install lint:
 
 .include <bsd.kernobj.mk>
@@ -148,7 +159,8 @@
 	    ${DESTDIR}/var/cron/tabs/root
 	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
 	    ${DESTDIR}/etc
-	pwd_mkdb -p -d ${DESTDIR}/ ${DESTDIR}/etc/master.passwd
+	pwd_mkdb -p ${TARGET_ENDIANNESS} -d ${DESTDIR}/ \
+	    ${DESTDIR}/etc/master.passwd
 	${INSTALL} ${INSTPRIV} -c -o ${BINOWN} -g ${BINGRP} -m 555 \
 	     MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev
 	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 minfree \
>Release-Note:
>Audit-Trail:
>Unformatted: