summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_vfsops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/nfsclient/nfs_vfsops.c')
-rw-r--r--sys/nfsclient/nfs_vfsops.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index d3044ff..00332f0 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <rpc/rpcclnt.h>
+#include <rpc/rpc.h>
#include <nfs/rpcv2.h>
#include <nfs/nfsproto.h>
@@ -142,6 +143,12 @@ VFS_SET(nfs_vfsops, nfs, VFCF_NETWORK);
/* So that loader and kldload(2) can find us, wherever we are.. */
MODULE_VERSION(nfs, 1);
+#ifndef NFS_LEGACYRPC
+MODULE_DEPEND(nfs, krpc, 1, 1, 1);
+#endif
+#ifdef KGSSAPI
+MODULE_DEPEND(nfs, kgssapi, 1, 1, 1);
+#endif
static struct nfs_rpcops nfs_rpcops = {
nfs_readrpc,
@@ -546,6 +553,26 @@ nfs_mountdiskless(char *path,
return (0);
}
+#ifndef NFS_LEGACYRPC
+static int
+nfs_sec_name_to_num(char *sec)
+{
+ if (!strcmp(sec, "krb5"))
+ return (RPCSEC_GSS_KRB5);
+ if (!strcmp(sec, "krb5i"))
+ return (RPCSEC_GSS_KRB5I);
+ if (!strcmp(sec, "krb5p"))
+ return (RPCSEC_GSS_KRB5P);
+ if (!strcmp(sec, "sys"))
+ return (AUTH_SYS);
+ /*
+ * Userland should validate the string but we will try and
+ * cope with unexpected values.
+ */
+ return (AUTH_SYS);
+}
+#endif
+
static void
nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
const char *hostname)
@@ -554,6 +581,10 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
int adjsock;
int maxio;
char *p;
+#ifndef NFS_LEGACYRPC
+ char *secname;
+ char *principal;
+#endif
s = splnet();
@@ -705,7 +736,13 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
nmp->nm_sotype = argp->sotype;
nmp->nm_soproto = argp->proto;
- if (nmp->nm_so && adjsock) {
+ if (
+#ifdef NFS_LEGACYRPC
+ nmp->nm_so
+#else
+ nmp->nm_client
+#endif
+ && adjsock) {
nfs_safedisconnect(nmp);
if (nmp->nm_sotype == SOCK_DGRAM)
while (nfs_connect(nmp, NULL)) {
@@ -721,6 +758,24 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
if (p)
*p = '\0';
}
+
+#ifndef NFS_LEGACYRPC
+ if (vfs_getopt(mp->mnt_optnew, "sec",
+ (void **) &secname, NULL) == 0) {
+ nmp->nm_secflavor = nfs_sec_name_to_num(secname);
+ } else {
+ nmp->nm_secflavor = AUTH_SYS;
+ }
+
+ if (vfs_getopt(mp->mnt_optnew, "principal",
+ (void **) &principal, NULL) == 0) {
+ strlcpy(nmp->nm_principal, principal,
+ sizeof(nmp->nm_principal));
+ } else {
+ snprintf(nmp->nm_principal, sizeof(nmp->nm_principal),
+ "nfs@%s", nmp->nm_hostname);
+ }
+#endif
}
static const char *nfs_opts[] = { "from", "nfs_args",
@@ -729,8 +784,8 @@ static const char *nfs_opts[] = { "from", "nfs_args",
"async", "dumbtimer", "noconn", "nolockd", "intr", "rdirplus", "resvport",
"readdirsize", "soft", "hard", "mntudp", "tcp", "udp", "wsize", "rsize",
"retrans", "acregmin", "acregmax", "acdirmin", "acdirmax",
- "deadthresh", "hostname", "timeout", "addr", "fh", "nfsv3",
- "maxgroups",
+ "deadthresh", "hostname", "timeout", "addr", "fh", "nfsv3", "sec",
+ "maxgroups", "principal",
NULL };
/*
OpenPOWER on IntegriCloud