diff options
| author | Chuck Lever <cel@citi.umich.edu> | 2002-09-17 20:17:23 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-09-17 20:17:23 -0700 |
| commit | b9239fb2e7a4e6d771e74631da4aafcc01e67bb8 (patch) | |
| tree | 57e32c96a61a866558154638b4e197eccbdfdbdf /net/sunrpc | |
| parent | 1e04f496f8d6c2237b554b6b049ea4eb803e54b1 (diff) | |
[PATCH] stricter type checking for rpc auth flavors
This implements stricter type checking for rpc auth flavors. it is a
prerequisite for RPC GSSAPI and its authentication pseudoflavors.
please apply it.
Diffstat (limited to 'net/sunrpc')
| -rw-r--r-- | net/sunrpc/auth.c | 20 | ||||
| -rw-r--r-- | net/sunrpc/auth_null.c | 16 | ||||
| -rw-r--r-- | net/sunrpc/auth_unix.c | 24 | ||||
| -rw-r--r-- | net/sunrpc/clnt.c | 5 | ||||
| -rw-r--r-- | net/sunrpc/svcauth.c | 21 |
5 files changed, 45 insertions, 41 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 3a04a5f07a7d..f2ad100286ea 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -1,7 +1,7 @@ /* - * linux/fs/nfs/rpcauth.c + * linux/net/sunrpc/auth.c * - * Generic RPC authentication API. + * Generic RPC client authentication API. * * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> */ @@ -18,9 +18,7 @@ # define RPCDBG_FACILITY RPCDBG_AUTH #endif -#define RPC_MAXFLAVOR 8 - -static struct rpc_authops * auth_flavors[RPC_MAXFLAVOR] = { +static struct rpc_authops * auth_flavors[RPC_AUTH_MAXFLAVOR] = { &authnull_ops, /* AUTH_NULL */ &authunix_ops, /* AUTH_UNIX */ NULL, /* others can be loadable modules */ @@ -29,9 +27,9 @@ static struct rpc_authops * auth_flavors[RPC_MAXFLAVOR] = { int rpcauth_register(struct rpc_authops *ops) { - unsigned int flavor; + rpc_authflavor_t flavor; - if ((flavor = ops->au_flavor) >= RPC_MAXFLAVOR) + if ((flavor = ops->au_flavor) >= RPC_AUTH_MAXFLAVOR) return -EINVAL; if (auth_flavors[flavor] != NULL) return -EPERM; /* what else? */ @@ -42,9 +40,9 @@ rpcauth_register(struct rpc_authops *ops) int rpcauth_unregister(struct rpc_authops *ops) { - unsigned int flavor; + rpc_authflavor_t flavor; - if ((flavor = ops->au_flavor) >= RPC_MAXFLAVOR) + if ((flavor = ops->au_flavor) >= RPC_AUTH_MAXFLAVOR) return -EINVAL; if (auth_flavors[flavor] != ops) return -EPERM; /* what else? */ @@ -53,11 +51,11 @@ rpcauth_unregister(struct rpc_authops *ops) } struct rpc_auth * -rpcauth_create(unsigned int flavor, struct rpc_clnt *clnt) +rpcauth_create(rpc_authflavor_t flavor, struct rpc_clnt *clnt) { struct rpc_authops *ops; - if (flavor >= RPC_MAXFLAVOR || !(ops = auth_flavors[flavor])) + if (flavor >= RPC_AUTH_MAXFLAVOR || !(ops = auth_flavors[flavor])) return NULL; clnt->cl_auth = ops->create(clnt); return clnt->cl_auth; diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index 8f71439adca2..dbad46309b66 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c @@ -1,5 +1,5 @@ /* - * linux/net/sunrpc/rpcauth_null.c + * linux/net/sunrpc/auth_null.c * * AUTH_NULL authentication. Really :-) * @@ -106,14 +106,18 @@ nul_refresh(struct rpc_task *task) static u32 * nul_validate(struct rpc_task *task, u32 *p) { - u32 n = ntohl(*p++); + rpc_authflavor_t flavor; + u32 size; - if (n != RPC_AUTH_NULL) { - printk("RPC: bad verf flavor: %ld\n", (unsigned long) n); + flavor = ntohl(*p++); + if (flavor != RPC_AUTH_NULL) { + printk("RPC: bad verf flavor: %u\n", flavor); return NULL; } - if ((n = ntohl(*p++)) != 0) { - printk("RPC: bad verf size: %ld\n", (unsigned long) n); + + size = ntohl(*p++); + if (size != 0) { + printk("RPC: bad verf size: %u\n", size); return NULL; } diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index fc42c873a0ed..90d91a73574b 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c @@ -1,5 +1,5 @@ /* - * linux/net/sunrpc/rpcauth_unix.c + * linux/net/sunrpc/auth_unix.c * * UNIX-style authentication; no AUTH_SHORT support * @@ -216,18 +216,24 @@ unx_refresh(struct rpc_task *task) static u32 * unx_validate(struct rpc_task *task, u32 *p) { - u32 n = ntohl(*p++); - - if (n != RPC_AUTH_NULL && n != RPC_AUTH_UNIX && n != RPC_AUTH_SHORT) { - printk("RPC: bad verf flavor: %ld\n", (unsigned long) n); + rpc_authflavor_t flavor; + u32 size; + + flavor = ntohl(*p++); + if (flavor != RPC_AUTH_NULL && + flavor != RPC_AUTH_UNIX && + flavor != RPC_AUTH_SHORT) { + printk("RPC: bad verf flavor: %u\n", flavor); return NULL; } - if ((n = ntohl(*p++)) > 400) { - printk("RPC: giant verf size: %ld\n", (unsigned long) n); + + size = ntohl(*p++); + if (size > 400) { + printk("RPC: giant verf size: %u\n", size); return NULL; } - task->tk_auth->au_rslack = (n >> 2) + 2; - p += (n >> 2); + task->tk_auth->au_rslack = (size >> 2) + 2; + p += (size >> 2); return p; } diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 078a204c7fa4..daa2e80f97c2 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -71,7 +71,8 @@ static u32 * call_verify(struct rpc_task *task); */ struct rpc_clnt * rpc_create_client(struct rpc_xprt *xprt, char *servname, - struct rpc_program *program, u32 vers, int flavor) + struct rpc_program *program, u32 vers, + rpc_authflavor_t flavor) { struct rpc_version *version; struct rpc_clnt *clnt = NULL; @@ -122,7 +123,7 @@ out_no_clnt: printk(KERN_INFO "RPC: out of memory in rpc_create_client\n"); goto out; out_no_auth: - printk(KERN_INFO "RPC: Couldn't create auth handle (flavor %d)\n", + printk(KERN_INFO "RPC: Couldn't create auth handle (flavor %u)\n", flavor); rpc_free(clnt); clnt = NULL; diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c index 3b0c40040d74..d5b02c44ea86 100644 --- a/net/sunrpc/svcauth.c +++ b/net/sunrpc/svcauth.c @@ -31,14 +31,9 @@ static void svcauth_null(struct svc_rqst *rqstp, u32 *statp, u32 *authp); static void svcauth_unix(struct svc_rqst *rqstp, u32 *statp, u32 *authp); /* - * Max number of authentication flavors we support - */ -#define RPC_SVCAUTH_MAX 8 - -/* * Table of authenticators */ -static auth_fn_t authtab[RPC_SVCAUTH_MAX] = { +static auth_fn_t authtab[RPC_AUTH_MAXFLAVOR] = { svcauth_null, svcauth_unix, NULL, @@ -47,8 +42,8 @@ static auth_fn_t authtab[RPC_SVCAUTH_MAX] = { void svc_authenticate(struct svc_rqst *rqstp, u32 *statp, u32 *authp) { - u32 flavor; - auth_fn_t func; + rpc_authflavor_t flavor; + auth_fn_t func; *statp = rpc_success; *authp = rpc_auth_ok; @@ -57,7 +52,7 @@ svc_authenticate(struct svc_rqst *rqstp, u32 *statp, u32 *authp) flavor = ntohl(flavor); dprintk("svc: svc_authenticate (%d)\n", flavor); - if (flavor >= RPC_SVCAUTH_MAX || !(func = authtab[flavor])) { + if (flavor >= RPC_AUTH_MAXFLAVOR || !(func = authtab[flavor])) { *authp = rpc_autherr_badcred; return; } @@ -67,18 +62,18 @@ svc_authenticate(struct svc_rqst *rqstp, u32 *statp, u32 *authp) } int -svc_auth_register(u32 flavor, auth_fn_t func) +svc_auth_register(rpc_authflavor_t flavor, auth_fn_t func) { - if (flavor >= RPC_SVCAUTH_MAX || authtab[flavor]) + if (flavor >= RPC_AUTH_MAXFLAVOR || authtab[flavor]) return -EINVAL; authtab[flavor] = func; return 0; } void -svc_auth_unregister(u32 flavor) +svc_auth_unregister(rpc_authflavor_t flavor) { - if (flavor < RPC_SVCAUTH_MAX) + if (flavor < RPC_AUTH_MAXFLAVOR) authtab[flavor] = NULL; } |
