From 487e9f1d59bbf7b37a30ceef5dbfd8ca77b94988 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 22 Jun 2010 11:30:23 +0000 Subject: moved 'auth_glusterfs' xdr definitions to rpc-lib as authentication is part of RPC header and GlusterFS payload comes at later stages Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875 --- xlators/protocol/rpc/rpc-lib/src/auth-glusterfs.c | 89 ++++++++++++++++++++++- xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h | 2 +- xlators/protocol/rpc/rpc-lib/src/xdr-common.h | 14 ++++ 3 files changed, 103 insertions(+), 2 deletions(-) (limited to 'xlators/protocol/rpc/rpc-lib/src') diff --git a/xlators/protocol/rpc/rpc-lib/src/auth-glusterfs.c b/xlators/protocol/rpc/rpc-lib/src/auth-glusterfs.c index 165e52a17..e248bf142 100644 --- a/xlators/protocol/rpc/rpc-lib/src/auth-glusterfs.c +++ b/xlators/protocol/rpc/rpc-lib/src/auth-glusterfs.c @@ -28,7 +28,94 @@ #include "list.h" #include "dict.h" #include "xdr-rpc.h" -#include "glusterfs-xdr.h" +#include "xdr-common.h" + +bool_t +xdr_auth_glusterfs_parms (XDR *xdrs, auth_glusterfs_parms *objp) +{ + register int32_t *buf; + + int i; + + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_u_quad_t (xdrs, &objp->lk_owner)) + return FALSE; + buf = XDR_INLINE (xdrs, (4 + 16 )* BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->pid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->ngrps)) + return FALSE; + if (!xdr_vector (xdrs, (char *)objp->groups, 16, + sizeof (u_int), (xdrproc_t) xdr_u_int)) + return FALSE; + } else { + IXDR_PUT_U_LONG(buf, objp->pid); + IXDR_PUT_U_LONG(buf, objp->uid); + IXDR_PUT_U_LONG(buf, objp->gid); + IXDR_PUT_U_LONG(buf, objp->ngrps); + { + register u_int *genp; + + for (i = 0, genp = objp->groups; + i < 16; ++i) { + IXDR_PUT_U_LONG(buf, *genp++); + } + } + } + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_u_quad_t (xdrs, &objp->lk_owner)) + return FALSE; + buf = XDR_INLINE (xdrs, (4 + 16 )* BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->pid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->ngrps)) + return FALSE; + if (!xdr_vector (xdrs, (char *)objp->groups, 16, + sizeof (u_int), (xdrproc_t) xdr_u_int)) + return FALSE; + } else { + objp->pid = IXDR_GET_U_LONG(buf); + objp->uid = IXDR_GET_U_LONG(buf); + objp->gid = IXDR_GET_U_LONG(buf); + objp->ngrps = IXDR_GET_U_LONG(buf); + { + register u_int *genp; + + for (i = 0, genp = objp->groups; + i < 16; ++i) { + *genp++ = IXDR_GET_U_LONG(buf); + } + } + } + return TRUE; + } + + if (!xdr_u_quad_t (xdrs, &objp->lk_owner)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->pid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->ngrps)) + return FALSE; + if (!xdr_vector (xdrs, (char *)objp->groups, 16, + sizeof (u_int), (xdrproc_t) xdr_u_int)) + return FALSE; + return TRUE; +} ssize_t xdr_to_glusterfs_auth (char *buf, struct auth_glusterfs_parms *req) diff --git a/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h b/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h index d962d0213..89942ce7f 100644 --- a/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h +++ b/xlators/protocol/rpc/rpc-lib/src/rpc-clnt.h @@ -23,7 +23,7 @@ #include "stack.h" #include "rpc-transport.h" #include "timer.h" -#include "glusterfs-xdr.h" +#include "xdr-common.h" typedef enum { RPC_CLNT_CONNECT, diff --git a/xlators/protocol/rpc/rpc-lib/src/xdr-common.h b/xlators/protocol/rpc/rpc-lib/src/xdr-common.h index 50a57ade9..775beb286 100644 --- a/xlators/protocol/rpc/rpc-lib/src/xdr-common.h +++ b/xlators/protocol/rpc/rpc-lib/src/xdr-common.h @@ -26,6 +26,20 @@ #endif #include + +struct auth_glusterfs_parms { + u_quad_t lk_owner; + u_int pid; + u_int uid; + u_int gid; + u_int ngrps; + u_int groups[16]; +}; +typedef struct auth_glusterfs_parms auth_glusterfs_parms; + +bool_t +xdr_auth_glusterfs_parms (XDR *xdrs, auth_glusterfs_parms *objp); + #define XDR_BYTES_PER_UNIT 4 /* Returns the address of the byte that follows the -- cgit