The new libsysfs and klibc don't need that anymore.
Wrap getpwnam(), so we can use the built-in /etc/passwd
parser for statically compiled glibc binaries too.
 CFLAGS := -pipe
 
 HEADERS = \
-       udev.h          \
-       udev_utils.h    \
-       namedev.h       \
-       udev_version.h  \
-       udev_db.h       \
-       udev_sysfs.h    \
-       logging.h       \
-       udev_selinux.h  \
+       udev.h                  \
+       udev_utils.h            \
+       namedev.h               \
+       udev_version.h          \
+       udev_db.h               \
+       udev_sysfs.h            \
+       logging.h               \
+       udev_libc_wrapper.h     \
+       udev_selinux.h          \
        list.h
 
 SYSFS_OBJS = \
        udev_db.o               \
        udev_multiplex.o        \
        namedev.o               \
-       namedev_parse.o
+       namedev_parse.o         \
+       udev_libc_wrapper.o
 
 OBJS = \
        udev.a                  \
                -I$(PWD)/libsysfs
 
 ifeq ($(strip $(USE_LOG)),true)
-       CFLAGS  += -DLOG
+       CFLAGS += -DLOG
 endif
 
 # if DEBUG is enabled, then we do not strip or optimize
 # If we are using our version of klibc, then we need to build, link it, and then
 # link udev against it statically. Otherwise, use glibc and link dynamically.
 ifeq ($(strip $(USE_KLIBC)),true)
-       KLIBC_FIXUPS_DIR= $(PWD)/klibc_fixups
        KLIBC_BASE      = $(PWD)/klibc
        KLIBC_DIR       = $(KLIBC_BASE)/klibc
        INCLUDE_DIR     := $(KLIBC_BASE)/include
        CFLAGS += $(WARNINGS) -nostdinc                         \
                $(OPTFLAGS) $(REQFLAGS)                         \
                -D__KLIBC__ -fno-builtin-printf                 \
-               -I$(KLIBC_FIXUPS_DIR)                           \
                -I$(INCLUDE_DIR)                                \
                -I$(INCLUDE_DIR)/arch/$(ARCH)                   \
                -I$(INCLUDE_DIR)/bits$(BITSIZE)                 \
        LIB_OBJS =
        LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
 
-       HEADERS += \
-               klibc_fixups/pwd.h
-
-       KLIBC_FIXUP_OBJS = \
-               klibc_fixups/klibc_fixups.o
-
-       OBJS += klibc_fixups/klibc_fixups.a
 else
        WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
        CRT0 =
        LIBC =
        CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
        LIB_OBJS = -lc
-       LDFLAGS =
 endif
 
 ifeq ($(strip $(USE_SELINUX)),true)
        $(QUIET) $(AR) cq $@ $(SYSFS_OBJS)
        $(QUIET) $(RANLIB) $@
 
-klibc_fixups/klibc_fixups.a: $(KLIBC_FIXUP_OBJS)
-       rm -f $@
-       $(QUIET) $(AR) cq $@ $(KLIBC_FIXUP_OBJS)
-       $(QUIET) $(RANLIB) $@
-
 # header files automatically generated
 GEN_HEADERS =  udev_version.h
 
 
 $(UDEV_OBJS): $(GEN_HEADERS) $(HOST_PROGS)
 $(SYSFS_OBJS): $(HOST_PROGS)
-$(KLIBC_FIXUP_OBJS): $(HOST_PROGS)
 $(OBJS): $(GEN_HEADERS) $(HOST_PROGS)
 $(ROOT).o: $(GEN_HEADERS) $(HOST_PROGS)
 $(TESTER).o: $(GEN_HEADERS) $(HOST_PROGS)
 
+++ /dev/null
-#ifdef __KLIBC__
-
-#ifndef _PWD_H
-#define _PWD_H
-
-struct passwd {
-       char    *pw_name;       /* user name */
-       char    *pw_passwd;     /* user password */
-       uid_t   pw_uid;         /* user id */
-       gid_t   pw_gid;         /* group id */
-       char    *pw_gecos;      /* real name */
-       char    *pw_dir;        /* home directory */
-       char    *pw_shell;      /* shell program */
-};
-
-struct group {
-       char    *gr_name;       /* group name */
-       char    *gr_passwd;     /* group password */
-       gid_t   gr_gid;         /* group id */
-       char    **gr_mem;       /* group members */
-};
-
-struct passwd *getpwnam(const char *name);
-struct group *getgrnam(const char *name);
-
-#endif /* _PWD_H */
-#endif /* __KLIBC__ */
 
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <linux/sockios.h>
-#include <pwd.h>
 
 #include "libsysfs/sysfs/libsysfs.h"
+#include "udev_libc_wrapper.h"
 #include "udev.h"
 #include "udev_utils.h"
 #include "udev_sysfs.h"
 
                if (endptr[0] == '\0')
                        uid = (uid_t) id;
-               else {
-                       struct passwd *pw;
-
-                       pw = getpwnam(udev->owner);
-                       if (pw == NULL)
-                               dbg("specified user unknown '%s'", udev->owner);
-                       else
-                               uid = pw->pw_uid;
-               }
+               else
+                       uid = lookup_user(udev->owner);
        }
 
        if (udev->group[0] != '\0') {
 
                if (endptr[0] == '\0')
                        gid = (gid_t) id;
-               else {
-                       struct group *gr = getgrnam(udev->group);
-                       if (gr == NULL)
-                               dbg("specified group unknown '%s'", udev->group);
-                       else
-                               gid = gr->gr_gid;
-               }
+               else
+                       gid = lookup_group(udev->group);
        }
 
        if (!udev->test_run) {
 
 /*
- * klibc_fixups.c - very simple implementation of stuff missing in klibc
+ * udev_libc_wrapper - wrapping of functions missing in a specific libc
+ *                    or not working in a statically compiled binary
  *
  * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (C) 2004 Kay Sievers <kay@vrfy.org>
+ * Copyright (C) 2005 Kay Sievers <kay@vrfy.org>
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the
  *
  */
 
-#ifdef __KLIBC__
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
 #include <sys/types.h>
 
-#include "pwd.h"
+#include "../udev_libc_wrapper.h"
 #include "../udev.h"
 #include "../udev_utils.h"
 #include "../logging.h"
 
-#define PW_FILE                "/etc/passwd"
-#define GR_FILE                "/etc/group"
+
+#ifdef __KLIBC__
+#define __OWN_USERDB_PARSER__
+#endif
+#ifdef USE_STATIC
+#define __OWN_USERDB_PARSER__
+#endif
+
+#ifndef __OWN_USERDB_PARSER__
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+
+uid_t lookup_user(const char *user)
+{
+       struct passwd *pw;
+       uid_t uid = 0;
+
+       pw = getpwnam(user);
+       if (pw == NULL)
+               dbg("specified user unknown '%s'", user);
+       else
+               uid = pw->pw_uid;
+
+       return uid;
+}
+
+gid_t lookup_group(const char *group)
+{
+       struct group *gr;
+       gid_t gid = 0;
+
+       gr = getgrnam(group);
+       if (gr == NULL)
+               dbg("specified group unknown '%s'", group);
+       else
+               gid = gr->gr_gid;
+
+       return gid;
+}
+
+#else /* __OWN_USERDB_PARSER__ */
+
+#define PASSWD_FILE            "/etc/passwd"
+#define GROUP_FILE             "/etc/group"
 
 /* return the id of a passwd style line, selected by the users name */
 static unsigned long get_id_by_name(const char *uname, const char *dbfile)
 {
-       unsigned long id = -1;
+       unsigned long id = 0;
        char line[LINE_SIZE];
        char *buf;
        char *bufline;
        char *idstr;
        char *tail;
 
-       if (file_map(dbfile, &buf, &bufsize) == 0) {
-               dbg("reading '%s' as db file", dbfile);
-       } else {
+       if (file_map(dbfile, &buf, &bufsize) != 0) {
                dbg("can't open '%s' as db file", dbfile);
-               return -1;
+               return 0;
        }
+       dbg("reading '%s' as db file", dbfile);
 
        /* loop through the whole file */
        cur = 0;
 
                if (strcmp(uname, name) == 0) {
                        id = strtoul(idstr, &tail, 10);
-                       if (tail[0] != '\0')
-                               id = -1;
-                       else
+                       if (tail[0] != '\0') {
+                               id = 0;
+                               dbg("no id found for '%s'",  name);
+                       } else
                                dbg("id for '%s' is '%li'", name, id);
                        break;
                }
        return id;
 }
 
-struct passwd *getpwnam(const char *name)
+uid_t lookup_user(const char *user)
 {
-       static struct passwd pw;
+       unsigned long id;
 
-       memset(&pw, 0x00, sizeof(struct passwd));
-       pw.pw_uid = (uid_t) get_id_by_name(name, PW_FILE);
-       if (pw.pw_uid < 0)
-               return NULL;
-       else
-               return &pw;
+       id = get_id_by_name(user, PASSWD_FILE);
+       return (uid_t) id;
 }
 
-struct group *getgrnam(const char *name)
+gid_t lookup_group(const char *group)
 {
-       static struct group gr;
+       unsigned long id;
 
-       memset(&gr, 0x00, sizeof(struct group));
-       gr.gr_gid = (gid_t) get_id_by_name(name, GR_FILE);
-       if (gr.gr_gid < 0)
-               return NULL;
-       else
-               return &gr;
+       id = get_id_by_name(group, GROUP_FILE);
+       return (gid_t) id;
 }
 
-#endif /* __KLIBC__ */
+#endif /* __OWN_USERDB_PARSER__ */
 
--- /dev/null
+/*
+ * udev_libc_wrapper - wrapping of functions missing in a specific libc
+ *                    or not working in a statically compiled binary
+ *
+ * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify it
+ *     under the terms of the GNU General Public License as published by the
+ *     Free Software Foundation version 2 of the License.
+ * 
+ *     This program is distributed in the hope that it will be useful, but
+ *     WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     General Public License for more details.
+ * 
+ *     You should have received a copy of the GNU General Public License along
+ *     with this program; if not, write to the Free Software Foundation, Inc.,
+ *     675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _UDEV_LIBC_WRAPPER_H_
+#define _UDEV_LIBC_WRAPPER_H_
+
+extern uid_t lookup_user(const char *user);
+extern gid_t lookup_group(const char *group);
+
+#endif /* _UDEV_LIBC_WRAPPER_H_ */