printf("Server-CGI: GridSite Admin %s\n", VERSION);
printf("Content-Length: %d\n", 2 * strlen(status) + 58);
puts("Content-Type: text/html\n");
-
+
printf("<head><title>%s</title></head>\n", status);
printf("<body><h1 >%s</h1 ></body>\n", status);
dir_uri, admin_file);
else GRSThttpPrintf(bp, "<a href=\"%s\">"
"Back to directory</a> .\n", dir_uri);
-
+
if (help_uri != NULL)
GRSThttpPrintf(bp, "<a href=\"%s\">Website Help</a> .\n", help_uri);
char *dir_uri, char *admin_file)
{
GRSThttpBody bp;
-
+
puts("Status: 200 OK\nContent-Type: text/html");
GRSThttpBodyInit(&bp);
if (GRSTgaclPermHasList(perm) || GRSTgaclPermHasWrite(perm)
- || GRSTgaclPermHasAdmin(perm))
+ || GRSTgaclPermHasAdmin(perm))
adminfooter(&bp, dn, help_uri, dir_uri, admin_file);
GRSThttpPrintHeaderFooter(&bp, dir_path, GRST_FOOTFILE);
int main()
{
- int gsiproxylimit_i = 1;
+ int i, gsiproxylimit_i = 1;
char *cmd, *dir_uri, *file, *dir_path, *admin_file, *dn = NULL,
*help_uri, *p, *content_type, *request_uri, *button,
- *grst_cred_0, *gsiproxylimit, *dn_lists;
+ *grst_cred_0, *gsiproxylimit, *dn_lists, buf[12];
GRSTgaclCred *cred;
GRSTgaclUser *user = NULL;
GRSTgaclAcl *acl;
if ((p = index(grst_cred_0, ' ')) &&
(p = index(++p, ' ')) &&
(p = index(++p, ' ')) &&
- (p = index(++p, ' '))) dn = &p[1];
- }
+ (p = index(++p, ' '))) dn = &p[1];
+ }
+ /* User has a cert so check for voms attributes */
+ for(i=1; ; i++)
+ {
+ sprintf (buf, "GRST_CRED_%d", i);
+
+
+ grst_cred_0 = getenv(buf);
+ if (grst_cred_0==NULL) break;
+
+ if (cred=GRSTx509CompactToCred(grst_cred_0))
+ GRSTgaclUserAddCred(user, cred);
+ }
+ /* no more voms attributes found found */
}
else if ((dn = getenv("SSL_CLIENT_S_DN")) != NULL)
- {
+ {
cred = GRSTgaclCredNew("person");
GRSTgaclCredAddValue(cred, "dn", dn);
user = GRSTgaclUserNew(cred);
if ((content_type != NULL) &&
(GRSTstrCmpShort(content_type, "multipart/form-data; boundary=") == 0))
- {
+ {
uploadfile(dn, perm, help_uri, dir_path, dir_uri, admin_file);
return 0;
}
{
GRSTgaclCred *crediter;
GRSTgaclNamevalue *usernamevalue, *crednamevalue;
- int i;
- char buf[12];
+
if (cred == NULL) return 0;
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 (strcmp(cred->type, "dns") == 0)
{
if ((user->firstcred == NULL) ||
((user->firstcred)->firstname == NULL) ||
if (strncmp(grst_cred, "VOMS ", 5) == 0)
{
- if ((sscanf(grst_cred, "VOMS %lu %lu",
+ if ((sscanf(grst_cred, "VOMS %lu %lu %d",
¬before, ¬after, &delegation) == 3)
&& (now >= notbefore)
&& (now <= notafter)
{
/* include /VO/group/subgroup/Role=role/Capability=cap */
- if (*p != '/') return NULL; /* must begin with / */
+ if (p[1] != '/') return NULL; /* must begin with / */
cred = GRSTgaclCredNew("voms");
GRSTgaclCredSetDelegation(cred, delegation);
- GRSTgaclCredAddValue(cred, "fqan", p);
+ GRSTgaclCredAddValue(cred, "fqan", &p[1]);
}
return cred;