Return-Path: Delivered-To: apache-bugdb-archive@hyperreal.org Received: (qmail 17323 invoked by uid 6000); 23 Nov 1999 23:40:14 -0000 Received: (qmail 17036 invoked by uid 2001); 23 Nov 1999 23:40:04 -0000 Received: (qmail 8884 invoked by uid 2012); 23 Nov 1999 23:35:05 -0000 Message-Id: <19991123233505.8882.qmail@hyperreal.org> Date: 23 Nov 1999 23:35:05 -0000 From: Alain Hebert Reply-To: ahebert@pubnix.net To: apbugs@hyperreal.org X-Send-Pr-Version: 3.2 Subject: mod_usertrack/5356: Turn the expiry cookie into a timeout Sender: apache-bugdb-owner@apache.org Precedence: bulk >Number: 5356 >Category: mod_usertrack >Synopsis: Turn the expiry cookie into a timeout >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: open >Class: change-request >Submitter-Id: apache >Arrival-Date: Tue Nov 23 15:40:02 PST 1999 >Last-Modified: >Originator: ahebert@pubnix.net >Organization: apache >Release: 1.3.9 >Environment: Any >Description: In order to determine when a new session start and finishs the Expiry must be updated every request. Thus changing the meaning of the CookieExpiry value into more like a timeout. To do so I've patched (very lightly) mod_usertrack.c to add CookeExtend (extending the expiry). Please let me know... >How-To-Repeat: http://aal.pubnix.net/cookie_demo >Fix: *** mod_usertrack.c.orig Tue Nov 23 18:23:50 1999 --- mod_usertrack.c Tue Nov 23 17:52:11 1999 *************** *** 116,119 **** --- 116,120 ---- typedef struct { int enabled; + int extend; char *cookie_name; } cookie_dir_rec; *************** *** 129,133 **** #define COOKIE_NAME "Apache" ! static void make_cookie(request_rec *r) { cookie_log_state *cls = ap_get_module_config(r->server->module_config, --- 130,134 ---- #define COOKIE_NAME "Apache" ! static void make_cookie(request_rec *r,int extend) { cookie_log_state *cls = ap_get_module_config(r->server->module_config, *************** *** 146,152 **** --- 147,158 ---- REMOTE_NAME); cookie_dir_rec *dcfg; + const char *cookie; + char *value; + char *cookieend; dcfg = ap_get_module_config(r->per_dir_config, &usertrack_module); + if (!extend) + { #if defined(NO_GETTIMEOFDAY) && !defined(NO_TIMES) /* We lack gettimeofday(), so we must use time() to obtain the epoch *************** *** 177,180 **** --- 183,200 ---- (long) tv.tv_sec, (int) tv.tv_usec / 1000); #endif + } + else + { + if ((cookie = ap_table_get(r->headers_in, "Cookie"))) + if ((value = strstr(cookie, dcfg->cookie_name))) + { + value += strlen(dcfg->cookie_name) + 1; /* Skip over the '=' */ + ap_snprintf(cookiebuf, sizeof(cookiebuf), + ap_pstrdup(r->pool, value)); + cookieend = strchr(cookiebuf, ';'); + if (cookieend) + *cookieend = '\0'; /* Ignore anything after a ; */ + } + } if (cls->expires) { *************** *** 236,242 **** ap_table_setn(r->notes, "cookie", cookiebuf); ! return DECLINED; /* There's already a cookie, no new one */ } ! make_cookie(r); return OK; /* We set our cookie */ } --- 256,268 ---- ap_table_setn(r->notes, "cookie", cookiebuf); ! if (dcfg->extend) ! { ! make_cookie(r,dcfg->extend); ! return OK; /* We set our cookie */ ! } ! else ! return DECLINED; /* There's already a cookie, no new one */ } ! make_cookie(r,0); return OK; /* We set our cookie */ } *************** *** 270,273 **** --- 296,307 ---- } + static const char *set_cookie_extend(cmd_parms *cmd, void *mconfig, int arg) + { + cookie_dir_rec *dcfg = mconfig; + + dcfg->extend = arg; + return NULL; + } + static const char *set_cookie_exp(cmd_parms *parms, void *dummy, const char *a rg) { *************** *** 348,351 **** --- 382,387 ---- {"CookieExpires", set_cookie_exp, NULL, RSRC_CONF, TAKE1, "an expiry date code"}, + {"CookieExtend", set_cookie_extend, NULL, OR_FILEINFO, FLAG, + "whether or not to extend the expiry of un-expired cookies"}, {"CookieTracking", set_cookie_enable, NULL, OR_FILEINFO, FLAG, "whether or not to enable cookies"}, >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]