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)
This commit is contained in:
parent
9b61a5b95e
commit
7e74551956
@ -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 nfsd_nfsd_args *args)
|
||||
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);
|
||||
/* 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 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);
|
||||
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();
|
||||
|
@ -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 nfssvc_args *uap)
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user