]> err.no Git - linux-2.6/blobdiff - net/sunrpc/auth_gss/svcauth_gss.c
[NET] CORE: Fix whitespace errors.
[linux-2.6] / net / sunrpc / auth_gss / svcauth_gss.c
index 8fde38ecaf211e9e4217007609aa34901eaed25d..490697542fc27d7f08dba7277c88ae46e71c57f0 100644 (file)
@@ -669,14 +669,14 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
        }
 
        if (gc->gc_seq > MAXSEQ) {
-               dprintk("RPC:      svcauth_gss: discarding request with large sequence number %d\n",
-                               gc->gc_seq);
+               dprintk("RPC:       svcauth_gss: discarding request with "
+                               "large sequence number %d\n", gc->gc_seq);
                *authp = rpcsec_gsserr_ctxproblem;
                return SVC_DENIED;
        }
        if (!gss_check_seq_num(rsci, gc->gc_seq)) {
-               dprintk("RPC:      svcauth_gss: discarding request with old sequence number %d\n",
-                               gc->gc_seq);
+               dprintk("RPC:       svcauth_gss: discarding request with "
+                               "old sequence number %d\n", gc->gc_seq);
                return SVC_DROP;
        }
        return SVC_OK;
@@ -743,6 +743,15 @@ find_gss_auth_domain(struct gss_ctx *ctx, u32 svc)
 
 static struct auth_ops svcauthops_gss;
 
+u32 svcauth_gss_flavor(struct auth_domain *dom)
+{
+       struct gss_domain *gd = container_of(dom, struct gss_domain, h);
+
+       return gd->pseudoflavor;
+}
+
+EXPORT_SYMBOL(svcauth_gss_flavor);
+
 int
 svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
 {
@@ -853,7 +862,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
        u32 priv_len, maj_stat;
        int pad, saved_len, remaining_len, offset;
 
-       rqstp->rq_sendfile_ok = 0;
+       rqstp->rq_splice_ok = 0;
 
        priv_len = svc_getnl(&buf->head[0]);
        if (rqstp->rq_deferred) {
@@ -913,10 +922,23 @@ svcauth_gss_set_client(struct svc_rqst *rqstp)
        struct gss_svc_data *svcdata = rqstp->rq_auth_data;
        struct rsc *rsci = svcdata->rsci;
        struct rpc_gss_wire_cred *gc = &svcdata->clcred;
+       int stat;
 
-       rqstp->rq_client = find_gss_auth_domain(rsci->mechctx, gc->gc_svc);
-       if (rqstp->rq_client == NULL)
+       /*
+        * A gss export can be specified either by:
+        *      export  *(sec=krb5,rw)
+        * or by
+        *      export gss/krb5(rw)
+        * The latter is deprecated; but for backwards compatibility reasons
+        * the nfsd code will still fall back on trying it if the former
+        * doesn't work; so we try to make both available to nfsd, below.
+        */
+       rqstp->rq_gssclient = find_gss_auth_domain(rsci->mechctx, gc->gc_svc);
+       if (rqstp->rq_gssclient == NULL)
                return SVC_DENIED;
+       stat = svcauth_unix_set_client(rqstp);
+       if (stat == SVC_DROP)
+               return stat;
        return SVC_OK;
 }
 
@@ -924,6 +946,7 @@ static inline int
 gss_write_init_verf(struct svc_rqst *rqstp, struct rsi *rsip)
 {
        struct rsc *rsci;
+       int        rc;
 
        if (rsip->major_status != GSS_S_COMPLETE)
                return gss_write_null_verf(rqstp);
@@ -932,7 +955,9 @@ gss_write_init_verf(struct svc_rqst *rqstp, struct rsi *rsip)
                rsip->major_status = GSS_S_NO_CONTEXT;
                return gss_write_null_verf(rqstp);
        }
-       return gss_write_verf(rqstp, rsci->mechctx, GSS_SEQ_WIN);
+       rc = gss_write_verf(rqstp, rsci->mechctx, GSS_SEQ_WIN);
+       cache_put(&rsci->h, &rsc_cache);
+       return rc;
 }
 
 /*
@@ -958,7 +983,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
        __be32          *reject_stat = resv->iov_base + resv->iov_len;
        int             ret;
 
-       dprintk("RPC:      svcauth_gss: argv->iov_len = %zd\n",argv->iov_len);
+       dprintk("RPC:       svcauth_gss: argv->iov_len = %zd\n",
+                       argv->iov_len);
 
        *authp = rpc_autherr_badcred;
        if (!svcdata)
@@ -1084,10 +1110,11 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
                        svc_putnl(resv, GSS_SEQ_WIN);
                        if (svc_safe_putnetobj(resv, &rsip->out_token))
                                goto drop;
-                       rqstp->rq_client = NULL;
                }
                goto complete;
        case RPC_GSS_PROC_DESTROY:
+               if (gss_write_verf(rqstp, rsci->mechctx, gc->gc_seq))
+                       goto auth_err;
                set_bit(CACHE_NEGATIVE, &rsci->h.flags);
                if (resv->iov_len + 4 > PAGE_SIZE)
                        goto drop;
@@ -1125,6 +1152,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
                }
                svcdata->rsci = rsci;
                cache_get(&rsci->h);
+               rqstp->rq_flavor = gss_svc_to_pseudoflavor(
+                                       rsci->mechctx->mech_type, gc->gc_svc);
                ret = SVC_OK;
                goto out;
        }
@@ -1195,13 +1224,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
        if (xdr_buf_subsegment(resbuf, &integ_buf, integ_offset,
                                integ_len))
                BUG();
-       if (resbuf->page_len == 0
-                       && resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE
-                       < PAGE_SIZE) {
-               BUG_ON(resbuf->tail[0].iov_len);
-               /* Use head for everything */
-               resv = &resbuf->head[0];
-       } else if (resbuf->tail[0].iov_base == NULL) {
+       if (resbuf->tail[0].iov_base == NULL) {
                if (resbuf->head[0].iov_len + RPC_MAX_AUTH_SIZE > PAGE_SIZE)
                        goto out_err;
                resbuf->tail[0].iov_base = resbuf->head[0].iov_base
@@ -1317,6 +1340,9 @@ out_err:
        if (rqstp->rq_client)
                auth_domain_put(rqstp->rq_client);
        rqstp->rq_client = NULL;
+       if (rqstp->rq_gssclient)
+               auth_domain_put(rqstp->rq_gssclient);
+       rqstp->rq_gssclient = NULL;
        if (rqstp->rq_cred.cr_group_info)
                put_group_info(rqstp->rq_cred.cr_group_info);
        rqstp->rq_cred.cr_group_info = NULL;