~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to support/split-logfile.in

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@perlbin@
 
2
#
 
3
# Licensed to the Apache Software Foundation (ASF) under one or more
 
4
# contributor license agreements.  See the NOTICE file distributed with
 
5
# this work for additional information regarding copyright ownership.
 
6
# The ASF licenses this file to You under the Apache License, Version 2.0
 
7
# (the "License"); you may not use this file except in compliance with
 
8
# the License.  You may obtain a copy of the License at
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# Unless required by applicable law or agreed to in writing, software
 
13
# distributed under the License is distributed on an "AS IS" BASIS,
 
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
# See the License for the specific language governing permissions and
 
16
# limitations under the License.
 
17
#
 
18
#
 
19
# This script will take a combined Web server access
 
20
# log file and break its contents into separate files.
 
21
# It assumes that the first field of each line is the
 
22
# virtual host identity (put there by "%v"), and that
 
23
# the logfiles should be named that+".log" in the current
 
24
# directory.
 
25
#
 
26
# The combined log file is read from stdin. Records read
 
27
# will be appended to any existing log files.
 
28
#
 
29
%is_open = ();
 
30
 
 
31
while ($log_line = <STDIN>) {
 
32
    #
 
33
    # Get the first token from the log record; it's the
 
34
    # identity of the virtual host to which the record
 
35
    # applies.
 
36
    #
 
37
    ($vhost) = split (/\s/, $log_line);
 
38
    #
 
39
    # Normalize the virtual host name to all lowercase.
 
40
    # If it's blank, the request was handled by the default
 
41
    # server, so supply a default name.  This shouldn't
 
42
    # happen, but caution rocks.
 
43
    #
 
44
    $vhost = lc ($vhost) or "access";
 
45
    #
 
46
    # if the vhost contains a "/" or "\", it is illegal so just use 
 
47
    # the default log to avoid any security issues due if it is interprted
 
48
    # as a directory separator.
 
49
    if ($vhost =~ m#[/\\]#) { $vhost = "access" }
 
50
    #
 
51
    # If the log file for this virtual host isn't opened
 
52
    # yet, do it now.
 
53
    #
 
54
    if (! $is_open{$vhost}) {
 
55
        open $vhost, ">>${vhost}.log"
 
56
            or die ("Can't open ${vhost}.log");
 
57
        $is_open{$vhost} = 1;
 
58
    }
 
59
    #
 
60
    # Strip off the first token (which may be null in the
 
61
    # case of the default server), and write the edited
 
62
    # record to the current log file.
 
63
    #
 
64
    $log_line =~ s/^\S*\s+//;
 
65
    printf $vhost "%s", $log_line;
 
66
}
 
67
exit 0;