1dc236
diff --git a/.gitignore b/.gitignore
1dc236
index 5a7546c..bee4bab 100644
1dc236
--- a/.gitignore
1dc236
+++ b/.gitignore
1dc236
@@ -1,3 +1,4 @@
1dc236
+INSTALL
1dc236
 Makefile
1dc236
 Makefile.in
1dc236
 aclocal.m4
1dc236
@@ -13,18 +14,14 @@ depcomp
1dc236
 install-sh
1dc236
 libtool
1dc236
 ltmain.sh
1dc236
-man/Makefile
1dc236
-man/Makefile.in
1dc236
 missing
1dc236
-src/.deps/
1dc236
-src/Makefile
1dc236
-src/Makefile.in
1dc236
 src/config.h
1dc236
 src/stamp-h2
1dc236
 stamp-h1
1dc236
 # file generated during compilation
1dc236
+.deps
1dc236
 *.o
1dc236
-src/rpcbind
1dc236
-src/rpcinfo
1dc236
+rpcbind
1dc236
+rpcinfo
1dc236
 # cscope database files
1dc236
 cscope.*
1dc236
diff --git a/INSTALL b/INSTALL
1dc236
index 98e5d87..7d1c323 100644
1dc236
--- a/INSTALL
1dc236
+++ b/INSTALL
1dc236
@@ -1,32 +1,25 @@
1dc236
-Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
1dc236
-Foundation, Inc.
1dc236
+Installation Instructions
1dc236
+*************************
1dc236
 
1dc236
-   This file is free documentation; the Free Software Foundation gives
1dc236
-unlimited permission to copy, distribute and modify it.
1dc236
-
1dc236
-
1dc236
-rpcbind Quick Installation
1dc236
-==========================
1dc236
-
1dc236
-$ ./configure
1dc236
-$ make
1dc236
-# make install
1dc236
-
1dc236
-   The install phase will install the rpcbind and rpcinfo commands
1dc236
-under /usr/bin.  If you wish they replace the basic portmap and 
1dc236
-rpcinfo commands, you can run:
1dc236
-
1dc236
-# mv /sbin/portmap /sbin/portmap.sav
1dc236
-# ln -s /usr/bin/rpcbind /sbin/portmap
1dc236
-
1dc236
-# mv /usr/sbin/rpcinfo /usr/sbin/rpcinfo.sav
1dc236
-# ln -s /usr/bin/rpcinfo /usr/sbin/rpcinfo
1dc236
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
1dc236
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
1dc236
 
1dc236
+   Copying and distribution of this file, with or without modification,
1dc236
+are permitted in any medium without royalty provided the copyright
1dc236
+notice and this notice are preserved.  This file is offered as-is,
1dc236
+without warranty of any kind.
1dc236
 
1dc236
 Basic Installation
1dc236
 ==================
1dc236
 
1dc236
-   These are generic installation instructions.
1dc236
+   Briefly, the shell commands `./configure; make; make install' should
1dc236
+configure, build, and install this package.  The following
1dc236
+more-detailed instructions are generic; see the `README' file for
1dc236
+instructions specific to this package.  Some packages provide this
1dc236
+`INSTALL' file but do not implement all of the features documented
1dc236
+below.  The lack of an optional feature in a given package is not
1dc236
+necessarily a bug.  More recommendations for GNU packages can be found
1dc236
+in *note Makefile Conventions: (standards)Makefile Conventions.
1dc236
 
1dc236
    The `configure' shell script attempts to guess correct values for
1dc236
 various system-dependent variables used during compilation.  It uses
1dc236
@@ -39,9 +32,9 @@ debugging `configure').
1dc236
 
1dc236
    It can also use an optional file (typically called `config.cache'
1dc236
 and enabled with `--cache-file=config.cache' or simply `-C') that saves
1dc236
-the results of its tests to speed up reconfiguring.  (Caching is
1dc236
+the results of its tests to speed up reconfiguring.  Caching is
1dc236
 disabled by default to prevent problems with accidental use of stale
1dc236
-cache files.)
1dc236
+cache files.
1dc236
 
1dc236
    If you need to do unusual things to compile the package, please try
1dc236
 to figure out how `configure' could check whether to do them, and mail
1dc236
@@ -51,30 +44,37 @@ some point `config.cache' contains results you don't want to keep, you
1dc236
 may remove or edit it.
1dc236
 
1dc236
    The file `configure.ac' (or `configure.in') is used to create
1dc236
-`configure' by a program called `autoconf'.  You only need
1dc236
-`configure.ac' if you want to change it or regenerate `configure' using
1dc236
-a newer version of `autoconf'.
1dc236
+`configure' by a program called `autoconf'.  You need `configure.ac' if
1dc236
+you want to change it or regenerate `configure' using a newer version
1dc236
+of `autoconf'.
1dc236
 
1dc236
-The simplest way to compile this package is:
1dc236
+   The simplest way to compile this package is:
1dc236
 
1dc236
   1. `cd' to the directory containing the package's source code and type
1dc236
-     `./configure' to configure the package for your system.  If you're
1dc236
-     using `csh' on an old version of System V, you might need to type
1dc236
-     `sh ./configure' instead to prevent `csh' from trying to execute
1dc236
-     `configure' itself.
1dc236
+     `./configure' to configure the package for your system.
1dc236
 
1dc236
-     Running `configure' takes awhile.  While running, it prints some
1dc236
-     messages telling which features it is checking for.
1dc236
+     Running `configure' might take a while.  While running, it prints
1dc236
+     some messages telling which features it is checking for.
1dc236
 
1dc236
   2. Type `make' to compile the package.
1dc236
 
1dc236
   3. Optionally, type `make check' to run any self-tests that come with
1dc236
-     the package.
1dc236
+     the package, generally using the just-built uninstalled binaries.
1dc236
 
1dc236
   4. Type `make install' to install the programs and any data files and
1dc236
-     documentation.
1dc236
-
1dc236
-  5. You can remove the program binaries and object files from the
1dc236
+     documentation.  When installing into a prefix owned by root, it is
1dc236
+     recommended that the package be configured and built as a regular
1dc236
+     user, and only the `make install' phase executed with root
1dc236
+     privileges.
1dc236
+
1dc236
+  5. Optionally, type `make installcheck' to repeat any self-tests, but
1dc236
+     this time using the binaries in their final installed location.
1dc236
+     This target does not install anything.  Running this target as a
1dc236
+     regular user, particularly if the prior `make install' required
1dc236
+     root privileges, verifies that the installation completed
1dc236
+     correctly.
1dc236
+
1dc236
+  6. You can remove the program binaries and object files from the
1dc236
      source code directory by typing `make clean'.  To also remove the
1dc236
      files that `configure' created (so you can compile the package for
1dc236
      a different kind of computer), type `make distclean'.  There is
1dc236
@@ -83,6 +83,16 @@ The simplest way to compile this package is:
1dc236
      all sorts of other programs in order to regenerate files that came
1dc236
      with the distribution.
1dc236
 
1dc236
+  7. Often, you can also type `make uninstall' to remove the installed
1dc236
+     files again.  In practice, not all packages have tested that
1dc236
+     uninstallation works correctly, even though it is required by the
1dc236
+     GNU Coding Standards.
1dc236
+
1dc236
+  8. Some packages, particularly those that use Automake, provide `make
1dc236
+     distcheck', which can by used by developers to test that all other
1dc236
+     targets like `make install' and `make uninstall' work correctly.
1dc236
+     This target is generally not run by end users.
1dc236
+
1dc236
 Compilers and Options
1dc236
 =====================
1dc236
 
1dc236
@@ -94,7 +104,7 @@ for details on some of the pertinent environment variables.
1dc236
 by setting variables in the command line or in the environment.  Here
1dc236
 is an example:
1dc236
 
1dc236
-     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
1dc236
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
1dc236
 
1dc236
    *Note Defining Variables::, for more details.
1dc236
 
1dc236
@@ -103,44 +113,89 @@ Compiling For Multiple Architectures
1dc236
 
1dc236
    You can compile the package for more than one kind of computer at the
1dc236
 same time, by placing the object files for each architecture in their
1dc236
-own directory.  To do this, you must use a version of `make' that
1dc236
-supports the `VPATH' variable, such as GNU `make'.  `cd' to the
1dc236
+own directory.  To do this, you can use GNU `make'.  `cd' to the
1dc236
 directory where you want the object files and executables to go and run
1dc236
 the `configure' script.  `configure' automatically checks for the
1dc236
-source code in the directory that `configure' is in and in `..'.
1dc236
+source code in the directory that `configure' is in and in `..'.  This
1dc236
+is known as a "VPATH" build.
1dc236
 
1dc236
-   If you have to use a `make' that does not support the `VPATH'
1dc236
-variable, you have to compile the package for one architecture at a
1dc236
-time in the source code directory.  After you have installed the
1dc236
-package for one architecture, use `make distclean' before reconfiguring
1dc236
-for another architecture.
1dc236
+   With a non-GNU `make', it is safer to compile the package for one
1dc236
+architecture at a time in the source code directory.  After you have
1dc236
+installed the package for one architecture, use `make distclean' before
1dc236
+reconfiguring for another architecture.
1dc236
+
1dc236
+   On MacOS X 10.5 and later systems, you can create libraries and
1dc236
+executables that work on multiple system types--known as "fat" or
1dc236
+"universal" binaries--by specifying multiple `-arch' options to the
1dc236
+compiler but only a single `-arch' option to the preprocessor.  Like
1dc236
+this:
1dc236
+
1dc236
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
1dc236
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
1dc236
+                 CPP="gcc -E" CXXCPP="g++ -E"
1dc236
+
1dc236
+   This is not guaranteed to produce working output in all cases, you
1dc236
+may have to build one architecture at a time and combine the results
1dc236
+using the `lipo' tool if you have problems.
1dc236
 
1dc236
 Installation Names
1dc236
 ==================
1dc236
 
1dc236
-   By default, `make install' will install the package's files in
1dc236
-`/usr/local/bin', `/usr/local/man', etc.  You can specify an
1dc236
-installation prefix other than `/usr/local' by giving `configure' the
1dc236
-option `--prefix=PATH'.
1dc236
+   By default, `make install' installs the package's commands under
1dc236
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
1dc236
+can specify an installation prefix other than `/usr/local' by giving
1dc236
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
1dc236
+absolute file name.
1dc236
 
1dc236
    You can specify separate installation prefixes for
1dc236
 architecture-specific files and architecture-independent files.  If you
1dc236
-give `configure' the option `--exec-prefix=PATH', the package will use
1dc236
-PATH as the prefix for installing programs and libraries.
1dc236
-Documentation and other data files will still use the regular prefix.
1dc236
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
1dc236
+PREFIX as the prefix for installing programs and libraries.
1dc236
+Documentation and other data files still use the regular prefix.
1dc236
 
1dc236
    In addition, if you use an unusual directory layout you can give
1dc236
-options like `--bindir=PATH' to specify different values for particular
1dc236
+options like `--bindir=DIR' to specify different values for particular
1dc236
 kinds of files.  Run `configure --help' for a list of the directories
1dc236
-you can set and what kinds of files go in them.
1dc236
+you can set and what kinds of files go in them.  In general, the
1dc236
+default for these options is expressed in terms of `${prefix}', so that
1dc236
+specifying just `--prefix' will affect all of the other directory
1dc236
+specifications that were not explicitly provided.
1dc236
+
1dc236
+   The most portable way to affect installation locations is to pass the
1dc236
+correct locations to `configure'; however, many packages provide one or
1dc236
+both of the following shortcuts of passing variable assignments to the
1dc236
+`make install' command line to change installation locations without
1dc236
+having to reconfigure or recompile.
1dc236
+
1dc236
+   The first method involves providing an override variable for each
1dc236
+affected directory.  For example, `make install
1dc236
+prefix=/alternate/directory' will choose an alternate location for all
1dc236
+directory configuration variables that were expressed in terms of
1dc236
+`${prefix}'.  Any directories that were specified during `configure',
1dc236
+but not in terms of `${prefix}', must each be overridden at install
1dc236
+time for the entire installation to be relocated.  The approach of
1dc236
+makefile variable overrides for each directory variable is required by
1dc236
+the GNU Coding Standards, and ideally causes no recompilation.
1dc236
+However, some platforms have known limitations with the semantics of
1dc236
+shared libraries that end up requiring recompilation when using this
1dc236
+method, particularly noticeable in packages that use GNU Libtool.
1dc236
+
1dc236
+   The second method involves providing the `DESTDIR' variable.  For
1dc236
+example, `make install DESTDIR=/alternate/directory' will prepend
1dc236
+`/alternate/directory' before all installation names.  The approach of
1dc236
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
1dc236
+does not work on platforms that have drive letters.  On the other hand,
1dc236
+it does better at avoiding recompilation issues, and works well even
1dc236
+when some directory options were not specified in terms of `${prefix}'
1dc236
+at `configure' time.
1dc236
+
1dc236
+Optional Features
1dc236
+=================
1dc236
 
1dc236
    If the package supports it, you can cause programs to be installed
1dc236
 with an extra prefix or suffix on their names by giving `configure' the
1dc236
 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
1dc236
 
1dc236
-Optional Features
1dc236
-=================
1dc236
-
1dc236
    Some packages pay attention to `--enable-FEATURE' options to
1dc236
 `configure', where FEATURE indicates an optional part of the package.
1dc236
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
1dc236
@@ -153,6 +208,45 @@ find the X include and library files automatically, but if it doesn't,
1dc236
 you can use the `configure' options `--x-includes=DIR' and
1dc236
 `--x-libraries=DIR' to specify their locations.
1dc236
 
1dc236
+   Some packages offer the ability to configure how verbose the
1dc236
+execution of `make' will be.  For these packages, running `./configure
1dc236
+--enable-silent-rules' sets the default to minimal output, which can be
1dc236
+overridden with `make V=1'; while running `./configure
1dc236
+--disable-silent-rules' sets the default to verbose, which can be
1dc236
+overridden with `make V=0'.
1dc236
+
1dc236
+Particular systems
1dc236
+==================
1dc236
+
1dc236
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
1dc236
+CC is not installed, it is recommended to use the following options in
1dc236
+order to use an ANSI C compiler:
1dc236
+
1dc236
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
1dc236
+
1dc236
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
1dc236
+
1dc236
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
1dc236
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
1dc236
+a workaround.  If GNU CC is not installed, it is therefore recommended
1dc236
+to try
1dc236
+
1dc236
+     ./configure CC="cc"
1dc236
+
1dc236
+and if that doesn't work, try
1dc236
+
1dc236
+     ./configure CC="cc -nodtk"
1dc236
+
1dc236
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
1dc236
+directory contains several dysfunctional programs; working variants of
1dc236
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
1dc236
+in your `PATH', put it _after_ `/usr/bin'.
1dc236
+
1dc236
+   On Haiku, software installed for all users goes in `/boot/common',
1dc236
+not `/usr/local'.  It is recommended to use the following options:
1dc236
+
1dc236
+     ./configure --prefix=/boot/common
1dc236
+
1dc236
 Specifying the System Type
1dc236
 ==========================
1dc236
 
1dc236
@@ -168,14 +262,15 @@ type, such as `sun4', or a canonical name which has the form:
1dc236
 
1dc236
 where SYSTEM can have one of these forms:
1dc236
 
1dc236
-     OS KERNEL-OS
1dc236
+     OS
1dc236
+     KERNEL-OS
1dc236
 
1dc236
    See the file `config.sub' for the possible values of each field.  If
1dc236
 `config.sub' isn't included in this package, then this package doesn't
1dc236
 need to know the machine type.
1dc236
 
1dc236
    If you are _building_ compiler tools for cross-compiling, you should
1dc236
-use the `--target=TYPE' option to select the type of system they will
1dc236
+use the option `--target=TYPE' to select the type of system they will
1dc236
 produce code for.
1dc236
 
1dc236
    If you want to _use_ a cross compiler, that generates code for a
1dc236
@@ -205,9 +300,14 @@ them in the `configure' command line, using `VAR=value'.  For example:
1dc236
 
1dc236
      ./configure CC=/usr/local2/bin/gcc
1dc236
 
1dc236
-will cause the specified gcc to be used as the C compiler (unless it is
1dc236
+causes the specified `gcc' to be used as the C compiler (unless it is
1dc236
 overridden in the site shell script).
1dc236
 
1dc236
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
1dc236
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
1dc236
+
1dc236
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
1dc236
+
1dc236
 `configure' Invocation
1dc236
 ======================
1dc236
 
1dc236
@@ -216,7 +316,14 @@ operates.
1dc236
 
1dc236
 `--help'
1dc236
 `-h'
1dc236
-     Print a summary of the options to `configure', and exit.
1dc236
+     Print a summary of all of the options to `configure', and exit.
1dc236
+
1dc236
+`--help=short'
1dc236
+`--help=recursive'
1dc236
+     Print a summary of the options unique to this package's
1dc236
+     `configure', and exit.  The `short' variant lists options used
1dc236
+     only in the top level, while the `recursive' variant lists options
1dc236
+     also present in any nested packages.
1dc236
 
1dc236
 `--version'
1dc236
 `-V'
1dc236
@@ -243,6 +350,16 @@ operates.
1dc236
      Look for the package's source code in directory DIR.  Usually
1dc236
      `configure' can determine that directory automatically.
1dc236
 
1dc236
+`--prefix=DIR'
1dc236
+     Use DIR as the installation prefix.  *note Installation Names::
1dc236
+     for more details, including other options available for fine-tuning
1dc236
+     the installation locations.
1dc236
+
1dc236
+`--no-create'
1dc236
+`-n'
1dc236
+     Run the configure checks, but stop before creating any output
1dc236
+     files.
1dc236
+
1dc236
 `configure' also accepts some other, not widely useful, options.  Run
1dc236
 `configure --help' for more details.
1dc236
 
1dc236
diff --git a/Makefile.am b/Makefile.am
1dc236
index cd56148..d10c906 100644
1dc236
--- a/Makefile.am
1dc236
+++ b/Makefile.am
1dc236
@@ -1,2 +1,44 @@
1dc236
-SUBDIRS= src man
1dc236
+AM_CPPFLAGS = \
1dc236
+	-DCHECK_LOCAL \
1dc236
+	-DPORTMAP \
1dc236
+	-DFACILITY=LOG_MAIL \
1dc236
+	-DSEVERITY=LOG_INFO \
1dc236
+	-DINET6 \
1dc236
+	-DRPCBIND_STATEDIR="\"$(statedir)\"" \
1dc236
+	-DRPCBIND_USER="\"$(rpcuser)\"" \
1dc236
+	-D_GNU_SOURCE \
1dc236
+	$(TIRPC_CFLAGS)
1dc236
 
1dc236
+if DEBUG
1dc236
+AM_CPPFLAGS +=	-DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
1dc236
+AM_CPPFLAGS +=	-DND_DEBUG -DBIND_DEBUG
1dc236
+endif
1dc236
+
1dc236
+if WARMSTART
1dc236
+AM_CPPFLAGS +=	-DWARMSTART
1dc236
+endif
1dc236
+
1dc236
+if LIBWRAP
1dc236
+AM_CPPFLAGS +=	-DLIBWRAP
1dc236
+endif
1dc236
+
1dc236
+bin_PROGRAMS = rpcbind rpcinfo
1dc236
+
1dc236
+rpcbind_SOURCES = \
1dc236
+	src/check_bound.c \
1dc236
+	src/pmap_svc.c \
1dc236
+	src/rpcb_stat.c \
1dc236
+	src/rpcb_svc.c \
1dc236
+	src/rpcb_svc_4.c \
1dc236
+	src/rpcb_svc_com.c \
1dc236
+	src/rpcbind.c \
1dc236
+	src/rpcbind.h \
1dc236
+	src/security.c \
1dc236
+	src/util.c \
1dc236
+	src/warmstart.c
1dc236
+rpcbind_LDADD = $(TIRPC_LIBS)
1dc236
+
1dc236
+rpcinfo_SOURCES =       src/rpcinfo.c
1dc236
+rpcinfo_LDADD   =       $(TIRPC_LIBS)
1dc236
+
1dc236
+dist_man8_MANS = man/rpcbind.8 man/rpcinfo.8
1dc236
diff --git a/autogen.sh b/autogen.sh
1dc236
index 1613b6d..761db90 100755
1dc236
--- a/autogen.sh
1dc236
+++ b/autogen.sh
1dc236
@@ -36,7 +36,7 @@ if test x"${1}" = x"clean"; then
1dc236
 fi
1dc236
 
1dc236
 aclocal
1dc236
-libtoolize --force --copy
1dc236
-autoheader
1dc236
+#libtoolize --force --copy
1dc236
+#autoheader
1dc236
 automake --add-missing --copy --gnu # -Wall
1dc236
 autoconf # -Wall
1dc236
diff --git a/configure.in b/configure.in
1dc236
index de1c730..2b67720 100644
1dc236
--- a/configure.in
1dc236
+++ b/configure.in
1dc236
@@ -1,66 +1,39 @@
1dc236
- AC_INIT(rpcbind, 0.2.0)
1dc236
+AC_INIT(rpcbind, 0.2.0)
1dc236
  
1dc236
- AM_INIT_AUTOMAKE
1dc236
-# AM_MAINTAINER_MODE
1dc236
+AM_INIT_AUTOMAKE
1dc236
 AC_CONFIG_SRCDIR([src/rpcbind.c])
1dc236
- AC_PROG_CC
1dc236
- AM_CONFIG_HEADER(config.h)
1dc236
- AC_HEADER_DIRENT
1dc236
- AC_PREFIX_DEFAULT(/usr)
1dc236
-
1dc236
-AC_CONFIG_SRCDIR([src/config.h.in])
1dc236
-AC_CONFIG_HEADERS([src/config.h])
1dc236
-
1dc236
-AC_PROG_LIBTOOL
1dc236
-
1dc236
-AC_ARG_ENABLE(debug,[  --enable-debug      Turns on rpcbind debugging], 
1dc236
-	[case "${enableval}" in
1dc236
-		yes) debug=true ;;
1dc236
-		no)  debug=no ;;
1dc236
-		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
1dc236
-	esac],[debug=false])
1dc236
-AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
1dc236
-
1dc236
-AC_ARG_ENABLE(warmstarts,[  --enable-warmstarts  Enables Warm Starts], 
1dc236
-	[case "${enableval}" in
1dc236
-		yes) warmstarts=true ;;
1dc236
-		no)  warmstarts=no ;;
1dc236
-		*) AC_MSG_ERROR(bad value ${enableval} for --enable-warmstarts) ;;
1dc236
-	esac],[warmstarts=false])
1dc236
-AM_CONDITIONAL(WARMSTART, test x$warmstarts = xtrue)
1dc236
-
1dc236
-if test "$warmstarts" = "true" ; then
1dc236
-	AC_ARG_WITH(statedir,
1dc236
-		[  --with-statedir=/foo use state dir /foo [/tmp]],
1dc236
-    	statedir=$withval,
1dc236
-		statedir=/tmp)
1dc236
-		AC_SUBST(statedir)
1dc236
-	AC_DEFINE_UNQUOTED(RPCBIND_STATEDIR, "$statedir", [This defines the location where the state files will be kept for warm starts])
1dc236
-fi
1dc236
-AC_ARG_WITH(rpcuser,
1dc236
-	[  --with-rpcuser=user uid to use [root]],
1dc236
-	rpcuser=$withval,
1dc236
-	rpcuser=root)
1dc236
-	AC_SUBST(rpcuser)
1dc236
-AC_DEFINE_UNQUOTED(RPCBIND_USER, "$rpcuser", [This defines the uid to run as])
1dc236
+AC_PREFIX_DEFAULT(/usr)
1dc236
+AC_PROG_CC
1dc236
+
1dc236
+AC_ARG_ENABLE([libwrap],
1dc236
+  AS_HELP_STRING([--enable-libwrap], [Enables host name checking through tcpd @<:@default=no@:>@]))
1dc236
+AM_CONDITIONAL(LIBWRAP, test x$enable_libwrap = xyes)
1dc236
+
1dc236
+AC_ARG_ENABLE([debug],
1dc236
+  AS_HELP_STRING([--enable-debug], [Turns on rpcbind debugging @<:@default=no@:>@]))
1dc236
+AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)
1dc236
+
1dc236
+AC_ARG_ENABLE([warmstarts],
1dc236
+  AS_HELP_STRING([--enable-warmstarts], [Enables Warm Starts @<:@default=no@:>@]))
1dc236
+AM_CONDITIONAL(WARMSTART, test x$enable_warmstarts = xyes)
1dc236
+
1dc236
+AC_ARG_WITH([statedir],
1dc236
+  AS_HELP_STRING([--with-statedir=ARG], [use ARG as state dir @<:@default=/tmp@:>@])
1dc236
+  ,, [with_statedir=/tmp])
1dc236
+AC_SUBST([statedir], [$with_statedir])
1dc236
+
1dc236
+AC_ARG_WITH([rpcuser],
1dc236
+  AS_HELP_STRING([--with-rpcuser=ARG], [use ARG for RPC @<:@default=root@:>@]),
1dc236
+  ,, [with_rpcuser=root])
1dc236
+AC_SUBST([rpcuser], [$with_rpcuser])
1dc236
+ 
1dc236
+PKG_CHECK_MODULES([TIRPC], [libtirpc])
1dc236
 
1dc236
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
1dc236
-                  netinet/in.h stdlib.h string.h \
1dc236
-                  sys/param.h sys/socket.h \
1dc236
-                  sys/time.h syslog.h \
1dc236
-                  unistd.h nss.h])
1dc236
+AS_IF([test x$enable_libwrap = xyes], [
1dc236
+	AC_CHECK_LIB([wrap], [hosts_access], ,
1dc236
+		AC_MSG_ERROR([libwrap support requested but unable to find libwrap]))
1dc236
+])
1dc236
 
1dc236
-AC_CHECK_LIB([pthread], [pthread_create])
1dc236
-AC_CHECK_LIB([tirpc], [clnt_create])
1dc236
-AC_ARG_ENABLE(libwrap,[ --enable-libwrap  Enables host name checking], 
1dc236
-	[case "${enableval}" in
1dc236
-		yes) libwarp=true 
1dc236
-			AC_CHECK_LIB([wrap],  [hosts_access]) ;;
1dc236
-		no)  libwarp=no ;;
1dc236
-		*) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
1dc236
-	esac],[libwarp=false])
1dc236
-AM_CONDITIONAL(LIBWRAP, test x$libwarp = xtrue)
1dc236
+AC_SEARCH_LIBS([pthread_create], [pthread])
1dc236
 
1dc236
-AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
1dc236
-AC_OUTPUT()
1dc236
-                                                                   
1dc236
+AC_OUTPUT([Makefile])
1dc236
diff --git a/man/Makefile.am b/man/Makefile.am
1dc236
deleted file mode 100644
1dc236
index 84818e9..0000000
1dc236
--- a/man/Makefile.am
1dc236
+++ /dev/null
1dc236
@@ -1,2 +0,0 @@
1dc236
-man8_MANS   = rpcbind.8
1dc236
-EXTRA_DIST  = $(man8_MANS)
1dc236
diff --git a/man/rpcbind.8 b/man/rpcbind.8
1dc236
index 32806d4..da32701 100644
1dc236
--- a/man/rpcbind.8
1dc236
+++ b/man/rpcbind.8
1dc236
@@ -82,6 +82,8 @@ during operation, and will abort on certain errors if
1dc236
 is also specified.
1dc236
 With this option, the name-to-address translation consistency
1dc236
 checks are shown in detail.
1dc236
+.It Fl f
1dc236
+Do not fork and become a background process.
1dc236
 .It Fl h
1dc236
 Specify specific IP addresses to bind to for UDP requests.
1dc236
 This option
1dc236
@@ -141,7 +143,6 @@ All RPC servers must be restarted if
1dc236
 .Nm
1dc236
 is restarted.
1dc236
 .Sh SEE ALSO
1dc236
-.Xr rpcbind 3 ,
1dc236
 .Xr rpcinfo 8
1dc236
 .Sh LINUX PORT
1dc236
 .Bl Aurelien Charbon <aurelien.charbon@bull.net>
1dc236
diff --git a/src/Makefile.am b/src/Makefile.am
1dc236
deleted file mode 100644
1dc236
index cc0a85b..0000000
1dc236
--- a/src/Makefile.am
1dc236
+++ /dev/null
1dc236
@@ -1,34 +0,0 @@
1dc236
-INCLUDES = -I$(srcdir)/tirpc -DPORTMAP -DINET6 -DVERSION="\"$(VERSION)\"" \
1dc236
-                                                -D_GNU_SOURCE -Wall -pipe
1dc236
-if DEBUG
1dc236
-INCLUDES +=	-DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
1dc236
-INCLUDES +=	-DND_DEBUG -DBIND_DEBUG
1dc236
-endif
1dc236
-
1dc236
-if WARMSTART
1dc236
-INCLUDES +=	-DWARMSTART
1dc236
-endif
1dc236
-
1dc236
-if LIBWRAP
1dc236
-INCLUDES +=	-DLIBWRAP
1dc236
-endif
1dc236
-
1dc236
-
1dc236
-bin_PROGRAMS = rpcbind rpcinfo
1dc236
-
1dc236
-rpcbind_SOURCES =       check_bound.c rpcbind.c \
1dc236
-                        rpcb_svc_4.c rpcb_svc_com.c \
1dc236
-                        util.c pmap_svc.c rpcb_stat.c \
1dc236
-                        rpcb_svc.c security.c warmstart.c \
1dc236
-                        rpcbind.h
1dc236
-
1dc236
-rpcinfo_SOURCES =       rpcinfo.c
1dc236
-rpcinfo_LDFLAGS =       -lpthread -ltirpc
1dc236
-rpcinfo_LDADD   =       $(LIB_TIRPC)
1dc236
-
1dc236
-
1dc236
-rpcbind_LDFLAGS = -lpthread -ltirpc
1dc236
-rpcbind_LDADD = $(LIB_TIRPC)
1dc236
-AM_CPPFLAGS = -I/usr/include/tirpc -DCHECK_LOCAL -DPORTMAP \
1dc236
-                       -DFACILITY=LOG_MAIL -DSEVERITY=LOG_INFO
1dc236
-     
1dc236
diff --git a/src/config.h.in b/src/config.h.in
1dc236
deleted file mode 100644
1dc236
index 67a0e39..0000000
1dc236
--- a/src/config.h.in
1dc236
+++ /dev/null
1dc236
@@ -1,105 +0,0 @@
1dc236
-/* config.h.in.  Generated from configure.in by autoheader.  */
1dc236
-
1dc236
-/* Define to 1 if you have the <arpa/inet.h> header file. */
1dc236
-#undef HAVE_ARPA_INET_H
1dc236
-
1dc236
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
1dc236
-   */
1dc236
-#undef HAVE_DIRENT_H
1dc236
-
1dc236
-/* Define to 1 if you have the <fcntl.h> header file. */
1dc236
-#undef HAVE_FCNTL_H
1dc236
-
1dc236
-/* Define to 1 if you have the <inttypes.h> header file. */
1dc236
-#undef HAVE_INTTYPES_H
1dc236
-
1dc236
-/* Define to 1 if you have the `pthread' library (-lpthread). */
1dc236
-#undef HAVE_LIBPTHREAD
1dc236
-
1dc236
-/* Define to 1 if you have the `tirpc' library (-ltirpc). */
1dc236
-#undef HAVE_LIBTIRPC
1dc236
-
1dc236
-/* Define to 1 if you have the <memory.h> header file. */
1dc236
-#undef HAVE_MEMORY_H
1dc236
-
1dc236
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
1dc236
-#undef HAVE_NDIR_H
1dc236
-
1dc236
-/* Define to 1 if you have the <netdb.h> header file. */
1dc236
-#undef HAVE_NETDB_H
1dc236
-
1dc236
-/* Define to 1 if you have the <netinet/in.h> header file. */
1dc236
-#undef HAVE_NETINET_IN_H
1dc236
-
1dc236
-/* Define to 1 if you have the <stdint.h> header file. */
1dc236
-#undef HAVE_STDINT_H
1dc236
-
1dc236
-/* Define to 1 if you have the <stdlib.h> header file. */
1dc236
-#undef HAVE_STDLIB_H
1dc236
-
1dc236
-/* Define to 1 if you have the <strings.h> header file. */
1dc236
-#undef HAVE_STRINGS_H
1dc236
-
1dc236
-/* Define to 1 if you have the <string.h> header file. */
1dc236
-#undef HAVE_STRING_H
1dc236
-
1dc236
-/* Define to 1 if you have the <syslog.h> header file. */
1dc236
-#undef HAVE_SYSLOG_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
1dc236
-   */
1dc236
-#undef HAVE_SYS_DIR_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
1dc236
-   */
1dc236
-#undef HAVE_SYS_NDIR_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/param.h> header file. */
1dc236
-#undef HAVE_SYS_PARAM_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/socket.h> header file. */
1dc236
-#undef HAVE_SYS_SOCKET_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/stat.h> header file. */
1dc236
-#undef HAVE_SYS_STAT_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/time.h> header file. */
1dc236
-#undef HAVE_SYS_TIME_H
1dc236
-
1dc236
-/* Define to 1 if you have the <sys/types.h> header file. */
1dc236
-#undef HAVE_SYS_TYPES_H
1dc236
-
1dc236
-/* Define to 1 if you have the <unistd.h> header file. */
1dc236
-#undef HAVE_UNISTD_H
1dc236
-
1dc236
-/* Name of package */
1dc236
-#undef PACKAGE
1dc236
-
1dc236
-/* Define to the address where bug reports for this package should be sent. */
1dc236
-#undef PACKAGE_BUGREPORT
1dc236
-
1dc236
-/* Define to the full name of this package. */
1dc236
-#undef PACKAGE_NAME
1dc236
-
1dc236
-/* Define to the full name and version of this package. */
1dc236
-#undef PACKAGE_STRING
1dc236
-
1dc236
-/* Define to the one symbol short name of this package. */
1dc236
-#undef PACKAGE_TARNAME
1dc236
-
1dc236
-/* Define to the version of this package. */
1dc236
-#undef PACKAGE_VERSION
1dc236
-
1dc236
-/* Define to 1 if you have the ANSI C header files. */
1dc236
-#undef STDC_HEADERS
1dc236
-
1dc236
-/* Version number of package */
1dc236
-#undef VERSION
1dc236
-
1dc236
-/* This defines the location where the state files will be kept for warm
1dc236
-   starts */
1dc236
-#undef RPCBIND_STATEDIR
1dc236
-
1dc236
-/* This defines the uid to run as */
1dc236
-#undef RPCBIND_USER
1dc236
-
1dc236
diff --git a/src/pmap_svc.c b/src/pmap_svc.c
1dc236
index 4736700..337e64d 100644
1dc236
--- a/src/pmap_svc.c
1dc236
+++ b/src/pmap_svc.c
1dc236
@@ -80,7 +80,7 @@ pmap_service(struct svc_req *rqstp, SVCXPRT *xprt)
1dc236
 		if (debugging)
1dc236
 			fprintf(stderr, "PMAPPROC_NULL\n");
1dc236
 #endif
1dc236
-		check_access(xprt, rqstp->rq_proc, NULL, PMAPVERS);
1dc236
+		check_access(xprt, rqstp->rq_proc, 0, PMAPVERS);
1dc236
 		if ((!svc_sendreply(xprt, (xdrproc_t) xdr_void, NULL)) &&
1dc236
 			debugging) {
1dc236
 			if (doabort) {
1dc236
@@ -201,11 +201,11 @@ pmapproc_change(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt, unsigned long
1dc236
 		  reg.pm_prog, reg.pm_vers);
1dc236
 #endif
1dc236
 
1dc236
-	if (!check_access(xprt, op, &reg, PMAPVERS)) {
1dc236
+	if (!check_access(xprt, op, reg.pm_prog, PMAPVERS)) {
1dc236
 		svcerr_weakauth(xprt);
1dc236
 		return (FALSE);
1dc236
 	}
1dc236
-		
1dc236
+
1dc236
 	rpcbreg.r_prog = reg.pm_prog;
1dc236
 	rpcbreg.r_vers = reg.pm_vers;
1dc236
 
1dc236
@@ -276,7 +276,7 @@ pmapproc_getport(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt)
1dc236
 		return (FALSE);
1dc236
 	}
1dc236
 
1dc236
-	if (!check_access(xprt, PMAPPROC_GETPORT, &reg, PMAPVERS)) {
1dc236
+	if (!check_access(xprt, PMAPPROC_GETPORT, reg.pm_prog, PMAPVERS)) {
1dc236
 		svcerr_weakauth(xprt);
1dc236
 		return FALSE;
1dc236
 	}
1dc236
@@ -340,7 +340,7 @@ pmapproc_dump(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt)
1dc236
 		return (FALSE);
1dc236
 	}
1dc236
 
1dc236
-	if (!check_access(xprt, PMAPPROC_DUMP, NULL, PMAPVERS)) {
1dc236
+	if (!check_access(xprt, PMAPPROC_DUMP, 0, PMAPVERS)) {
1dc236
 		svcerr_weakauth(xprt);
1dc236
 		return FALSE;
1dc236
 	}
1dc236
diff --git a/src/rpcb_svc.c b/src/rpcb_svc.c
1dc236
index 0514ba5..e350f85 100644
1dc236
--- a/src/rpcb_svc.c
1dc236
+++ b/src/rpcb_svc.c
1dc236
@@ -75,6 +75,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
1dc236
 	char *result;
1dc236
 	xdrproc_t xdr_argument, xdr_result;
1dc236
 	void *(*local) __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
1dc236
+	rpcprog_t setprog = 0;
1dc236
 
1dc236
 	rpcbs_procinfo(RPCBVERS_3_STAT, rqstp->rq_proc);
1dc236
 
1dc236
@@ -88,7 +89,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
1dc236
 			fprintf(stderr, "RPCBPROC_NULL\n");
1dc236
 #endif
1dc236
 		/* This call just logs, no actual checks */
1dc236
-		check_access(transp, rqstp->rq_proc, NULL, RPCBVERS);
1dc236
+		check_access(transp, rqstp->rq_proc, 0, RPCBVERS);
1dc236
 		(void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
1dc236
 		return;
1dc236
 
1dc236
@@ -166,7 +167,13 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
1dc236
 			(void) fprintf(stderr, "rpcbind: could not decode\n");
1dc236
 		return;
1dc236
 	}
1dc236
-	if (!check_access(transp, rqstp->rq_proc, &argument, RPCBVERS)) {
1dc236
+
1dc236
+	if (rqstp->rq_proc == RPCBPROC_SET
1dc236
+	 || rqstp->rq_proc == RPCBPROC_UNSET
1dc236
+	 || rqstp->rq_proc == RPCBPROC_GETADDR)
1dc236
+		setprog = argument.rpcbproc_set_3_arg.r_prog;
1dc236
+
1dc236
+	if (!check_access(transp, rqstp->rq_proc, setprog, RPCBVERS)) {
1dc236
 		svcerr_weakauth(transp);
1dc236
 		goto done;
1dc236
 	}
1dc236
diff --git a/src/rpcb_svc_4.c b/src/rpcb_svc_4.c
1dc236
index 9fd5bef..313e6d1 100644
1dc236
--- a/src/rpcb_svc_4.c
1dc236
+++ b/src/rpcb_svc_4.c
1dc236
@@ -78,6 +78,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
1dc236
 	char *result;
1dc236
 	xdrproc_t xdr_argument, xdr_result;
1dc236
 	void *(*local) __P((void *, struct svc_req *, SVCXPRT *, rpcvers_t));
1dc236
+	rpcprog_t setprog = 0;
1dc236
 
1dc236
 	rpcbs_procinfo(RPCBVERS_4_STAT, rqstp->rq_proc);
1dc236
 
1dc236
@@ -90,7 +91,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
1dc236
 		if (debugging)
1dc236
 			fprintf(stderr, "RPCBPROC_NULL\n");
1dc236
 #endif
1dc236
-		check_access(transp, rqstp->rq_proc, NULL, RPCBVERS4);
1dc236
+		check_access(transp, rqstp->rq_proc, 0, RPCBVERS4);
1dc236
 		(void) svc_sendreply(transp, (xdrproc_t) xdr_void,
1dc236
 					(char *)NULL);
1dc236
 		return;
1dc236
@@ -220,7 +221,13 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
1dc236
 			(void) fprintf(stderr, "rpcbind: could not decode\n");
1dc236
 		return;
1dc236
 	}
1dc236
-	if (!check_access(transp, rqstp->rq_proc, &argument, RPCBVERS4)) {
1dc236
+
1dc236
+	if (rqstp->rq_proc == RPCBPROC_SET
1dc236
+	 || rqstp->rq_proc == RPCBPROC_UNSET
1dc236
+	 || rqstp->rq_proc == RPCBPROC_GETADDR)
1dc236
+		setprog = argument.rpcbproc_set_4_arg.r_prog;
1dc236
+
1dc236
+	if (!check_access(transp, rqstp->rq_proc, setprog, RPCBVERS4)) {
1dc236
 		svcerr_weakauth(transp);
1dc236
 		goto done;
1dc236
 	}
1dc236
diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
1dc236
index 291421f..f6bd6bd 100644
1dc236
--- a/src/rpcb_svc_com.c
1dc236
+++ b/src/rpcb_svc_com.c
1dc236
@@ -1227,6 +1227,8 @@ send_svcsyserr(SVCXPRT *xprt, struct finfo *fi)
1dc236
 	return;
1dc236
 }
1dc236
 
1dc236
+extern SVCAUTH svc_auth_none;
1dc236
+
1dc236
 static void
1dc236
 handle_reply(int fd, SVCXPRT *xprt)
1dc236
 {
1dc236
@@ -1293,7 +1295,10 @@ handle_reply(int fd, SVCXPRT *xprt)
1dc236
 	a.rmt_localvers = fi->versnum;
1dc236
 
1dc236
 	xprt_set_caller(xprt, fi);
1dc236
+	xprt->xp_auth = &svc_auth_none;
1dc236
 	svc_sendreply(xprt, (xdrproc_t) xdr_rmtcall_result, (char *) &a);
1dc236
+	SVCAUTH_DESTROY(xprt->xp_auth);
1dc236
+	xprt->xp_auth = NULL;
1dc236
 done:
1dc236
 	if (buffer)
1dc236
 		free(buffer);
1dc236
@@ -1372,10 +1377,13 @@ static char *
1dc236
 getowner(SVCXPRT *transp, char *owner, size_t ownersize)
1dc236
 {
1dc236
 	uid_t uid;
1dc236
- 
1dc236
-	if (__rpc_get_local_uid(transp, &uid) < 0)
1dc236
-		snprintf(owner, ownersize, "unknown");
1dc236
-	else if (uid == 0)
1dc236
+
1dc236
+	if (__rpc_get_local_uid(transp, &uid) < 0) {
1dc236
+		if (is_localroot(svc_getrpccaller(transp)))
1dc236
+			snprintf(owner, ownersize, "superuser");
1dc236
+		else 
1dc236
+			snprintf(owner, ownersize, "unknown");
1dc236
+	} else if (uid == 0)
1dc236
 		snprintf(owner, ownersize, "superuser");
1dc236
 	else
1dc236
 		snprintf(owner, ownersize, "%d", uid);  
1dc236
diff --git a/src/rpcbind.c b/src/rpcbind.c
1dc236
index 525ffba..9a0504d 100644
1dc236
--- a/src/rpcbind.c
1dc236
+++ b/src/rpcbind.c
1dc236
@@ -68,7 +68,6 @@
1dc236
 #include <string.h>
1dc236
 #include <errno.h>
1dc236
 #include <nss.h>
1dc236
-#include "config.h"
1dc236
 #include "rpcbind.h"
1dc236
 
1dc236
 /*#define RPCBIND_DEBUG*/
1dc236
@@ -77,6 +76,7 @@
1dc236
 
1dc236
 int debugging = 0;	/* Tell me what's going on */
1dc236
 int doabort = 0;	/* When debugging, do an abort on errors */
1dc236
+int dofork = 1;		/* fork? */
1dc236
 
1dc236
 rpcblist_ptr list_rbl;	/* A list of version 3/4 rpcbind services */
1dc236
 
1dc236
@@ -213,8 +213,8 @@ main(int argc, char *argv[])
1dc236
 			printf("\n");
1dc236
 		}
1dc236
 #endif
1dc236
-	} else {
1dc236
-		if (daemon(0, 0)) 
1dc236
+	} else if (dofork) {
1dc236
+		if (daemon(0, 0))
1dc236
         		err(1, "fork failed");
1dc236
 	}
1dc236
 
1dc236
@@ -236,6 +236,10 @@ main(int argc, char *argv[])
1dc236
                         syslog(LOG_ERR, "setgid to '%s' (%d) failed: %m", id, p->pw_gid);
1dc236
                         exit(1);
1dc236
                 }
1dc236
+		if (setgroups(0, NULL) == -1) {
1dc236
+			syslog(LOG_ERR, "dropping supplemental groups failed: %m");
1dc236
+			exit(1);
1dc236
+		}
1dc236
 		if (setuid(p->pw_uid) == -1) {
1dc236
 			syslog(LOG_ERR, "setuid to '%s' (%d) failed: %m", id, p->pw_uid);
1dc236
 			exit(1);
1dc236
@@ -276,6 +280,7 @@ init_transport(struct netconfig *nconf)
1dc236
 	int addrlen = 0;
1dc236
 	int nhostsbak;
1dc236
 	int checkbind;
1dc236
+	int on = 1;
1dc236
 	struct sockaddr *sa = NULL;
1dc236
 	u_int32_t host_addr[4];  /* IPv4 or IPv6 */
1dc236
 	struct sockaddr_un sun;
1dc236
@@ -493,6 +498,14 @@ init_transport(struct netconfig *nconf)
1dc236
 		}
1dc236
 		oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
1dc236
 		__rpc_fd2sockinfo(fd, &si);
1dc236
+		if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on,
1dc236
+				sizeof(on)) != 0) {
1dc236
+			syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s",
1dc236
+				nconf->nc_netid);
1dc236
+			if (res != NULL)
1dc236
+				freeaddrinfo(res);
1dc236
+			return 1;
1dc236
+		}
1dc236
 		if (bind(fd, sa, addrlen) < 0) {
1dc236
 			syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
1dc236
 			if (res != NULL)
1dc236
@@ -731,7 +744,7 @@ parseargs(int argc, char *argv[])
1dc236
 {
1dc236
 	int c;
1dc236
 	oldstyle_local = 1;
1dc236
-	while ((c = getopt(argc, argv, "dwah:ils")) != -1) {
1dc236
+	while ((c = getopt(argc, argv, "adh:ilswf")) != -1) {
1dc236
 		switch (c) {
1dc236
 		case 'a':
1dc236
 			doabort = 1;	/* when debugging, do an abort on */
1dc236
@@ -758,13 +771,16 @@ parseargs(int argc, char *argv[])
1dc236
 		case 's':
1dc236
 			runasdaemon = 1;
1dc236
 			break;
1dc236
+		case 'f':
1dc236
+			dofork = 0;
1dc236
+			break;
1dc236
 #ifdef WARMSTART
1dc236
 		case 'w':
1dc236
 			warmstart = 1;
1dc236
 			break;
1dc236
 #endif
1dc236
 		default:	/* error */
1dc236
-			fprintf(stderr,	"usage: rpcbind [-Idwils]\n");
1dc236
+			fprintf(stderr,	"usage: rpcbind [-adhilswf]\n");
1dc236
 			exit (1);
1dc236
 		}
1dc236
 	}
1dc236
diff --git a/src/rpcbind.h b/src/rpcbind.h
1dc236
index c800577..74f9591 100644
1dc236
--- a/src/rpcbind.h
1dc236
+++ b/src/rpcbind.h
1dc236
@@ -119,7 +119,7 @@ void rpcbind_abort(void);
1dc236
 void reap(int);
1dc236
 void toggle_verboselog(int);
1dc236
 
1dc236
-int check_access(SVCXPRT *, rpcproc_t, void *, unsigned int);
1dc236
+int check_access(SVCXPRT *, rpcproc_t, rpcprog_t, unsigned int);
1dc236
 int check_callit(SVCXPRT *, struct r_rmtcall_args *, int);
1dc236
 void logit(int, struct sockaddr *, rpcproc_t, rpcprog_t, const char *);
1dc236
 int is_loopback(struct netbuf *);
1dc236
diff --git a/src/security.c b/src/security.c
1dc236
index 0edeac6..d272f74 100644
1dc236
--- a/src/security.c
1dc236
+++ b/src/security.c
1dc236
@@ -62,34 +62,21 @@ int log_severity = PORTMAP_LOG_FACILITY|PORTMAP_LOG_SEVERITY;
1dc236
 extern int verboselog;
1dc236
 
1dc236
 int 
1dc236
-check_access(SVCXPRT *xprt, rpcproc_t proc, void *args, unsigned int rpcbvers)
1dc236
+check_access(SVCXPRT *xprt, rpcproc_t proc, rpcprog_t prog, unsigned int rpcbvers)
1dc236
 {
1dc236
 	struct netbuf *caller = svc_getrpccaller(xprt);
1dc236
 	struct sockaddr *addr = (struct sockaddr *)caller->buf;
1dc236
 #ifdef LIBWRAP
1dc236
 	struct request_info req;
1dc236
 #endif
1dc236
-	rpcprog_t prog = 0;
1dc236
-	rpcb *rpcbp;
1dc236
-	struct pmap *pmap;
1dc236
 
1dc236
 	/*
1dc236
 	 * The older PMAP_* equivalents have the same numbers, so
1dc236
 	 * they are accounted for here as well.
1dc236
 	 */
1dc236
 	switch (proc) {
1dc236
-	case RPCBPROC_GETADDR:
1dc236
 	case RPCBPROC_SET:
1dc236
 	case RPCBPROC_UNSET:
1dc236
-		if (rpcbvers > PMAPVERS) {
1dc236
-			rpcbp = (rpcb *)args;
1dc236
-			prog = rpcbp->r_prog;
1dc236
-		} else {
1dc236
-			pmap = (struct pmap *)args;
1dc236
-			prog = pmap->pm_prog;
1dc236
-		}
1dc236
-		if (proc == RPCBPROC_GETADDR)
1dc236
-			break;
1dc236
 		if (!insecure && !is_loopback(caller)) {
1dc236
 #ifdef RPCBIND_DEBUG
1dc236
 			  if (debugging)
1dc236
@@ -101,6 +88,7 @@ check_access(SVCXPRT *xprt, rpcproc_t proc, void *args, unsigned int rpcbvers)
1dc236
 			return 0;
1dc236
 		}
1dc236
 		break;
1dc236
+	case RPCBPROC_GETADDR:
1dc236
 	case RPCBPROC_CALLIT:
1dc236
 	case RPCBPROC_INDIRECT:
1dc236
 	case RPCBPROC_DUMP:
1dc236
@@ -150,8 +138,7 @@ is_loopback(struct netbuf *nbuf)
1dc236
 				  "Checking caller's adress (port = %d)\n",
1dc236
 				  ntohs(sin->sin_port));
1dc236
 #endif
1dc236
-	       	return ((sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) &&
1dc236
-		    (ntohs(sin->sin_port) < IPPORT_RESERVED));
1dc236
+	       	return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK));
1dc236
 #ifdef INET6
1dc236
 	case AF_INET6:
1dc236
 		if (!oldstyle_local)
1dc236
@@ -163,10 +150,9 @@ is_loopback(struct netbuf *nbuf)
1dc236
 				  "Checking caller's adress (port = %d)\n",
1dc236
 				  ntohs(sin6->sin6_port));
1dc236
 #endif
1dc236
-		return ((IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) ||
1dc236
+		return (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) ||
1dc236
 			 (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) &&
1dc236
-			  sin6->sin6_addr.s6_addr32[3] == htonl(INADDR_LOOPBACK))) &&
1dc236
-		        (ntohs(sin6->sin6_port) < IPV6PORT_RESERVED));
1dc236
+			  sin6->sin6_addr.s6_addr32[3] == htonl(INADDR_LOOPBACK)));
1dc236
 #endif
1dc236
 	case AF_LOCAL:
1dc236
 		return 1;
1dc236
diff --git a/src/warmstart.c b/src/warmstart.c
1dc236
index 25e5d89..d1bb971 100644
1dc236
--- a/src/warmstart.c
1dc236
+++ b/src/warmstart.c
1dc236
@@ -46,7 +46,6 @@
1dc236
 #include <unistd.h>
1dc236
 #include <errno.h>
1dc236
 
1dc236
-#include "config.h"
1dc236
 #include "rpcbind.h"
1dc236
 
1dc236
 #ifndef RPCBIND_STATEDIR