Blame modules/metadata/mod_usertrack.c

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/* User Tracking Module (Was mod_cookies.c)
Packit 90a5c9
 *
Packit 90a5c9
 * *** IMPORTANT NOTE: This module is not designed to generate
Packit 90a5c9
 * *** cryptographically secure cookies.  This means you should not
Packit 90a5c9
 * *** use cookies generated by this module for authentication purposes
Packit 90a5c9
 *
Packit 90a5c9
 * This Apache module is designed to track users paths through a site.
Packit 90a5c9
 * It uses the client-side state ("Cookie") protocol developed by Netscape.
Packit 90a5c9
 * It is known to work on most browsers.
Packit 90a5c9
 *
Packit 90a5c9
 * Each time a page is requested we look to see if the browser is sending
Packit 90a5c9
 * us a Cookie: header that we previously generated.
Packit 90a5c9
 *
Packit 90a5c9
 * If we don't find one then the user hasn't been to this site since
Packit 90a5c9
 * starting their browser or their browser doesn't support cookies.  So
Packit 90a5c9
 * we generate a unique Cookie for the transaction and send it back to
Packit 90a5c9
 * the browser (via a "Set-Cookie" header)
Packit 90a5c9
 * Future requests from the same browser should keep the same Cookie line.
Packit 90a5c9
 *
Packit 90a5c9
 * By matching up all the requests with the same cookie you can
Packit 90a5c9
 * work out exactly what path a user took through your site.  To log
Packit 90a5c9
 * the cookie use the " %{Cookie}n " directive in a custom access log;
Packit 90a5c9
 *
Packit 90a5c9
 * Example 1 : If you currently use the standard Log file format (CLF)
Packit 90a5c9
 * and use the command "TransferLog somefilename", add the line
Packit 90a5c9
 *       LogFormat "%h %l %u %t \"%r\" %s %b %{Cookie}n"
Packit 90a5c9
 * to your config file.
Packit 90a5c9
 *
Packit 90a5c9
 * Example 2 : If you used to use the old "CookieLog" directive, you
Packit 90a5c9
 * can emulate it by adding the following command to your config file
Packit 90a5c9
 *       CustomLog filename "%{Cookie}n \"%r\" %t"
Packit 90a5c9
 *
Packit 90a5c9
 * Mark Cox, mjc@apache.org, 6 July 95
Packit 90a5c9
 *
Packit 90a5c9
 * This file replaces mod_cookies.c
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#include "apr.h"
Packit 90a5c9
#include "apr_lib.h"
Packit 90a5c9
#include "apr_strings.h"
Packit 90a5c9
Packit 90a5c9
#define APR_WANT_STRFUNC
Packit 90a5c9
#include "apr_want.h"
Packit 90a5c9
Packit 90a5c9
#include "httpd.h"
Packit 90a5c9
#include "http_config.h"
Packit 90a5c9
#include "http_core.h"
Packit 90a5c9
#include "http_request.h"
Packit 90a5c9
#include "http_log.h"
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
module AP_MODULE_DECLARE_DATA usertrack_module;
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    int always;
Packit 90a5c9
    int expires;
Packit 90a5c9
} cookie_log_state;
Packit 90a5c9
Packit 90a5c9
typedef enum {
Packit 90a5c9
    CT_UNSET,
Packit 90a5c9
    CT_NETSCAPE,
Packit 90a5c9
    CT_COOKIE,
Packit 90a5c9
    CT_COOKIE2
Packit 90a5c9
} cookie_type_e;
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    int enabled;
Packit 90a5c9
    cookie_type_e style;
Packit 90a5c9
    const char *cookie_name;
Packit 90a5c9
    const char *cookie_domain;
Packit 90a5c9
    char *regexp_string;  /* used to compile regexp; save for debugging */
Packit 90a5c9
    ap_regex_t *regexp;  /* used to find usertrack cookie in cookie header */
Packit 90a5c9
} cookie_dir_rec;
Packit 90a5c9
Packit 90a5c9
/* Make Cookie: Now we have to generate something that is going to be
Packit 90a5c9
 * pretty unique.  We can base it on the pid, time, hostip */
Packit 90a5c9
Packit 90a5c9
#define COOKIE_NAME "Apache"
Packit 90a5c9
Packit 90a5c9
static void make_cookie(request_rec *r)
Packit 90a5c9
{
Packit 90a5c9
    cookie_log_state *cls = ap_get_module_config(r->server->module_config,
Packit 90a5c9
                                                 &usertrack_module);
Packit 90a5c9
    char cookiebuf[2 * (sizeof(apr_uint64_t) + sizeof(int)) + 2];
Packit 90a5c9
    unsigned int random;
Packit 90a5c9
    apr_time_t now = r->request_time ? r->request_time : apr_time_now();
Packit 90a5c9
    char *new_cookie;
Packit 90a5c9
    cookie_dir_rec *dcfg;
Packit 90a5c9
Packit 90a5c9
    ap_random_insecure_bytes(&random, sizeof(random));
Packit 90a5c9
    apr_snprintf(cookiebuf, sizeof(cookiebuf), "%x.%" APR_UINT64_T_HEX_FMT,
Packit 90a5c9
                 random, (apr_uint64_t)now);
Packit 90a5c9
    dcfg = ap_get_module_config(r->per_dir_config, &usertrack_module);
Packit 90a5c9
    if (cls->expires) {
Packit 90a5c9
Packit 90a5c9
        /* Cookie with date; as strftime '%a, %d-%h-%y %H:%M:%S GMT' */
Packit 90a5c9
        new_cookie = apr_psprintf(r->pool, "%s=%s; path=/",
Packit 90a5c9
                                  dcfg->cookie_name, cookiebuf);
Packit 90a5c9
Packit 90a5c9
        if ((dcfg->style == CT_UNSET) || (dcfg->style == CT_NETSCAPE)) {
Packit 90a5c9
            apr_time_exp_t tms;
Packit 90a5c9
            apr_time_exp_gmt(&tms, r->request_time
Packit 90a5c9
                                 + apr_time_from_sec(cls->expires));
Packit 90a5c9
            new_cookie = apr_psprintf(r->pool,
Packit 90a5c9
                                       "%s; expires=%s, "
Packit 90a5c9
                                       "%.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
Packit 90a5c9
                                       new_cookie, apr_day_snames[tms.tm_wday],
Packit 90a5c9
                                       tms.tm_mday,
Packit 90a5c9
                                       apr_month_snames[tms.tm_mon],
Packit 90a5c9
                                       tms.tm_year % 100,
Packit 90a5c9
                                       tms.tm_hour, tms.tm_min, tms.tm_sec);
Packit 90a5c9
        }
Packit 90a5c9
        else {
Packit 90a5c9
            new_cookie = apr_psprintf(r->pool, "%s; max-age=%d",
Packit 90a5c9
                                      new_cookie, cls->expires);
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
    else {
Packit 90a5c9
        new_cookie = apr_psprintf(r->pool, "%s=%s; path=/",
Packit 90a5c9
                                  dcfg->cookie_name, cookiebuf);
Packit 90a5c9
    }
Packit 90a5c9
    if (dcfg->cookie_domain != NULL) {
Packit 90a5c9
        new_cookie = apr_pstrcat(r->pool, new_cookie, "; domain=",
Packit 90a5c9
                                 dcfg->cookie_domain,
Packit 90a5c9
                                 (dcfg->style == CT_COOKIE2
Packit 90a5c9
                                  ? "; version=1"
Packit 90a5c9
                                  : ""),
Packit 90a5c9
                                 NULL);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    apr_table_addn(r->err_headers_out,
Packit 90a5c9
                   (dcfg->style == CT_COOKIE2 ? "Set-Cookie2" : "Set-Cookie"),
Packit 90a5c9
                   new_cookie);
Packit 90a5c9
    apr_table_setn(r->notes, "cookie", apr_pstrdup(r->pool, cookiebuf));   /* log first time */
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
/* dcfg->regexp is "^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)",
Packit 90a5c9
 * which has three subexpressions, $0..$2 */
Packit 90a5c9
#define NUM_SUBS 3
Packit 90a5c9
Packit 90a5c9
static void set_and_comp_regexp(cookie_dir_rec *dcfg,
Packit 90a5c9
                                apr_pool_t *p,
Packit 90a5c9
                                const char *cookie_name)
Packit 90a5c9
{
Packit 90a5c9
    int danger_chars = 0;
Packit 90a5c9
    const char *sp = cookie_name;
Packit 90a5c9
Packit 90a5c9
    /* The goal is to end up with this regexp,
Packit 90a5c9
     * ^cookie_name=([^;,]+)|[;,][ \t]+cookie_name=([^;,]+)
Packit 90a5c9
     * with cookie_name obviously substituted either
Packit 90a5c9
     * with the real cookie name set by the user in httpd.conf, or with the
Packit 90a5c9
     * default COOKIE_NAME. */
Packit 90a5c9
Packit 90a5c9
    /* Anyway, we need to escape the cookie_name before pasting it
Packit 90a5c9
     * into the regex
Packit 90a5c9
     */
Packit 90a5c9
    while (*sp) {
Packit 90a5c9
        if (!apr_isalnum(*sp)) {
Packit 90a5c9
            ++danger_chars;
Packit 90a5c9
        }
Packit 90a5c9
        ++sp;
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    if (danger_chars) {
Packit 90a5c9
        char *cp;
Packit 90a5c9
        cp = apr_palloc(p, sp - cookie_name + danger_chars + 1); /* 1 == \0 */
Packit 90a5c9
        sp = cookie_name;
Packit 90a5c9
        cookie_name = cp;
Packit 90a5c9
        while (*sp) {
Packit 90a5c9
            if (!apr_isalnum(*sp)) {
Packit 90a5c9
                *cp++ = '\\';
Packit 90a5c9
            }
Packit 90a5c9
            *cp++ = *sp++;
Packit 90a5c9
        }
Packit 90a5c9
        *cp = '\0';
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    dcfg->regexp_string = apr_pstrcat(p, "^",
Packit 90a5c9
                                      cookie_name,
Packit 90a5c9
                                      "=([^;,]+)|[;,][ \t]*",
Packit 90a5c9
                                      cookie_name,
Packit 90a5c9
                                      "=([^;,]+)", NULL);
Packit 90a5c9
Packit 90a5c9
    dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, AP_REG_EXTENDED);
Packit 90a5c9
    ap_assert(dcfg->regexp != NULL);
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static int spot_cookie(request_rec *r)
Packit 90a5c9
{
Packit 90a5c9
    cookie_dir_rec *dcfg = ap_get_module_config(r->per_dir_config,
Packit 90a5c9
                                                &usertrack_module);
Packit 90a5c9
    const char *cookie_header;
Packit 90a5c9
    ap_regmatch_t regm[NUM_SUBS];
Packit 90a5c9
Packit 90a5c9
    /* Do not run in subrequests */
Packit 90a5c9
    if (!dcfg->enabled || r->main) {
Packit 90a5c9
        return DECLINED;
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    if ((cookie_header = apr_table_get(r->headers_in, "Cookie"))) {
Packit 90a5c9
        if (!ap_regexec(dcfg->regexp, cookie_header, NUM_SUBS, regm, 0)) {
Packit 90a5c9
            char *cookieval = NULL;
Packit 90a5c9
            int err = 0;
Packit 90a5c9
            /* Our regexp,
Packit 90a5c9
             * ^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)
Packit 90a5c9
             * only allows for $1 or $2 to be available. ($0 is always
Packit 90a5c9
             * filled with the entire matched expression, not just
Packit 90a5c9
             * the part in parentheses.) So just check for either one
Packit 90a5c9
             * and assign to cookieval if present. */
Packit 90a5c9
            if (regm[1].rm_so != -1) {
Packit 90a5c9
                cookieval = ap_pregsub(r->pool, "$1", cookie_header,
Packit 90a5c9
                                       NUM_SUBS, regm);
Packit 90a5c9
                if (cookieval == NULL)
Packit 90a5c9
                    err = 1;
Packit 90a5c9
            }
Packit 90a5c9
            if (regm[2].rm_so != -1) {
Packit 90a5c9
                cookieval = ap_pregsub(r->pool, "$2", cookie_header,
Packit 90a5c9
                                       NUM_SUBS, regm);
Packit 90a5c9
                if (cookieval == NULL)
Packit 90a5c9
                    err = 1;
Packit 90a5c9
            }
Packit 90a5c9
            if (err) {
Packit 90a5c9
                ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, APLOGNO(01499)
Packit 90a5c9
                              "Failed to extract cookie value (out of mem?)");
Packit 90a5c9
                return HTTP_INTERNAL_SERVER_ERROR;
Packit 90a5c9
            }
Packit 90a5c9
            /* Set the cookie in a note, for logging */
Packit 90a5c9
            apr_table_setn(r->notes, "cookie", cookieval);
Packit 90a5c9
Packit 90a5c9
            return DECLINED;    /* There's already a cookie, no new one */
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
    make_cookie(r);
Packit 90a5c9
    return OK;                  /* We set our cookie */
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static void *make_cookie_log_state(apr_pool_t *p, server_rec *s)
Packit 90a5c9
{
Packit 90a5c9
    cookie_log_state *cls =
Packit 90a5c9
    (cookie_log_state *) apr_palloc(p, sizeof(cookie_log_state));
Packit 90a5c9
Packit 90a5c9
    cls->expires = 0;
Packit 90a5c9
Packit 90a5c9
    return (void *) cls;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static void *make_cookie_dir(apr_pool_t *p, char *d)
Packit 90a5c9
{
Packit 90a5c9
    cookie_dir_rec *dcfg;
Packit 90a5c9
Packit 90a5c9
    dcfg = (cookie_dir_rec *) apr_pcalloc(p, sizeof(cookie_dir_rec));
Packit 90a5c9
    dcfg->cookie_name = COOKIE_NAME;
Packit 90a5c9
    dcfg->cookie_domain = NULL;
Packit 90a5c9
    dcfg->style = CT_UNSET;
Packit 90a5c9
    dcfg->enabled = 0;
Packit 90a5c9
Packit 90a5c9
    /* In case the user does not use the CookieName directive,
Packit 90a5c9
     * we need to compile the regexp for the default cookie name. */
Packit 90a5c9
    set_and_comp_regexp(dcfg, p, COOKIE_NAME);
Packit 90a5c9
Packit 90a5c9
    return dcfg;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static const char *set_cookie_enable(cmd_parms *cmd, void *mconfig, int arg)
Packit 90a5c9
{
Packit 90a5c9
    cookie_dir_rec *dcfg = mconfig;
Packit 90a5c9
Packit 90a5c9
    dcfg->enabled = arg;
Packit 90a5c9
    return NULL;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static const char *set_cookie_exp(cmd_parms *parms, void *dummy,
Packit 90a5c9
                                  const char *arg)
Packit 90a5c9
{
Packit 90a5c9
    cookie_log_state *cls;
Packit 90a5c9
    time_t factor, modifier = 0;
Packit 90a5c9
    time_t num = 0;
Packit 90a5c9
    char *word;
Packit 90a5c9
Packit 90a5c9
    cls  = ap_get_module_config(parms->server->module_config,
Packit 90a5c9
                                &usertrack_module);
Packit 90a5c9
    /* The simple case first - all numbers (we assume) */
Packit 90a5c9
    if (apr_isdigit(arg[0]) && apr_isdigit(arg[strlen(arg) - 1])) {
Packit 90a5c9
        cls->expires = atol(arg);
Packit 90a5c9
        return NULL;
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    /*
Packit 90a5c9
     * The harder case - stolen from mod_expires
Packit 90a5c9
     *
Packit 90a5c9
     * CookieExpires "[plus] {<num> <type>}*"
Packit 90a5c9
     */
Packit 90a5c9
Packit 90a5c9
    word = ap_getword_conf(parms->temp_pool, &arg;;
Packit 90a5c9
    if (!strncasecmp(word, "plus", 1)) {
Packit 90a5c9
        word = ap_getword_conf(parms->temp_pool, &arg;;
Packit 90a5c9
    };
Packit 90a5c9
Packit 90a5c9
    /* {<num> <type>}* */
Packit 90a5c9
    while (word[0]) {
Packit 90a5c9
        /* <num> */
Packit 90a5c9
        if (apr_isdigit(word[0]))
Packit 90a5c9
            num = atoi(word);
Packit 90a5c9
        else
Packit 90a5c9
            return "bad expires code, numeric value expected.";
Packit 90a5c9
Packit 90a5c9
        /* <type> */
Packit 90a5c9
        word = ap_getword_conf(parms->temp_pool, &arg;;
Packit 90a5c9
        if (!word[0])
Packit 90a5c9
            return "bad expires code, missing <type>";
Packit 90a5c9
Packit 90a5c9
        if (!strncasecmp(word, "years", 1))
Packit 90a5c9
            factor = 60 * 60 * 24 * 365;
Packit 90a5c9
        else if (!strncasecmp(word, "months", 2))
Packit 90a5c9
            factor = 60 * 60 * 24 * 30;
Packit 90a5c9
        else if (!strncasecmp(word, "weeks", 1))
Packit 90a5c9
            factor = 60 * 60 * 24 * 7;
Packit 90a5c9
        else if (!strncasecmp(word, "days", 1))
Packit 90a5c9
            factor = 60 * 60 * 24;
Packit 90a5c9
        else if (!strncasecmp(word, "hours", 1))
Packit 90a5c9
            factor = 60 * 60;
Packit 90a5c9
        else if (!strncasecmp(word, "minutes", 2))
Packit 90a5c9
            factor = 60;
Packit 90a5c9
        else if (!strncasecmp(word, "seconds", 1))
Packit 90a5c9
            factor = 1;
Packit 90a5c9
        else
Packit 90a5c9
            return "bad expires code, unrecognized type";
Packit 90a5c9
Packit 90a5c9
        modifier = modifier + factor * num;
Packit 90a5c9
Packit 90a5c9
        /* next <num> */
Packit 90a5c9
        word = ap_getword_conf(parms->temp_pool, &arg;;
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    cls->expires = modifier;
Packit 90a5c9
Packit 90a5c9
    return NULL;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static const char *set_cookie_name(cmd_parms *cmd, void *mconfig,
Packit 90a5c9
                                   const char *name)
Packit 90a5c9
{
Packit 90a5c9
    cookie_dir_rec *dcfg = (cookie_dir_rec *) mconfig;
Packit 90a5c9
Packit 90a5c9
    dcfg->cookie_name = name;
Packit 90a5c9
Packit 90a5c9
    set_and_comp_regexp(dcfg, cmd->pool, name);
Packit 90a5c9
Packit 90a5c9
    if (dcfg->regexp == NULL) {
Packit 90a5c9
        return "Regular expression could not be compiled.";
Packit 90a5c9
    }
Packit 90a5c9
    if (dcfg->regexp->re_nsub + 1 != NUM_SUBS) {
Packit 90a5c9
        return apr_pstrcat(cmd->pool, "Invalid cookie name \"",
Packit 90a5c9
                           name, "\"", NULL);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    return NULL;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * Set the value for the 'Domain=' attribute.
Packit 90a5c9
 */
Packit 90a5c9
static const char *set_cookie_domain(cmd_parms *cmd, void *mconfig,
Packit 90a5c9
                                     const char *name)
Packit 90a5c9
{
Packit 90a5c9
    cookie_dir_rec *dcfg;
Packit 90a5c9
Packit 90a5c9
    dcfg = (cookie_dir_rec *) mconfig;
Packit 90a5c9
Packit 90a5c9
    /*
Packit 90a5c9
     * Apply the restrictions on cookie domain attributes.
Packit 90a5c9
     */
Packit 90a5c9
    if (!name[0]) {
Packit 90a5c9
        return "CookieDomain values may not be null";
Packit 90a5c9
    }
Packit 90a5c9
    if (name[0] != '.') {
Packit 90a5c9
        return "CookieDomain values must begin with a dot";
Packit 90a5c9
    }
Packit 90a5c9
    if (ap_strchr_c(&name[1], '.') == NULL) {
Packit 90a5c9
        return "CookieDomain values must contain at least one embedded dot";
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    dcfg->cookie_domain = name;
Packit 90a5c9
    return NULL;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * Make a note of the cookie style we should use.
Packit 90a5c9
 */
Packit 90a5c9
static const char *set_cookie_style(cmd_parms *cmd, void *mconfig,
Packit 90a5c9
                                    const char *name)
Packit 90a5c9
{
Packit 90a5c9
    cookie_dir_rec *dcfg;
Packit 90a5c9
Packit 90a5c9
    dcfg = (cookie_dir_rec *) mconfig;
Packit 90a5c9
Packit 90a5c9
    if (strcasecmp(name, "Netscape") == 0) {
Packit 90a5c9
        dcfg->style = CT_NETSCAPE;
Packit 90a5c9
    }
Packit 90a5c9
    else if ((strcasecmp(name, "Cookie") == 0)
Packit 90a5c9
             || (strcasecmp(name, "RFC2109") == 0)) {
Packit 90a5c9
        dcfg->style = CT_COOKIE;
Packit 90a5c9
    }
Packit 90a5c9
    else if ((strcasecmp(name, "Cookie2") == 0)
Packit 90a5c9
             || (strcasecmp(name, "RFC2965") == 0)) {
Packit 90a5c9
        dcfg->style = CT_COOKIE2;
Packit 90a5c9
    }
Packit 90a5c9
    else {
Packit 90a5c9
        return apr_psprintf(cmd->pool, "Invalid %s keyword: '%s'",
Packit 90a5c9
                            cmd->cmd->name, name);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    return NULL;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static const command_rec cookie_log_cmds[] = {
Packit 90a5c9
    AP_INIT_TAKE1("CookieExpires", set_cookie_exp, NULL, OR_FILEINFO,
Packit 90a5c9
                  "an expiry date code"),
Packit 90a5c9
    AP_INIT_TAKE1("CookieDomain", set_cookie_domain, NULL, OR_FILEINFO,
Packit 90a5c9
                  "domain to which this cookie applies"),
Packit 90a5c9
    AP_INIT_TAKE1("CookieStyle", set_cookie_style, NULL, OR_FILEINFO,
Packit 90a5c9
                  "'Netscape', 'Cookie' (RFC2109), or 'Cookie2' (RFC2965)"),
Packit 90a5c9
    AP_INIT_FLAG("CookieTracking", set_cookie_enable, NULL, OR_FILEINFO,
Packit 90a5c9
                 "whether or not to enable cookies"),
Packit 90a5c9
    AP_INIT_TAKE1("CookieName", set_cookie_name, NULL, OR_FILEINFO,
Packit 90a5c9
                  "name of the tracking cookie"),
Packit 90a5c9
    {NULL}
Packit 90a5c9
};
Packit 90a5c9
Packit 90a5c9
static void register_hooks(apr_pool_t *p)
Packit 90a5c9
{
Packit 90a5c9
    ap_hook_fixups(spot_cookie,NULL,NULL,APR_HOOK_REALLY_FIRST);
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
AP_DECLARE_MODULE(usertrack) = {
Packit 90a5c9
    STANDARD20_MODULE_STUFF,
Packit 90a5c9
    make_cookie_dir,            /* dir config creater */
Packit 90a5c9
    NULL,                       /* dir merger --- default is to override */
Packit 90a5c9
    make_cookie_log_state,      /* server config */
Packit 90a5c9
    NULL,                       /* merge server configs */
Packit 90a5c9
    cookie_log_cmds,            /* command apr_table_t */
Packit 90a5c9
    register_hooks              /* register hooks */
Packit 90a5c9
};