You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(23) |
Oct
(2) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(4) |
Feb
(11) |
Mar
(1) |
Apr
(104) |
May
(18) |
Jun
(42) |
Jul
|
Aug
(4) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: <al...@us...> - 2003-05-28 18:03:09
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv1899/src/modules Modified Files: om_mysql.c Log Message: delay reconnects add option to specify the reconnect wait interval in seconds document it this needs testing Index: om_mysql.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_mysql.c,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- om_mysql.c 23 Apr 2003 18:42:30 -0000 1.89 +++ om_mysql.c 28 May 2003 18:03:05 -0000 1.90 @@ -67,9 +67,13 @@ #define MAX_QUERY 8192 /* how many seconds to wait to give again the error message */ #define MSYSLOG_MYSQL_ERROR_DELAY 30 +/* wait 10 secs before reconnect */ +#define RECONNECT_WAIT 10 struct om_mysql_ctx { void *h; + time_t next_reconnect; + int reconnect_wait; int lost; char *table; char *host; @@ -99,6 +103,40 @@ #define MYSQL_PORT 3306 +int +do_connect (struct om_mysql_ctx *c) +{ + char err_buf[64]; + + /* connect to the database */ + if (! (c->h = (c->mysql_init)(NULL)) ) { + + snprintf(err_buf, sizeof(err_buf), "om_mysql_init: Error " + "initializing handle"); + logerror(err_buf); + return (-1); + } + + m_dprintf(MSYSLOG_INFORMATIVE, "om_mysql_init: mysql_init returned %p\n", + c->h); + + m_dprintf(MSYSLOG_INFORMATIVE, "om_mysql_init: params %p %s %s %s %i" + " \n", c->h, c->host, c->user, c->db, c->port); + + if (!((c->mysql_real_connect)(c->h, c->host, c->user, + c->passwd, c->db, c->port, NULL, 0)) ) { + + snprintf(err_buf, sizeof(err_buf), "om_mysql_init: Error " + "connecting to db server [%s], [%s:%i] user [%s] db [%s]", + c->mysql_error? c->mysql_error(c->h) : "<unknown>", + c->host, c->port, c->user, c->db); + logerror(err_buf); + + return (-1); + } + + return (1); +} int om_mysql_write(struct filed *f, struct m_msg *m, void *ctx) @@ -119,22 +157,28 @@ /* ignore sigpipes for mysql_ping */ sigsave = place_signal(SIGPIPE, SIG_IGN); -#warning ON SOME MYSQL BUG THIS LOCKS OR LOOPS, FIX ASAP - if ( ((c->mysql_ping)(c->h)) != 0 && (((c->mysql_init)(c->h) == NULL) - || ((c->mysql_real_connect)(c->h, c->host, c->user, c->passwd, c->db, - c->port, NULL, 0)) == NULL) ) { + if (((c->mysql_ping)(c->h)) != 0) { + time_t now; /* restore previous SIGPIPE handler */ place_signal(SIGPIPE, sigsave); c->lost++; + + time(&now); + if (c->next_reconnect < now) + return(0); /* wait reconnect time */ + + c->next_reconnect = now + c->reconnect_wait; + + if (do_connect(c) == -1) + return (0); + if (c->lost == 1) { snprintf(err_buf, sizeof(err_buf), "om_mysql_write: " "Lost connection! [%s]", c->mysql_error? c->mysql_error(c->h) : "<unknown>"); - m_dprintf(MSYSLOG_SERIOUS, "%s", err_buf); logerror(err_buf); } - return (1); } /* restore previous SIGPIPE handler */ @@ -251,8 +295,6 @@ void **c, char **status) { - char err_buf[256]; - char statbuf[1024]; struct om_mysql_ctx *ctx; char *p; int ch; @@ -304,8 +346,8 @@ argcnt = 1; /* skip module name */ while ((ch = getxopt(argc, argv, "s!server: u!user: p!password:" - " d!database: t!table: D!delayed P!priority F!facility", &argcnt)) - != -1) { + " d!database: t!table: D!delayed P!priority F!facility w!wait:", + &argcnt)) != -1) { switch (ch) { case 's': @@ -339,60 +381,31 @@ case 'F': ctx->flags |= OM_MYSQL_FACILITY; break; + case 'w': + ctx->reconnect_wait = strtol(argv[argcnt], NULL, 10); + break; default: - goto om_mysql_init_bad; + return (-1); } argcnt++; } - if (ctx->user == NULL || ctx->db == NULL || ctx->port == 0 || - ctx->host == NULL || ctx->table == NULL) - goto om_mysql_init_bad; - - /* connect to the database */ - if (! (ctx->h = (ctx->mysql_init)(NULL)) ) { - - snprintf(err_buf, sizeof(err_buf), "om_mysql_init: Error " - "initializing handle"); - logerror(err_buf); - goto om_mysql_init_bad; - } - - m_dprintf(MSYSLOG_INFORMATIVE, "om_mysql_init: mysql_init returned %p\n", - ctx->h); - - m_dprintf(MSYSLOG_INFORMATIVE, "om_mysql_init: params %p %s %s %s %i" - " \n", ctx->h, ctx->host, ctx->user, ctx->db, ctx->port); - - snprintf(statbuf, sizeof(statbuf), "om_mysql: sending " - "messages to %s, database %s, table %s.", ctx->host, - ctx->db, ctx->table); - *status = strdup(statbuf); - - if (!((ctx->mysql_real_connect)(ctx->h, ctx->host, ctx->user, - ctx->passwd, ctx->db, ctx->port, NULL, 0)) ) { + if (ctx->reconnect_wait < 1 || ctx->reconnect_wait > 10000) + ctx->reconnect_wait = RECONNECT_WAIT; - snprintf(err_buf, sizeof(err_buf), "om_mysql_init: Error " - "connecting to db server [%s], [%s:%i] user [%s] db [%s]", - ctx->mysql_error? ctx->mysql_error(ctx->h) : "<unknown>", - ctx->host, ctx->port, ctx->user, ctx->db); - logerror(err_buf); + if (((ctx->user != NULL && ctx->db != NULL && ctx->port != 0 && + ctx->host != NULL && ctx->table != NULL)) && + (do_connect(ctx) != -1)) return (1); - } - - return (1); -om_mysql_init_bad: + /* error */ if (ctx) { om_mysql_close(f, ctx); - FREE_PTR(ctx); } - *status = NULL; - - return(-1); + return (-1); } |
From: <al...@us...> - 2003-05-26 19:26:27
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv11875 Modified Files: TODO Log Message: done static compiles done vis import Index: TODO =================================================================== RCS file: /cvsroot/msyslog/syslog/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TODO 22 May 2003 06:59:54 -0000 1.3 +++ TODO 26 May 2003 19:26:24 -0000 1.4 @@ -3,8 +3,6 @@ Todo for 1.10 ============= -- static compile -- move vis(3) inside or replace somehow - fix om_mysql prob on looping reconnects - single entry function for each module - allow somehow to set inputs on syslog.conf |
From: <al...@us...> - 2003-05-26 19:25:35
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv11254/src Modified Files: Makefile.in config.h.in syslogd.c Added Files: vis.c vis.h Log Message: import OpenBSD's vis(3) to our tree this is yet to be tested on most archs! --- NEW FILE: vis.c --- /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if 0 #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = "$OpenBSD: vis.c,v 1.10 2002/07/01 11:28:06 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #endif #include <sys/types.h> #include <limits.h> #include <ctype.h> #include <string.h> #include "vis.h" #define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') #define isvisible(c) (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) && \ isgraph((u_char)(c))) || \ ((flag & VIS_SP) == 0 && (c) == ' ') || \ ((flag & VIS_TAB) == 0 && (c) == '\t') || \ ((flag & VIS_NL) == 0 && (c) == '\n') || \ ((flag & VIS_SAFE) && \ ((c) == '\b' || (c) == '\007' || (c) == '\r'))) /* * vis - visually encode characters */ char * vis(dst, c, flag, nextc) register char *dst; int c, nextc; register int flag; { if (isvisible(c)) { *dst++ = c; if (c == '\\' && (flag & VIS_NOSLASH) == 0) *dst++ = '\\'; *dst = '\0'; return (dst); } if (flag & VIS_CSTYLE) { switch(c) { case '\n': *dst++ = '\\'; *dst++ = 'n'; goto done; case '\r': *dst++ = '\\'; *dst++ = 'r'; goto done; case '\b': *dst++ = '\\'; *dst++ = 'b'; goto done; case '\a': *dst++ = '\\'; *dst++ = 'a'; goto done; case '\v': *dst++ = '\\'; *dst++ = 'v'; goto done; case '\t': *dst++ = '\\'; *dst++ = 't'; goto done; case '\f': *dst++ = '\\'; *dst++ = 'f'; goto done; case ' ': *dst++ = '\\'; *dst++ = 's'; goto done; case '\0': *dst++ = '\\'; *dst++ = '0'; if (isoctal(nextc)) { *dst++ = '0'; *dst++ = '0'; } goto done; } } if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) { *dst++ = '\\'; *dst++ = ((u_char)c >> 6 & 07) + '0'; *dst++ = ((u_char)c >> 3 & 07) + '0'; *dst++ = ((u_char)c & 07) + '0'; goto done; } if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; if (c & 0200) { c &= 0177; *dst++ = 'M'; } if (iscntrl(c)) { *dst++ = '^'; if (c == 0177) *dst++ = '?'; else *dst++ = c + '@'; } else { *dst++ = '-'; *dst++ = c; } done: *dst = '\0'; return (dst); } /* * strvis, strnvis, strvisx - visually encode characters from src into dst * * Dst must be 4 times the size of src to account for possible * expansion. The length of dst, not including the trailing NULL, * is returned. * * Strnvis will write no more than siz-1 bytes (and will NULL terminate). * The number of bytes needed to fully encode the string is returned. * * Strvisx encodes exactly len bytes from src into dst. * This is useful for encoding a block of data. */ int strvis(dst, src, flag) register char *dst; register const char *src; int flag; { register char c; char *start; for (start = dst; (c = *src);) dst = vis(dst, c, flag, *++src); *dst = '\0'; return (dst - start); } int strnvis(dst, src, siz, flag) char *dst; const char *src; size_t siz; int flag; { char c; char *start, *end; char tbuf[5]; int i; i = 0; for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) { if (isvisible(c)) { i = 1; *dst++ = c; if (c == '\\' && (flag & VIS_NOSLASH) == 0) { /* need space for the extra '\\' */ if (dst < end) *dst++ = '\\'; else { dst--; i = 2; break; } } src++; } else { i = vis(tbuf, c, flag, *++src) - tbuf; if (dst + i <= end) { memcpy(dst, tbuf, i); dst += i; } else { src--; break; } } } if (siz > 0) *dst = '\0'; if (dst + i > end) { /* adjust return value for truncation */ while ((c = *src)) dst += vis(tbuf, c, flag, *++src) - tbuf; } return (dst - start); } int strvisx(dst, src, len, flag) register char *dst; register const char *src; register size_t len; int flag; { register char c; char *start; for (start = dst; len > 1; len--) { c = *src; dst = vis(dst, c, flag, *++src); } if (len) dst = vis(dst, *src, flag, '\0'); *dst = '\0'; return (dst - start); } --- NEW FILE: vis.h --- /* $OpenBSD: vis.h,v 1.5 2002/02/16 21:27:17 millert Exp $ */ /* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)vis.h 5.9 (Berkeley) 4/3/91 */ #ifndef _VIS_H_ #define _VIS_H_ /* * to select alternate encoding format */ #define VIS_OCTAL 0x01 /* use octal \ddd format */ #define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */ /* * to alter set of characters encoded (default is to encode all * non-graphic except space, tab, and newline). */ #define VIS_SP 0x04 /* also encode space */ #define VIS_TAB 0x08 /* also encode tab */ #define VIS_NL 0x10 /* also encode newline */ #define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) #define VIS_SAFE 0x20 /* only encode "unsafe" characters */ /* * other */ #define VIS_NOSLASH 0x40 /* inhibit printing '\' */ /* * unvis return codes */ #define UNVIS_VALID 1 /* character valid */ #define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ #define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ #define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ #define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ /* * unvis flags */ #define UNVIS_END 1 /* no more characters */ #include <sys/cdefs.h> __BEGIN_DECLS char *vis(char *, int, int, int); int strvis(char *, const char *, int); int strnvis(char *, const char *, size_t, int); int strvisx(char *, const char *, size_t, int); int strunvis(char *, const char *); int unvis(char *, char, int *, int); __END_DECLS #endif /* !_VIS_H_ */ Index: Makefile.in =================================================================== RCS file: /cvsroot/msyslog/syslog/src/Makefile.in,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- Makefile.in 26 May 2003 17:03:48 -0000 1.58 +++ Makefile.in 26 May 2003 19:25:32 -0000 1.59 @@ -40,7 +40,7 @@ PROG= @MSYSLOG_DAEMON_NAME@ PROG_FLAGS= $(CFLAGS) $(CPPFLAGS) $(LIBS) $(SYSLOGD_LIBS) $(MAIN_CPPFLAGS) -SRCS= modules.c syslogd.c options.c +SRCS= modules.c syslogd.c options.c @VIS_C@ TMP= @MSRCS@ @HASH_SRCS@ MSRCS= $(TMP:%=modules/%) Index: config.h.in =================================================================== RCS file: /cvsroot/msyslog/syslog/src/config.h.in,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- config.h.in 22 May 2003 06:57:38 -0000 1.35 +++ config.h.in 26 May 2003 19:25:32 -0000 1.36 @@ -155,3 +155,5 @@ /* for Solaris */ #undef _REENTRANT + +#undef HAVE_VIS_H Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.257 retrieving revision 1.258 diff -u -d -r1.257 -r1.258 --- syslogd.c 26 May 2003 18:39:03 -0000 1.257 +++ syslogd.c 26 May 2003 19:25:32 -0000 1.258 @@ -116,7 +116,11 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <vis.h> +#ifdef HAVE_VIS_H +# include <vis.h> +#else +# include "vis.h" +#endif #define SYSLOG_NAMES #include <syslog.h> |
From: <al...@us...> - 2003-05-26 19:25:35
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv11254 Modified Files: configure.in configure Log Message: import OpenBSD's vis(3) to our tree this is yet to be tested on most archs! Index: configure.in =================================================================== RCS file: /cvsroot/msyslog/syslog/configure.in,v retrieving revision 1.161 retrieving revision 1.162 diff -u -d -r1.161 -r1.162 --- configure.in 22 May 2003 06:57:38 -0000 1.161 +++ configure.in 26 May 2003 19:25:31 -0000 1.162 @@ -25,6 +25,14 @@ sys/types.h sys/time.h machine/endian.h syslog.h unistd.h sysctl.h \ err.h sys/context.h) +VIS_C=""; + +AC_CHECK_HEADER(vis.h, [ + AC_DEFINE(HAVE_VIS_H, 1) +], [ + VIS_C="vis.c"; +]) + dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_OFF_T @@ -548,7 +556,7 @@ AC_SUBST(MAIN_CPPFLAGS) AC_SUBST(MSYSLOG_DAEMON_NAME) AC_SUBST(MSYSLOG_VERSION) -AC_SUBST(EXTRA_MODULES) +AC_SUBST(VIS_C) dnl AC_SUBST(SYMBOL_PREFIX) Index: configure =================================================================== RCS file: /cvsroot/msyslog/syslog/configure,v retrieving revision 1.98 retrieving revision 1.99 diff -u -d -r1.98 -r1.99 --- configure 22 May 2003 06:57:37 -0000 1.98 +++ configure 26 May 2003 19:25:31 -0000 1.99 @@ -2332,7 +2332,58 @@ fi done -echo "$as_me:2335: checking for $CC option to accept ANSI C" >&5 +VIS_C=""; + +echo "$as_me:2337: checking for vis.h" >&5 +echo $ECHO_N "checking for vis.h... $ECHO_C" >&6 +if test "${ac_cv_header_vis_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else [...1995 lines suppressed...] { (exit 1); exit 1; }; } echo $f;; @@ -5887,7 +5938,7 @@ echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5890: error: cannot find input file: $f" >&5 + { { echo "$as_me:5941: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -6004,7 +6055,7 @@ rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:6007: $ac_file is unchanged" >&5 + { echo "$as_me:6058: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ |
From: <al...@us...> - 2003-05-26 18:39:07
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv24263/src Modified Files: syslogd.c Log Message: add missing brake from last param reorder (my fault!) fix func calling fix unaligned comment Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.256 retrieving revision 1.257 diff -u -d -r1.256 -r1.257 --- syslogd.c 22 May 2003 06:57:38 -0000 1.256 +++ syslogd.c 26 May 2003 18:39:03 -0000 1.257 @@ -292,6 +292,7 @@ } else if (isdigit((int) *argv[argcnt])) { Debug = strtol(argv[argcnt], NULL, 10); } + break; case 'f': /* configuration file */ ConfFile = argv[argcnt]; break; @@ -1152,14 +1153,15 @@ * The rule has "fired" if all its modules "fire". */ - ret = (*(om->func->write)) (f, m, om->ctx); + ret = (om->func->write) (f, m, om->ctx); /* zero indicates that the module did not fire/match */ if (ret == 0) break; /* negative indicates an error, an error should not - * be treated as a fire/match situation */ + * be treated as a fire/match situation + */ if (ret < 0) { m_dprintf(MSYSLOG_SERIOUS, "do_log: error with output " "module [%s] for message [%s]\n", |
From: <al...@us...> - 2003-05-26 17:03:53
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv19898/src Modified Files: Makefile.in Log Message: depend on source files Index: Makefile.in =================================================================== RCS file: /cvsroot/msyslog/syslog/src/Makefile.in,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- Makefile.in 22 May 2003 06:57:38 -0000 1.57 +++ Makefile.in 26 May 2003 17:03:48 -0000 1.58 @@ -48,7 +48,7 @@ all: $(PROG) -$(PROG): config.h +$(PROG): config.h $(SRCS) $(MSRCS) $(CC) $(PROG_FLAGS) -o $@ $(SRCS) $(MSRCS) .PHONY: clean distclean |
From: <al...@us...> - 2003-05-22 06:59:57
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv891 Modified Files: TODO Log Message: new order of goals Index: TODO =================================================================== RCS file: /cvsroot/msyslog/syslog/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TODO 23 Apr 2003 19:35:09 -0000 1.2 +++ TODO 22 May 2003 06:59:54 -0000 1.3 @@ -3,12 +3,13 @@ Todo for 1.10 ============= -- test and regression tests - static compile -- single entry function for each module +- move vis(3) inside or replace somehow - fix om_mysql prob on looping reconnects +- single entry function for each module - allow somehow to set inputs on syslog.conf - fix/improve input module reopens on errors +- test and regression tests - check consistency on logerror vs m_dprintf - improve use of m_msg on sql modules - use queue.h everywhere |
From: <al...@us...> - 2003-05-22 06:57:41
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv31529/src/modules Removed Files: Makefile.in Log Message: static link needs more work, but compiles --- Makefile.in DELETED --- |
From: <al...@us...> - 2003-05-22 06:57:41
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv31529/src Modified Files: Makefile.in config.h.in modules.c syslogd.c syslogd.h Log Message: static link needs more work, but compiles Index: Makefile.in =================================================================== RCS file: /cvsroot/msyslog/syslog/src/Makefile.in,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- Makefile.in 17 Sep 2002 05:20:26 -0000 1.56 +++ Makefile.in 22 May 2003 06:57:38 -0000 1.57 @@ -41,25 +41,20 @@ PROG= @MSYSLOG_DAEMON_NAME@ PROG_FLAGS= $(CFLAGS) $(CPPFLAGS) $(LIBS) $(SYSLOGD_LIBS) $(MAIN_CPPFLAGS) SRCS= modules.c syslogd.c options.c -OBJS= $(SRCS:.c=.o) - -all: $(PROG) -.c.o: - $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ +TMP= @MSRCS@ @HASH_SRCS@ +MSRCS= $(TMP:%=modules/%) -modules.o: config.h -$(OBJS): $(SRCS) - $(CC) $(CFLAGS) $(CPPFLAGS) -c $(@:.o=.c) -o $@ +all: $(PROG) -$(PROG): $(OBJS) - $(CC) $(PROG_FLAGS) $(OBJS) -o $@ +$(PROG): config.h + $(CC) $(PROG_FLAGS) -o $@ $(SRCS) $(MSRCS) .PHONY: clean distclean clean: - -rm -f $(OBJS) core *.core $(PROG) + -rm -f core *.core $(PROG) distclean: clean -rm -f Makefile config.h Index: config.h.in =================================================================== RCS file: /cvsroot/msyslog/syslog/src/config.h.in,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- config.h.in 14 Aug 2002 14:32:21 -0000 1.34 +++ config.h.in 22 May 2003 06:57:38 -0000 1.35 @@ -133,14 +133,18 @@ #undef HAVE_LINUX_IMODULE #undef HAVE_BSD_IMODULE #undef HAVE_UNIX_IMODULE +#undef HAVE_SERIAL_IMODULE + +#undef HAVE_OREACLE8I_0MODULE +#undef HAVE_SNMPTRAP_0MODULE +#undef HAVE_QUEUE_0MODULE +#undef HAVE_REFRACT_0MODULE #undef HAVE_SOCKADDR_SA_LEN #undef _USE_IRS #undef SIGALTSTACK_WITH_STACK_T #undef HAVE_SYS_CONTEXT_H - -#undef NEEDS_DLOPEN_NULL #undef _SGIAPI #undef INET6 Index: modules.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules.c,v retrieving revision 1.174 retrieving revision 1.175 diff -u -d -r1.174 -r1.175 --- modules.c 9 May 2003 14:38:34 -0000 1.174 +++ modules.c 22 May 2003 06:57:38 -0000 1.175 @@ -49,128 +49,159 @@ #include <string.h> #include <syslog.h> #include <unistd.h> -#include <dlfcn.h> #include <limits.h> #include <time.h> #include "modules.h" #include "syslogd.h" -#ifdef _POSIX_PATH_MAX -#define LIB_PATH_MAX _POSIX_PATH_MAX -#else -#define LIB_PATH_MAX 254 -#endif - void logerror(char *); int parseParams(char ***, char *); -struct imodule *getImodule(char *); -struct omodule *getOmodule(char *); -struct imodule *addImodule(char *); -struct omodule *addOmodule(char *); - -struct omodule *omodules; -struct imodule *imodules; +int getImodule(char *); +int getOmodule(char *); char err_buf[MAXLINE]; -extern char *libdir; -extern void *main_lib; extern int Debug; -/* - * Prepare libraries for a module - */ -int -prepare_module_libs(const char *modname, void **ret) -{ -#if BUGGY_LIBRARY_OPEN - int i; - char buf[LIB_PATH_MAX]; - - m_dprintf(MSYSLOG_INFORMATIVE, "prepare_module_libs: called for " - "module: %s\n", modname); - - /* Try to open LIBDIR/MYSLOG_LIB */ - snprintf(buf, sizeof(buf), "%s/" MLIBNAME_STR, - (libdir != NULL) ? libdir : INSTALL_LIBDIR); - m_dprintf(MSYSLOG_INFORMATIVE, "prepare_module_libs: Going to open %s\n", - buf); - *ret = dlopen(buf, DLOPEN_FLAGS); - - /* Try ./ if debugging. We don't care if it is not open */ - if (Debug && *ret == NULL) { - snprintf(buf, sizeof(buf), "./" MLIBNAME_STR); - m_dprintf(MSYSLOG_INFORMATIVE, "prepare_module_libs: Going" - " to open %s\n", buf); - *ret = dlopen(buf, DLOPEN_FLAGS); - } - - m_dprintf(MSYSLOG_INFORMATIVE, "prepare_module_libs: lib %s was " - "%sopened\n", buf, (*ret == NULL) ? "not " : ""); +int om_classic_init (int, char **, struct filed *, struct global*, void **, char **); +int om_tcp_init (int, char **, struct filed *, struct global*, void **, char **); +int om_udp_init (int, char **, struct filed *, struct global*, void **, char **); +int om_peo_init (int, char **, struct filed *, struct global*, void **, char **); +int om_regex_init (int, char **, struct filed *, struct global*, void **, char **); +int om_mysql_init (int, char **, struct filed *, struct global*, void **, char **); +int om_pgsql_init (int, char **, struct filed *, struct global*, void **, char **); +int om_classic_write (struct filed *, struct m_msg *, void *); +int om_tcp_write (struct filed *, struct m_msg *, void *); +int om_udp_write (struct filed *, struct m_msg *, void *); +int om_peo_write (struct filed *, struct m_msg *, void *); +int om_regex_write (struct filed *, struct m_msg *, void *); +int om_mysql_write (struct filed *, struct m_msg *, void *); +int om_pgsql_write (struct filed *, struct m_msg *, void *); +int om_classic_flush (struct filed *, void *); +int om_regex_flush (struct filed *, void *); +int om_pgsql_flush (struct filed *, void *); +int om_classic_close (struct filed *, void *); +int om_tcp_close (struct filed *, void *); +int om_udp_close (struct filed *, void *); +int om_peo_close (struct filed *, void *); +int om_regex_close (struct filed *, void *); +int om_mysql_close (struct filed *, void *); +int om_pgsql_close (struct filed *, void *); +#ifdef HAVE_ORACLE8I_OMODULE +int om_oracle8i_init (int, char **, struct filed *, struct global*, void **, char **); +int om_oracle8i_write (struct filed *, struct m_msg *, void *); +int om_oracle8i_close (struct filed *, void *); #endif -return (1); -} - -/* - * This function gets function name from the main libmsyslog.so.X.X - * library or if not there try to open the external module library - * called libmsyslog_<modulename>.so - */ -int -get_symbol(const char *modname, const char *funcname, void **h, void **ret) -{ - char buf[LIB_PATH_MAX]; - - snprintf(buf, sizeof(buf), SYMBOL_PREFIX "%s_%s", modname, funcname); - *ret = NULL; - - /* - * Search for symbol on main library - * and in module libs - */ - if (*h == NULL) { - if (main_lib == NULL || ((*ret = dlsym(main_lib, buf)) == NULL - && (*ret = dlsym(main_lib, buf + 1)) == NULL)) - { - - m_dprintf(MSYSLOG_INFORMATIVE, "get_symbol: func %s " - "not found on main library\n", buf); - - /* Try to open libmsyslog_<modulename>.so */ - if (*h == NULL) { - char extlib[LIB_PATH_MAX]; +#ifdef HAVE_SNMPTRAP_OMODULE +int om_snmptrap_init (int, char **, struct filed *, struct global*, void **, char **); +int om_snmptrap_write (struct filed *, struct m_msg *, void *); +int om_snmptrap_close (struct filed *, void *); +#endif - snprintf(extlib, sizeof(extlib), - "%s/libmsyslog_%s.so", (libdir == NULL) ? - INSTALL_LIBDIR : libdir, modname); +#ifdef HAVE_QUEUE_OMODULE +int om_directory_init (int, char **, struct filed *, struct global*, void **, char **); +int om_queue_init (int, char **, struct filed *, struct global*, void **, char **); +int om_directory_write (struct filed *, struct m_msg *, void *); +int om_queue_write (struct filed *, struct m_msg *, void *); +int om_directory_flush (struct filed *, void *); +int om_queue_flush (struct filed *, void *); +int om_directory_close (struct filed *, void *); +int om_queue_close (struct filed *, void *); +#endif - m_dprintf(MSYSLOG_INFORMATIVE, "get_symbol: " - "Trying to open %s... ", extlib); - *h = dlopen(extlib, DLOPEN_FLAGS); - if (*h == NULL) - m_dprintf(MSYSLOG_INFORMATIVE, - "failed [%s]\n", dlerror()); - else - m_dprintf(MSYSLOG_INFORMATIVE, "ok"); - } - } - } +#ifdef HAVE_REFRACT_OMODULE +int om_refract_init (int, char **, struct filed *, struct global*, void **, char **); +int om_refract_write (struct filed *, struct m_msg *, void *); +int om_refract_flush (struct filed *, void *); +int om_refract_close (struct filed *, void *); +#endif - /* If can't found the symbol on the main library try the external one */ - if (*ret == NULL && *h != NULL) { - *ret = dlsym(*h, buf); - m_dprintf(MSYSLOG_INFORMATIVE, "get_symbol: func %s %sfound on " - "external lib\n", buf, (*ret == NULL) ? "not " : ""); - } +#ifdef HAVE_BSD_IMODULE +int im_bsd_init (struct i_module *, char **, int); +int im_bsd_read (struct i_module *, int, struct m_msg *); +int im_bsd_close (struct i_module *); /* close input, optional */ +#endif +#ifdef HAVE_LINUX_IMODULE +int im_linux_init (struct i_module *, char **, int); +int im_linux_read (struct i_module *, int, struct m_msg *); +int im_linux_close (struct i_module *); /* close input, optional */ +#endif +#ifdef HAVE_UNIX_IMODULE +int im_unix_init (struct i_module *, char **, int); +int im_unix_read (struct i_module *, int, struct m_msg *); +int im_unix_close (struct i_module *); /* close input, optional */ +#endif +#ifdef HAVE_STREAMS_IMODULE +int im_streams_init (struct i_module *, char **, int); +int im_streams_read (struct i_module *, int, struct m_msg *); +int im_streams_close (struct i_module *); /* close input, optional */ +#endif +#ifdef HAVE_SERIAL_IMODULE +int im_serial_init (struct i_module *, char **, int); +int im_serial_read (struct i_module *, int, struct m_msg *); +int im_serial_close (struct i_module *); /* close input, optional */ +#endif +int im_file_init (struct i_module *, char **, int); +int im_file_read (struct i_module *, int, struct m_msg *); +int im_file_close (struct i_module *); /* close input, optional */ +int im_file_poll (struct i_module *); +int im_tcp_init (struct i_module *, char **, int); +int im_tcp_read (struct i_module *, int, struct m_msg *); +int im_tcp_close (struct i_module *); /* close input, optional */ +int im_udp_init (struct i_module *, char **, int); +int im_udp_read (struct i_module *, int, struct m_msg *); +int im_udp_close (struct i_module *); /* close input, optional */ -return ((*ret == NULL) ? -1 : 1); -} +struct omodule omodules[] = { + { "classic", om_classic_init, om_classic_write, om_classic_flush, om_classic_close }, + { "tcp", om_tcp_init, om_tcp_write, NULL, om_tcp_close }, + { "udp", om_udp_init, om_udp_write, NULL, om_udp_close }, + { "peo", om_peo_init, om_peo_write, NULL, om_peo_close }, + { "regex", om_regex_init, om_regex_write, om_regex_flush, om_regex_close }, + { "mysql", om_mysql_init, om_mysql_write, NULL, om_mysql_close }, + { "pgsql", om_pgsql_init, om_pgsql_write, om_pgsql_flush, om_pgsql_close }, +#ifdef HAVE_ORACLE8I_OMODULE + { "oracle8i", om_oracle8i_init, om_oracle8i_write, NULL, om_oracle8i_close }, +#endif +#ifdef HAVE_SNMPTRAP_OMODULE + { "snmptrap", om_snmptrap_init, om_snmptrap_write, NULL, om_snmptrap_close }, +#endif +#ifdef HAVE_QUEUE_OMODULE + { "directory", om_directory_init, om_directory_write, om_directory_flush, om_directory_close }, + { "queue", om_queue_init, om_queue_write, om_queue_flush, om_queue_close }, +#endif +#ifdef HAVE_REFRACT_OMODULE + { "refract", om_refract_init, om_refract_write, om_refract_flush, om_refract_close }, +#endif + { NULL, NULL,NULL,NULL,NULL } +}; +struct imodule imodules[] = { +#ifdef HAVE_BSD_IMODULE + { "bsd", im_bsd_init, im_bsd_read, im_bsd_close, NULL }, +#endif +#ifdef HAVE_LINUX_IMODULE + { "linux", im_linux_init, im_linux_read, im_linux_close, NULL }, +#endif +#ifdef HAVE_UNIX_IMODULE + { "unix", im_unix_init, im_unix_read, im_unix_close, NULL }, +#endif +#ifdef HAVE_STREAMS_IMODULE + { "streams", im_streams_init, im_streams_read, im_streams_close, NULL }, +#endif +#ifdef HAVE_SERIAL_IMODULE + { "serial", im_serial_init, im_serial_read, im_serial_close, NULL }, +#endif + { "file", im_file_init, im_file_read, im_file_close, im_file_poll }, + { "tcp", im_tcp_init, im_tcp_read, im_tcp_close, NULL }, + { "udp", im_udp_init, im_udp_read, im_udp_close, NULL }, + { NULL, NULL, NULL, NULL, NULL } +}; /* * Create a new input module, and assign module functions to a generic pointer @@ -187,11 +218,6 @@ int ret = 1; /* create initial node for Inputs list */ - if (I == NULL) { - m_dprintf(MSYSLOG_SERIOUS, "imodule_create: Error from caller\n"); -return (-1); - } - /* go to last item on list */ for (im_prev = I; im_prev->next != NULL; im_prev = im_prev->next); @@ -220,14 +246,13 @@ } /* is it already initialized ? searching... */ - if ( ((im->func = getImodule(argv[0])) == NULL) - && ((im->func = addImodule(argv[0])) == NULL) ) - { - snprintf(err_buf, sizeof(err_buf), - "Error loading dynamic input module %s [%s]\n", - argv[0], line); - goto imodule_create_bad; - } + if ((i = getImodule(argv[0])) == -1) { + snprintf(err_buf, sizeof(err_buf), "Error loading dynamic " + "input module %s [%s]\n", argv[0], line); + goto imodule_create_bad; + } + + im->func = &imodules[i]; /* got it, now try to initialize it */ if ((*(im->func->init))(im, argv, argc) < 0) { @@ -280,7 +305,7 @@ { #define OMODULE_ARGV_MAX 20 char *line, *p, quotes, *argv[OMODULE_ARGV_MAX]; - int argc; + int argc, i; struct o_module *om, *om_prev; line = strdup(c); quotes = 0; @@ -313,18 +338,18 @@ *p++ = 0; /* find for matching module */ - if ((om->func = getOmodule(argv[0])) == NULL) { - if ((om->func = addOmodule(argv[0])) - == NULL) { + if ((i = getOmodule(argv[0])) == -1) { + snprintf(err_buf, sizeof(err_buf), "Error " "loading dynamic output " "module %s [%s]\n", argv[0], line); goto omodule_create_bad; - } } + om->func = &omodules[i]; + m_dprintf(MSYSLOG_INFORMATIVE, "omodule_create: " "got output module %s\n", argv[0]); @@ -377,16 +402,15 @@ argv[argc++] = p; p += strlen(p); /* find for matching module */ - if ((om->func = getOmodule(argv[0])) == NULL) { - if ((om->func = addOmodule(argv[0])) - == NULL) { + if ((i = getOmodule(argv[0])) == -1) { snprintf(err_buf, sizeof(err_buf), "Error loading " "dynamic output module %s [%s]\n", argv[0], line); goto omodule_create_bad; - } } + + om->func = &omodules[i]; } if (!om->func->init || @@ -491,242 +515,27 @@ } -struct imodule * -addImodule(char *name) -{ - struct imodule *im; - char buf[LIB_PATH_MAX]; - - if (name == NULL) -return (NULL); - - if (imodules == NULL) { - imodules = (struct imodule *)calloc(1, sizeof(struct imodule)); - im = imodules; - } else { - for (im = imodules; im->next; im = im->next); - im->next = (struct imodule *) calloc(1, sizeof(struct imodule)); - im = im->next; - } - im->init = NULL; - im->read = NULL; - im->close = NULL; - im->poll = NULL; - - snprintf(buf, sizeof(buf), "im_%s", name); - - if (prepare_module_libs(buf, &im->h) == -1 || - get_symbol(buf, "init", &im->h, (void *) &im->init) == -1 || - get_symbol(buf, "read", &im->h, (void *) &im->read) == -1) { - - if (imodules == im) { - imodules = NULL; - } else { - struct imodule *i = imodules; - for (; i && i->next == im; i = i->next); - if (i) - i->next = NULL; - } - - FREE_PTR(im); - - m_dprintf(MSYSLOG_SERIOUS, - "addImodule: couldn't config %s input module\n", buf); -return(NULL); - } - - /* these functions are not mandatory */ - get_symbol(buf, "close", &im->h, (void *) &im->close); - get_symbol(buf, "poll", &im->h, (void *) &im->poll); - - im->name = strdup(name); - - m_dprintf(MSYSLOG_INFORMATIVE, - "addImodule: successfully configured %s input module\n", buf); - -return (im); -} - - -struct omodule * -addOmodule(char *name) -{ - struct omodule *om; - char buf[LIB_PATH_MAX]; - - if (name == NULL) -return (NULL); - - if (omodules == NULL) { - omodules = (struct omodule *) calloc(1, sizeof(struct omodule)); - om = omodules; - } else { - for (om = omodules; om->next != NULL; om = om->next); - om->next = (struct omodule *)calloc(1, sizeof(struct omodule)); - om = om->next; - } - om->init = NULL; - om->write = NULL; - om->flush = NULL; - om->close = NULL; - - if (om == NULL) { - m_dprintf(MSYSLOG_CRITICAL, "addOmodule: %s\n", strerror(errno)); -return (NULL); - } - - snprintf(buf, sizeof(buf), "om_%s", name); - - if (prepare_module_libs(buf, &om->h) == -1 || - get_symbol(buf, "init", &om->h, (void *) &om->init) == -1 || - get_symbol(buf, "write", &om->h, (void *) &om->write) == -1) { - - if (omodules == om) { - omodules = NULL; - } else { - struct omodule *o = omodules; - - for (; o != NULL && o->next != om; o = o->next); - if (o != NULL) - o->next = NULL; - } - - FREE_PTR(om); -return (NULL); - } - - /* this is not mandatory */ - get_symbol(buf, "close", &om->h, (void *)&om->close); - get_symbol(buf, "flush", &om->h, (void *)&om->flush); - - m_dprintf(MSYSLOG_INFORMATIVE, "addOmodule: successfully configured %s " - "output module\n", buf); - - om->name = strdup(name); - -return (om); -} - - int -omoduleDestroy(struct omodule *om) -{ - if (om == NULL || om->h == NULL || om->next) -return (-1); - - if (om->h && dlclose(om->h) < 0) { - m_dprintf(MSYSLOG_SERIOUS, "Error [%s]\n", dlerror()); -return (-1); - } - - FREE_PTR(om->name); - -return (1); -} - - -struct imodule * getImodule(char *name) { - struct imodule *im; - unsigned int len; - - if (imodules == NULL || name == NULL) -return (NULL); - - for(im = imodules, len = strlen(name); im; im = im->next) - if (im->name && !strncmp(im->name, name, len)) - break; - -return (im); -} - - -struct omodule * -getOmodule(char *name) -{ - struct omodule *om; - unsigned int len; - - if (omodules == NULL || name == NULL) -return (NULL); - - for (om = omodules, len = strlen(name); om; om = om->next) - if (om->name && !strncmp(om->name, name, len)) - break; - -return (om); -} - - -/* - * This function removes an input module and - * its dynamic libraries - * - */ -int -imodules_destroy(struct imodule *i) -{ - struct imodule *im, *next, *last; - - for (im = i, last = NULL; im; im = next) { - - next = im->next; - - if (!im->h) { - last = im; - continue; - } - - if (last) - last->next = im->next; - - dlclose(im->h); - - FREE_PTR(im); - } + int i; - if (last) { - last->next = NULL; -return (1); /* there are some static modules on */ - } + for(i = 0; imodules[i].name != NULL ; i++) + if (strcmp(imodules[i].name, name) == 0) + return (i); -return (0); + return (-1); } -/* - * This function removes an output module and - * its dynamic libraries - * - */ int -omodules_destroy(struct omodule *o) +getOmodule(char *name) { - struct omodule *om, *next, *last; - - for (om = o, last = NULL; om != NULL; om = next) { - - next = om->next; - - if (om->h == NULL) { - last = om; - continue; - } - - if (last != NULL) - last->next = om->next; - - dlclose(om->h); - FREE_PTR(om); - } + int i; - if (last != NULL) { - last->next = NULL; -return (1); /* there are some static modules on */ - } + for(i = 0; omodules[i].name != NULL ; i++) + if (strcmp(omodules[i].name, name) == 0) + return (i); -return (0); + return (-1); } - - Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.255 retrieving revision 1.256 diff -u -d -r1.255 -r1.256 --- syslogd.c 9 May 2003 14:38:34 -0000 1.255 +++ syslogd.c 22 May 2003 06:57:38 -0000 1.256 @@ -39,9 +39,8 @@ #endif /* not lint */ #ifndef lint -/* static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; */ static char rcsid[] = "$Id$"; -#endif /* not lint */ +#endif /* not lint */ /* * syslogd -- log system messages @@ -205,16 +204,12 @@ void usage(void); int imodule_create(struct i_module *, char *); int omodule_create(char *, struct filed *, struct global *); -int omodules_destroy(struct omodule *); -int imodules_destroy(struct imodule *); void logerror(char *); void log_msgs(struct m_msg *); int read_input(struct i_module *, int); -void *main_lib = NULL; +int resolv_domain(char *, int, char *); -extern struct omodule *omodules; -extern struct imodule *imodules; struct i_module Inputs; /* @@ -253,29 +248,12 @@ int ch; int argcnt; int default_inputs = 1; /* start default modules? */ - int (*resolv_domain) (char *, int, char *); Inputs.next = NULL; Inputs.fd = -1; - /* init module list */ - imodules = NULL; - omodules = NULL; - setlinebuf(stdout); -#ifdef NEEDS_DLOPEN_NULL - if (dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL) == NULL) - printf("syslogd: error exporting%s\n", dlerror()); -#endif - - main_lib = dlopen(INSTALL_LIBDIR "/" MLIBNAME_STR, DLOPEN_FLAGS); - - if (main_lib == NULL) { - printf("Warning, could not open main library, [%s] file [%s]\n", - dlerror(), INSTALL_LIBDIR "/" MLIBNAME_STR); - return (-1); - } /* * Daemon options * @@ -314,9 +292,6 @@ } else if (isdigit((int) *argv[argcnt])) { Debug = strtol(argv[argcnt], NULL, 10); } - if (main_lib == NULL) - main_lib = dlopen("./" MLIBNAME_STR, DLOPEN_FLAGS); - break; case 'f': /* configuration file */ ConfFile = argv[argcnt]; break; @@ -445,11 +420,9 @@ } } gethostname(LocalHostName, sizeof(LocalHostName)); - if ((DaemonFlags & USE_LOCALDOMAIN) && - (resolv_domain = dlsym(main_lib, SYMBOL_PREFIX "resolv_domain")) - != NULL && resolv_domain(LocalHostName, sizeof(LocalHostName) - 1, - LocalHostName) == -1) - gethostname(LocalHostName, sizeof(LocalHostName)); /* again */ + if ((DaemonFlags & USE_LOCALDOMAIN) && resolv_domain(LocalHostName, + sizeof(LocalHostName) - 1, LocalHostName) == -1) + gethostname(LocalHostName, sizeof(LocalHostName)); /* again */ /* Set signal handlers */ /* XXX: use one signal handler for all signals other than HUP */ @@ -1389,34 +1362,10 @@ FREE_PTR(f); } -#ifdef REOPEN_MAIN_LIBRARY_ON_HUP - if (main_lib) { - dlclose(main_lib); - main_lib = NULL; - } - /* Load main modules library */ - if ((main_lib = dlopen(INSTALL_LIBDIR "/" MLIBNAME_STR, DLOPEN_FLAGS)) - == NULL && (Debug && (main_lib = dlopen("./" MLIBNAME_STR, - DLOPEN_FLAGS)) == NULL)) { - m_dprintf(MSYSLOG_CRITICAL, "init: Error opening main library, [%s] " - "file [%s]\n", dlerror(), INSTALL_LIBDIR "/" MLIBNAME_STR); - exit(-1); - } -#endif - /* list of filed is now empty */ Files = NULL; fnextp = &Files; - /* free all modules and their dynamic libs */ - if (signo == SIGHUP) { - if (omodules_destroy(omodules) == 0) - omodules = NULL; -#if DESTROY_INPUTS_ON_HUP - if (imodules_destroy(imodules) == 0) - imodules = NULL; -#endif - } /* open the file listing */ /* it might be useful to have this go to stdout but for now... */ if ((globals.flist_des = fopen(globals.FileListing, "w")) == NULL) { Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.118 retrieving revision 1.119 diff -u -d -r1.118 -r1.119 --- syslogd.h 6 May 2003 17:51:12 -0000 1.118 +++ syslogd.h 22 May 2003 06:57:38 -0000 1.119 @@ -262,24 +262,19 @@ #define MLIB_MAX 10 /* max external libs per module */ struct omodule { - struct omodule *next; char *name; int (*init) (int, char **, struct filed *, struct global*, void **, char **); int (*write) (struct filed *, struct m_msg *, void *); int (*flush) (struct filed *, void *); int (*close) (struct filed *, void *); - void *h; /* handle to open dynamic library */ - void *oh[MLIB_MAX]; /* handle to other dynamic libraries */ }; struct imodule { - struct imodule *next; char *name; int (*init) (struct i_module *, char **, int); int (*read) (struct i_module *, int, struct m_msg *); int (*close) (struct i_module *); /* close input, optional */ int (*poll) (struct i_module *); - void *h; /* handle to open dynamic library */ }; |
From: <al...@us...> - 2003-05-22 06:57:41
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv31529 Modified Files: Makefile.in configure configure.in Log Message: static link needs more work, but compiles Index: Makefile.in =================================================================== RCS file: /cvsroot/msyslog/syslog/Makefile.in,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- Makefile.in 17 Sep 2002 05:20:25 -0000 1.29 +++ Makefile.in 22 May 2003 06:57:37 -0000 1.30 @@ -28,9 +28,8 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -MODULES_SUBDIR = src/modules -SUBDIRS = src/peo $(MODULES_SUBDIR) src src/man -INSTALL_SUBDIRS = src/modules src/peo src/man src +SUBDIRS = src/peo src src/man +INSTALL_SUBDIRS = src src/peo src/man MSYSLOG_VERSION = @MSYSLOG_VERSION@ RELEASE= msyslog-v${MSYSLOG_VERSION} TARBALL= ${RELEASE}-src.tar.gz @@ -51,12 +50,6 @@ for subdir in $$list; do \ (cd $$subdir && exec $(MAKE) $$target) \ done - -modules: - cd $(MODULES_SUBDIR) && make all - -modules-install: - cd $(MODULES_SUBDIR) && make install .PHONY: clean distclean install Index: configure =================================================================== RCS file: /cvsroot/msyslog/syslog/configure,v retrieving revision 1.97 retrieving revision 1.98 diff -u -d -r1.97 -r1.98 --- configure 17 Apr 2003 18:36:44 -0000 1.97 +++ configure 22 May 2003 06:57:37 -0000 1.98 @@ -3711,7 +3711,6 @@ #define SYMBOL_PREFIX "_" EOF - SHARED_PARAMS="-Bshareable" DCCFLAGS="-fPIC" elif test "$UNAME" = "Linux" ; then cat >>confdefs.h <<\EOF @@ -3723,7 +3722,6 @@ EOF MAIN_CPPFLAGS="-Xlinker -E"; [...1101 lines suppressed...] { (exit 1); exit 1; }; } echo $f;; @@ -5882,7 +5887,7 @@ echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5885: error: cannot find input file: $f" >&5 + { { echo "$as_me:5890: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -5999,7 +6004,7 @@ rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:6002: $ac_file is unchanged" >&5 + { echo "$as_me:6007: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ Index: configure.in =================================================================== RCS file: /cvsroot/msyslog/syslog/configure.in,v retrieving revision 1.160 retrieving revision 1.161 diff -u -d -r1.160 -r1.161 --- configure.in 17 Apr 2003 18:36:44 -0000 1.160 +++ configure.in 22 May 2003 06:57:38 -0000 1.161 @@ -143,20 +143,17 @@ if test "$UNAME" = "OpenBSD" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) AC_DEFINE(SYMBOL_PREFIX, "_") - SHARED_PARAMS="-Bshareable" DCCFLAGS="-fPIC" elif test "$UNAME" = "Linux" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY | RTLD_GLOBAL) AC_DEFINE(SYMBOL_PREFIX, "") MAIN_CPPFLAGS="-Xlinker -E"; - SHARED_PARAMS="-Bshareable" DCCFLAGS="" AC_DEFINE(_GNU_SOURCE, 1) elif test "$UNAME" = "SunOS" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) AC_DEFINE(_REENTRANT, 1) AC_DEFINE(SYMBOL_PREFIX, "") - SHARED_PARAMS="-G" DCCFLAGS="-fPIC" elif test "$UNAME" = "IRIX" -o "$UNAME" = "IRIX64" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) @@ -172,13 +169,11 @@ CFLAGS="$CFLAGS -g3 -Ofast" fi fi - SHARED_PARAMS="-shared -soname $MLIBNAME -all" elif test "$UNAME" = "AIX" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY | RTLD_GLOBAL) AC_DEFINE(NEEDS_DLOPEN_NULL, 1) AC_DEFINE(SYMBOL_PREFIX, "") DCCFLAGS="-shared" - SHARED_PARAMS="-lc -bI:libmsyslog.imp -bexpall -bnoentry -brtl" cat > src/modules/libmsyslog.imp <<-EOF #! . m_dprintf @@ -194,7 +189,6 @@ AC_MSG_WARN(cannot determine system type falling to defaults) AC_DEFINE(SYMBOL_PREFIX, "") AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) - SHARED_PARAMS="-Bshareable" fi # Name of pidfile @@ -289,7 +283,7 @@ ],[ temp_res="$with_serial"; ]) if test "X$temp_res" = "Xyes" ; then MSRCS="$MSRCS im_serial.c" - AC_DEFINE(HAVE_FILE_IMODULE, 1) + AC_DEFINE(HAVE_SERIAL_IMODULE, 1) MANPAGES="$MANPAGES im_serial.8" fi @@ -350,6 +344,7 @@ MANPAGES="$MANPAGES om_classic.8" fi + AC_ARG_WITH(tcp, [ --without-tcp Use tcp input and output modules. Activated by default. @@ -379,11 +374,14 @@ if test $with_oracle8i = "yes" ; then MSRCS="$MSRCS om_oracle8i.c" MANPAGES="$MANPAGES om_oracle8i.8" + USESQL="yes" + AC_DEFINE(HAVE_ORACLE8I_OMODULE, 1) fi ],[ MSRCS="$MSRCS om_oracle8i.c" MANPAGES="$MANPAGES om_oracle8i.8" USESQL="yes" + AC_DEFINE(HAVE_ORACLE8I_MODULE, 1) ]) AC_ARG_WITH(mysql, @@ -438,11 +436,13 @@ if test $with_queue = "yes" ; then MSRCS="$MSRCS om_queue.c om_directory.c" MANPAGES="$MANPAGES om_directory.8" + AC_DEFINE(HAVE_QUEUE_OMODULE, 1) fi ] dnl ,[ dnl MSRCS="$MSRCS om_queue.c om_directory.c" dnl MANPAGES="$MANPAGES om_directory.8" +dnl AC_DEFINE(HAVE_QUEUE_OMODULE, 1) dnl ] ) @@ -453,10 +453,12 @@ if test $with_refract = "yes" ; then MSRCS="$MSRCS om_refract.c" MANPAGES="$MANPAGES om_refract.8" + AC_DEFINE(HAVE_REFRACT_OMODULE, 1) fi ],[ MSRCS="$MSRCS om_refract.c" MANPAGES="$MANPAGES om_refract.8" + AC_DEFINE(HAVE_REFRACT_OMODULE, 1) ]) HASH_SRCS=""; @@ -466,22 +468,14 @@ MANPAGES="$MANPAGES om_peo.8 peochk.8" HASH_SRCS="../peo/hash.c"; - HASH_SRCS_MODULES="../peo/hash.c"; - HASH_OBJS_MODULES="../peo/hash.o"; AC_CHECK_FUNC(MD5Init, AC_DEFINE(HAVE_MD5, 1), HASH_SRCS="$HASH_SRCS ../peo/md5c.c"; - HASH_SRCS_MODULES="$HASH_SRCS_MODULES ../peo/md5c.c"; - HASH_OBJS_MODULES="$HASH_OBJS_MODULES ../peo/md5c.o"; ) AC_CHECK_FUNC(SHA1Init, AC_DEFINE(HAVE_SHA1, 1), HASH_SRCS="$HASH_SRCS ../peo/sha1.c"; - HASH_SRCS_MODULES="$HASH_SRCS_MODULES ../peo/sha1.c"; - HASH_OBJS_MODULES="$HASH_OBJS_MODULES ../peo/sha1.o"; ) AC_CHECK_FUNC(RMD160Init, AC_DEFINE(HAVE_RMD160, 1), HASH_SRCS="$HASH_SRCS ../peo/rmd160.c"; - HASH_SRCS_MODULES="$HASH_SRCS_MODULES ../peo/rmd160.c"; - HASH_OBJS_MODULES="$HASH_OBJS_MODULES ../peo/rmd160.o"; ) if test -r /dev/srandom ; then AC_DEFINE(HAVE_SRANDOM, 1) @@ -521,6 +515,7 @@ -o "$ac_cv_header_ucd_snmp_ucd_snmp_config_h" == yes \); then MSRCS="$MSRCS om_snmptrap.c" MANPAGES="$MANPAGES om_snmptrap.8" + AC_DEFINE(HAVE_SNMPTRAP_OMODULE, 1) fi @@ -543,15 +538,12 @@ AC_SUBST(SYSLOGD_LIBS) -AC_SUBST(SHARED_PARAMS) AC_SUBST(DCCFLAGS) AC_SUBST(MSRCS) AC_SUBST(MLIBS) AC_SUBST(MLIBNAME) AC_SUBST(MANPAGES) AC_SUBST(HASH_SRCS) -AC_SUBST(HASH_SRCS_MODULES) -AC_SUBST(HASH_OBJS_MODULES) AC_SUBST(HAVE_SOCKLEN_T) AC_SUBST(MAIN_CPPFLAGS) AC_SUBST(MSYSLOG_DAEMON_NAME) @@ -562,7 +554,6 @@ AC_OUTPUT([Makefile src/Makefile - src/modules/Makefile src/peo/Makefile src/man/Makefile src/man/BSDmakefile |
From: <al...@us...> - 2003-05-20 05:23:48
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv2408/src/modules Modified Files: om_classic.c Log Message: add comment to avoid future wrong string fix, from OpenBSD Index: om_classic.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_classic.c,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- om_classic.c 24 Apr 2003 17:21:38 -0000 1.96 +++ om_classic.c 20 May 2003 05:23:42 -0000 1.97 @@ -524,6 +524,7 @@ #endif continue; + /* must use strncpy since ut_* may not be NUL terminated */ strncpy(line, ut.ut_line, sizeof (line) - 1); line[sizeof (line) - 1] = '\0'; |
From: <ph...@us...> - 2003-05-09 14:38:38
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv20369/syslog/src/modules Modified Files: om_queue.c Log Message: When an output module's write function returns an error the rule should fail. Index: om_queue.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_queue.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- om_queue.c 23 Apr 2003 18:42:32 -0000 1.9 +++ om_queue.c 9 May 2003 14:38:35 -0000 1.10 @@ -252,10 +252,10 @@ { int encoded_length = strlen(fil->prevhost) * 6; char encoded_payload[encoded_length]; - fprintf( filehandle, "\n<patient>%s</patient>", - xml_encode(fil->prevhost, encoded_payload, encoded_length) ); + fprintf( filehandle, "\n<patient addr=\"%s\"/>", + xml_encode(fil->f_prevhost, encoded_payload, encoded_length) ); } - fprintf( filehandle, "\n<timestamp>%d</timestamp>", (int)timer ); + fprintf( filehandle, "\n<timestamp epoch=\"%d\"/>", (int)timer ); if (ctx->key) { int encoded_length = strlen(ctx->key) * 6; @@ -517,7 +517,8 @@ if (ctx->semaphore >= 0) break; if (ix > 5) { snprintf(statbuf, sizeof(statbuf), "om_queue: " - "semaphore set for key (0x%lx) NOT created", semkey); + "semaphore set for key (0x%lx) NOT created", + (long unsigned int)semkey); m_dprintf(MSYSLOG_SERIOUS, "%s\n", statbuf); *status = strdup(statbuf); return (-1); |
From: <ph...@us...> - 2003-05-09 14:38:38
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv20369/syslog/src Modified Files: modules.c syslogd.c Log Message: When an output module's write function returns an error the rule should fail. Index: modules.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules.c,v retrieving revision 1.173 retrieving revision 1.174 diff -u -d -r1.173 -r1.174 --- modules.c 23 Apr 2003 18:39:42 -0000 1.173 +++ modules.c 9 May 2003 14:38:34 -0000 1.174 @@ -267,7 +267,7 @@ /* - * Create a new input module, and assign module functions to generic pointer + * Create a new output module, and assign module functions to generic pointer * while addinf it to a filed * * c (line) is the command line of the input module @@ -660,7 +660,7 @@ /* - * This function removes an output module and + * This function removes an input module and * its dynamic libraries * */ Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.254 retrieving revision 1.255 diff -u -d -r1.254 -r1.255 --- syslogd.c 6 May 2003 17:51:40 -0000 1.254 +++ syslogd.c 9 May 2003 14:38:34 -0000 1.255 @@ -1185,22 +1185,22 @@ if (ret == 0) break; - /* negative) indicative of an error */ + /* negative indicates an error, an error should not + * be treated as a fire/match situation */ if (ret < 0) { - m_dprintf(MSYSLOG_SERIOUS, "do_log: error with output " "module [%s] for message [%s]\n", om->func->name, m->msg); - } else { + break; + } - /* positive indicates if the module fired/matched */ - /* - * if this was the last module, then all of the - * modules have fired, and hence the rule has fired - */ - if (om->next == NULL) - INCREASE_SENT(m); - } + /* positive indicates that the module fired/matched */ + /* + * if this was the last module, then all of the + * modules have fired, and hence the rule has fired + */ + if (om->next == NULL) + INCREASE_SENT(m); } } |
From: <al...@us...> - 2003-05-06 17:51:44
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv1763/src Modified Files: syslogd.c Log Message: remove old unused listings Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.253 retrieving revision 1.254 diff -u -d -r1.253 -r1.254 --- syslogd.c 25 Apr 2003 03:17:17 -0000 1.253 +++ syslogd.c 6 May 2003 17:51:40 -0000 1.254 @@ -189,7 +189,7 @@ #define DONT_COLLAPSE 0x10 char *libdir = NULL; -struct global globals = {NULL, NULL, NULL}; +struct global globals = {NULL, NULL, NULL}; RETSIGTYPE domark(int); RETSIGTYPE reapchild(int); @@ -298,16 +298,13 @@ * XXX: this should be sorted alphabetically (string and case) */ - for (argcnt = 1; (ch = getxopt(argc, argv, " l!list d!debug: i!input: " + for (argcnt = 1; (ch = getxopt(argc, argv, " d!debug: i!input: " "f!conf: m!markinterval: P!pidfile: c!console A!localdomain " "n!nodefault C!nocollapse h!help u!udp p!path a!add s!savemsgs:", &argcnt)) != -1; argcnt++) { char buf[512]; switch (ch) { - case 'l': /* listing of files/directories etc. */ - globals.FileListing = argv[argcnt]; - break; case 'd': /* debug */ if (argcnt >= argc || *argv[argcnt] == '-' || !isdigit((int) *argv[argcnt])) { |
From: <al...@us...> - 2003-05-06 17:51:16
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv1560/src Modified Files: syslogd.h Log Message: fix priorities Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -r1.117 -r1.118 --- syslogd.h 24 Apr 2003 21:16:31 -0000 1.117 +++ syslogd.h 6 May 2003 17:51:12 -0000 1.118 @@ -313,7 +313,7 @@ #ifdef INTERNAL_NOPRI #undef INTERNAL_NOPRI #endif -#define INTERNAL_NOPRI 0x100 +#define INTERNAL_NOPRI 0x10 #ifndef HAVE_CODE # ifdef SYSLOG_NAMES @@ -360,6 +360,7 @@ { "panic", LOG_EMERG }, /* DEPRECATED */ { "warn", LOG_WARNING }, /* DEPRECATED */ { "warning", LOG_WARNING }, + {"*", TABLE_ALLPRI}, { NULL, -1 } }; |
From: <al...@us...> - 2003-04-25 03:17:23
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv25415/src Modified Files: syslogd.c Log Message: set priority mask properly reinsert debug msg Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.252 retrieving revision 1.253 diff -u -d -r1.252 -r1.253 --- syslogd.c 24 Apr 2003 22:27:06 -0000 1.252 +++ syslogd.c 25 Apr 2003 03:17:17 -0000 1.253 @@ -1041,6 +1041,10 @@ sigaddset(&mask, SIGTSTP); sigprocmask(SIG_BLOCK, &mask, &omask); + m_dprintf(MSYSLOG_INFORMATIVE, "log_msgs: pri 0%o, flags 0x%x, from " + "%s, msg %s\n", LOG_MAKEPRI(m->vals[M_VAL_FAC], m->vals[M_VAL_PRI]), + m->flags, m->host, m->msg); + /* log the message to the particular outputs */ if (!Initialized) { @@ -1573,7 +1577,10 @@ singlpri = 0; /* clear out file entry */ - memset(f->pmask, TABLE_NOPRI, sizeof(f->pmask)); + memset(f->pmask, 0, sizeof(f->pmask)); + + for (i = 0; i <= LOG_NFACILITIES; i++) + f->pmask[i] = INTERNAL_NOPRI; /* save program name if any */ if (!strcmp(prog, "*")) { |
From: <al...@us...> - 2003-04-24 22:27:10
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv31673/src Modified Files: syslogd.c Log Message: duh, parehtheses typo Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.251 retrieving revision 1.252 diff -u -d -r1.251 -r1.252 --- syslogd.c 24 Apr 2003 22:24:45 -0000 1.251 +++ syslogd.c 24 Apr 2003 22:27:06 -0000 1.252 @@ -1072,7 +1072,7 @@ || (f->pmask[m->vals[M_VAL_FAC]] == INTERNAL_NOPRI)) continue; - if (f->program[0] != '\0') && m->flags & M_FLAG_PROG) + if (f->program[0] != '\0' && m->flags & M_FLAG_PROG) if (strcmp(m->program, f->program) != 0) continue; |
From: <al...@us...> - 2003-04-24 22:24:55
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv30537/src Modified Files: syslogd.c Log Message: move MARK code to proper place while there, some style Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.250 retrieving revision 1.251 diff -u -d -r1.250 -r1.251 --- syslogd.c 24 Apr 2003 21:09:18 -0000 1.250 +++ syslogd.c 24 Apr 2003 22:24:45 -0000 1.251 @@ -832,11 +832,7 @@ } /* now sepparate it */ - if ((m->fields & M_FIELD_FLAGS) && (m->flags & M_FLAG_MARK)) - - m->vals[M_VAL_FAC] = LOG_NFACILITIES; - else - m->vals[M_VAL_FAC] = LOG_FAC(prifac); + m->vals[M_VAL_FAC] = LOG_FAC(prifac); m->vals[M_VAL_PRI] = LOG_PRI(prifac); m->fields |= M_FIELD_PRI | M_FIELD_FAC; @@ -997,7 +993,11 @@ m->flags = flags; m->vals[M_VAL_PRI] = LOG_PRI(pri); - m->vals[M_VAL_FAC] = LOG_FAC(pri); + + if ((m->fields & M_FIELD_FLAGS) && (m->flags & M_FLAG_MARK)) + m->vals[M_VAL_FAC] = LOG_NFACILITIES; + else + m->vals[M_VAL_FAC] = LOG_FAC(pri); strncpy(m->msg, msg, sizeof (m->msg) - 1); m->msg[sizeof (m->msg) - 1] = '\0'; @@ -1057,7 +1057,9 @@ FREE_PTR(consfile.omod); } } + sigprocmask(SIG_SETMASK, &omask, NULL); + return; } @@ -1109,9 +1111,9 @@ /* new line, save it */ /* flush previous line */ - if (f->prevcount) { + if (f->prevcount) do_log(f, NULL); - } + /* * Start counting again, save host data etc. */ @@ -1122,7 +1124,8 @@ do_log(f, m); } } - (void) sigprocmask(SIG_SETMASK, &omask, NULL); + + sigprocmask(SIG_SETMASK, &omask, NULL); } |
From: <al...@us...> - 2003-04-24 21:16:35
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv2339/src Modified Files: syslogd.h Log Message: nuke strings, just for fun Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.116 retrieving revision 1.117 diff -u -d -r1.116 -r1.117 --- syslogd.h 23 Apr 2003 18:38:53 -0000 1.116 +++ syslogd.h 24 Apr 2003 21:16:31 -0000 1.117 @@ -212,7 +212,9 @@ uint32_t ulen; /* user (name) length */ }; -#define CLEAR_MSG(m) { (m)->next = NULL; (m)->fields = 0; (m)->flags = 0; } +#define CLEAR_MSG(m) { (m)->next = NULL; (m)->fields = 0; (m)->flags = 0; \ + (m)->msg[0] = '\0'; (m)->host[0] = '\0'; \ + (m)->program[0] = '\0'; (m)->user[0] = '\0'; } #define INCREASE_SENT(m) { if (m->fields & M_FIELD_SENT) { \ m->vals[M_VAL_SENT]++; \ |
From: <al...@us...> - 2003-04-24 21:09:27
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv31422/src Modified Files: syslogd.c Log Message: only compare program if there's something to compare to Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.249 retrieving revision 1.250 diff -u -d -r1.249 -r1.250 --- syslogd.c 24 Apr 2003 19:52:26 -0000 1.249 +++ syslogd.c 24 Apr 2003 21:09:18 -0000 1.250 @@ -1,5 +1,4 @@ /* $Id$ */ - /* * Copyright (c) 1983, 1988, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -1071,7 +1070,7 @@ || (f->pmask[m->vals[M_VAL_FAC]] == INTERNAL_NOPRI)) continue; - if (f->program[0] != '\0') + if (f->program[0] != '\0') && m->flags & M_FLAG_PROG) if (strcmp(m->program, f->program) != 0) continue; |
From: <al...@us...> - 2003-04-24 19:52:33
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv31233/src Modified Files: syslogd.c Log Message: lower the warn level Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.248 retrieving revision 1.249 diff -u -d -r1.248 -r1.249 --- syslogd.c 24 Apr 2003 17:18:32 -0000 1.248 +++ syslogd.c 24 Apr 2003 19:52:26 -0000 1.249 @@ -1417,7 +1417,7 @@ /* open the file listing */ /* it might be useful to have this go to stdout but for now... */ if ((globals.flist_des = fopen(globals.FileListing, "w")) == NULL) { - m_dprintf(MSYSLOG_SERIOUS, "cannot open listing: %s\n", globals.FileListing); + m_dprintf(MSYSLOG_WARNING, "cannot open listing: %s\n", globals.FileListing); } /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { |
From: <al...@us...> - 2003-04-24 17:21:43
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv30842/src/modules Modified Files: om_classic.c Log Message: fix mixed m_dprintf lines Index: om_classic.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_classic.c,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- om_classic.c 23 Apr 2003 18:42:29 -0000 1.95 +++ om_classic.c 24 Apr 2003 17:21:38 -0000 1.96 @@ -169,8 +169,6 @@ v->iov_len = m->mlen; v++; - m_dprintf(MSYSLOG_INFORMATIVE, "Logging to %s", TypeNames[c->f_type]); - switch (c->f_type) { case F_UNUSED: m_dprintf(MSYSLOG_INFORMATIVE, "\n"); @@ -183,7 +181,9 @@ return(-1); } - m_dprintf(MSYSLOG_INFORMATIVE, " %s\n", c->f_un.f_forw.f_hname); + m_dprintf(MSYSLOG_INFORMATIVE, "om_classic: logging to %s %s\n", + TypeNames[c->f_type], c->f_un.f_forw.f_hname); + l = snprintf(line, sizeof(line), "<%d>%.15s %s", LOG_MAKEPRI(m->vals[M_VAL_FAC], m->vals[M_VAL_PRI]), (char *) iov[0].iov_base, (char *) iov[4].iov_base); @@ -195,7 +195,7 @@ #endif sizeof(struct sockaddr_in)) != l) { c->f_type = F_UNUSED; - m_dprintf(MSYSLOG_WARNING, "om_classic: error on sendto()"); + m_dprintf(MSYSLOG_WARNING, "om_classic: error on sendto()\n"); } break; @@ -212,7 +212,10 @@ case F_TTY: case F_PIPE: case F_FILE: - m_dprintf(MSYSLOG_INFORMATIVE, " %s\n", c->f_un.f_fname); + + m_dprintf(MSYSLOG_INFORMATIVE, "om_classic: logging to %s %s\n", + TypeNames[c->f_type], c->f_un.f_fname); + if (c->f_type != F_FILE) { v->iov_base = "\r\n"; v->iov_len = 2; @@ -240,7 +243,9 @@ if (c->fd < 0) { c->f_type = F_UNUSED; m_dprintf(MSYSLOG_WARNING, "om_classic: " - "error on %s", c->f_un.f_fname); + "error on %s [%s]\n", c->f_un.f_fname, + strerror(errno)); + fflush(stdout); } else goto again; } else { @@ -248,7 +253,8 @@ c->fd = -1; errno = e; m_dprintf(MSYSLOG_WARNING, "om_classic: error " - "on %s", c->f_un.f_fname); + "on %s [%s]\n", c->f_un.f_fname, + strerror(errno)); } } else if ((m->fields & M_FIELD_FLAGS) @@ -261,7 +267,10 @@ case F_USERS: case F_WALL: - m_dprintf(MSYSLOG_INFORMATIVE, "\n"); + + m_dprintf(MSYSLOG_INFORMATIVE, "om_classic: logging to %s\n", + TypeNames[c->f_type]); + v->iov_base = "\r\n"; v->iov_len = 2; wallmsg(f, iov, c); |
From: <al...@us...> - 2003-04-24 17:18:40
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv29413/src Modified Files: syslogd.c Log Message: add_host() to add local host, internal msgsneeded it too Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.247 retrieving revision 1.248 diff -u -d -r1.247 -r1.248 --- syslogd.c 23 Apr 2003 23:06:08 -0000 1.247 +++ syslogd.c 24 Apr 2003 17:18:32 -0000 1.248 @@ -723,6 +723,16 @@ } void +add_host(struct m_msg *m) +{ + /* add local host name */ + strncpy(m->host, LocalHostName, sizeof (m->host) - 1); + m->host[sizeof (m->host) - 1] = '\0'; + m->hlen = strlen(m->host); + m->fields |= M_FIELD_HOST; +} + +void set_date(struct m_msg *m) { time_t now; @@ -863,11 +873,7 @@ if ((m->fields & M_FIELD_FLAGS) && (m->flags & M_FLAG_ADDHOST)) { - /* add local host name */ - strncpy(m->host, LocalHostName, sizeof (m->host) - 1); - m->host[sizeof (m->host) - 1] = '\0'; - m->hlen = strlen(m->host); - m->fields |= M_FIELD_HOST; + add_host(m); } else if (!(m->fields & M_FIELD_HOST)) { @@ -1010,6 +1016,8 @@ set_date(m); set_tm(m); } + + add_host(m); log_msgs(m); } |
From: <al...@us...> - 2003-04-23 23:06:13
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv26533/src Modified Files: syslogd.c Log Message: for now, only use "program[PID]:" for program parsing Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.246 retrieving revision 1.247 diff -u -d -r1.246 -r1.247 --- syslogd.c 23 Apr 2003 21:01:07 -0000 1.246 +++ syslogd.c 23 Apr 2003 23:06:08 -0000 1.247 @@ -907,12 +907,14 @@ m->fields |= M_FIELD_PROG; b += n; +#if 0 } else if (sscanf(&buf[b], "%" MAX_PROGNAME_SIZE_STR "[^:]: %n", m->program, &n) == 1 && n > 0) { m->plen = strlen(m->program); m->fields |= M_FIELD_PROG; b += n; +#endif } } else if (!(m->fields & M_FIELD_PROG)) |
From: <al...@us...> - 2003-04-23 21:01:16
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv8327/src Modified Files: syslogd.c Log Message: parse correctly program & pid while there, correct assingments on length, and remove unneeded string terminations from sscanf() Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.245 retrieving revision 1.246 diff -u -d -r1.245 -r1.246 --- syslogd.c 23 Apr 2003 18:39:15 -0000 1.245 +++ syslogd.c 23 Apr 2003 21:01:07 -0000 1.246 @@ -876,8 +876,7 @@ if (sscanf(&buf[b], "%" MAX_HOST_SIZE_STR "s %n", m->host, &n) == 1 && n > 0) { - m->host[sizeof (m->host) - 1] = '\0'; /* XXX: needed ? */ - m->hlen = n; + m->hlen = strlen(m->host); b += n; } else { @@ -894,12 +893,24 @@ /* Extract program name */ if ((m->fields & M_FIELD_FLAGS) && (m->flags & M_FLAG_PROG)) { + /* + * program[pid] or just program + */ + n = 0; - if (sscanf(&buf[b], "%" MAX_PROGNAME_SIZE_STR "s %n", m->program, &n) - == 1 && n > 0) { + if (sscanf(&buf[b], "%" MAX_PROGNAME_SIZE_STR "[^[][%d]: %n", + m->program, &m->vals[M_VAL_PID], &n) == 1 && n > 0) { - m->program[sizeof (m->program) - 1] = '\0'; /* XXX: needed ? */ - m->plen = n; + m->fields |= M_FIELD_PID; + + m->plen = strlen(m->program); + m->fields |= M_FIELD_PROG; + b += n; + + } else if (sscanf(&buf[b], "%" MAX_PROGNAME_SIZE_STR "[^:]: %n", + m->program, &n) == 1 && n > 0) { + + m->plen = strlen(m->program); m->fields |= M_FIELD_PROG; b += n; } |