summaryrefslogtreecommitdiff
blob: 68aca3ac01fc9ca2217e997182c1e2e382eb43b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /usr/bin/perl

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.

# Tue Jan 13 01:47:57 MET 1998: Martin Schulze <joey@infodrom.north.de>
#	Fixed typo.
#
#	Modified logfile detection routine to take care of double
#	listed logfiles.  It does this by using a hash instead of
#	immediate printout.  Thanks to Roman Hodek <roman@debian.org>
#	for providing an appropriate patch.

$conf = "/etc/syslog.conf";
$opt_daily = 1;
$opt_all = 0;
$opt_auth = 0;
$opt_news = 0;

sub usage
{
    print STDERR
"
Debian GNU/Linux syslogd-listfiles =VER=.  Copyright (C) 1997
Martin Schulze.  This is free software; see the GNU General Public Licence
version 2 or later for copying conditions.  There is NO warranty.

Usage: syslogd-listfiles <options>
Options: -f file	specifies another syslog.conf file
         -a | --all	list all files (including news)
         --auth		list all files containing auth.<some prio>
         --news		include news logfiles, too
         -w | --weekly	use weekly pattern instead of daily
";
}

while (@ARGV) {
    $_=shift(@ARGV);
    if (m/^-f$/) {
	$conf = shift(@ARGV);
    } elsif (m/^--weekly|-w$/) {
	$opt_daily = 0;
    } elsif (m/^(-a|--all)$/) {
	$opt_all = 1;
    } elsif (m/^--auth$/) {
	$opt_auth = 1;
    } elsif (m/^--news$/) {
	$opt_news = 1;
    } else {
	&usage();exit (0);
    }
}

open (C, $conf) || die "Can't open $conf, $!";
while (<C>) {
    next if (/^(\#|$)/);
    chop;

    s/\s*(\S.*)$/$1/ if ($line);

    $line .= $_;
    chop ($line) if (/\\$/);
    if (!/\\$/) {
	$line =~ s/\s+/\t/;
	$line =~ s/\t-/\t/;
	push (@lines, $line) if ($line =~ /\t\/(?!dev\/)/);
	$line = "";
    }
}
close (C);

foreach $line (@lines) {
    ($pat,$file) = split (/\t/,$line);

    # handled by news.daily from INN
    next if (!$opt_news && ($pat =~ /news\.(crit|err|notice)/));

    if ($opt_all) {
	$output{$file} = 1;
    } elsif ($opt_auth) {
	$output{$file} = 1 if ($pat =~ /auth[^\.]*\.(?!none).*/);
    } else {
	$i = ($pat =~ /\*\.\*/);
	$output{$file} = 1 if (($i && $opt_daily) || (!$i && !$opt_daily));
    }
}

foreach $file (keys (%output)) {
    print $file . "\n";
}