fail2ban
Christos Ricudis
ricudis at komodino.itc.auth.gr
Tue Apr 24 18:48:04 EEST 2007
Giorgos Keramidas wrote:
> %%%
> diff -r c74c7571633b sysklogd.8
> --- a/sysklogd.8 Tue Apr 24 14:14:47 2007 +0300
> +++ b/sysklogd.8 Tue Apr 24 14:27:13 2007 +0300
> @@ -86,6 +86,12 @@ described by the people from OpenBSD at
> described by the people from OpenBSD at
> http://www.psionic.com/papers/dns.html.
> .TP
> +.B "\-c"
> +Disable the compression of repeated instances of the same line into
> +a single line of the form ``last message repeated N times'' when the
> +output is a pipe to another program. If specified twice disable this
> +compression in all cases.
> +.TP
> .B "\-d"
> Turns on debug mode. Using this the daemon will not proceed a
> .BR fork (2)
> diff -r c74c7571633b syslogd.c
> --- a/syslogd.c Tue Apr 24 14:14:47 2007 +0300
> +++ b/syslogd.c Tue Apr 24 14:27:13 2007 +0300
> @@ -720,6 +720,7 @@ struct code FacNames[] = {
> {NULL, -1},
> };
>
> +int Compression = 1; /* compression of repeated messages flag */
> int Debug; /* debug flag */
> char LocalHostName[MAXHOSTNAMELEN+1]; /* our hostname */
> char *LocalDomain; /* our local domain name */
> @@ -829,13 +830,17 @@ int main(argc, argv)
> funix[i] = -1;
> }
>
> - while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
> + while ((ch = getopt(argc, argv, "a:cdhf:l:m:np:rs:v")) != EOF)
> switch((char)ch) {
> case 'a':
> if (nfunix < MAXFUNIX)
> funixn[nfunix++] = optarg;
> else
> fprintf(stderr, "Out of descriptors, ignoring %s\n", optarg);
> + break;
> + case 'c':
> + if (Compression >= 0)
> + Compression--;
> break;
> case 'd': /* debug */
> Debug = 1;
> @@ -1174,7 +1179,7 @@ int main(argc, argv)
>
> int usage()
> {
> - fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
> + fprintf(stderr, "usage: syslogd [-cdrvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
> " [-s domainlist] [-f conffile]\n");
> exit(1);
> }
> @@ -1731,7 +1736,9 @@ void fprintlog(f, from, flags, msg)
> if (msg) {
> v->iov_base = msg;
> v->iov_len = strlen(msg);
> - } else if (f->f_prevcount > 1) {
> + } else if (f->f_prevcount > 1 &&
> + ((Compression == 0 && f->f_type != F_PIPE) ||
> + Compression > 0)) {
> (void) snprintf(repbuf, sizeof(repbuf), "last message repeated %d times",
> f->f_prevcount);
> v->iov_base = repbuf;
> %%%
>
>
Ama einai na kanei olh ayth th manoura, tote giati na mhn xrhsimopoihsei kati poy tou dinei ligo perissoteres dynatothes?
diff -ruN sysklogd-1.4.1/sysklogd.8 sysklogd-1.4.1-useful/sysklogd.8
--- sysklogd-1.4.1/sysklogd.8 2007-04-24 14:59:45.000000000 +0300
+++ sysklogd-1.4.1-useful/sysklogd.8 2007-04-24 18:35:12.000000000 +0300
@@ -86,6 +86,17 @@
described by the people from OpenBSD at
http://www.psionic.com/papers/dns.html.
.TP
+.B "\-c"
+Disable the compression of repeated instances of the same line into
+a single line of the form ``last message repeated N times'' when the
+output is a pipe to another program. If specified twice, disable
+this compression in all cases. If specified thrice, do the same as
+specified twice, except if it's Easter Sunday. If specified four times,
+it must also be a leap year under Julian Calendar rules. Specified
+five times changes the rule to a Revised Julian Calendar calculation,
+and the repetition of a sixth occurrence finally switches to a Gregorian
+leap day.
+.TP
.B "\-d"
Turns on debug mode. Using this the daemon will not proceed a
.BR fork (2)
diff -ruN sysklogd-1.4.1/syslogd.c sysklogd-1.4.1-useful/syslogd.c
--- sysklogd-1.4.1/syslogd.c 2007-04-24 14:59:45.000000000 +0300
+++ sysklogd-1.4.1-useful/syslogd.c 2007-04-24 18:27:00.000000000 +0300
@@ -720,6 +720,7 @@
{NULL, -1},
};
+int cflag = 0; /* omit compression of repeated messages flag */
int Debug; /* debug flag */
char LocalHostName[MAXHOSTNAMELEN+1]; /* our hostname */
char *LocalDomain; /* our local domain name */
@@ -829,7 +830,7 @@
funix[i] = -1;
}
- while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
+ while ((ch = getopt(argc, argv, "a:cdhf:l:m:np:rs:v")) != EOF)
switch((char)ch) {
case 'a':
if (nfunix < MAXFUNIX)
@@ -837,6 +838,9 @@
else
fprintf(stderr, "Out of descriptors, ignoring %s\n", optarg);
break;
+ case 'c':
+ cflag++;
+ break;
case 'd': /* debug */
Debug = 1;
break;
@@ -1174,7 +1178,7 @@
int usage()
{
- fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
+ fprintf(stderr, "usage: syslogd [-cdrvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
" [-s domainlist] [-f conffile]\n");
exit(1);
}
@@ -1707,6 +1711,8 @@
struct iovec iov[6];
register struct iovec *v = iov;
char repbuf[80];
+ struct tm *curtime_tm;
+ time_t curtime;
#ifdef SYSLOG_INET
register int l;
char line[MAXLINE + 1];
@@ -1716,6 +1722,9 @@
dprintf("Called fprintlog, ");
+ time(&curtime);
+ curtime_tm=localtime(&curtime);
+
v->iov_base = f->f_lasttime;
v->iov_len = 15;
v++;
@@ -1731,7 +1740,7 @@
if (msg) {
v->iov_base = msg;
v->iov_len = strlen(msg);
- } else if (f->f_prevcount > 1) {
+ } else if (f->f_prevcount > 1 && (!(cflag==0?1:(cflag==1?(f->f_type==F_PIPE?1:0):(cflag==2?1:(((curtime_tm->tm_mon+1==((((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)+((32+2*(((curtime_tm->tm_year+1900)/100)%4)+2*(((curtime_tm->tm_year+1900)%100)/4)-((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)-(((curtime_tm->tm_year+1900)%100)%4))%7)-7*((((curtime_tm->tm_year+1900)%19)+11*((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)+22*((32+2*(((curtime_tm->tm_year+1900)/100)%4)+2*(((curtime_tm->tm_year+1900)%100)/4)-((19*((curtime_tm->tm_yea
r+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)-(((curtime_tm->tm_year+1900)%100)%4))%7))/451)+114)/31))&&(curtime_tm->tm_mday==(((((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)+((32+2*(((curtime_tm->tm_year+1900)/100)%4)+2*(((curtime_tm->tm_year+1900)%100)/4)-((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)-(((curtime_tm->tm_year+1900)%100)%4))%7)-7*((((curtime_tm->tm_year+1900)%19)+11*((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100
)+8)/25)+1)/3)+15)%30)+22*((32+2*(((curtime_tm->tm_year+1900)/100)%4)+2*(((curtime_tm->tm_year+1900)%100)/4)-((19*((curtime_tm->tm_year+1900)%19)+((curtime_tm->tm_year+1900)/100)-(((curtime_tm->tm_year+1900)/100)/4)-((((curtime_tm->tm_year+1900)/100)-((((curtime_tm->tm_year+1900)/100)+8)/25)+1)/3)+15)%30)-(((curtime_tm->tm_year+1900)%100)%4))%7))/451)+114)%31)+1)))?(cflag<4?(0):(((curtime_tm->tm_year+1900)%4==0?(cflag==4?1:((curtime_tm->tm_year+1900)%100==0?(cflag==5?((curtime_tm->tm_year+1900)%400==0?1:0):(cflag>5?(((curtime_tm->tm_year+1900)%900==600)||((curtime_tm->tm_year+1900)%900==200)?1:0):0)):1)):0)==1?0:1)):1)))))) {
(void) snprintf(repbuf, sizeof(repbuf), "last message repeated %d times",
f->f_prevcount);
v->iov_base = repbuf;
--
Christos Ricudis ricudis at itc.auth.gr
Systems Administrator +30-2310-998656
IT Support Center
Aristotle University of Thessaloniki, GREECE
More information about the Linux-greek-users
mailing list