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