Added checking vor VOMS creds in GRSTgaclUserHasCred - needed for GACL editor
authorShiv Kaushal <shiv.kaushal@manchester.ac.uk>
Fri, 27 May 2005 13:38:06 +0000 (13:38 +0000)
committerShiv Kaushal <shiv.kaushal@manchester.ac.uk>
Fri, 27 May 2005 13:38:06 +0000 (13:38 +0000)
org.gridsite.core/src/grst_gacl.c

index a9bc561..e5180de 100644 (file)
@@ -837,6 +837,8 @@ int GRSTgaclUserHasCred(GRSTgaclUser *user, GRSTgaclCred *cred)
 {
   GRSTgaclCred      *crediter;
   GRSTgaclNamevalue *usernamevalue, *crednamevalue;
+  int i;
+  char buf[12];
 
   if (cred == NULL) return 0;
 
@@ -852,7 +854,32 @@ int GRSTgaclUserHasCred(GRSTgaclUser *user, GRSTgaclCred *cred)
       
       return GRSTgaclDNlistHasUser((cred->firstname)->value, user);
     }
-    
+  /* Check for voms attributes*/
+  
+  if  (strcmp(cred->type, "voms")==0)
+    {
+      if ( (user->firstcred==NULL) ||
+           ((user->firstcred)->firstname == NULL) ||
+           (cred->firstname == NULL) ||
+           (strcmp((cred->firstname)->name, "fqan") != 0) ||
+           ((cred->firstname)->next != NULL)) return 0;
+          
+      /*assuimng only one name/value pair per cred*/
+      for(i=1; ; i++)
+      {
+             sprintf (buf, "GRST_CRED_%d", i);
+             if (getenv(buf)==NULL) break;
+
+             if (strcmp ( 
+                          index(getenv(buf),'/'), 
+                          (cred->firstname)->value
+                        )  
+                  == 0) return 1;
+      }
+      /* no match found */
+      return 0;
+    }
+
   if (strcmp(cred->type, "dns") == 0) 
     {
       if ((user->firstcred == NULL) ||
@@ -872,7 +899,8 @@ int GRSTgaclUserHasCred(GRSTgaclUser *user, GRSTgaclCred *cred)
             return (fnmatch((cred->firstname)->value, 
                             (crediter->firstname)->value, FNM_CASEFOLD) == 0);
           }
-                
+          
+           
       return 0;    
     }
     
@@ -924,7 +952,7 @@ int GRSTgaclUserHasCred(GRSTgaclUser *user, GRSTgaclCred *cred)
               usernamevalue = (GRSTgaclNamevalue *) usernamevalue->next;
             }
        }
-       
+         
   return 0;
 }