diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-01-14 12:24:39 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-01-15 14:55:52 -0500 |
commit | 7dd134204d88c22b414a4ecfcd986efb57fedebf (patch) | |
tree | 6bd69aac2d908848a019394121de166b9fa7548a /utils | |
parent | e2446fda6e7cdb1b9462162b81b0e50fd6efaf56 (diff) | |
download | nfs-utils-7dd134204d88c22b414a4ecfcd986efb57fedebf.tar.gz nfs-utils-7dd134204d88c22b414a4ecfcd986efb57fedebf.tar.xz nfs-utils-7dd134204d88c22b414a4ecfcd986efb57fedebf.zip |
statd: Support TI-RPC statd listener
If TI-RPC is available, use it to create statd's svc listener. If
not, use the old function, rpc_init(), to create statd's listener.
IPv6 can be supported if TI-RPC is available. In this case,
/etc/netconfig is searched to determine which transports to advertise.
Add the new listener creation API in libnfs.a since other components
of nfs-utils (such as rpc.mountd) will eventually want to share it.
A little re-arrangement of when the statd listener is created is done
to make unregistration of the statd service more reliable. As it is
now, the statd service is never unregistered when it exits. After it
is gone, other programs usually hang when trying to access statd or
see if it's running, since the registration is still there but statd
itself does not respond.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/statd/statd.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/utils/statd/statd.c b/utils/statd/statd.c index 72c9b41..7be6454 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -90,13 +90,18 @@ sm_prog_1_wrapper (struct svc_req *rqstp, register SVCXPRT *transp) #define sm_prog_1 sm_prog_1_wrapper #endif +static void +statd_unregister(void) { + nfs_svc_unregister(SM_PROG, SM_VERS); +} + /* * Signal handler. */ static void killer (int sig) { - pmap_unset (SM_PROG, SM_VERS); + statd_unregister (); xlog_err ("Caught signal %d, un-registering and exiting", sig); } @@ -125,6 +130,9 @@ static void log_modes(void) strcat(buf,"No-Daemon "); if (run_mode & MODE_LOG_STDERR) strcat(buf,"Log-STDERR "); +#ifdef HAVE_LIBTIRPC + strcat(buf, "TI-RPC "); +#endif xlog_warn(buf); } @@ -424,10 +432,29 @@ int main (int argc, char **argv) xlog(D_GENERAL, "Local NSM state number: %d", MY_STATE); nsm_update_kernel_state(MY_STATE); - pmap_unset (SM_PROG, SM_VERS); + /* + * ORDER + * Clear old listeners while still root, to override any + * permission checking done by rpcbind. + */ + statd_unregister(); + + /* + * ORDER + */ + if (!nsm_drop_privileges(pidfd)) + exit(1); - /* this registers both UDP and TCP services */ - rpc_init("statd", SM_PROG, SM_VERS, sm_prog_1, port); + /* + * ORDER + * Create RPC listeners after dropping privileges. This permits + * statd to unregister its own listeners when it exits. + */ + if (nfs_svc_create("statd", SM_PROG, SM_VERS, sm_prog_1, port) == 0) { + xlog(L_ERROR, "failed to create RPC listeners, exiting"); + exit(1); + } + atexit(statd_unregister); /* If we got this far, we have successfully started, so notify parent */ if (pipefds[1] > 0) { @@ -440,9 +467,6 @@ int main (int argc, char **argv) pipefds[1] = -1; } - if (!nsm_drop_privileges(pidfd)) - exit(1); - for (;;) { /* * Handle incoming requests: SM_NOTIFY socket requests, as |