On Fri, Apr 18, 2008 at 2:34 PM, J. Bruce Fields <bfields@xxxxxxxxxxxx> wrote: > I was looking at recent git. Note the most recent tarball on > sourceforge.net is 1.1.2, and that has the relevant changes. There you go, against 1.1.2. -- // Janne
--- rmtcall.c.org 2008-04-18 15:41:16.000000000 -0400 +++ rmtcall.c 2008-04-18 15:40:12.000000000 -0400 @@ -27,6 +27,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> +#include <sys/stat.h> #include <netinet/in.h> #include <net/if.h> #include <arpa/inet.h> @@ -37,6 +38,9 @@ #include <netdb.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <netdb.h> #ifdef HAVE_IFADDRS_H #include <ifaddrs.h> #endif /* HAVE_IFADDRS_H */ @@ -54,6 +58,34 @@ static unsigned long xid = 0; /* RPC XID counter */ static int sockfd = -1; /* notify socket */ +static int ifset = 0; + +/* + * Notify lockd of non-standard binding + */ +void +nlm_nsm_set(unsigned int addr) +{ + ssize_t sz = 0; + char buf[20]; + int fd; + + if ( ifset ) + return ; + + sprintf (buf,"%u",addr); + + fd = open ("/proc/sys/fs/nfs/nlm_nsm_interface", O_RDWR); + if (fd > 0) { + sz = write (fd,buf,strlen((char*)buf)); + if ( sz == -1 ) + note(N_CRIT, "statd: write: %s\n", strerror(errno)); + close (fd); + } else + note(N_CRIT, "statd: -n was specified with with no kernel support?\n"); + + ifset = 1; +} /* * Initialize callback socket @@ -63,6 +95,7 @@ statd_get_socket(void) { struct sockaddr_in sin; struct servent *se; + struct hostent *hp; int loopcnt = 100; if (sockfd >= 0) @@ -77,11 +110,18 @@ statd_get_socket(void) return -1; } - memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; + if (MY_NAME) { + hp = gethostbyname(MY_NAME); + if (hp) { + sin.sin_addr = *(struct in_addr *) hp->h_addr; + nlm_nsm_set ((unsigned int)sin.sin_addr.s_addr); + } + } + if (bindresvport(sockfd, &sin) < 0) { dprintf(N_WARNING, "process_hosts: can't bind to reserved port\n");