Subject: install/13153: libhack/getpwent.c
To: None <gnats-bugs@gnats.netbsd.org>
From: None <makoto@ki.nu>
List: netbsd-bugs
Date: 06/10/2001 21:54:10
>Number:         13153
>Category:       install
>Synopsis:       sysinst/libhack/getpwent.c wants /etc/pwd.db, chown fails
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    install-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 10 05:53:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Makoto Fujiwara
>Release:        2001-06-02
>Organization:
        www.ki.nu
>Environment:
        
System: NetBSD u.ki.nu 1.5W NetBSD 1.5W (GENERIC) #4: Sat Jun 9 14:07:06 JST 2001 root@nazuha:/usr/src/sys/arch/macppc/compile
/GENERIC macppc
Architecture: powerpc
Machine: macppc
>Description:
        Sysinst fails:
         Some releases at least 2001-05-17 thru 2001-06-02, sysinst fails when
        doing chown at "./MAKEDEV all" equivalent process.
         It turns out that chown calls getpwent which requires /etc/pwd.db to
        opereta properly. The reason for this is getpwent behaves as if regular
        libc function thus needs /etc/pwd.db. In the pwd.db missing environment,
        say doing sysinst, chown root.wheel filename resulting 
        root: invalid user name.
        With this problem all the sysinst with ELF migrated arch may fail.

        (The similar thing is reported as
        http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=13050
        but the patch shown was not appropriate and addresses macppc only,
        I will raise the issue again here, sorry for some duplication.
	please close 13050, sorry.)

>How-To-Repeat:
        Run macppc/snapshot/20010524/installation/boot.fs  or  binary/kernel
        netbsd.GENERIC_MD.gz, found at ftp.ki.nu/pub/NetBSD/arch/macppc.
	mount /dev/wd0a  /mnt
        mknod /mnt/dev/console c 0 0
        chown root.wheel /mnt/dev/console 
        will say root: invalid user name

>Fix:
	Change src/distrib/utils/libhack/getpwent.c not to use libc function
        but provide own code. Similar thing may be necessary for the other 
        function found in libhack.

Index: src/distrib/utils/libhack/getpwent.c
*** getpwent.c~	Fri Mar 26 23:48:27 1999
--- getpwent.c	Mon May 28 23:25:26 2001
***************
*** 43,48 ****
--- 43,63 ----
  #define	PWNULL	(struct passwd *)0
  #define MAXFIELD 8
  
+ #ifdef __weak_alias
+ __weak_alias(endpwent,_endpwent)
+ __weak_alias(getpwent,_getpwent)
+ __weak_alias(getpwnam,_getpwnam)
+ __weak_alias(getpwuid,_getpwuid)
+ __weak_alias(setpassent,_setpassent)
+ __weak_alias(setpwent,_setpwent)
+ #define endpwent _endpwent
+ #define getpwent _getpwent
+ #define getpwnam _getpwnam
+ #define getpwuid _getpwuid
+ #define setpassent _setpassent
+ #define setpwent _setpwent
+ #endif
+ 
  static char *pw_file = "/etc/passwd";
  static FILE *pw_fp;
  static char  pw_line[128];


>Release-Note:
>Audit-Trail:
>Unformatted: