From: NeilBrown Fix some discrepencies between the server-side auth_null and auth_unix rpc code: in particular, make sure we return an auth error in the auth_null case instead of dropping when we fail to match an export entry, and make sure such responses are encoded correctly. Signed-off-by: J. Bruce Fields Signed-off-by: Neil Brown Signed-off-by: Andrew Morton --- 25-akpm/net/sunrpc/svcauth_unix.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff -puN net/sunrpc/svcauth_unix.c~knfsd-svcrpc-auth_null-fixes net/sunrpc/svcauth_unix.c --- 25/net/sunrpc/svcauth_unix.c~knfsd-svcrpc-auth_null-fixes 2004-11-15 22:06:50.666007984 -0800 +++ 25-akpm/net/sunrpc/svcauth_unix.c 2004-11-15 22:06:50.669007528 -0800 @@ -335,9 +335,13 @@ svcauth_null_accept(struct svc_rqst *rqs { struct kvec *argv = &rqstp->rq_arg.head[0]; struct kvec *resv = &rqstp->rq_res.head[0]; + struct svc_cred *cred = &rqstp->rq_cred; int rv=0; struct ip_map key, *ipm; + cred->cr_group_info = NULL; + rqstp->rq_client = NULL; + if (argv->iov_len < 3*4) return SVC_GARBAGE; @@ -353,23 +357,17 @@ svcauth_null_accept(struct svc_rqst *rqs } /* Signal that mapping to nobody uid/gid is required */ - rqstp->rq_cred.cr_uid = (uid_t) -1; - rqstp->rq_cred.cr_gid = (gid_t) -1; - rqstp->rq_cred.cr_group_info = groups_alloc(0); - if (rqstp->rq_cred.cr_group_info == NULL) + cred->cr_uid = (uid_t) -1; + cred->cr_gid = (gid_t) -1; + cred->cr_group_info = groups_alloc(0); + if (cred->cr_group_info == NULL) return SVC_DROP; /* kmalloc failure - client must retry */ - /* Put NULL verifier */ - svc_putu32(resv, RPC_AUTH_NULL); - svc_putu32(resv, 0); - strcpy(key.m_class, rqstp->rq_server->sv_program->pg_class); key.m_addr = rqstp->rq_addr.sin_addr; ipm = ip_map_lookup(&key, 0); - rqstp->rq_client = NULL; - if (ipm) switch (cache_check(&ip_map_cache, &ipm->h, &rqstp->rq_chandle)) { case -EAGAIN: @@ -388,10 +386,18 @@ svcauth_null_accept(struct svc_rqst *rqs } else rv = SVC_DROP; - if (rqstp->rq_client == NULL && rqstp->rq_proc != 0) - *authp = rpc_autherr_badcred; + if (rv == SVC_OK && rqstp->rq_client == NULL && rqstp->rq_proc != 0) + goto badcred; + + /* Put NULL verifier */ + svc_putu32(resv, RPC_AUTH_NULL); + svc_putu32(resv, 0); return rv; + +badcred: + *authp = rpc_autherr_badcred; + return SVC_DENIED; } static int _