diff -urN Linux-PAM-0.72/defs/debian.defs Linux-PAM-0.72.new/defs/debian.defs
--- Linux-PAM-0.72/defs/debian.defs	Fri Jun  7 01:11:02 2002
+++ Linux-PAM-0.72.new/defs/debian.defs	Fri Jun  7 01:04:32 2002
@@ -7,7 +7,7 @@
 # installed files on the system.
 ##
 
-CFLAGS	:= -O2 -D_GNU_SOURCE -D_REENTRANT
+CFLAGS	:= -O2 -D_GNU_SOURCE -D_REENTRANT -DHAVE_UTMP_H
 ifneq (,$(findstring $(DEB_BUILD_OPTIONS),debug DEBUG Debug))
   CFLAGS += -g
 endif
diff -urN Linux-PAM-0.72/modules/pam_rhosts/pam_rhosts_auth.c Linux-PAM-0.72.new/modules/pam_rhosts/pam_rhosts_auth.c
--- Linux-PAM-0.72/modules/pam_rhosts/pam_rhosts_auth.c	Fri Jun  7 01:11:01 2002
+++ Linux-PAM-0.72.new/modules/pam_rhosts/pam_rhosts_auth.c	Fri Jun  7 01:04:32 2002
@@ -48,10 +48,6 @@
 #include <sys/fsuid.h>
 #endif
 
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <string.h>
@@ -60,6 +56,11 @@
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+
 #include <netdb.h>       /* This is supposed(?) to contain the following */
 int innetgr(const char *, const char *, const char *,const char *);
 
diff -urN Linux-PAM-0.72/modules/pam_unix/Makefile Linux-PAM-0.72.new/modules/pam_unix/Makefile
--- Linux-PAM-0.72/modules/pam_unix/Makefile	Fri Jun  7 01:11:02 2002
+++ Linux-PAM-0.72.new/modules/pam_unix/Makefile	Fri Jun  7 01:04:32 2002
@@ -25,7 +25,7 @@
 ########################################################################
 
 CFLAGS += $(USE_LCKPWDF) $(NEED_LCKPWDF) $(EXTRAS)
-LDLIBS = $(EXTRALS)
+LDLIBS = $(EXTRALS) -lshadow
 
 LIBOBJ = pam_unix_auth.o pam_unix_acct.o pam_unix_sess.o pam_unix_passwd.o \
 		support.o
diff -urN Linux-PAM-0.72/modules/pam_unix/md5.h Linux-PAM-0.72.new/modules/pam_unix/md5.h
--- Linux-PAM-0.72/modules/pam_unix/md5.h	Fri Jun  7 01:11:07 2002
+++ Linux-PAM-0.72.new/modules/pam_unix/md5.h	Fri Jun  7 01:04:32 2002
@@ -1,7 +1,11 @@
 
 #ifndef MD5_H
 #define MD5_H
+#if defined(__FreeBSD__) || defined (__NetBSD__)
+#include <inttypes.h>
+#else
 #include <stdint.h>
+#endif
 
 typedef uint32_t uint32;
 
diff -urN Linux-PAM-0.72/modules/pam_unix/pam_unix_passwd.c Linux-PAM-0.72.new/modules/pam_unix/pam_unix_passwd.c
--- Linux-PAM-0.72/modules/pam_unix/pam_unix_passwd.c	Fri Jun  7 01:11:07 2002
+++ Linux-PAM-0.72.new/modules/pam_unix/pam_unix_passwd.c	Fri Jun  7 01:09:56 2002
@@ -45,6 +45,9 @@
 #include <pwd.h>
 #include <syslog.h>
 #include <shadow.h>
+#if defined (__FreeBSD__) || defined (__NetBSD__)
+#include <epwd.h>
+#endif
 #include <time.h>		/* for time() */
 #include <fcntl.h>
 #include <ctype.h>
@@ -75,10 +78,12 @@
 #include "md5.h"
 #include "support.h"
 
+#if !defined (__FreeBSD__) && !defined (__NetBSD__)
 #if !((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
 extern int getrpcport(const char *host, unsigned long prognum,
 		      unsigned long versnum, unsigned int proto);
 #endif				/* GNU libc 2.1 */
+#endif
 
 /*
  * PAM framework looks for these entry-points to pass control to the
@@ -370,6 +375,7 @@
 	else
 		unlink(PW_TMPFILE);
 
+	spsync();
 	return retval;
 }
 
@@ -424,6 +430,7 @@
 	else
 		unlink(SH_TMPFILE);
 
+	spsync();
 	return retval;
 }
 
diff -urN Linux-PAM-0.72/modules/pam_unix/support.c Linux-PAM-0.72.new/modules/pam_unix/support.c
--- Linux-PAM-0.72/modules/pam_unix/support.c	Fri Jun  7 01:11:07 2002
+++ Linux-PAM-0.72.new/modules/pam_unix/support.c	Fri Jun  7 01:04:32 2002
@@ -13,6 +13,7 @@
 #include <shadow.h>
 #include <limits.h>
 #include <utmp.h>
+#include <signal.h>
 
 #include <security/_pam_macros.h>
 #include <security/pam_modules.h>
