Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/nfs/nfs_commonsubs.c
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | |||||
static int nfs_bigreply[NFSV41_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, | static int nfs_bigreply[NFSV41_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }; | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }; | ||||
/* local functions */ | /* local functions */ | ||||
static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep); | static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep); | ||||
static void nfsv4_wanted(struct nfsv4lock *lp); | static void nfsv4_wanted(struct nfsv4lock *lp); | ||||
static int nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len); | static int nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len); | ||||
static int nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char *name, | static int nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char *name); | ||||
NFSPROC_T *p); | |||||
static void nfsrv_removeuser(struct nfsusrgrp *usrp, int isuser); | static void nfsrv_removeuser(struct nfsusrgrp *usrp, int isuser); | ||||
static int nfsrv_getrefstr(struct nfsrv_descript *, u_char **, u_char **, | static int nfsrv_getrefstr(struct nfsrv_descript *, u_char **, u_char **, | ||||
int *, int *); | int *, int *); | ||||
static void nfsrv_refstrbigenough(int, u_char **, u_char **, int *); | static void nfsrv_refstrbigenough(int, u_char **, u_char **, int *); | ||||
static struct { | static struct { | ||||
int op; | int op; | ||||
int opcnt; | int opcnt; | ||||
▲ Show 20 Lines • Show All 2,871 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(usrp, &hp->lughead, lug_numhash) { | ||||
TAILQ_INSERT_TAIL(&hp->lughead, usrp, | TAILQ_INSERT_TAIL(&hp->lughead, usrp, | ||||
lug_numhash); | lug_numhash); | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
cnt++; | cnt++; | ||||
ret = nfsrv_getuser(RPCNFSUSERD_GETUID, uid, (gid_t)0, | ret = nfsrv_getuser(RPCNFSUSERD_GETUID, uid, (gid_t)0, NULL); | ||||
NULL, p); | |||||
if (ret == 0 && cnt < 2) | if (ret == 0 && cnt < 2) | ||||
goto tryagain; | goto tryagain; | ||||
} | } | ||||
/* | /* | ||||
* No match, just return a string of digits. | * No match, just return a string of digits. | ||||
*/ | */ | ||||
tmp = uid; | tmp = uid; | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(usrp, &hp->lughead, lug_numhash) { | ||||
TAILQ_INSERT_TAIL(&hp->lughead, usrp, | TAILQ_INSERT_TAIL(&hp->lughead, usrp, | ||||
lug_numhash); | lug_numhash); | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
return (newcred); | return (newcred); | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
cnt++; | cnt++; | ||||
ret = nfsrv_getuser(RPCNFSUSERD_GETUID, uid, (gid_t)0, | ret = nfsrv_getuser(RPCNFSUSERD_GETUID, uid, (gid_t)0, NULL); | ||||
NULL, curthread); | |||||
if (ret == 0 && cnt < 2) | if (ret == 0 && cnt < 2) | ||||
goto tryagain; | goto tryagain; | ||||
} | } | ||||
return (oldcred); | return (oldcred); | ||||
} | } | ||||
/* | /* | ||||
* Convert a string to a uid. | * Convert a string to a uid. | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(usrp, &hp->lughead, lug_namehash) { | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
error = 0; | error = 0; | ||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
cnt++; | cnt++; | ||||
ret = nfsrv_getuser(RPCNFSUSERD_GETUSER, (uid_t)0, (gid_t)0, | ret = nfsrv_getuser(RPCNFSUSERD_GETUSER, (uid_t)0, (gid_t)0, | ||||
str, p); | str); | ||||
if (ret == 0 && cnt < 2) | if (ret == 0 && cnt < 2) | ||||
goto tryagain; | goto tryagain; | ||||
} | } | ||||
error = NFSERR_BADOWNER; | error = NFSERR_BADOWNER; | ||||
out: | out: | ||||
NFSEXITCODE(error); | NFSEXITCODE(error); | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(usrp, &hp->lughead, lug_numhash) { | ||||
TAILQ_INSERT_TAIL(&hp->lughead, usrp, | TAILQ_INSERT_TAIL(&hp->lughead, usrp, | ||||
lug_numhash); | lug_numhash); | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
cnt++; | cnt++; | ||||
ret = nfsrv_getuser(RPCNFSUSERD_GETGID, (uid_t)0, gid, | ret = nfsrv_getuser(RPCNFSUSERD_GETGID, (uid_t)0, gid, NULL); | ||||
NULL, p); | |||||
if (ret == 0 && cnt < 2) | if (ret == 0 && cnt < 2) | ||||
goto tryagain; | goto tryagain; | ||||
} | } | ||||
/* | /* | ||||
* No match, just return a string of digits. | * No match, just return a string of digits. | ||||
*/ | */ | ||||
tmp = gid; | tmp = gid; | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(usrp, &hp->lughead, lug_namehash) { | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
error = 0; | error = 0; | ||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&hp->mtx); | mtx_unlock(&hp->mtx); | ||||
cnt++; | cnt++; | ||||
ret = nfsrv_getuser(RPCNFSUSERD_GETGROUP, (uid_t)0, (gid_t)0, | ret = nfsrv_getuser(RPCNFSUSERD_GETGROUP, (uid_t)0, (gid_t)0, | ||||
str, p); | str); | ||||
if (ret == 0 && cnt < 2) | if (ret == 0 && cnt < 2) | ||||
goto tryagain; | goto tryagain; | ||||
} | } | ||||
error = NFSERR_BADOWNER; | error = NFSERR_BADOWNER; | ||||
out: | out: | ||||
NFSEXITCODE(error); | NFSEXITCODE(error); | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Do upcalls to the nfsuserd, for cache misses of the owner/ownergroup | * Do upcalls to the nfsuserd, for cache misses of the owner/ownergroup | ||||
* name<-->id cache. | * name<-->id cache. | ||||
* Returns 0 upon success, non-zero otherwise. | * Returns 0 upon success, non-zero otherwise. | ||||
*/ | */ | ||||
static int | static int | ||||
nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char *name, NFSPROC_T *p) | nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char *name) | ||||
{ | { | ||||
u_int32_t *tl; | u_int32_t *tl; | ||||
struct nfsrv_descript *nd; | struct nfsrv_descript *nd; | ||||
int len; | int len; | ||||
struct nfsrv_descript nfsd; | struct nfsrv_descript nfsd; | ||||
struct ucred *cred; | struct ucred *cred; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 1,125 Lines • Show Last 20 Lines |