diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/imklog/imklog.c | 18 | ||||
-rw-r--r-- | plugins/imklog/imklog.h | 16 | ||||
-rw-r--r-- | plugins/imptcp/imptcp.c | 5 | ||||
-rw-r--r-- | plugins/ommongodb/README | 15 | ||||
-rw-r--r-- | plugins/ommysql/ommysql.c | 20 | ||||
-rw-r--r-- | plugins/omudpspoof/omudpspoof.c | 28 |
6 files changed, 37 insertions, 65 deletions
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c index 90b424f3..f476c5ff 100644 --- a/plugins/imklog/imklog.c +++ b/plugins/imklog/imklog.c @@ -82,7 +82,6 @@ typedef struct configSettings_s { int iFacilIntMsg; /* the facility to use for internal messages (set by driver) */ uchar *pszPath; int console_log_level; - char *symfile; /* TODO: actually unsued currently! */ } configSettings_t; static configSettings_t cs; @@ -104,7 +103,6 @@ initConfigSettings(void) cs.bPermitNonKernel = 0; cs.console_log_level = -1; cs.pszPath = NULL; - cs.symfile = NULL; cs.iFacilIntMsg = klogFacilIntMsg(); } @@ -194,11 +192,9 @@ rsRetVal imklogLogIntMsg(int priority, char *fmt, ...) DEFiRet; va_list ap; uchar msgBuf[2048]; /* we use the same size as sysklogd to remain compatible */ - uchar *pLogMsg; va_start(ap, fmt); vsnprintf((char*)msgBuf, sizeof(msgBuf) / sizeof(char), fmt, ap); - pLogMsg = msgBuf; va_end(ap); logmsgInternal(NO_ERRCODE ,priority, msgBuf, 0); @@ -302,21 +298,8 @@ CODESTARTendCnfLoad loadModConf->pszPath = cs.pszPath; } cs.pszPath = NULL; - if((cs.symfile == NULL) || (cs.symfile[0] == '\0')) { - loadModConf->symfile = NULL; - if(cs.symfile != NULL) - free(cs.symfile); - } else { - loadModConf->symfile = cs.symfile; - } - cs.symfile = NULL; loadModConf = NULL; /* done loading */ - /* free legacy config vars */ - free(cs.pszPath); - cs.pszPath = NULL; - free(cs.symfile); - cs.symfile = NULL; ENDendCnfLoad @@ -380,7 +363,6 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a cs.dbgPrintSymbols = 0; cs.symbols_twice = 0; cs.use_syscall = 0; - cs.symfile = NULL; cs.symbol_lookup = 0; cs.bPermitNonKernel = 0; if(cs.pszPath != NULL) { diff --git a/plugins/imklog/imklog.h b/plugins/imklog/imklog.h index 7f6c810a..795dd68c 100644 --- a/plugins/imklog/imklog.h +++ b/plugins/imklog/imklog.h @@ -39,7 +39,6 @@ struct modConfData_s { int iFacilIntMsg; uchar *pszPath; int console_log_level; - char *symfile; rsconf_t *pConf; }; @@ -54,21 +53,6 @@ rsRetVal klogWillRun(modConfData_t *pModConf); rsRetVal klogAfterRun(modConfData_t *pModConf); int klogFacilIntMsg(); -/* the following data members may be accessed by the "drivers" - * I admit this is not the cleanest way to doing things, but I honestly - * believe it is appropriate for the job that needs to be done. - * rgerhards, 2008-04-09 - */ -#if 0 -extern int symbols_twice; -extern int use_syscall; -extern int symbol_lookup; -extern char *symfile; -extern int console_log_level; -extern int dbgPrintSymbols; -extern uchar *pszPath; -#endif - /* the functions below may be called by the drivers */ rsRetVal imklogLogIntMsg(int priority, char *fmt, ...) __attribute__((format(printf,2, 3))); rsRetVal Syslog(int priority, uchar *msg, struct timeval *tp); diff --git a/plugins/imptcp/imptcp.c b/plugins/imptcp/imptcp.c index ba323a94..6961a696 100644 --- a/plugins/imptcp/imptcp.c +++ b/plugins/imptcp/imptcp.c @@ -262,6 +262,7 @@ destructSrv(ptcpsrv_t *pSrv) { prop.Destruct(&pSrv->pInputName); pthread_mutex_destroy(&pSrv->mutSessLst); + free(pSrv->pszInputName); free(pSrv->port); free(pSrv); } @@ -1071,7 +1072,7 @@ addListner(modConfData_t __attribute__((unused)) *modConf, instanceConf_t *inst) CHKmalloc(pSrv->lstnIP = ustrdup(inst->pszBindAddr)); } pSrv->pRuleset = inst->pBindRuleset; - pSrv->pszInputName = (inst->pszInputName == NULL) ? UCHAR_CONSTANT("imptcp") : ustrdup(inst->pszInputName); + pSrv->pszInputName = ustrdup((inst->pszInputName == NULL) ? UCHAR_CONSTANT("imptcp") : inst->pszInputName); CHKiRet(prop.Construct(&pSrv->pInputName)); CHKiRet(prop.SetString(pSrv->pInputName, pSrv->pszInputName, ustrlen(pSrv->pszInputName))); CHKiRet(prop.ConstructFinalize(pSrv->pInputName)); @@ -1362,6 +1363,8 @@ CODESTARTendCnfLoad /* free legacy config vars */ free(cs.pszInputName); free(cs.lstnIP); + cs.pszInputName = NULL; + cs.lstnIP = NULL; ENDendCnfLoad diff --git a/plugins/ommongodb/README b/plugins/ommongodb/README index 71d56cfa..7581131a 100644 --- a/plugins/ommongodb/README +++ b/plugins/ommongodb/README @@ -2,21 +2,6 @@ plugin to use MongoDB as backend. tested in ubuntu 10.04 and ubuntu 10.10 -BUILDING THIS PLUGIN -Right now, it seems to be necessary to copy the 10gen c-driver directly under -the ./plugins/ommongodb subdirectory. Then, you need to follow their build -instructions on how to build the mongodb c driver: -http://api.mongodb.org/c/current/building.html - -This is clumpsy, and if someone has ideas on how to improve this situation, -please drop us a line. For obvious reasons, ./configure does not detect -a missing mongodb c driver. - -In order to successfully build ommongodb, you NEED to use the v0.2 version of -the mongo c driver. As it looks, the driver breaks API compatibility and the -curret v0.4 driver seems to have a totally different API (at least this is -what I currently (2012-03-08) see. - configuration: in your /etc/rsyslog.conf, together with other modules: diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 32d4d73a..253fc4c0 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -120,7 +120,6 @@ static void closeMySQL(instanceData *pData) ASSERT(pData != NULL); if(pData->f_hmysql != NULL) { /* just to be on the safe side... */ - mysql_server_end(); mysql_close(pData->f_hmysql); pData->f_hmysql = NULL; } @@ -426,6 +425,11 @@ ENDparseSelectorAct BEGINmodExit CODESTARTmodExit +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_end(); +# else + mysql_server_end(); +# endif ENDmodExit @@ -455,6 +459,20 @@ INITLegCnfVars *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); + + /* we need to init the MySQL library. If that fails, we cannot run */ + if( +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_init(0, NULL, NULL) +# else + mysql_server_init(0, NULL, NULL) +# endif + ) { + errmsg.LogError(0, NO_ERRCODE, "ommysql: mysql_server_init() failed, plugin " + "can not run"); + ABORT_FINALIZE(RS_RET_ERR); + } + /* register our config handlers */ CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionommysqlserverport", 0, eCmdHdlrInt, NULL, &cs.iSrvPort, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"ommysqlconfigfile",0,eCmdHdlrGetWord,NULL,&cs.pszMySQLConfigFile,STD_LOADABLE_MODULE_ID)); diff --git a/plugins/omudpspoof/omudpspoof.c b/plugins/omudpspoof/omudpspoof.c index 506fca77..43b36551 100644 --- a/plugins/omudpspoof/omudpspoof.c +++ b/plugins/omudpspoof/omudpspoof.c @@ -24,7 +24,7 @@ * rgerhards, 2009-07-10 * * Copyright 2009 David Lang (spoofing code) - * Copyright 2009 Rainer Gerhards and Adiscon GmbH. + * Copyright 2009-2012 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -132,6 +132,7 @@ ENDinitConfVars /* add some variables needed for libnet */ libnet_t *libnet_handle; char errbuf[LIBNET_ERRBUF_SIZE]; +pthread_mutex_t mutLibnet; /* forward definitions */ static rsRetVal doTryResume(instanceData *pData); @@ -194,6 +195,8 @@ ENDdbgPrintInstInfo /* Send a message via UDP + * Note: libnet is not thread-safe, so we need to ensure that only one + * instance ever is calling libnet code. * rgehards, 2007-12-20 */ static inline rsRetVal @@ -202,11 +205,10 @@ UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len) struct addrinfo *r; int lsent = 0; int bSendSuccess; - int j, build_ip; - u_char opt[20]; struct sockaddr_in *tempaddr,source_ip; libnet_ptag_t ip, ipo; libnet_ptag_t udp; + sbool bNeedUnlock = 0; DEFiRet; if(pData->pSockArray == NULL) { @@ -221,6 +223,8 @@ UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len) inet_pton(AF_INET, (char*)pszSourcename, &(source_ip.sin_addr)); bSendSuccess = FALSE; + d_pthread_mutex_lock(&mutLibnet); + bNeedUnlock = 1; for (r = pData->f_addr; r; r = r->ai_next) { tempaddr = (struct sockaddr_in *)r->ai_addr; libnet_clear_packet(libnet_handle); @@ -238,17 +242,8 @@ UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len) DBGPRINTF("Can't build UDP header: %s\n", libnet_geterror(libnet_handle)); } - build_ip = 0; - /* this is not a legal options string */ - for (j = 0; j < 20; j++) { - opt[j] = libnet_get_prand(LIBNET_PR2); - } - ipo = libnet_build_ipv4_options(opt, 20, libnet_handle, ipo); - if (ipo == -1) { - DBGPRINTF("Can't build IP options: %s\n", libnet_geterror(libnet_handle)); - } ip = libnet_build_ipv4( - LIBNET_IPV4_H + 20 + len + LIBNET_UDP_H, /* length */ + LIBNET_IPV4_H + len + LIBNET_UDP_H, /* length */ 0, /* TOS */ 242, /* IP ID */ 0, /* IP Frag */ @@ -281,6 +276,9 @@ UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len) } finalize_it: + if(bNeedUnlock) { + d_pthread_mutex_unlock(&mutLibnet); + } RETiRet; } @@ -422,7 +420,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(2) pData->port = NULL; else CHKmalloc(pData->port = ustrdup(cs.pszTargetPort)); - CHKiRet(OMSRsetEntry(*ppOMSR, 1, ustrdup(cs.pszSourceNameTemplate), OMSR_NO_RQD_TPL_OPTS)); + CHKiRet(OMSRsetEntry(*ppOMSR, 1, ustrdup(sourceTpl), OMSR_NO_RQD_TPL_OPTS)); pData->compressionLevel = cs.iCompressionLevel; pData->sourcePort = pData->sourcePortStart = cs.iSourcePortStart; pData->sourcePortEnd = cs.iSourcePortEnd; @@ -454,6 +452,7 @@ BEGINmodExit CODESTARTmodExit /* destroy the libnet state needed for forged UDP sources */ libnet_destroy(libnet_handle); + pthread_mutex_destroy(&mutLibnet); /* release what we no longer need */ objRelease(errmsg, CORE_COMPONENT); objRelease(glbl, CORE_COMPONENT); @@ -503,6 +502,7 @@ CODEmodInit_QueryRegCFSLineHdlr errmsg.LogError(0, NO_ERRCODE, "Error initializing libnet, can not continue "); ABORT_FINALIZE(RS_RET_ERR_LIBNET_INIT); } + pthread_mutex_init(&mutLibnet, NULL); CHKiRet(regCfSysLineHdlr((uchar *)"actionomudpspoofdefaulttemplate", 0, eCmdHdlrGetWord, NULL, &cs.pszTplName, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"actionomudpspoofsourcenametemplate", 0, eCmdHdlrGetWord, NULL, &cs.pszSourceNameTemplate, NULL)); |