Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143458104
D19191.id53908.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D19191.id53908.diff
View Options
Index: libexec/rc/rc.d/nfsd
===================================================================
--- libexec/rc/rc.d/nfsd
+++ libexec/rc/rc.d/nfsd
@@ -13,6 +13,7 @@
desc="Remote NFS server"
rcvar="nfs_server_enable"
command="/usr/sbin/${name}"
+nfs_server_vhost=""
load_rc_config $name
start_precmd="nfsd_precmd"
@@ -20,6 +21,7 @@
nfsd_precmd()
{
+ local _vhost
rc_flags="${nfs_server_flags}"
# Load the modules now, so that the vfs.nfsd sysctl
@@ -46,6 +48,9 @@
force_depend rpcbind || return 1
force_depend mountd || return 1
+ if [ -n "${nfs_server_vhost}" ]; then
+ command_args="-V \"${nfs_server_vhost}\""
+ fi
}
run_rc_command "$1"
Index: usr.sbin/nfsd/nfsd.8
===================================================================
--- usr.sbin/nfsd/nfsd.8
+++ usr.sbin/nfsd/nfsd.8
@@ -43,6 +43,7 @@
.Op Fl h Ar bindip
.Op Fl p Ar pnfs_setup
.Op Fl m Ar mirror_level
+.Op Fl V Ar virtual_hostname
.Op Fl Fl maxthreads Ar max_threads
.Op Fl Fl minthreads Ar min_threads
.Sh DESCRIPTION
@@ -78,6 +79,9 @@
service with
.Xr rpcbind 8
without creating any servers.
+.It Fl V Ar virtual_hostname
+Specifies a hostname to be used as a principal name, instead of
+the default hostname.
.It Fl n Ar threads
Specifies how many servers to create. This option is equivalent to specifying
.Fl Fl maxthreads
Index: usr.sbin/nfsd/nfsd.c
===================================================================
--- usr.sbin/nfsd/nfsd.c
+++ usr.sbin/nfsd/nfsd.c
@@ -122,7 +122,7 @@
static void reapchild(int);
static int setbindhost(struct addrinfo **ia, const char *bindhost,
struct addrinfo hints);
-static void start_server(int, struct nfsd_nfsd_args *);
+static void start_server(int, struct nfsd_nfsd_args *, const char *vhost);
static void unregistration(void);
static void usage(void);
static void open_stable(int *, int *);
@@ -176,6 +176,7 @@
char **bindhost = NULL;
pid_t pid;
struct nfsd_nfsd_args nfsdargs;
+ const char *vhostname = NULL;
nfsdargs.mirrorcnt = 1;
nfsdargs.addr = NULL;
@@ -183,16 +184,20 @@
nfsdcnt = DEFNFSDCNT;
unregister = reregister = tcpflag = maxsock = 0;
bindanyflag = udpflag = connect_type_cnt = bindhostc = 0;
- getopt_shortopts = "ah:n:rdtuep:m:";
+ getopt_shortopts = "ah:n:rdtuep:m:V:";
getopt_usage =
"usage:\n"
" nfsd [-ardtue] [-h bindip]\n"
" [-n numservers] [--minthreads #] [--maxthreads #]\n"
- " [-p/--pnfs dsserver0:/dsserver0-mounted-on-dir,...,"
- "dsserverN:/dsserverN-mounted-on-dir] [-m mirrorlevel]\n";
+ " [-p/--pnfs dsserver0:/dsserver0-mounted-on-dir,...,\n"
+ " [-V virtual_hostname]\n"
+ " dsserverN:/dsserverN-mounted-on-dir] [-m mirrorlevel]\n";
while ((ch = getopt_long(argc, argv, getopt_shortopts, longopts,
&longindex)) != -1)
switch (ch) {
+ case 'V':
+ vhostname = optarg;
+ break;
case 'a':
bindanyflag = 1;
break;
@@ -473,7 +478,7 @@
} else {
(void)signal(SIGUSR1, child_cleanup);
setproctitle("server");
- start_server(0, &nfsdargs);
+ start_server(0, &nfsdargs, vhostname);
}
}
@@ -790,7 +795,7 @@
* a "server" too. start_server will not return.
*/
if (!tcpflag)
- start_server(1, &nfsdargs);
+ start_server(1, &nfsdargs, vhostname);
/*
* Loop forever accepting connections and passing the sockets
@@ -987,7 +992,7 @@
}
static void
-start_server(int master, struct nfsd_nfsd_args *nfsdargp)
+start_server(int master, struct nfsd_nfsd_args *nfsdargp, const char *vhost)
{
char principal[MAXHOSTNAMELEN + 5];
int status, error;
@@ -995,7 +1000,10 @@
struct addrinfo *aip, hints;
status = 0;
- gethostname(hostname, sizeof (hostname));
+ if (vhost == NULL)
+ gethostname(hostname, sizeof (hostname));
+ else
+ strlcpy(hostname, vhost, sizeof (hostname));
snprintf(principal, sizeof (principal), "nfs@%s", hostname);
if ((cp = strchr(hostname, '.')) == NULL ||
*(cp + 1) == '\0') {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 31, 4:10 PM (13 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28123293
Default Alt Text
D19191.id53908.diff (3 KB)
Attached To
Mode
D19191: Add support for a virtual hostname to nfsd
Attached
Detach File
Event Timeline
Log In to Comment