rpcbind: rpcuser not being set in Makefile.am

Commit 8d7a0708 cause a regression where the rpcuser id was not
being set, which in turn cause rpcbind to immediately exit.
This patch removes the extra ',' that was in the AC_ARG_WITH
statement in the configure.ac file.

Signed-off-by: Steve Dickson <steved@redhat.com>
Silence a warning about setgroups() being implicitly defined

Signed-off-by: Olaf Kirch <okir@suse.de>
Remove obsolete function in6_fillscopeid

This seems to be an old remnant from the very early days of IPv6
when the kernel would include the ifindex in the link-local
addresses returned by getifaddrs(). This is no longer the case on
Linux, so the code is a no-op.

A no-op that makes gcc throw warnings about illegal type-punning.

Signed-off-by: Olaf Kirch <okir@suse.de>
In init_transport, move creation of COTS sockets closer to where they are used

Signed-off-by: Olaf Kirch <okir@suse.de>
The use of AI_NUMERICHOST in init_transport() is broken.

In its current form, when seeing a dotted quad or a numeric IPv6 address,
it will clear all flags in hints.ai_flags (which has been set to AI_PASSIVE
a few lines above).

What this code should really be doing is to *set* AI_NUMERICHOST if and only
if it sees a numeric address.

Signed-off-by: Olaf Kirch <okir@suse.de>
First part of init_transport refactoring

This patch splits out the hostname resolution and socket creation/binding
code into individual functions, and calls those from init_transport instead.

Signed-off-by: Olaf Kirch <okir@suse.de>
init_transport: move the registration code into a separate function

Signed-off-by: Olaf Kirch <okir@suse.de>
Fix the behavior when specifying the -h option

Currently, when specifying the "-h" option, rpcbind will try to create
sockets for all specified addresses, plus the loopback address. However,
it will only register its programs on the last SVCXPRT created, which
will usually be the first address specified via -h.

This patch fixes this problem by introducing a new function that creates
the socket *and* registers all programs, and use that from the while
loop.

Signed-off-by: Olaf Kirch <okir@suse.de>
Clean up the way we handle the -h option in init_transport

There's some odd realloc()ing going on, which is plain ugly.
Make the code a little more readable.

Signed-off-by: Olaf Kirch <okir@suse.de>
Support systemd activation.

This code is loosely based on previous work by Tom Gundersen <teg@jklm.no>.

Signed-off-by: Olaf Kirch <okir@suse.de>
socket-activation: Fix rpcbind.service to use separate sockets

 systemd will, by default, pass a socket that provides both IPv4 and
 IPv6 services. RPC netconfig requires that sockets be either IPv4
 or IPv6.

 This patch fixes the rpcbind.socket unit file and adds a warning
 to rpcbind should the user encounter an issue.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
When using systemd, redirect syslog() calls to the systemd journal

Signed-off-by: Olaf Kirch <okir@suse.de>
When using systemd activation, make rpcbind notify system when ready to service requests

Signed-off-by: Olaf Kirch <okir@suse.de>
Notify systemd unconditionally

rpcbind may be started from systemd with or without socket activation.
However, in both cases systemd would expect to be notified of successful
startup.

If we're started from the command line, calling sd_notify doesn't do
any harm either; it will just silently fail.

Signed-off-by: Olaf Kirch <okir@suse.de>
Pull the sysconfig file into rpcbind.service and use

Signed-off-by: Olaf Kirch <okir@suse.de>
Fix a thinko in init_transport

Signed-off-by: Olaf Kirch <okir@suse.de>
configure: check for <nss.h>

There's code in rpcbind that tries to configure nss lookups so that it
avoids NIS when resolving user names or service names. Unfortunately, this
code is turned into a no-op unless HAVE_NSS_H is defined. Which it is not
unless the configure script actually checks for it.

Signed-off-by: Olaf Kirch <okir@suse.de>
rpcinfo ip_ping: clean up client ping/create/destroy

The code doing the actual RPC NULL calls and the handling of
VERSMISMATCH was a bit convoluted. We would destroy and re-create
the client handle, and sometimes the associated file descriptor
would be closed and sometimes not.

Clean this up by introducing a new function ip_ping_one, which
does the actual NULL call to the indicated program version without
destroying the client handle, ever.

Signed-off-by: Olaf Kirch <okir@suse.de>
rpcinfo: introduce new helper function ip_getclient

This function tries to obtain the address of a given host/program/version,
using the specified protocol (one of udp or tcp), and create a client
handle for it.

This loops over all netconfig entries (according to the order given
by netpath and the config file), and tries to resolve the hostname,
and obtain the address using rpcb_getaddr.

Signed-off-by: Olaf Kirch <okir@suse.de>
rpcinfo: make -t/-u options support IPv6 addresses, too

Currently, rpcinfo supports two ways to test whether a given
service is alive.

For IPv4 hosts, you can use -u and -t. But for IPv6, you need
to use "rpcinfo -a" and specify the host through a universal
address, which is fairly inconvenient.

This patch modifies ip_ping to allow using -u and -t for IPv6
addresses and hosts as well.

Signed-off-by: Olaf Kirch <okir@suse.de>