Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  * linux/include/linux/sunrpc/auth.h
  3  *
  4  * Declarations for the RPC client authentication machinery.
  5  *
  6  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  7  */
  8 
  9 #ifndef _LINUX_SUNRPC_AUTH_H
 10 #define _LINUX_SUNRPC_AUTH_H
 11 
 12 #ifdef __KERNEL__
 13 
 14 #include <linux/config.h>
 15 #include <linux/sunrpc/sched.h>
 16 #include <linux/sunrpc/msg_prot.h>
 17 #include <linux/sunrpc/xdr.h>
 18 
 19 #include <asm/atomic.h>
 20 
 21 /* size of the nodename buffer */
 22 #define UNX_MAXNODENAME 32
 23 
 24 /* Maximum size (in bytes) of an rpc credential or verifier */
 25 #define RPC_MAX_AUTH_SIZE (400)
 26 
 27 /* Work around the lack of a VFS credential */
 28 struct auth_cred {
 29         uid_t   uid;
 30         gid_t   gid;
 31         struct group_info *group_info;
 32 };
 33 
 34 /*
 35  * Client user credentials
 36  */
 37 struct rpc_cred {
 38         struct list_head        cr_hash;        /* hash chain */
 39         struct rpc_auth *       cr_auth;
 40         struct rpc_credops *    cr_ops;
 41         unsigned long           cr_expire;      /* when to gc */
 42         atomic_t                cr_count;       /* ref count */
 43         unsigned short          cr_flags;       /* various flags */
 44 #ifdef RPC_DEBUG
 45         unsigned long           cr_magic;       /* 0x0f4aa4f0 */
 46 #endif
 47 
 48         uid_t                   cr_uid;
 49 
 50         /* per-flavor data */
 51 };
 52 #define RPCAUTH_CRED_LOCKED     0x0001
 53 #define RPCAUTH_CRED_UPTODATE   0x0002
 54 
 55 #define RPCAUTH_CRED_MAGIC      0x0f4aa4f0
 56 
 57 /*
 58  * Client authentication handle
 59  */
 60 #define RPC_CREDCACHE_NR        8
 61 #define RPC_CREDCACHE_MASK      (RPC_CREDCACHE_NR - 1)
 62 struct rpc_auth {
 63         struct list_head        au_credcache[RPC_CREDCACHE_NR];
 64         unsigned long           au_expire;      /* cache expiry interval */
 65         unsigned long           au_nextgc;      /* next garbage collection */
 66         unsigned int            au_cslack;      /* call cred size estimate */
 67         unsigned int            au_rslack;      /* reply verf size guess */
 68         unsigned int            au_flags;       /* various flags */
 69         struct rpc_authops *    au_ops;         /* operations */
 70         rpc_authflavor_t        au_flavor;      /* pseudoflavor (note may
 71                                                  * differ from the flavor in
 72                                                  * au_ops->au_flavor in gss
 73                                                  * case) */
 74         atomic_t                au_count;       /* Reference counter */
 75 
 76         /* per-flavor data */
 77 };
 78 #define RPC_AUTH_PROC_CREDS     0x0010          /* process creds (including
 79                                                  * uid/gid, fs[ug]id, gids)
 80                                                  */
 81 
 82 /*
 83  * Client authentication ops
 84  */
 85 struct rpc_authops {
 86         struct module           *owner;
 87         rpc_authflavor_t        au_flavor;      /* flavor (RPC_AUTH_*) */
 88 #ifdef RPC_DEBUG
 89         char *                  au_name;
 90 #endif
 91         struct rpc_auth *       (*create)(struct rpc_clnt *, rpc_authflavor_t);
 92         void                    (*destroy)(struct rpc_auth *);
 93 
 94         struct rpc_cred *       (*crcreate)(struct rpc_auth*, struct auth_cred *, int);
 95 };
 96 
 97 struct rpc_credops {
 98         void                    (*crdestroy)(struct rpc_cred *);
 99 
100         int                     (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
101         u32 *                   (*crmarshal)(struct rpc_task *, u32 *, int);
102         int                     (*crrefresh)(struct rpc_task *);
103         u32 *                   (*crvalidate)(struct rpc_task *, u32 *);
104         int                     (*crwrap_req)(struct rpc_task *, kxdrproc_t,
105                                                 void *, u32 *, void *);
106         int                     (*crunwrap_resp)(struct rpc_task *, kxdrproc_t,
107                                                 void *, u32 *, void *);
108 };
109 
110 extern struct rpc_authops       authunix_ops;
111 extern struct rpc_authops       authnull_ops;
112 #ifdef CONFIG_SUNRPC_SECURE
113 extern struct rpc_authops       authdes_ops;
114 #endif
115 
116 int                     rpcauth_register(struct rpc_authops *);
117 int                     rpcauth_unregister(struct rpc_authops *);
118 struct rpc_auth *       rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);
119 void                    rpcauth_destroy(struct rpc_auth *);
120 struct rpc_cred *       rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
121 struct rpc_cred *       rpcauth_lookupcred(struct rpc_auth *, int);
122 struct rpc_cred *       rpcauth_bindcred(struct rpc_task *);
123 void                    rpcauth_holdcred(struct rpc_task *);
124 void                    put_rpccred(struct rpc_cred *);
125 void                    rpcauth_unbindcred(struct rpc_task *);
126 u32 *                   rpcauth_marshcred(struct rpc_task *, u32 *);
127 u32 *                   rpcauth_checkverf(struct rpc_task *, u32 *);
128 int                     rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, u32 *data, void *obj);
129 int                     rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, u32 *data, void *obj);
130 int                     rpcauth_refreshcred(struct rpc_task *);
131 void                    rpcauth_invalcred(struct rpc_task *);
132 int                     rpcauth_uptodatecred(struct rpc_task *);
133 void                    rpcauth_init_credcache(struct rpc_auth *);
134 void                    rpcauth_free_credcache(struct rpc_auth *);
135 
136 static inline
137 struct rpc_cred *       get_rpccred(struct rpc_cred *cred)
138 {
139         atomic_inc(&cred->cr_count);
140         return cred;
141 }
142 
143 #endif /* __KERNEL__ */
144 #endif /* _LINUX_SUNRPC_AUTH_H */
145 
  This page was automatically generated by the LXR engine.