- edg_wll_UserJobsServer() now observes alternative identities if ID mappings exist
authorZdeněk Šustr <sustr4@cesnet.cz>
Mon, 10 Sep 2012 09:47:14 +0000 (09:47 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Mon, 10 Sep 2012 09:47:14 +0000 (09:47 +0000)
- grid map IDs are normalized on load

org.glite.lb.server/src/lb_authz.c
org.glite.lb.server/src/userjobs.c

index b0d4ceb..ebbf658 100644 (file)
@@ -1344,6 +1344,7 @@ parse_gridmap(edg_wll_Context ctx,
                }
 
                strncpy(a, line + index, len); // Copy token contents and assign
+               edg_wll_gss_normalize_subj(a, 1);
                if (!i) mapping->rules[mapping->num].a = a;
                else mapping->rules[mapping->num].b = a;
 
index 81ccaf6..c91e21d 100644 (file)
@@ -40,7 +40,7 @@ int edg_wll_UserJobsServer(
        edg_wll_JobStat **states
 )
 {
-       char    *userid, *stmt = NULL,
+       char    *userid, *stmt = NULL, *opt_userid,
                *res = NULL;
        char    *can_peername;
        char    *srv_name = NULL;
@@ -77,7 +77,29 @@ int edg_wll_UserJobsServer(
        free(stmt); stmt = NULL;
        free(res); res = NULL;
 
-       trio_asprintf(&stmt,"select dg_jobid from jobs where userid = '%|Ss' and grey='0'",userid);
+       trio_asprintf (&opt_userid,"userid = '%|Ss'", userid);
+
+       //Alternative identities
+       if(ctx->id_mapping.num) {
+               int i;
+               char *alter, *opt_tmp;
+
+               for (i = 0; i< ctx->id_mapping.num; i++) {
+                       alter = NULL;
+                       if (edg_wll_gss_equal_subj(ctx->peerName, ctx->id_mapping.rules[i].a))
+                               alter = strmd5(ctx->id_mapping.rules[i].b, NULL);
+                       else if (edg_wll_gss_equal_subj(ctx->peerName, ctx->id_mapping.rules[i].b))
+                               alter = strmd5(ctx->id_mapping.rules[i].a, NULL);
+                       if (alter) {
+                               trio_asprintf(&opt_tmp, "%s OR userid = '%|Ss'", opt_userid, alter);
+                               free(opt_userid);
+                               opt_userid = opt_tmp;
+                       }
+               }
+       }
+
+       trio_asprintf(&stmt,"select dg_jobid from jobs where (%s) and grey='0'",opt_userid);
+       free(opt_userid);
        glite_common_log_msg(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        switch (njobs = edg_wll_ExecSQL(ctx,stmt,&sth)) {
                case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName);