From 3c53fc835b6e3b3387e7827ccb6aa7e6d6e6568d Mon Sep 17 00:00:00 2001 From: Andrew McNab Date: Thu, 16 Mar 2006 23:50:44 +0000 Subject: [PATCH] Onetime passcode and 200/201 fixes --- org.gridsite.core/CHANGES | 3 +++ org.gridsite.core/VERSION | 2 +- org.gridsite.core/src/htcp.c | 6 ----- org.gridsite.core/src/mod_gridsite.c | 44 +++++++++++++++++++++++------------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/org.gridsite.core/CHANGES b/org.gridsite.core/CHANGES index e637fdd..154c0a0 100644 --- a/org.gridsite.core/CHANGES +++ b/org.gridsite.core/CHANGES @@ -1,3 +1,6 @@ +* Thu Mar 16 2006 Andrew McNab +- Fixes for 200/201 error pages produced by Apache +- Fixes for onetime passcode non-removal if HTTPS * Fri Mar 03 2006 Shiv Kaushal - Modify GridSiteDelegationURI directive to insert HTTP headers instead of modifying HTML diff --git a/org.gridsite.core/VERSION b/org.gridsite.core/VERSION index 099f252..6de3614 100644 --- a/org.gridsite.core/VERSION +++ b/org.gridsite.core/VERSION @@ -1,4 +1,4 @@ MAJOR_VERSION=1 MINOR_VERSION=1.1 -PATCH_VERSION=1.1.15 +PATCH_VERSION=1.1.17 VERSION=$(PATCH_VERSION) diff --git a/org.gridsite.core/src/htcp.c b/org.gridsite.core/src/htcp.c index 3fd4b11..9c8edb7 100644 --- a/org.gridsite.core/src/htcp.c +++ b/org.gridsite.core/src/htcp.c @@ -526,7 +526,6 @@ int do_copies(char *sources[], char *destination, } if ((thiserror != 0) || - (header_data.retcode < 200) || (header_data.retcode >= 300)) { fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", @@ -580,7 +579,6 @@ int do_deletes(char *sources[], struct grst_stream_data *common_data) thiserror = curl_easy_perform(easyhandle); if ((thiserror != 0) || - (header_data.retcode < 200) || (header_data.retcode >= 300)) { fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", @@ -639,7 +637,6 @@ int do_move(char *source, char *destination, thiserror = curl_easy_perform(easyhandle); if ((thiserror != 0) || - (header_data.retcode < 200) || (header_data.retcode >= 300)) { fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", @@ -690,7 +687,6 @@ int do_mkdirs(char *sources[], struct grst_stream_data *common_data) thiserror = curl_easy_perform(easyhandle); if ((thiserror != 0) || - (header_data.retcode < 200) || (header_data.retcode >= 300)) { fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", @@ -1400,7 +1396,6 @@ int do_listings(char *sources[], struct grst_stream_data *common_data, thiserror = curl_easy_perform(easyhandle); if ((thiserror != 0) || - (header_data.retcode < 200) || (header_data.retcode >= 300)) { fprintf(stderr, "... curl error: %s (%d), HTTP error: %d\n", @@ -1834,7 +1829,6 @@ int main(int argc, char *argv[]) else if (strcmp(executable,"htrmtcp")==0) common_data.method=HTCP_RMTCP; } -printf("%d\n", common_data.method); if (common_data.method == HTCP_PING) { if (common_data.groups != NULL) return do_ping(&common_data); diff --git a/org.gridsite.core/src/mod_gridsite.c b/org.gridsite.core/src/mod_gridsite.c index 03e5fa5..3404939 100644 --- a/org.gridsite.core/src/mod_gridsite.c +++ b/org.gridsite.core/src/mod_gridsite.c @@ -996,17 +996,17 @@ int http_gridhttp(request_rec *r, mod_gridsite_dir_cfg *conf) APR_CREATE | APR_WRITE | APR_EXCL, r->pool) != APR_SUCCESS) return HTTP_INTERNAL_SERVER_ERROR; - + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Created passcode file %s", filetemplate); - expires_time = apr_time_now() + apr_time_from_sec(3600); - /* passcode cookies are valid for only 60 mins! */ + expires_time = apr_time_now() + apr_time_from_sec(300); + /* passcode cookies are valid for only 5 mins! */ - apr_file_printf(fp, - "expires=%lu\ndomain=%s\npath=%s\nmethod=%s\n", - (time_t) apr_time_sec(expires_time), - r->hostname, r->uri, r->method); + apr_file_printf(fp, + "expires=%lu\ndomain=%s\npath=%s\nonetime=yes\nmethod=%s\n", + (time_t) apr_time_sec(expires_time), + r->hostname, r->uri, r->method); /* above variables are evaluated in order and method= MUST be last! */ for (i=0; ; ++i) @@ -1153,7 +1153,11 @@ int http_put_method(request_rec *r, mod_gridsite_dir_cfg *conf) if (apr_file_close(fp) != 0) return HTTP_INTERNAL_SERVER_ERROR; - if (retcode == OK) retcode = (stat_ret == 0) ? HTTP_OK : HTTP_CREATED; + if ((retcode == OK) && (stat_ret != 0)) + { + retcode = HTTP_CREATED; + ap_custom_response(r, HTTP_CREATED, ""); + } return retcode; } @@ -1642,7 +1646,7 @@ static void *create_gridsite_srv_config(apr_pool_t *p, server_rec *s) { gridhttpport = GRST_HTTP_PORT; - passcodesdir = apr_pstrdup(p, "/var/www/passcodes"); + passcodesdir = apr_pstrdup(p, "/var/www/onetimes"); /* GridSiteOnetimesDir dir-path */ sitecastdnlists = NULL; @@ -2275,9 +2279,9 @@ static int mod_gridsite_perm_handler(request_rec *r) */ { int retcode = DECLINED, i, n, file_is_acl = 0, - destination_is_acl = 0, proxylevel; + destination_is_acl = 0, proxylevel, ishttps = 0; char *dn, *p, envname[14], *grst_cred_0 = NULL, *dir_path, - *remotehost, s[99], *grst_cred_i, *cookies, *file, + *remotehost, s[99], *grst_cred_i, *cookies, *file, *https, *gridauthpasscode = NULL, *cookiefile, oneline[1025], *key_i, *destination = NULL, *destination_uri = NULL, *querytmp, *destination_prefix = NULL, *destination_translated = NULL; @@ -2307,6 +2311,9 @@ static int mod_gridsite_perm_handler(request_rec *r) env = r->subprocess_env; + p = (char *) apr_table_get(r->subprocess_env, "HTTPS"); + if ((p != NULL) && (strcmp(p, "on") == 0)) ishttps = 1; + /* do we need/have per-connection (SSL) cred variable(s)? */ sslconn = (SSLConnRec *) ap_get_module_config(r->connection->conn_config, @@ -2459,7 +2466,9 @@ static int mod_gridsite_perm_handler(request_rec *r) if (gridauthpasscode != NULL) { - for (p = &gridauthpasscode[18]; + gridauthpasscode = &gridauthpasscode[19]; + + for (p = gridauthpasscode; (*p != '\0') && (*p != ';'); ++p) if (!isalnum(*p)) *p = '\0'; } @@ -2475,9 +2484,11 @@ static int mod_gridsite_perm_handler(request_rec *r) gridauthpasscode = strstr(querytmp, "&GRIDHTTP_PASSCODE="); - if (gridauthpasscode != NULL) + if (gridauthpasscode != NULL) { - for (p = &gridauthpasscode[18]; + gridauthpasscode = &gridauthpasscode[19]; + + for (p = gridauthpasscode; (*p != '\0') && (*p != '&'); ++p) if (!isalnum(*p)) *p = '\0'; } @@ -2489,7 +2500,7 @@ static int mod_gridsite_perm_handler(request_rec *r) cookiefile = apr_psprintf(r->pool, "%s/%s", ap_server_root_relative(r->pool, passcodesdir), - &gridauthpasscode[18]); + gridauthpasscode); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Opening GridHTTP passcode file %s", cookiefile); @@ -2522,7 +2533,8 @@ static int mod_gridsite_perm_handler(request_rec *r) else if ((strncmp(oneline, "path=", 5) == 0) && (strcmp(&oneline[5], r->uri) != 0)) break; - else if (strncmp(oneline, "onetime=yes", 11) == 0) + else if ((strncmp(oneline, "onetime=yes", 11) == 0) + && !ishttps) apr_file_remove(cookiefile, r->pool); else if (strncmp(oneline, "method=PUT", 10) == 0) perm |= GRST_PERM_WRITE; -- 1.8.2.3