Index: usr.sbin/mountd/mountd.8 =================================================================== --- usr.sbin/mountd/mountd.8 +++ usr.sbin/mountd/mountd.8 @@ -104,6 +104,10 @@ that require it. It will automatically clear the vfs.nfsd.nfs_privport sysctl flag, which controls if the kernel will accept NFS requests from reserved ports only. +.It Fl N +Cause +.Nm +to execute in the foreground instead of in daemon mode. .It Fl p Ar port Force .Nm @@ -145,6 +149,13 @@ Specify an alternate location for the exports file. More than one exports file can be specified. +.It Fl s +Cause +.Nm +to skip automatic binding to localhost for IPv4 and IPv6. +This option is meaningless unless +.Fl h +has also been used. .It Fl S Tell mountd to suspend/resume execution of the nfsd threads whenever the exports list is being reloaded. Index: usr.sbin/mountd/mountd.c =================================================================== --- usr.sbin/mountd/mountd.c +++ usr.sbin/mountd/mountd.c @@ -287,6 +287,8 @@ static int sock_fdcnt; static int sock_fdpos; static int suspend_nfsd = 0; +static int nofork = 0; +static int skiplocalhost = 0; static int opt_flags; static int have_v6 = 1; @@ -495,6 +497,12 @@ case 'S': suspend_nfsd = 1; break; + case 'N': + nofork = 1; + break; + case 's': + skiplocalhost = 1; + break; default: usage(); } @@ -514,6 +522,9 @@ } } + if (nhosts == 0 && skiplocalhost != 0) + warnx("-s without -h, ignored"); + if (modfind("nfsd") < 0) { /* Not present in kernel, try loading it */ if (kldload("nfsd") < 0 || modfind("nfsd") < 0) @@ -535,7 +546,7 @@ get_mountlist(); if (debug) warnx("here we go"); - if (debug == 0) { + if (debug == 0 && nofork == 0) { daemon(0, 0); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); @@ -571,7 +582,7 @@ out_of_mem(); hosts[0] = "*"; nhosts = 1; - } else { + } else if (skiplocalhost == 0) { hosts_bak = hosts; if (have_v6) { hosts_bak = realloc(hosts, (nhosts + 2) * @@ -1111,7 +1122,7 @@ usage(void) { fprintf(stderr, - "usage: mountd [-2] [-d] [-e] [-l] [-n] [-p ] [-r] " + "usage: mountd [-2] [-d] [-e] [-l] [-n] [-N] [-p ] [-r] [-s] " "[-S] [-h ] [export_file ...]\n"); exit(1); } Index: usr.sbin/nfsd/nfsd.8 =================================================================== --- usr.sbin/nfsd/nfsd.8 +++ usr.sbin/nfsd/nfsd.8 @@ -34,7 +34,7 @@ NFS server .Sh SYNOPSIS .Nm -.Op Fl ardute +.Op Fl arduteN .Op Fl n Ar num_servers .Op Fl h Ar bindip .Op Fl p Ar pnfs_setup @@ -216,6 +216,10 @@ Serve UDP NFS clients. .It Fl e Ignored; included for backward compatibility. +.It Fl N +Cause +.Nm +to execute in the foreground instead of in daemon mode. .El .Pp For example, Index: usr.sbin/nfsd/nfsd.c =================================================================== --- usr.sbin/nfsd/nfsd.c +++ usr.sbin/nfsd/nfsd.c @@ -68,6 +68,7 @@ #include static int debug = 0; +static int nofork = 0; #define NFSD_STABLERESTART "/var/db/nfs-stablerestart" #define NFSD_STABLEBACKUP "/var/db/nfs-stablerestart.bak" @@ -170,10 +171,10 @@ nfsdcnt = DEFNFSDCNT; unregister = reregister = tcpflag = maxsock = 0; bindanyflag = udpflag = connect_type_cnt = bindhostc = 0; - getopt_shortopts = "ah:n:rdtuep:m:V:"; + getopt_shortopts = "ah:n:rdtuep:m:V:N"; getopt_usage = "usage:\n" - " nfsd [-ardtue] [-h bindip]\n" + " nfsd [-ardtueN] [-h bindip]\n" " [-n numservers] [--minthreads #] [--maxthreads #]\n" " [-p/--pnfs dsserver0:/dsserver0-mounted-on-dir,...," "dsserverN:/dsserverN-mounted-on-dir] [-m mirrorlevel]\n" @@ -230,6 +231,9 @@ NFSDEV_MAXMIRRORS); nfsdargs.mirrorcnt = i; break; + case 'N': + nofork = 1; + break; case 0: lopt = longopts[longindex].name; if (!strcmp(lopt, "minthreads")) { @@ -411,7 +415,7 @@ } exit (0); } - if (debug == 0) { + if (debug == 0 && nofork == 0) { daemon(0, 0); (void)signal(SIGHUP, SIG_IGN); (void)signal(SIGINT, SIG_IGN); Index: usr.sbin/rpcbind/rpcbind.8 =================================================================== --- usr.sbin/rpcbind/rpcbind.8 +++ usr.sbin/rpcbind/rpcbind.8 @@ -99,12 +99,19 @@ sent to. Note that when specifying IP addresses with .Fl h , +and no +.Fl I +option is specified, .Nm will automatically add .Li 127.0.0.1 and if IPv6 is enabled, .Li ::1 to the list. +.It Fl I +Cause +.Nm +not to bind to the localhost. .It Fl i .Dq Insecure mode. Index: usr.sbin/rpcbind/rpcbind.c =================================================================== --- usr.sbin/rpcbind/rpcbind.c +++ usr.sbin/rpcbind/rpcbind.c @@ -88,6 +88,7 @@ #endif int nofork = 0; int verboselog = 0; +int nobind_localhost = 0; static char **hosts = NULL; static struct sockaddr **bound_sa; @@ -342,9 +343,9 @@ if (nhostsbak == 1) hosts[0] = "*"; else { - if (hints.ai_family == AF_INET) { + if (hints.ai_family == AF_INET && nobind_localhost == 0) { hosts[nhostsbak - 1] = "127.0.0.1"; - } else if (hints.ai_family == AF_INET6) { + } else if (hints.ai_family == AF_INET6 && nobind_localhost == 0) { hosts[nhostsbak - 1] = "::1"; } else return 1; @@ -823,6 +824,9 @@ if (hosts[nhosts - 1] == NULL) errx(1, "Out of memory"); break; + case 'I': + nobind_localhost = 1; + break; case 'i': insecure = 1; break; @@ -850,7 +854,7 @@ #endif default: /* error */ fprintf(stderr, - "usage: rpcbind [-6adiLls%s%s] [-h bindip]\n", + "usage: rpcbind [-6adIiLls%s%s] [-h bindip]\n", WRAPOP, WSOP); exit (1); }