+++ /dev/null
---- rpcbind-0.1.4/src/Makefile.am~ 2004-11-15 14:38:02.000000000 +0100
-+++ rpcbind-0.1.4/src/Makefile.am 2007-04-24 16:29:08.000000000 +0200
-@@ -1,7 +1,4 @@
--INCLUDES = -I$(srcdir)/tirpc -DPORTMAP -DINET6 -DVERSION="\"$(VERSION)\"" \
-- -D_GNU_SOURCE -Wall -pipe
--
--bin_PROGRAMS = rpcbind rpcinfo
-+sbin_PROGRAMS = rpcbind rpcinfo
-
- rpcbind_SOURCES = check_bound.c rpcbind.c \
- rpcb_svc_4.c rpcb_svc_com.c \
-@@ -14,10 +11,12 @@
- rpcinfo_LDADD = $(LIB_TIRPC)
-
-
--rpcbind_LDFLAGS = -lpthread -ltirpc
-+rpcbind_LDFLAGS = -lpthread -ltirpc -lwrap
- rpcbind_LDADD = $(LIB_TIRPC)
--AM_CPPFLAGS = -I/usr/include/tirpc -DCHECK_LOCAL -DPORTMAP \
-- -DFACILITY=LOG_MAIL -DSEVERITY=LOG_INFO
-+
-+AM_CFLAGS = -I/usr/include/tirpc -DCHECK_LOCAL -DPORTMAP -DINET6 -DLIBWRAP \
-+ -DFACILITY=LOG_AUTH -DSEVERITY=LOG_INFO -DWARMSTART \
-+ -DVERSION="\"$(VERSION)\"" -D_GNU_SOURCE -Wall -pipe
- ## -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL \
- ## -DND_DEBUG -DBIND_DEBUG
-
+++ /dev/null
-diff --git a/configure.in b/configure.in
-index 0298c80..9a64b45 100644
---- a/configure.in
-+++ b/configure.in
-@@ -10,6 +10,13 @@ AC_CONFIG_SRCDIR([src/rpcbind.c])
- AC_HEADER_DIRENT
- AC_PREFIX_DEFAULT(/usr)
-
-+AC_ARG_ENABLE(debug,[ --enable-debug Turns on rpcbind debugging],
-+ [case "${enableval}" in
-+ yes) debug=true ;;
-+ no) debug=no ;;
-+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
-+ esac],[debug=false])
-+AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
-
- AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
- netinet/in.h stdlib.h string.h \
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 8684a4b..52d3857 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -18,8 +18,10 @@ rpcbind_LDFLAGS = -lpthread -ltirpc
- rpcbind_LDADD = $(LIB_TIRPC)
- AM_CPPFLAGS = -I/usr/include/tirpc -DCHECK_LOCAL -DPORTMAP \
- -DFACILITY=LOG_MAIL -DSEVERITY=LOG_INFO
--## -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL \
--## -DND_DEBUG -DBIND_DEBUG
-+if DEBUG
-+INCLUDES += -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
-+INCLUDES += -DND_DEBUG -DBIND_DEBUG
-+endif
-
- $(rpcbind_OBJECTS) : security.o util.o check_bound.o pmap_svc.o \
- rpcb_svc.o rpcb_svc_com.o rpcb_svc_4.o \
+++ /dev/null
---- rpcbind-0.1.4/src/pmap_svc.c~ 2005-01-03 14:55:50.000000000 +0100
-+++ rpcbind-0.1.4/src/pmap_svc.c 2007-04-24 16:30:54.000000000 +0200
-@@ -314,7 +314,7 @@
- if ((pt2 = strrchr(ua, '.')) != NULL) {
- *pt2 = 0;
- snprintf(serveuaddr, sizeof serveuaddr,
-- "%s.%d.%d", ua,
-+ "%s.%ld.%ld", ua,
- (fnd->pml_map.pm_port >> 8) & 0xff,
- (fnd->pml_map.pm_port) & 0xff);
- *pt2 = '.';
+++ /dev/null
---- rpcbind-0.1.4/src/util.c.iff_up 2007-05-22 11:14:39.000000000 -0400
-+++ rpcbind-0.1.4/src/util.c 2007-05-22 11:14:56.000000000 -0400
-@@ -359,7 +359,8 @@ network_init()
- * interface, join the RPC multicast group on that interface.
- */
- for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) {
-- if (ifap->ifa_addr->sa_family != AF_INET6 ||
-+ if (!ifap->ifa_addr ||
-+ ifap->ifa_addr->sa_family != AF_INET6 ||
- !(ifap->ifa_flags & IFF_MULTICAST))
- continue;
- ifindex = if_nametoindex(ifap->ifa_name);
+++ /dev/null
-diff --git a/Makefile.am b/Makefile.am
-index 54d0a92..cd56148 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -1,2 +1,2 @@
--SUBDIRS= src
-+SUBDIRS= src man
-
-diff --git a/configure.in b/configure.in
-index a158927..0298c80 100644
---- a/configure.in
-+++ b/configure.in
-@@ -20,6 +20,6 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
- AC_CHECK_LIB([pthread], [pthread_create])
- AC_CHECK_LIB([tirpc], [clnt_create])
-
--AC_CONFIG_FILES([Makefile src/Makefile])
-+AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
- AC_OUTPUT()
-
-diff --git a/man/Makefile.am b/man/Makefile.am
-new file mode 100644
-index 0000000..84818e9
---- /dev/null
-+++ b/man/Makefile.am
-@@ -0,0 +1,2 @@
-+man8_MANS = rpcbind.8
-+EXTRA_DIST = $(man8_MANS)
+++ /dev/null
-diff --git a/configure.in b/configure.in
-index 0e2f163..dfe5907 100644
---- a/configure.in
-+++ b/configure.in
-@@ -37,6 +37,12 @@ if test "$warmstarts" = "true" ; then
- AC_SUBST(statedir)
- AC_DEFINE_UNQUOTED(RPCBIND_STATEDIR, "$statedir", [This defines the location where the state files will be kept for warm starts])
- fi
-+AC_ARG_WITH(rpcuser,
-+ [ --with-rpcuser=user uid to use [root]],
-+ rpcuser=$withval,
-+ rpcuser=root)
-+ AC_SUBST(rpcuser)
-+AC_DEFINE_UNQUOTED(RPCBIND_USER, "$rpcuser", [This defines the uid to run as])
-
- AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
- netinet/in.h stdlib.h string.h \
-diff --git a/src/rpcbind.c b/src/rpcbind.c
-index 55bbd8d..2a900d9 100644
---- a/src/rpcbind.c
-+++ b/src/rpcbind.c
-@@ -68,6 +68,7 @@
- #include <pwd.h>
- #include <string.h>
- #include <errno.h>
-+#include "config.h"
- #include "rpcbind.h"
-
- /*#define RPCBIND_DEBUG*/
-@@ -79,6 +80,11 @@ int doabort = 0; /* When debugging, do an abort on errors */
-
- rpcblist_ptr list_rbl; /* A list of version 3/4 rpcbind services */
-
-+#ifdef RPCBIND_USER
-+char *rpcbinduser = RPCBIND_USER;
-+#else
-+char *rpcbinduser = NULL;
-+#endif
-
- /* who to suid to if -s is given */
- #define RUN_AS "daemon"
-@@ -206,15 +212,16 @@ main(int argc, char *argv[])
- err(1, "fork failed");
- }
-
-- if (runasdaemon) {
-+ if (runasdaemon || rpcbinduser) {
- struct passwd *p;
-+ char *id = runasdaemon ? RUN_AS : rpcbinduser;
-
-- if((p = getpwnam(RUN_AS)) == NULL) {
-- syslog(LOG_ERR, "cannot get uid of daemon: %m");
-+ if((p = getpwnam(id)) == NULL) {
-+ syslog(LOG_ERR, "cannot get uid of '%s': %m", id);
- exit(1);
- }
- if (setuid(p->pw_uid) == -1) {
-- syslog(LOG_ERR, "setuid to daemon failed: %m");
-+ syslog(LOG_ERR, "setuid to '%s' failed: %m", id);
- exit(1);
- }
- }
---- rpcbind-0.1.4/src/warmstart.c~ 2007-05-08 14:48:17.000000000 +0200
-+++ rpcbind-0.1.4/src/warmstart.c 2007-05-08 14:52:30.000000000 +0200
-@@ -113,7 +113,7 @@
- "rpcbind: cannot stat file = %s for reading\n", filename);
- goto error;
- }
-- if ((sbuf.st_uid != 0) || (sbuf.st_mode & S_IRWXG) ||
-+ if ((sbuf.st_mode & S_IRWXG) ||
- (sbuf.st_mode & S_IRWXO)) {
- fprintf(stderr,
- "rpcbind: invalid permissions on file = %s for reading\n",
+++ /dev/null
-diff --git a/configure.in b/configure.in
-index 9a64b45..0e2f163 100644
---- a/configure.in
-+++ b/configure.in
-@@ -18,6 +21,23 @@ AC_ARG_ENABLE(debug,[ --enable-debug Turns on rpcbind debugging],
- esac],[debug=false])
- AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
-
-+AC_ARG_ENABLE(warmstarts,[ --enable-warmstarts Enables Warm Starts],
-+ [case "${enableval}" in
-+ yes) warmstarts=true ;;
-+ no) warmstarts=no ;;
-+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-warmstarts) ;;
-+ esac],[warmstarts=false])
-+AM_CONDITIONAL(WARMSTART, test x$warmstarts = xtrue)
-+
-+if test "$warmstarts" = "true" ; then
-+ AC_ARG_WITH(statedir,
-+ [ --with-statedir=/foo use state dir /foo [/tmp]],
-+ statedir=$withval,
-+ statedir=/tmp)
-+ AC_SUBST(statedir)
-+ AC_DEFINE_UNQUOTED(RPCBIND_STATEDIR, "$statedir", [This defines the location where the state files will be kept for warm starts])
-+fi
-+
- AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
- netinet/in.h stdlib.h string.h \
- sys/param.h sys/socket.h \
-diff --git a/man/rpcbind.8 b/man/rpcbind.8
-index 2d59ce8..7985f0f 100644
---- a/man/rpcbind.8
-+++ b/man/rpcbind.8
-@@ -131,6 +131,14 @@ to use non-privileged ports for outgoing connections, preventing non-privileged
- clients from using
- .Nm
- to connect to services from a privileged port.
-+.It Fl w
-+Cause
-+.Nm
-+to do a "warm start" by read a state file when
-+.Nm
-+starts up. The state file is created when
-+.Nm
-+terminates.
- .El
- .Sh NOTES
- All RPC servers must be restarted if
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 52d3857..fd80847 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -1,5 +1,14 @@
- INCLUDES = -I$(srcdir)/tirpc -DPORTMAP -DINET6 -DVERSION="\"$(VERSION)\"" \
- -D_GNU_SOURCE -Wall -pipe
-+if DEBUG
-+INCLUDES += -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
-+INCLUDES += -DND_DEBUG -DBIND_DEBUG
-+endif
-+
-+if WARMSTART
-+INCLUDES += -DWARMSTART
-+endif
-+
-
- bin_PROGRAMS = rpcbind rpcinfo
-
-@@ -18,10 +27,6 @@ rpcbind_LDFLAGS = -lpthread -ltirpc
- rpcbind_LDADD = $(LIB_TIRPC)
- AM_CPPFLAGS = -I/usr/include/tirpc -DCHECK_LOCAL -DPORTMAP \
- -DFACILITY=LOG_MAIL -DSEVERITY=LOG_INFO
--if DEBUG
--INCLUDES += -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
--INCLUDES += -DND_DEBUG -DBIND_DEBUG
--endif
-
- $(rpcbind_OBJECTS) : security.o util.o check_bound.o pmap_svc.o \
- rpcb_svc.o rpcb_svc_com.o rpcb_svc_4.o \
-diff --git a/src/warmstart.c b/src/warmstart.c
-index 4a40639..6a50c41 100644
---- a/src/warmstart.c
-+++ b/src/warmstart.c
-@@ -46,17 +46,21 @@
- #include <syslog.h>
- #include <unistd.h>
-
-+#include "config.h"
- #include "rpcbind.h"
-
- /*
- * XXX this code is unsafe and is not used. It should be made safe.
- */
-
-+#ifndef RPCBIND_STATEDIR
-+#define RPCBIND_STATEDIR "/tmp"
-+#endif
-
- /* These files keep the pmap_list and rpcb_list in XDR format */
--#define RPCBFILE "/tmp/rpcbind.file"
-+#define RPCBFILE RPCBIND_STATEDIR "/rpcbind.file"
- #ifdef PORTMAP
--#define PMAPFILE "/tmp/portmap.file"
-+#define PMAPFILE RPCBIND_STATEDIR "/portmap.file"
- #endif
-
- static bool_t write_struct __P((char *, xdrproc_t, void *));