From 1c98bfec22d96aaafe156e55e19aa8087ff14cc6 Mon Sep 17 00:00:00 2001 From: Shiv Kaushal Date: Fri, 3 Mar 2006 11:52:15 +0000 Subject: [PATCH] GridSiteDelegationURI updated --- org.gridsite.core/CHANGES | 5 ++- org.gridsite.core/src/mod_gridsite.c | 76 ++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/org.gridsite.core/CHANGES b/org.gridsite.core/CHANGES index a3f314d..e637fdd 100644 --- a/org.gridsite.core/CHANGES +++ b/org.gridsite.core/CHANGES @@ -1,4 +1,7 @@ -* Mon Feb 6 2005 Shiv Kaushal +* Fri Mar 03 2006 Shiv Kaushal +- Modify GridSiteDelegationURI directive to insert HTTP + headers instead of modifying HTML +* Mon Feb 6 2006 Shiv Kaushal - Add GridSiteDelegationURI directive to mod_gridsite to allow Firefox extension to locate delegation service * Thu Jan 12 2005 Andrew McNab diff --git a/org.gridsite.core/src/mod_gridsite.c b/org.gridsite.core/src/mod_gridsite.c index ae4ada7..03e5fa5 100644 --- a/org.gridsite.core/src/mod_gridsite.c +++ b/org.gridsite.core/src/mod_gridsite.c @@ -586,21 +586,22 @@ char *make_admin_footer(request_rec *r, mod_gridsite_dir_cfg *conf, out = apr_pstrcat(r->pool, out, temp, NULL); } - if (conf->delegationuri) - { - temp = apr_psprintf(r->pool, - "
Delegation service active\n", - r->server->server_hostname, conf->delegationuri); - out = apr_pstrcat(r->pool, out, temp, NULL); - - } out = apr_pstrcat(r->pool, out, "\n\n", NULL); return out; } +void delegation_header(request_rec *r, mod_gridsite_dir_cfg *conf){ + + apr_table_add(r->headers_out, + apr_pstrdup(r->pool, "Grst-Delegation-Service"), + apr_psprintf(r->pool,"https://%s%s", r->hostname, conf->delegationuri)); + return; + +} + int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) -/* +/* try to do GridSite formatting of .html files (NOT .shtml etc) */ { @@ -610,12 +611,16 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) size_t length; struct stat statbuf; apr_file_t *fp; - + if (r->finfo.filetype == APR_NOFILE) return HTTP_NOT_FOUND; - + if (apr_file_open(&fp, r->filename, APR_READ, 0, r->pool) != 0) return HTTP_INTERNAL_SERVER_ERROR; - + + + /* Put in Delegation service header if required */ + if (conf->delegationuri) delegation_header(r, conf); + file = rindex(r->uri, '/'); if (file != NULL) ++file; /* file points to name without path */ @@ -631,7 +636,7 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) fd = -1; s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); strcpy(s, r->filename); - + for (;;) { p = rindex(s, '/'); @@ -644,7 +649,7 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; } - + free(s); if (fd == -1) /* not found, so set up not to output one */ @@ -665,7 +670,7 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) if (p == NULL) p = strstr(buf, "pool, ""); body_formatted = buf; @@ -675,7 +680,7 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; head_formatted = buf; ++p; - + while ((*p != '>') && (*p != '\0')) ++p; if (*p == '\0') @@ -687,7 +692,7 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; ++p; body_formatted = p; - } + } } } @@ -696,38 +701,38 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) p = strstr(body_formatted, "filename) + strlen(conf->footfile)); strcpy(s, r->filename); - + for (;;) { p = rindex(s, '/'); if (p == NULL) break; /* failed to find one */ - + p[1] = '\0'; strcat(p, conf->footfile); - + fd = open(s, O_RDONLY); if (fd != -1) break; /* found one */ *p = '\0'; } - + free(s); if (fd == -1) /* failed to find a footer, so set up empty default */ - { + { footer_formatted = apr_pstrdup(r->pool, ""); } else /* found a footer, so set up to use it */ @@ -740,8 +745,8 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) } /* **** can now calculate the Content-Length and output headers **** */ - - length = strlen(head_formatted) + strlen(header_formatted) + + + length = strlen(head_formatted) + strlen(header_formatted) + strlen(body_formatted) + strlen(admin_formatted) + strlen(footer_formatted); @@ -776,7 +781,11 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) if (r->finfo.filetype == APR_NOFILE) return HTTP_NOT_FOUND; - head_formatted = apr_psprintf(r->pool, + + /* Put in Delegation service header if required */ + if (conf->delegationuri) delegation_header(r, conf); + + head_formatted = apr_psprintf(r->pool, "Directory listing %s\n", r->uri); if (conf->format) @@ -787,7 +796,7 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) fd = -1; s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); strcpy(s, r->filename); - + for (;;) { p = rindex(s, '/'); @@ -1198,7 +1207,6 @@ static int mod_gridsite_dir_handler(request_rec *r, mod_gridsite_dir_cfg *conf) } /* *** directory listing? *** */ - if ((r->method_number == M_GET) && (conf->indexes)) return html_dir_list(r, conf); /* directory listing */ @@ -2003,10 +2011,10 @@ static const char *mod_gridsite_take1_cmds(cmd_parms *a, void *cfg, { if (*parm != '/') return "GridSiteDelegationURI must begin with /"; - if (*parm != '\0') + if (*parm != '\0') ((mod_gridsite_dir_cfg *) cfg)->delegationuri = apr_pstrdup(a->pool, parm); - + } else if (strcasecmp(a->cmd->name, "GridSiteExecMethod") == 0) { @@ -2015,12 +2023,12 @@ static const char *mod_gridsite_take1_cmds(cmd_parms *a, void *cfg, ((mod_gridsite_dir_cfg *) cfg)->execmethod = NULL; return NULL; } - + if ((strcasecmp(parm, "suexec") != 0) && (strcasecmp(parm, "X509DN") != 0) && (strcasecmp(parm, "directory") != 0)) return "GridsiteExecMethod must be nosetuid, suexec, X509DN or directory"; - + ((mod_gridsite_dir_cfg *) cfg)->execmethod = apr_pstrdup(a->pool, parm); } @@ -2184,7 +2192,7 @@ static const command_rec mod_gridsite_cmds[] = NULL, OR_FILEINFO, "format to save access control lists in"), AP_INIT_TAKE1("GridSiteDelegationURI", mod_gridsite_take1_cmds, - NULL, OR_FILEINFO, "location of the delegation service CGI"), + NULL, OR_FILEINFO, "URI of the delegation service CGI"), AP_INIT_TAKE1("GridSiteExecMethod", mod_gridsite_take1_cmds, NULL, OR_FILEINFO, "execution strategy used by gsexec"), -- 1.8.2.3