int lsacl_fileproc(void *callerdat, struct file_info *finfo) { CXmlNodePtr acl; acl = fileattr_getroot(); acl->xpathVariable("name",finfo->file); if(acl->Lookup("file[cvs:filename(@name,$name)]/acl") && acl->XPathResultNext()) { printf("File: %s\n",finfo->file); show_acl(acl); } return 0; }
/* * Show file ACL */ static Dtype lsacl_dirproc (void *callerdat, char *dir, char *repos, char *update_dir, List *entries, const char *virtual_repository, Dtype hint) { const char *owner; CXmlNodePtr acl; if(hint!=R_PROCESS) return hint; owner = fileattr_getvalue(NULL,"directory/owner"); if(is_rlsacl && !strcmp(update_dir,".")) update_dir="<root>"; printf("Directory: %s\n",update_dir); printf("Owner: %s\n",(owner&&*owner)?owner:"<not set>"); acl = fileattr_find(NULL,"directory/acl"); show_acl(acl); return R_PROCESS; }
int main() { int i, gsiproxylimit_i = 1, delegation = 0; char *cmd, *dir_uri, *file, *dir_path, *admin_file, *dn = NULL, *help_uri, *p, *content_type, *request_uri, *button, *grst_auri_i, *grst_valid_i, *gsiproxylimit, buf[12]; GRSTgaclCred *cred; GRSTgaclUser *user = NULL; GRSTgaclAcl *acl; GRSTgaclPerm perm = GRST_PERM_NONE; help_uri = getenv("REDIRECT_GRST_HELP_URI"); /* can be NULL */ admin_file = getenv("REDIRECT_GRST_ADMIN_FILE"); dir_path = getenv("REDIRECT_GRST_DIR_PATH"); request_uri = getenv("REQUEST_URI"); if ((dir_path == NULL) || (admin_file == NULL) || (request_uri == NULL)) { puts("Status: 500 Internal Server Error\nContent-type: text/plain\n\n" "REDIRECT_GRST_DIR_PATH or REDIRECT_GRST_ADMIN_FILE " "or REQUEST_URI missing"); return -1; } GRSTgaclInit(); gsiproxylimit = getenv("REDIRECT_GRST_GSIPROXY_LIMIT"); if (gsiproxylimit != NULL) sscanf(gsiproxylimit, "%d", &gsiproxylimit_i); grst_auri_i = getenv("GRST_CRED_AURI_0"); grst_valid_i = getenv("GRST_CRED_VALID_0"); if ((grst_auri_i != NULL) && (strncmp(grst_auri_i, "dn:", 3) == 0)) { dn = &grst_auri_i[3]; sscanf(grst_valid_i, "notbefore=%*ld notafter=%*ld delegation=%d nist-loa=%*d", &delegation); if (delegation <= gsiproxylimit_i) { cred = GRSTgaclCredCreate(grst_auri_i, NULL); user = GRSTgaclUserNew(cred); /* User has a cert so check for VOMS attributes etc */ for (i=1; ; i++) { sprintf (buf, "GRST_CRED_%d", i); grst_auri_i = getenv(buf); if (grst_auri_i == NULL) break; cred = GRSTgaclCredCreate(grst_auri_i, NULL); GRSTgaclUserAddCred(user, cred); } /* no more VOMS attributes etc found */ } } else if ((dn = getenv("SSL_CLIENT_S_DN")) != NULL) { cred = GRSTgaclCredCreate("dn:", GRSThttpUrlMildencode(dn)); user = GRSTgaclUserNew(cred); } if (GRSTgaclUserHasAURI(user, getenv("REDIRECT_GRST_ADMIN_LIST"))) perm = GRST_PERM_ALL; else { p = getenv("REMOTE_HOST"); if (p != NULL) { cred = GRSTgaclCredCreate("dns:", p); if (user == NULL) user = GRSTgaclUserNew(cred); else GRSTgaclUserAddCred(user, cred); } acl = GRSTgaclAclLoadforFile(dir_path); if (acl != NULL) perm = GRSTgaclAclTestUser(acl, user); } /* we're relying on being a CGI with all this un-free()ed strdup()ing */ dir_uri = strdup(request_uri); p = rindex(dir_uri, '?'); if (p != NULL) *p = '\0'; p = rindex(dir_uri, '/'); if (p != NULL) p[1] = '\0'; content_type = getenv("CONTENT_TYPE"); 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; } cmd = GRSThttpGetCGI("cmd"); button = GRSThttpGetCGI("button"); file = GRSThttpGetCGI("file"); if ((index(file, '/') != NULL) || (index(file, '<') != NULL) || (index(file, '>') != NULL) || (index(file, '&') != NULL) || (index(file, '"') != NULL)) file[0] = '\0'; /* file and directory functions in grst_admin_file.c */ if (strcmp(cmd, "header") == 0) justheader(dn, perm, help_uri, dir_path, dir_uri, admin_file); else if (strcmp(cmd, "footer") == 0) justfooter(dn, perm, help_uri, dir_path, dir_uri, admin_file); else if (strcmp(cmd, "managedir") == 0) managedir(dn, perm, help_uri, dir_path, dir_uri, admin_file); else if (strcmp(cmd, "print") == 0) printfile(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "history") == 0) filehistory(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "managednlists") == 0) managednlists(user, dn, perm, help_uri, dir_path, dir_uri, admin_file); else if (strcmp(cmd, "editdnlist") == 0) editdnlistform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "edit") == 0) { if ((strcasecmp(button, "new directory") == 0) || (strcasecmp(button, "Create") == 0)) newdirectory(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else editfileform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); } else if (strcmp(cmd, "editaction") == 0) editfileaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "editdnlistaction") == 0) editdnlistaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "delete") == 0) deletefileform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "deleteaction") == 0) deletefileaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "rename") == 0) renameform(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "renameaction") == 0) renameaction(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "ziplist") == 0) ziplist(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "unzipfile") == 0) unzipfile(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "create_acl") == 0) create_acl(dn, perm, help_uri, dir_path, file, dir_uri, admin_file); /* GACL functions in grst_admin_gacl.c */ else if (strcmp(cmd, "show_acl") == 0) show_acl(0, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "admin_acl") == 0) show_acl(1, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "acl_history") == 0) show_acl(2, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd, "revert_acl") == 0) revert_acl(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); //show_acl(2, user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"new_entry_form")==0) new_entry_form(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"new_entry")==0) new_entry(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"del_entry_sure")==0) del_entry_sure(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"del_entry")==0) del_entry(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"edit_entry_form")==0) edit_entry_form(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"edit_entry")==0) edit_entry(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"add_cred_form")==0) add_cred_form(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"add_cred")==0) add_cred(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"del_cred_sure")==0) del_cred_sure(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); else if (strcmp(cmd,"del_cred")==0) del_cred(user, dn, perm, help_uri, dir_path, file, dir_uri, admin_file); /* you what? */ else GRSThttpError("500 Internal Server Error"); }