Subject: bin/11454: getpwuid() does not work with cross-compiled /etc/pwd.db (spwd.db?)
To: None <>
From: Andrew Brown <>
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
>Originator:     TheMan
>Release:        -current from 2000-10-31
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


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.


build and install the cross pkg called cross-sparc-netbsdelf-
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.


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>/

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
 all clean cleandir depend distclean etc includes install lint:
 .include <>
@@ -148,7 +159,8 @@
 	${INSTALL} ${INSTPRIV} -c -o root -g wheel -m 600 master.passwd \
-	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 \