1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

mountd: Add options to disable daemon mode and setting localhost

In our products, we need those options to support our features.

Add daemon mode option for mountd, nfsd.
Add skip local host binding option for rpcd.
Add skip local host binding option for mountd.

Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D45118
This commit is contained in:
Joyu Liao 2024-07-11 12:38:04 -07:00 committed by Rick Macklem
parent d68d124817
commit 7c2901b08b

View File

@ -287,6 +287,8 @@ static int *sock_fd;
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;
@ -436,7 +438,7 @@ main(int argc, char **argv)
else
close(s);
while ((c = getopt(argc, argv, "2Adeh:lnp:RrS")) != -1)
while ((c = getopt(argc, argv, "2Adeh:lNnp:RrSs")) != -1)
switch (c) {
case '2':
force_v2 = 1;
@ -495,6 +497,12 @@ main(int argc, char **argv)
case 'S':
suspend_nfsd = 1;
break;
case 'N':
nofork = 1;
break;
case 's':
skiplocalhost = 1;
break;
default:
usage();
}
@ -514,6 +522,9 @@ main(int argc, char **argv)
}
}
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 @@ main(int argc, char **argv)
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 @@ main(int argc, char **argv)
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,8 +1122,8 @@ static void
usage(void)
{
fprintf(stderr,
"usage: mountd [-2] [-d] [-e] [-l] [-n] [-p <port>] [-r] "
"[-S] [-h <bindip>] [export_file ...]\n");
"usage: mountd [-2] [-d] [-e] [-l] [-N] [-n] [-p <port>] [-r] [-S] "
"[-s] [-h <bindip>] [export_file ...]\n");
exit(1);
}