rpcbind: Add option to disable local host binding

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-06 13:39:07 -07:00
committed by Rick Macklem
parent 6677621bad
commit d8a99eaa1f
+8 -4
View File
@@ -88,6 +88,7 @@ int libwrap = 0;
#endif #endif
int nofork = 0; int nofork = 0;
int verboselog = 0; int verboselog = 0;
int nobind_localhost = 0;
static char **hosts = NULL; static char **hosts = NULL;
static struct sockaddr **bound_sa; static struct sockaddr **bound_sa;
@@ -342,9 +343,9 @@ init_transport(struct netconfig *nconf)
if (nhostsbak == 1) if (nhostsbak == 1)
hosts[0] = "*"; hosts[0] = "*";
else { else {
if (hints.ai_family == AF_INET) { if (hints.ai_family == AF_INET && nobind_localhost == 0) {
hosts[nhostsbak - 1] = "127.0.0.1"; 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"; hosts[nhostsbak - 1] = "::1";
} else } else
return 1; return 1;
@@ -802,7 +803,7 @@ parseargs(int argc, char *argv[])
#else #else
#define WRAPOP "" #define WRAPOP ""
#endif #endif
while ((c = getopt(argc, argv, "6adh:iLlNs" WRAPOP WSOP)) != -1) { while ((c = getopt(argc, argv, "6adh:IiLlNs" WRAPOP WSOP)) != -1) {
switch (c) { switch (c) {
case '6': case '6':
ipv6_only = 1; ipv6_only = 1;
@@ -823,6 +824,9 @@ parseargs(int argc, char *argv[])
if (hosts[nhosts - 1] == NULL) if (hosts[nhosts - 1] == NULL)
errx(1, "Out of memory"); errx(1, "Out of memory");
break; break;
case 'I':
nobind_localhost = 1;
break;
case 'i': case 'i':
insecure = 1; insecure = 1;
break; break;
@@ -850,7 +854,7 @@ parseargs(int argc, char *argv[])
#endif #endif
default: /* error */ default: /* error */
fprintf(stderr, fprintf(stderr,
"usage: rpcbind [-6adiLls%s%s] [-h bindip]\n", "usage: rpcbind [-6adIiLls%s%s] [-h bindip]\n",
WRAPOP, WSOP); WRAPOP, WSOP);
exit (1); exit (1);
} }