Received: by taz.hyperreal.com (8.6.12/8.6.5) id LAA19553; Sun, 31 Mar 1996 11:17:31 -0800 Received: from deliverator.io.com by taz.hyperreal.com (8.6.12/8.6.5) with ESMTP id LAA19545; Sun, 31 Mar 1996 11:17:28 -0800 Received: from shangri-la.io.com (cloos@shangri-la.io.com [199.170.88.8]) by deliverator.io.com (8.7.5/8.7.3) with ESMTP id MAA23682 for ; Sun, 31 Mar 1996 12:49:15 -0600 (CST) Received: (cloos@localhost) by shangri-la.io.com (8.7.4/8.6.12) id MAA18763; Sun, 31 Mar 1996 12:49:14 -0600 Date: Sun, 31 Mar 1996 12:49:14 -0600 Message-Id: <199603311849.MAA18763@shangri-la.io.com> From: "James H. Cloos Jr." To: new-httpd@hyperreal.com Subject: Patch for mod_cookies.c Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com This patch allows the cookie log to go to a pipe rather than just to a file. The new code was taken from mod_log_agent.c. BTW, the CookieLog is still not quite right. It is failing to put the \0 at the right spot when creating the line for the log. The result is alternate lines with valid log entries and a fragment from the end of a log entry. The fragment is always of the form: ``-600] -'', where -600 is our tz. The patch below is running on our server now w/o any new problem (cf above). I'd appreciate it if someone w/ CVS privs were to comit it. As you can see, I even copied agent_log_child()'s comment into cookie_log_child(). This should of course become a function in util.c. I'll work on a patch that does that this week, unless someone does it first. ------------------------------------------------------------ # diff -C3 ../../apache_19960321140014/src/mod_cookies.c mod_cookies.c *** ../../apache_19960321140014/src/mod_cookies.c Thu Mar 21 12:28:52 1996 --- mod_cookies.c Sun Mar 31 12:07:40 1996 *************** *** 81,86 **** --- 81,90 ---- * * 18.3.96 MJC Generate cookies for EVERY request no matter what the * browser. + * + * 96/03/31 -JimC Allow the log to be sent to a pipe. Copies the relevant + * code from mod_log_agent.c. + * */ #include "httpd.h" *************** *** 166,171 **** --- 170,188 ---- { NULL } }; + void cookie_log_child (void *cmd) + { + /* Child process code for 'CookieLog "|..."'; + * may want a common framework for this, since I expect it will + * be common for other foo-loggers to want this sort of thing... + */ + + cleanup_for_exec(); + signal (SIGHUP, SIG_IGN); + execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); + exit (1); + } + void open_cookie_log (server_rec *s, pool *p) { cookie_log_state *cls = get_module_config (s->module_config, *************** *** 173,179 **** char *fname = server_root_relative (p, cls->fname); if (cls->log_fd > 0) return; ! if(*cls->fname != '\0') { if((cls->log_fd = popenf(p, fname, cookie_flags, cookie_mode)) < 0) { fprintf(stderr, "httpd: could not open cookie log file %s.\n", fname); perror("open"); --- 190,210 ---- char *fname = server_root_relative (p, cls->fname); if (cls->log_fd > 0) return; ! ! if (*cls->fname == '|') { ! FILE *dummy; ! ! spawn_child(p, cookie_log_child, (void *)(cls->fname+1), ! kill_after_timeout, &dummy, NULL); ! ! if (dummy == NULL) { ! fprintf (stderr, "Couldn't fork child for CookieLog process\n"); ! exit (1); ! } ! ! cls->log_fd = fileno (dummy); ! } ! else if(*cls->fname != '\0') { if((cls->log_fd = popenf(p, fname, cookie_flags, cookie_mode)) < 0) { fprintf(stderr, "httpd: could not open cookie log file %s.\n", fname); perror("open"); ------------------------------------------------------------ -JimC -- James H. Cloos, Jr. cloos@jhcloos.com Work: cloos@io.com LPF,Usenix,SAGE,ISOC