FreeBSD/sys/fs/nfsserver/nfs_nfsdport.c
/*
 * Check/setup export credentials.
 */
Check/setup export credentials.
Check / setup export credentials .
int
nfsd_excred(struct nfsrv_descript *nd, struct nfsexstuff *exp,
    struct ucred *credanon)
{
	int error = 0;
	if (nd->nd_flag & ND_GSS)
		exp->nes_exflag &= ~MNT_EXPORTANON;
	if (nfsvno_testexp(nd, exp) &&
	    nd->nd_procnum != NFSV4OP_SECINFO &&
	    nd->nd_procnum != NFSPROC_FSINFO) {
		if (nd->nd_flag & ND_NFSV4)
			error = NFSERR_WRONGSEC;
		else
			error = (NFSERR_AUTHERR | AUTH_TOOWEAK);
		goto out;
	}
	if (NFSVNO_EXV4ONLY(exp) && !(nd->nd_flag & ND_NFSV4)) {
		error = NFSERR_PROGNOTV4;
		goto out;
	}
	if (NFSVNO_EXPORTED(exp)) {
		if (((nd->nd_flag & ND_GSS) == 0 && nd->nd_cred->cr_uid == 0) ||
		     NFSVNO_EXPORTANON(exp) ||
		     (nd->nd_flag & ND_AUTHNONE) != 0) {
			nd->nd_cred->cr_uid = credanon->cr_uid;
			nd->nd_cred->cr_gid = credanon->cr_gid;
			crsetgroups(nd->nd_cred, credanon->cr_ngroups,
			    credanon->cr_groups);
		} else if ((nd->nd_flag & ND_GSS) == 0) {
			nd->nd_cred = nfsrv_getgrpscred(nd->nd_cred);
		}
	}
out:
	NFSEXITCODE2(error, nd);
	return (error);
}
int nfsd_excred ( struct nfsrv_descript * nd , struct nfsexstuff * exp , struct ucred * credanon ) { int error = 0 ; if ( nd -> nd_flag & ND_GSS ) exp -> nes_exflag &= ~ MNT_EXPORTANON ; if ( nfsvno_testexp ( nd , exp ) && nd -> nd_procnum != NFSV4OP_SECINFO && nd -> nd_procnum != NFSPROC_FSINFO ) { if ( nd -> nd_flag & ND_NFSV4 ) error = NFSERR_WRONGSEC ; else error = ( NFSERR_AUTHERR | AUTH_TOOWEAK ) ; goto out ; } if ( NFSVNO_EXV4ONLY ( exp ) && ! ( nd -> nd_flag & ND_NFSV4 ) ) { error = NFSERR_PROGNOTV4 ; goto out ; } if ( NFSVNO_EXPORTED ( exp ) ) { if ( ( ( nd -> nd_flag & ND_GSS ) == 0 && nd -> nd_cred -> cr_uid == 0 ) || NFSVNO_EXPORTANON ( exp ) || ( nd -> nd_flag & ND_AUTHNONE ) != 0 ) { nd -> nd_cred -> cr_uid = credanon -> cr_uid ; nd -> nd_cred -> cr_gid = credanon -> cr_gid ; crsetgroups ( nd -> nd_cred , credanon -> cr_ngroups , credanon -> cr_groups ) ; } else if ( ( nd -> nd_flag & ND_GSS ) == 0 ) { nd -> nd_cred = nfsrv_getgrpscred ( nd -> nd_cred ) ; } } out : NFSEXITCODE2 ( error , nd ) ; return ( error ) ; }
Check/setup export credentials.
Check / setup export credentials .
/*
	 * Check/setup credentials.
	 */ /*
	 * Check to see if the operation is allowed for this security flavor.
	 * RFC2623 suggests that the NFSv3 Fsinfo RPC be allowed to
	 * AUTH_NONE or AUTH_SYS for file systems requiring RPCSEC_GSS.
	 * Also, allow Secinfo, so that it can acquire the correct flavor(s).
	 */ /*
	 * Check to see if the file system is exported V4 only.
	 */ /*
	 * Now, map the user credentials.
	 * (Note that ND_AUTHNONE will only be set for an NFSv3
	 *  Fsinfo RPC. If set for anything else, this code might need
	 *  to change.)
	 */ /*
			 * If using AUTH_SYS, call nfsrv_getgrpscred() to see
			 * if there is a replacement credential with a group
			 * list set up by "nfsuserd -manage-gids".
			 * If there is no replacement, nfsrv_getgrpscred()
			 * simply returns its argument.
			 */