From e0d0ec7bd6277c4c89b731b05c000f22b31e7644 Mon Sep 17 00:00:00 2001 From: wangdi Date: Wed, 10 Aug 2005 14:08:05 +0000 Subject: [PATCH] Branch: HEAD some fixes about crypto api --- lustre/llite/llite_gs.c | 15 +++++++++++---- lustre/mdc/mdc_reint.c | 3 ++- lustre/mdc/mdc_request.c | 6 +++++- lustre/mds/handler.c | 8 +++++--- lustre/mds/mds_reint.c | 6 +++--- lustre/sec/gks/gks_client.c | 3 ++- lustre/sec/gks/gks_server.c | 2 ++ 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lustre/llite/llite_gs.c b/lustre/llite/llite_gs.c index f28396c..83b1255 100644 --- a/lustre/llite/llite_gs.c +++ b/lustre/llite/llite_gs.c @@ -347,14 +347,20 @@ out: RETURN(rc); } static void get_real_parameters(struct inode *inode, struct iattr *iattr, - mode_t *mode, __u32 *uid, __u32 *gid) + struct posix_acl *new_acl, mode_t *mode, + __u32 *uid, __u32 *gid) { LASSERT(iattr); - if (iattr->ia_valid & ATTR_MODE) + if (iattr->ia_valid & ATTR_MODE) { *mode = iattr->ia_mode; - else + } else { *mode = inode->i_mode; + if (new_acl) { + posix_acl_equiv_mode(new_acl, mode); + CDEBUG(D_INFO, "get new mode %d \n", *mode); + } + } if (iattr->ia_valid & ATTR_UID) *uid = iattr->ia_uid; @@ -403,6 +409,7 @@ int ll_gks_get_mac(struct inode *inode, struct iattr *iattr, void *value, acl, inode->i_mode, GKS_GET_MAC, iattr->ia_valid); spin_unlock(&lli->lli_lock); if (value) { + new_acl = posix_acl_from_xattr(value, size); if (IS_ERR(new_acl)) { rc = PTR_ERR(new_acl); CERROR("convert from xattr to acl error: %d",rc); @@ -419,7 +426,7 @@ int ll_gks_get_mac(struct inode *inode, struct iattr *iattr, void *value, acl_count = new_acl ? new_acl->a_count : 0; kperm_size = crypto_kperm_size(acl_count); OBD_ALLOC(kperm, kperm_size); - get_real_parameters(inode, iattr, &mac_mode, &uid, &gid); + get_real_parameters(inode, iattr, new_acl, &mac_mode, &uid, &gid); ll_init_key_perm(kperm, new_acl, uid, gid, mac_mode); kparms.context = kcontext; kparms.context_size = kcontext_size; diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 6679464..09d915f 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -78,7 +78,8 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, struct mds_rec_setattr *rec; struct mdc_rpc_lock *rpc_lock; struct obd_device *obd = exp->exp_obd; - int rc, bufcount = 2, size[4] = {0, sizeof(*rec), ealen, ea2len}; + int rc, bufcount = 2, size[5] = {0, sizeof(*rec), ealen, ea2len, + ea3len}; ENTRY; LASSERT(iattr != NULL); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index eb7bcdf..caf54c3 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -480,6 +480,8 @@ static int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req } md->posix_acl = acl; } + } else { + *offset += 2; } RETURN(rc); } @@ -500,7 +502,9 @@ static int mdc_unpack_gskey(struct obd_export *exp_lmv, struct ptlrpc_request *r buf, key_off, size); md->key = (struct lustre_key *)buf; *offset = key_off; - } + } else { + *offset += 2; + } RETURN(rc); } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 985f5a1..956de88 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -4153,14 +4153,16 @@ static int mds_intent_prepare_reply_buffers(struct ptlrpc_request *req, reply_buffers = 3; if (it->opc & ( IT_OPEN | IT_GETATTR | IT_LOOKUP | IT_CHDIR )) { + /*Ugly here, Actually, we should prepare the reply buffer + *after we know whether these stuff exist or not, which should + * be fixed in future, Now each item is in the fix position, + * the sequence is lsm, acl, crypto ea, capa.*/ repsize[reply_buffers++] = sizeof(int); /* XXX: mds_remote_perm is stored here too, and for it * the 'size' is ignored */ repsize[reply_buffers++] = xattr_acl_size(LL_ACL_MAX_ENTRIES); - - /*FIXME: ugly here, should be optimize for there - * is no crypto key*/ + repsize[reply_buffers++] = sizeof(int); repsize[reply_buffers++] = sizeof(struct crypto_key); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index f84077b..eb2c1dc 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -655,9 +655,9 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, int keylen; LASSERT(rec->ur_eadatalen || rec->ur_ea3datalen); LASSERT(rec->ur_eadata || rec->ur_ea3data); - key = rec->ur_eadata ? rec->ur_eadata : rec->ur_ea3data; - keylen = rec->ur_eadatalen ? rec->ur_eadatalen : - rec->ur_ea3datalen; + key = rec->ur_ea3data ? rec->ur_ea3data : rec->ur_eadata; + keylen = rec->ur_ea3datalen ? rec->ur_ea3datalen : + rec->ur_eadatalen; mds_set_gskey(obd, handle, inode, key, keylen, rec->ur_iattr.ia_valid); } diff --git a/lustre/sec/gks/gks_client.c b/lustre/sec/gks/gks_client.c index 161f938..5e1fb45 100644 --- a/lustre/sec/gks/gks_client.c +++ b/lustre/sec/gks/gks_client.c @@ -71,7 +71,8 @@ static int gkc_get_key(struct obd_export *exp, struct key_parms *kparms, memcpy(ckey, rep_key, sizeof(*rep_key)); - CDEBUG(D_INFO, "get enkey %s, mac %s\n", ckey->ck_key, ckey->ck_mac); + CDEBUG(D_INFO, "get enkey %s, mac %s type %d\n", ckey->ck_key, ckey->ck_mac, + ckey->ck_type); ptlrpc_req_finished(req); RETURN(rc); diff --git a/lustre/sec/gks/gks_server.c b/lustre/sec/gks/gks_server.c index 1a9ec27..c7f8b5a 100644 --- a/lustre/sec/gks/gks_server.c +++ b/lustre/sec/gks/gks_server.c @@ -250,6 +250,7 @@ static int gks_mac_verification(struct ptlrpc_request *req, OBD_FREE(tmp_mac, MAC_SIZE); RETURN(0); } + CERROR("new_created %s EA is %s \n", tmp_mac, key->ck_mac); OBD_FREE(tmp_mac, MAC_SIZE); RETURN(-EPERM); } @@ -328,6 +329,7 @@ static int gks_get_mac(struct ptlrpc_request *req, int offset) memcpy(ckey, &kctxt->kc_ck, sizeof(*ckey)); + ckey->ck_type = GKS_TYPE; rc = crypto_get_gks_mac(req, kperm, ckey->ck_mac); if (rc != 0) { CERROR("get new mac error %d \n", rc); -- 1.8.3.1