* Modified by H.J. Lu, 1998.
* Modified by Lon Hohberger, Oct. 2000
* - Bugfix handling client responses.
+ * - Paranoia on NOTIFY_CALLBACK case
*
* NSM for Linux.
*/
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_rmt.h>
+#include <time.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
/*
* Initialize callback socket
*/
-static int
-get_socket(void)
+int
+statd_get_socket(int port)
{
struct sockaddr_in sin;
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
+ sin.sin_port = port;
if (bindresvport(sockfd, &sin) < 0) {
dprintf(L_WARNING,
"process_hosts: can't bind to reserved port\n");
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = lp->port;
- sin.sin_addr = lp->addr;
+ /* LH - moved address into switch */
switch (NL_TYPE(lp)) {
case NOTIFY_REBOOT:
prog = SM_PROG;
vers = SM_VERS;
proc = SM_NOTIFY;
+
+ /* Use source address for notify replies */
+ sin.sin_addr = lp->addr;
+
func = (xdrproc_t) xdr_stat_chge;
objp = &SM_stat_chge;
break;
prog = NL_MY_PROG(lp);
vers = NL_MY_VERS(lp);
proc = NL_MY_PROC(lp);
+
+ /* __FORCE__ loopback for callbacks to lockd ... */
+ /* Just in case we somehow ignored it thus far */
+ sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
func = (xdrproc_t) xdr_status;
objp = &new_status;
new_status.mon_name = NL_MON_NAME(lp);
time_t now;
int fd;
- if ((fd = get_socket()) < 0)
+ if ((fd = statd_get_socket(0)) < 0)
return 0;
while ((entry = notify) != NULL && NL_WHEN(entry) < time(&now)) {