diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-23 09:18:52 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-23 09:18:52 +0000 |
commit | 81cb74af2e580d29cff01543119f646c3f4ff987 (patch) | |
tree | 965acdbc566ff0295d62dc19752426c387508a2f | |
parent | 8425445c2dd68d91bb62487032151f06d35c583a (diff) | |
download | rsyslog-81cb74af2e580d29cff01543119f646c3f4ff987.tar.gz rsyslog-81cb74af2e580d29cff01543119f646c3f4ff987.tar.xz rsyslog-81cb74af2e580d29cff01543119f646c3f4ff987.zip |
fixed a very nasty bug in structure creation of struct filed (caused
omusrmsg to be defunct) - many thanks to maharaja for providing the
right idea at the right time ;)
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | module.h | 1 | ||||
-rw-r--r-- | omusrmsg.c | 19 | ||||
-rw-r--r-- | rsyslog.h | 5 | ||||
-rw-r--r-- | syslogd-types.h | 51 | ||||
-rw-r--r-- | syslogd.c | 33 |
6 files changed, 25 insertions, 86 deletions
diff --git a/Makefile.am b/Makefile.am index 1bb3ca0a..1c2146a9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ rfc3195d_SOURCES=rfc3195d.c rsyslog.h man_MANS = rfc3195d.8 rklogd.8 rsyslogd.8 rsyslog.conf.5 -rsyslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h template.h outchannel.h syslogd.h stringbuf.h parse.h srUtils.h liblogging-stub.h net.c net.h msg.c msg.h omshell.c omshell.h omusrmsg.c omusrmsg.h ommysql.c ommysql.h omfwd.c omfwd.h tcpsyslog.c tcpsyslog.h omfile.h omfile.c +rsyslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h template.h outchannel.h syslogd.h stringbuf.h parse.h srUtils.h liblogging-stub.h net.c net.h msg.c msg.h omshell.c omshell.h omusrmsg.c omusrmsg.h ommysql.c ommysql.h omfwd.c omfwd.h tcpsyslog.c tcpsyslog.h omfile.h omfile.c modules.c modules.h rsyslogd_CPPFLAGS=$(mysql_includes) rsyslogd_LDADD=$(mysql_libs) $(zlib_libs) $(pthreads_libs) @@ -1,4 +1,3 @@ - /* Module definitions for klogd's module support */ struct kernel_sym { @@ -27,6 +27,7 @@ * A copy of the GPL can be found in the file "COPYING" in this distribution. */ #include "config.h" +#include "rsyslog.h" #include <stdio.h> #include <stdarg.h> #include <stdlib.h> @@ -44,10 +45,10 @@ #else #include <sys/msgbuf.h> #endif -#include "rsyslog.h" -#include "syslogd.h" -#include "syslogd-types.h" #include "srUtils.h" +#include "stringbuf.h" +#include "syslogd-types.h" +#include "syslogd.h" #include "omusrmsg.h" @@ -104,7 +105,7 @@ void endutent(void) * Adjust the size of a variable to prevent a buffer overflow * should _PATH_DEV ever contain something different than "/dev/". */ -static void wallmsg(register selector_t *f) +static void wallmsg(selector_t *f) { char p[sizeof(_PATH_DEV) + UNAMESZ]; @@ -120,8 +121,6 @@ static void wallmsg(register selector_t *f) return; iovCreate(f); /* init the iovec */ -printf("gen iIovUsed %d\n", f->f_iIovUsed); -printf("iovUsed address: %x, size %d\n",&f->f_iIovUsed, sizeof(selector_t)); /* open the user login file */ setutent(); @@ -181,19 +180,13 @@ printf("iovUsed address: %x, size %d\n",&f->f_iIovUsed, sizeof(selector_t)); (void) signal(SIGALRM, endtty); (void) alarm(15); /* open the terminal */ -//errno = 0; ttyf = open(p, O_WRONLY|O_NOCTTY); -printf("try tty '%s' open: %d\n", p, ttyf); if (ttyf >= 0) { -printf("tty open!\n"); struct stat statb; if (fstat(ttyf, &statb) == 0 && (statb.st_mode & S_IWRITE)) { -int written; - // (void) writev(ttyf, f->f_iov, f->f_iIovUsed); - written = writev(ttyf, f->f_iov, f->f_iIovUsed); -printf("write tty %d bytes, iIovUsed %d\n", written, f->f_iIovUsed); + (void) writev(ttyf, f->f_iov, f->f_iIovUsed); } close(ttyf); ttyf = -1; @@ -19,12 +19,15 @@ # undef _LARGEFILE_SOURCE # undef _LARGEFILE64_SOURCE # undef _FILE_OFFSET_BITS -# define _GNU_SOURCE # define _LARGEFILE_SOURCE # define _LARGEFILE64_SOURCE # define _FILE_OFFSET_BITS 64 #endif +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + /* The error codes below are orginally "borrowed" from * liblogging. As such, we reserve values up to -2999 * just in case we need to borrow something more ;) diff --git a/syslogd-types.h b/syslogd-types.h index b565a964..d4e9e81d 100644 --- a/syslogd-types.h +++ b/syslogd-types.h @@ -30,6 +30,7 @@ #include "net.h" #include <sys/param.h> #include <sys/syslog.h> +#include <utmp.h> /* TOODO: this goes away when struct filed has been relieved of UT_NAMESIZE */ #define FALSE 0 #define TRUE 1 @@ -241,56 +242,6 @@ struct filed { typedef struct filed selector_t; /* new type name */ -/* The following definitions are to be used for modularization. Currently, - * the code is NOT actually used. I am just adding pieces to it as I - * go along in designing the interface. - * rgerhards, 2007-07-19 - */ -typedef enum eModType_ { - eMOD_IN, /* input module */ - eMOD_OUT, /* output module */ - eMOD_FILTER /* filter module (not know yet if we will once have such at all...) */ -} eModType_t; - -/* how is this module linked? */ -typedef enum eModLinkType_ { - eMOD_LINK_STATIC, - eMOD_LINK_DYNAMIC_UNLOADED, /* dynalink module, currently not loaded */ - eMOD_LINK_DYNAMIC_LOADED /* dynalink module, currently loaded */ -} eModLinkType_t; - -typedef struct moduleInfo { - struct moduleInfo *pNext; /* support for creating a linked module list */ - int iModVers; /* Interface version of module */ - eModType_t eModType; /* type of this module */ - eModLinkType_t eModLinkType; - uchar* pszModName; /* printable module name, e.g. for dprintf */ - /* functions supported by all types of modules */ - rsRetVal (*modInit)(); /* initialize the module */ - /* be sure to support version handshake! */ - rsRetVal (*modExit)(); /* called before termination or module unload */ - /* below: parse a configuration line - return if processed - * or not. If not, must be parsed to next module. - */ - rsRetVal (*parseConfigLine)(uchar **pConfLine); - /* below: create an instance of this module. Most importantly the module - * can allocate instance memory in this call. - */ - rsRetVal (*createInstance)(); - union { - struct {/* data for input modules */ - /* input modules come after output modules are finished, I am - * currently not really thinking about them. rgerhards, 2007-07-19 - */ - }; - struct {/* data for output modules */ - /* below: perform the configured action - */ - rsRetVal (*doAction)(); - }; - } mod; -} modInfo_t; - #ifdef SYSLOG_INET struct AllowedSenders { struct NetAddr allowedSender; /* ip address allowed */ @@ -83,13 +83,12 @@ * A copy of the GPL can be found in the file "COPYING" in this distribution. */ #include "config.h" +#include "rsyslog.h" #ifdef __FreeBSD__ #define BSD #endif -#define _GNU_SOURCE - /* change the following setting to e.g. 32768 if you would like to * support large message sizes for IHE (32k is the current maximum * needed for IHE). I was initially tempted to increase it to 32k, @@ -204,7 +203,6 @@ #include "mysql/errmsg.h" #endif -#include "rsyslog.h" #include "srUtils.h" #include "stringbuf.h" #include "syslogd-types.h" @@ -3215,11 +3213,9 @@ void iovCreate(selector_t *f) f->f_iIovUsed = iIOVused; -#if 1 /* debug aid */ +#if 0 /* debug aid */ { int i; - printf("iovUsed address: %x, size %d\n",&f->f_iIovUsed, sizeof(selector_t)); - printf("dumping iov:\n"); v = f->f_iov; for(i = 0 ; i < iIOVused ; ++i, ++v) { printf("iovCreate(%d), string '%s', mustbeFreed %d\n", i, @@ -4538,13 +4534,12 @@ static void cflineSetTemplateAndIOV(selector_t *f, char *pTemplateName) * to be \0 in this case. * rgerhards 2004-11-19 */ -static void cflineParseTemplateName(selector_t *f, uchar** pp, +static void cflineParseTemplateName(uchar** pp, register char* pTemplateName, int iLenTemplate) { register uchar *p; int i; - assert(f != NULL); assert(pp != NULL); assert(*pp != NULL); @@ -4601,7 +4596,7 @@ static void cflineParseFileName(selector_t *f, uchar* p) if(*p == ';') ++p; /* eat it */ - cflineParseTemplateName(f, &p, szTemplateName, + cflineParseTemplateName(&p, szTemplateName, sizeof(szTemplateName) / sizeof(char)); if(szTemplateName[0] == '\0') /* no template? */ @@ -4687,7 +4682,7 @@ static void cflineParseOutchannel(selector_t *f, uchar* p) if(*p == ';') ++p; /* eat it */ - cflineParseTemplateName(f, &p, szBuf, + cflineParseTemplateName(&p, szBuf, sizeof(szBuf) / sizeof(char)); if(szBuf[0] == '\0') /* no template? */ @@ -4970,14 +4965,13 @@ static rsRetVal cflineProcessPropFilter(uchar **pline, register selector_t *f) * from the config file ("+/-hostname"). It stores it for further reference. * rgerhards 2005-10-19 */ -static rsRetVal cflineProcessHostSelector(uchar **pline, register selector_t *f) +static rsRetVal cflineProcessHostSelector(uchar **pline) { rsRetVal iRet; assert(pline != NULL); assert(*pline != NULL); assert(**pline == '-' || **pline == '+'); - assert(f != NULL); dprintf(" - host selector line\n"); @@ -5023,14 +5017,13 @@ static rsRetVal cflineProcessHostSelector(uchar **pline, register selector_t *f) * from the config file ("!tagname"). It stores it for further reference. * rgerhards 2005-10-18 */ -static rsRetVal cflineProcessTagSelector(uchar **pline, register selector_t *f) +static rsRetVal cflineProcessTagSelector(uchar **pline) { rsRetVal iRet; assert(pline != NULL); assert(*pline != NULL); assert(**pline == '!'); - assert(f != NULL); dprintf(" - programname selector line\n"); @@ -5103,11 +5096,11 @@ static rsRetVal cfline(char *line, register selector_t *f) iRet = cflineProcessPropFilter(&p, f); break; case '!': - iRet = cflineProcessTagSelector(&p, f); + iRet = cflineProcessTagSelector(&p); return iRet; /* in this case, we are done */ case '+': case '-': - iRet = cflineProcessHostSelector(&p, f); + iRet = cflineProcessHostSelector(&p); return iRet; /* in this case, we are done */ default: iRet = cflineProcessTradPRIFilter(&p, f); @@ -5262,7 +5255,7 @@ static rsRetVal cfline(char *line, register selector_t *f) *p = '\0'; /* trick to obtain hostname (later)! */ ++p; /* Now look for the template! */ - cflineParseTemplateName(f, &p, szTemplateName, + cflineParseTemplateName(&p, szTemplateName, sizeof(szTemplateName) / sizeof(char)); } else szTemplateName[0] = '\0'; @@ -5412,7 +5405,7 @@ static rsRetVal cfline(char *line, register selector_t *f) if(*(p+1) == ';') { /* we have a template specifier! */ p += 2; /* eat "*;" */ - cflineParseTemplateName(f, &p, szTemplateName, + cflineParseTemplateName(&p, szTemplateName, sizeof(szTemplateName) / sizeof(uchar)); } else /* assign default format if none given! */ @@ -5476,7 +5469,7 @@ static rsRetVal cfline(char *line, register selector_t *f) szTemplateName[0] = '\0'; } else { /* we have a template specifier! */ - cflineParseTemplateName(f, &p, szTemplateName, + cflineParseTemplateName(&p, szTemplateName, sizeof(szTemplateName) / sizeof(char)); } @@ -5551,7 +5544,7 @@ static rsRetVal cfline(char *line, register selector_t *f) if(*p == ';') { /* we have a template specifier! */ ++p; /* eat ";" */ - cflineParseTemplateName(f, &p, szTemplateName, + cflineParseTemplateName(&p, szTemplateName, sizeof(szTemplateName) / sizeof(char)); } if(szTemplateName[0] == '\0') |