Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 May 2009 16:04:51 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192017 - head/sys/fs/nfsserver
Message-ID:  <200905121604.n4CG4p8D026834@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Tue May 12 16:04:51 2009
New Revision: 192017
URL: http://svn.freebsd.org/changeset/base/192017

Log:
  Modify the experimental nfs server to use the new nfsd_nfsd_args
  structure for nfsd. Includes a change that clarifies the use of
  an empty principal name string to indicate AUTH_SYS only.
  
  Approved by:	kib (mentor)

Modified:
  head/sys/fs/nfsserver/nfs_nfsdkrpc.c
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdkrpc.c	Tue May 12 15:14:37 2009	(r192016)
+++ head/sys/fs/nfsserver/nfs_nfsdkrpc.c	Tue May 12 16:04:51 2009	(r192017)
@@ -350,20 +350,16 @@ int
 nfsrvd_nfsd(struct thread *td, struct nfsd_nfsd_args *args)
 {
 #ifdef KGSSAPI
-	char principal[128];
+	char principal[MAXHOSTNAMELEN + 5];
 	int error;
 	bool_t ret2, ret3, ret4;
 #endif
 
 #ifdef KGSSAPI
-	if (args != NULL) {
-		error = copyinstr(args->principal, principal,
-		    sizeof(principal), NULL);
-		if (error)
-			return (error);
-	} else {
-		snprintf(principal, sizeof(principal), "nfs@%s", hostname);
-	}
+	error = copyinstr(args->principal, principal, sizeof (principal),
+	    NULL);
+	if (error)
+		return (error);
 #endif
 
 	/*
@@ -380,40 +376,36 @@ nfsrvd_nfsd(struct thread *td, struct nf
 		NFSD_UNLOCK();
 
 #ifdef KGSSAPI
-		ret2 = rpc_gss_set_svc_name(principal, "kerberosv5",
-		    GSS_C_INDEFINITE, NFS_PROG, NFS_VER2);
-		ret3 = rpc_gss_set_svc_name(principal, "kerberosv5",
-		    GSS_C_INDEFINITE, NFS_PROG, NFS_VER3);
-		ret4 = rpc_gss_set_svc_name(principal, "kerberosv5",
-		    GSS_C_INDEFINITE, NFS_PROG, NFS_VER4);
-
-		/*
-		 * If the principal name was specified, these should have
-		 * succeeded.
-		 */
-		if (args != NULL && principal[0] != '\0' &&
-		    (!ret2 || !ret3 || !ret4)) {
-			NFSD_LOCK();
-			newnfs_numnfsd--;
-			NFSD_UNLOCK();
-			return (EAUTH);
+		/* An empty string implies AUTH_SYS only. */
+		if (principal[0] != '\0') {
+			ret2 = rpc_gss_set_svc_name(principal, "kerberosv5",
+			    GSS_C_INDEFINITE, NFS_PROG, NFS_VER2);
+			ret3 = rpc_gss_set_svc_name(principal, "kerberosv5",
+			    GSS_C_INDEFINITE, NFS_PROG, NFS_VER3);
+			ret4 = rpc_gss_set_svc_name(principal, "kerberosv5",
+			    GSS_C_INDEFINITE, NFS_PROG, NFS_VER4);
+
+			if (!ret2 || !ret3 || !ret4) {
+				NFSD_LOCK();
+				newnfs_numnfsd--;
+				nfsrvd_init(1);
+				NFSD_UNLOCK();
+				return (EAUTH);
+			}
 		}
 #endif
 
-		if (args != NULL) {
-			nfsrvd_pool->sp_minthreads = args->minthreads;
-			nfsrvd_pool->sp_maxthreads = args->maxthreads;
-		} else {
-			nfsrvd_pool->sp_minthreads = 4;
-			nfsrvd_pool->sp_maxthreads = 4;
-		}
+		nfsrvd_pool->sp_minthreads = args->minthreads;
+		nfsrvd_pool->sp_maxthreads = args->maxthreads;
 			
 		svc_run(nfsrvd_pool);
 
 #ifdef KGSSAPI
-		rpc_gss_clear_svc_name(NFS_PROG, NFS_VER2);
-		rpc_gss_clear_svc_name(NFS_PROG, NFS_VER3);
-		rpc_gss_clear_svc_name(NFS_PROG, NFS_VER4);
+		if (principal[0] != '\0') {
+			rpc_gss_clear_svc_name(NFS_PROG, NFS_VER2);
+			rpc_gss_clear_svc_name(NFS_PROG, NFS_VER3);
+			rpc_gss_clear_svc_name(NFS_PROG, NFS_VER4);
+		}
 #endif
 
 		NFSD_LOCK();

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c	Tue May 12 15:14:37 2009	(r192016)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c	Tue May 12 16:04:51 2009	(r192017)
@@ -2866,14 +2866,15 @@ static int
 nfssvc_nfsd(struct thread *td, struct nfssvc_args *uap)
 {
 	struct file *fp;
-	struct nfsd_addsock_args nfsdarg;
+	struct nfsd_addsock_args sockarg;
+	struct nfsd_nfsd_args nfsdarg;
 	int error;
 
 	if (uap->flag & NFSSVC_NFSDADDSOCK) {
-		error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg));
+		error = copyin(uap->argp, (caddr_t)&sockarg, sizeof (sockarg));
 		if (error)
 			return (error);
-		if ((error = fget(td, nfsdarg.sock, &fp)) != 0) {
+		if ((error = fget(td, sockarg.sock, &fp)) != 0) {
 			return (error);
 		}
 		if (fp->f_type != DTYPE_SOCKET) {
@@ -2883,7 +2884,13 @@ nfssvc_nfsd(struct thread *td, struct nf
 		error = nfsrvd_addsock(fp);
 		fdrop(fp, td);
 	} else if (uap->flag & NFSSVC_NFSDNFSD) {
-		error = nfsrvd_nfsd(td, NULL);
+		if (uap->argp == NULL) 
+			return (EINVAL);
+		error = copyin(uap->argp, (caddr_t)&nfsdarg,
+		    sizeof (nfsdarg));
+		if (error)
+			return (error);
+		error = nfsrvd_nfsd(td, &nfsdarg);
 	} else {
 		error = nfssvc_srvcall(td, uap, td->td_ucred);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905121604.n4CG4p8D026834>