From: Daniel KouĊ™il Date: Mon, 8 Feb 2010 12:55:56 +0000 (+0000) Subject: Initial support for ordering of voms attributes X-Git-Tag: glite-security-proxyrenewal_R_1_3_9_1~3 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=1f6ae8336563e40aafaae65dfeccaf4ed648816f;p=jra1mw.git Initial support for ordering of voms attributes - hit a strange issue with the number of ordered attributes. Must be clarified with the VOMS developers. --- diff --git a/org.glite.security.proxyrenewal/src/voms.c b/org.glite.security.proxyrenewal/src/voms.c index 36accef..958e905 100644 --- a/org.glite.security.proxyrenewal/src/voms.c +++ b/org.glite.security.proxyrenewal/src/voms.c @@ -114,33 +114,49 @@ my_VOMS_Export(glite_renewal_core_context ctx, void *buf, int buf_len, X509_EXTE static int create_voms_command(glite_renewal_core_context ctx, struct vomsdata *vd, struct voms **voms_cert, char **command) { - int ret; + int ret, voms_err, i; struct data **attribs; - -#if 0 - VOMS_ResetOrder(vd, &voms_error); - for (i = 2; i < argc; i++) { - ret = VOMS_Ordering(argv[i], vd, &voms_error); - if (ret == 0) { - edg_wlpr_Log(ctx, LOG_ERR, "VOMS_Ordering() failed\n"); - return 1; - } - } -#endif + char *str = NULL; + char *role, *cmd = NULL, *tmp = NULL; if (voms_cert == NULL || *voms_cert == NULL || (*voms_cert)->std == NULL) { glite_renewal_core_set_err(ctx, "Invalid VOMS certificate"); return 1; } + VOMS_ResetOrder(vd, &voms_err); attribs = (*voms_cert)->std; + i = 0; + while (attribs && attribs[i]) { + role = NULL; + if ((attribs[i])->role && strcmp ((attribs[i])->role, "NULL") != 0 && + strcmp((attribs[i])->role, "") != 0) + role = (attribs[i])->role; + + asprintf(&str, "%s%s%s", + (attribs[i])->group, + (role) ? ":" : "", + (role) ? role : ""); + + /* XXXXXXX */ + if (i < 5) + { + VOMS_Ordering(str, vd, &voms_err); + } - if (attribs[0]->role == NULL || strcmp (attribs[0]->role, "NULL") == 0 || - strcmp(attribs[0]->role, "") == 0) - ret = asprintf(command, "G%s", attribs[0]->group); - else - ret = asprintf(command, "B%s:%s", attribs[0]->group, attribs[0]->role); + asprintf(&tmp, "%s%s%s%s", + (cmd) ? cmd : "", + (cmd) ? "," : "", + (role) ? "B" : "G", + str); + cmd = tmp; + + free(str); + str = NULL; + i++; + } + *command = cmd; return 0; }