summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imfile/imfile.c13
-rw-r--r--plugins/imgssapi/Makefile.am2
-rw-r--r--plugins/imgssapi/imgssapi.c44
-rw-r--r--plugins/imudp/imudp.c8
-rw-r--r--plugins/imuxsock/imuxsock.c8
-rw-r--r--plugins/omgssapi/Makefile.am2
-rw-r--r--plugins/omgssapi/omgssapi.c40
-rw-r--r--plugins/omsnmp/omsnmp.c15
8 files changed, 78 insertions, 54 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index ef452bc5..aa866a6d 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -39,6 +39,7 @@
#include "srUtils.h" /* some utility functions */
#include "msg.h"
#include "stream.h"
+#include "errmsg.h"
MODULE_TYPE_INPUT /* must be present for input modules, do not remove */
@@ -46,6 +47,7 @@ MODULE_TYPE_INPUT /* must be present for input modules, do not remove */
/* Module static data */
DEF_IMOD_STATIC_DATA /* must be present, starts static data */
+DEFobjCurrIf(errmsg)
typedef struct fileInfo_s {
uchar *pszFileName;
@@ -278,7 +280,7 @@ ENDrunInput
BEGINwillRun
CODESTARTwillRun
if(iFilPtr == 0) {
- logerror("No files configured to be monitored");
+ errmsg.LogError(NO_ERRCODE, "No files configured to be monitored");
ABORT_FINALIZE(RS_RET_NO_RUN);
}
@@ -398,21 +400,21 @@ static rsRetVal addMonitor(void __attribute__((unused)) *pVal, uchar __attribute
pThis = &files[iFilPtr];
/* TODO: check for strdup() NULL return */
if(pszFileName == NULL) {
- logerror("imfile error: no file name given, file monitor can not be created");
+ errmsg.LogError(NO_ERRCODE, "imfile error: no file name given, file monitor can not be created");
ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
} else {
pThis->pszFileName = (uchar*) strdup((char*) pszFileName);
}
if(pszFileTag == NULL) {
- logerror("imfile error: no tag value given , file monitor can not be created");
+ errmsg.LogError(NO_ERRCODE, "imfile error: no tag value given , file monitor can not be created");
ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
} else {
pThis->pszTag = (uchar*) strdup((char*) pszFileTag);
}
if(pszStateFile == NULL) {
- logerror("imfile error: not state file name given, file monitor can not be created");
+ errmsg.LogError(NO_ERRCODE, "imfile error: not state file name given, file monitor can not be created");
ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
} else {
pThis->pszStateFile = (uchar*) strdup((char*) pszStateFile);
@@ -421,7 +423,7 @@ static rsRetVal addMonitor(void __attribute__((unused)) *pVal, uchar __attribute
pThis->iSeverity = iSeverity;
pThis->iFacility = iFacility;
} else {
- logerror("Too many file monitors configured - ignoring this one");
+ errmsg.LogError(NO_ERRCODE, "Too many file monitors configured - ignoring this one");
ABORT_FINALIZE(RS_RET_OUT_OF_DESRIPTORS);
}
@@ -447,6 +449,7 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputfilename", 0, eCmdHdlrGetWord,
NULL, &pszFileName, STD_LOADABLE_MODULE_ID));
diff --git a/plugins/imgssapi/Makefile.am b/plugins/imgssapi/Makefile.am
index 6c2d6625..33f2d32d 100644
--- a/plugins/imgssapi/Makefile.am
+++ b/plugins/imgssapi/Makefile.am
@@ -3,4 +3,4 @@ pkglib_LTLIBRARIES = imgssapi.la
imgssapi_la_SOURCES = imgssapi.c
imgssapi_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(mudflap_cflags)
imgssapi_la_LDFLAGS = $(mudflap_libs) -module -avoid-version
-imgssapi_la_LIBADD = $(gss_libs) $(top_builddir)/libgssapi-misc.la
+imgssapi_la_LIBADD = $(gss_libs)
diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c
index d93799f3..fb80f3e2 100644
--- a/plugins/imgssapi/imgssapi.c
+++ b/plugins/imgssapi/imgssapi.c
@@ -28,7 +28,6 @@
*
* A copy of the GPL can be found in the file "COPYING" in this distribution.
*/
-
#include "config.h"
#include <stdlib.h>
#include <assert.h>
@@ -54,6 +53,7 @@
#include "gss-misc.h"
#include "tcpsrv.h"
#include "tcps_sess.h"
+#include "errmsg.h"
MODULE_TYPE_INPUT
@@ -75,6 +75,8 @@ static rsRetVal OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd);
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(tcpsrv)
DEFobjCurrIf(tcps_sess)
+DEFobjCurrIf(gssutil)
+DEFobjCurrIf(errmsg)
static tcpsrv_t *pOurTcpsrv = NULL; /* our TCP server(listener) TODO: change for multiple instances */
static gss_cred_id_t gss_server_creds = GSS_C_NO_CREDENTIAL;
@@ -143,7 +145,7 @@ OnSessDestruct(void *ppUsr)
OM_uint32 maj_stat, min_stat;
maj_stat = gss_delete_sec_context(&min_stat, &(*ppGSess)->gss_context, GSS_C_NO_BUFFER);
if (maj_stat != GSS_S_COMPLETE)
- display_status("deleting context", maj_stat, min_stat);
+ gssutil.display_status("deleting context", maj_stat, min_stat);
}
free(*ppGSess);
@@ -258,7 +260,7 @@ doOpenLstnSocks(tcpsrv_t *pSrv)
if(pGSrv->allowedMethods) {
if(pGSrv->allowedMethods & ALLOWEDMETHOD_GSS) {
if(TCPSessGSSInit()) {
- logerror("GSS-API initialization failed\n");
+ errmsg.LogError(NO_ERRCODE, "GSS-API initialization failed\n");
pGSrv->allowedMethods &= ~(ALLOWEDMETHOD_GSS);
}
}
@@ -345,7 +347,7 @@ static int TCPSessGSSInit(void)
name_buf.length = strlen(name_buf.value) + 1;
maj_stat = gss_import_name(&min_stat, &name_buf, GSS_C_NT_HOSTBASED_SERVICE, &server_name);
if (maj_stat != GSS_S_COMPLETE) {
- display_status("importing name", maj_stat, min_stat);
+ gssutil.display_status("importing name", maj_stat, min_stat);
return -1;
}
@@ -353,7 +355,7 @@ static int TCPSessGSSInit(void)
GSS_C_NULL_OID_SET, GSS_C_ACCEPT,
&gss_server_creds, NULL, NULL);
if (maj_stat != GSS_S_COMPLETE) {
- display_status("acquiring credentials", maj_stat, min_stat);
+ gssutil.display_status("acquiring credentials", maj_stat, min_stat);
return -1;
}
@@ -413,7 +415,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
ret = select(fdSess + 1, &fds, NULL, NULL, &tv);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
- logerrorVar("TCP session %p will be closed, error ignored\n", pSess);
+ errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess);
tcps_sess.Close(pSess);
ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes
// was: return -1;
@@ -431,7 +433,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
if (ret == 0)
dbgprintf("GSS-API Connection closed by peer\n");
else
- logerrorVar("TCP(GSS) session %p will be closed, error ignored\n", pSess);
+ errmsg.LogError(NO_ERRCODE, "TCP(GSS) session %p will be closed, error ignored\n", pSess);
tcps_sess.Close(pSess);
ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes
// was: return -1;
@@ -454,7 +456,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
if (ret == 0)
dbgprintf("GSS-API Connection closed by peer\n");
else
- logerrorVar("TCP session %p will be closed, error ignored\n", pSess);
+ errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess);
tcps_sess.Close(pSess);
ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes
//was: return -1;
@@ -478,8 +480,8 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
*context = GSS_C_NO_CONTEXT;
sess_flags = &pGSess->gss_flags;
do {
- if (recv_token(fdSess, &recv_tok) <= 0) {
- logerrorVar("TCP session %p will be closed, error ignored\n", pSess);
+ if (gssutil.recv_token(fdSess, &recv_tok) <= 0) {
+ errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess);
tcps_sess.Close(pSess);
ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes
//was: return -1;
@@ -500,7 +502,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
dbgprintf("GSS-API Reverting to plain TCP\n");
dbgprintf("tcp session socket with new data: #%d\n", fdSess);
if(tcps_sess.DataRcvd(pSess, buf, ret) == 0) {
- logerrorVar("Tearing down TCP Session %p - see "
+ errmsg.LogError(NO_ERRCODE, "Tearing down TCP Session %p - see "
"previous messages for reason(s)\n",
pSess);
tcps_sess.Close(pSess);
@@ -511,15 +513,15 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
ABORT_FINALIZE(RS_RET_OK); // TODO: define good error codes
// was: return 0;
}
- display_status("accepting context", maj_stat, acc_sec_min_stat);
+ gssutil.display_status("accepting context", maj_stat, acc_sec_min_stat);
tcps_sess.Close(pSess);
ABORT_FINALIZE(RS_RET_ERR); // TODO: define good error codes
//was: return -1;
}
if (send_tok.length != 0) {
- if (send_token(fdSess, &send_tok) < 0) {
+ if(gssutil.send_token(fdSess, &send_tok) < 0) {
gss_release_buffer(&min_stat, &send_tok);
- logerrorVar("TCP session %p will be closed, error ignored\n", pSess);
+ errmsg.LogError(NO_ERRCODE, "TCP session %p will be closed, error ignored\n", pSess);
if (*context != GSS_C_NO_CONTEXT)
gss_delete_sec_context(&min_stat, context, GSS_C_NO_BUFFER);
tcps_sess.Close(pSess);
@@ -532,14 +534,14 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd)
maj_stat = gss_display_name(&min_stat, client, &recv_tok, NULL);
if (maj_stat != GSS_S_COMPLETE)
- display_status("displaying name", maj_stat, min_stat);
+ gssutil.display_status("displaying name", maj_stat, min_stat);
else
dbgprintf("GSS-API Accepted connection from: %s\n", (char*) recv_tok.value);
gss_release_name(&min_stat, &client);
gss_release_buffer(&min_stat, &recv_tok);
dbgprintf("GSS-API Provided context flags:\n");
- display_ctx_flags(*sess_flags);
+ gssutil.display_ctx_flags(*sess_flags);
pGSess->allowedMethods = ALLOWEDMETHOD_GSS;
}
@@ -567,14 +569,14 @@ int TCPSessGSSRecv(tcps_sess_t *pSess, void *buf, size_t buf_len)
pGSess = (gss_sess_t*) pSess->pUsr;
fdSess = pSess->sock;
- if ((state = recv_token(fdSess, &xmit_buf)) <= 0)
+ if ((state = gssutil.recv_token(fdSess, &xmit_buf)) <= 0)
return state;
context = &pGSess->gss_context;
maj_stat = gss_unwrap(&min_stat, *context, &xmit_buf, &msg_buf,
&conf_state, (gss_qop_t *) NULL);
if(maj_stat != GSS_S_COMPLETE) {
- display_status("unsealing message", maj_stat, min_stat);
+ gssutil.display_status("unsealing message", maj_stat, min_stat);
if(xmit_buf.value) {
free(xmit_buf.value);
xmit_buf.value = 0;
@@ -609,7 +611,7 @@ void TCPSessGSSClose(tcps_sess_t* pSess)
context = &pGSess->gss_context;
maj_stat = gss_delete_sec_context(&min_stat, context, GSS_C_NO_BUFFER);
if (maj_stat != GSS_S_COMPLETE)
- display_status("deleting context", maj_stat, min_stat);
+ gssutil.display_status("deleting context", maj_stat, min_stat);
*context = GSS_C_NO_CONTEXT;
pGSess->gss_flags = 0;
pGSess->allowedMethods = 0;
@@ -629,7 +631,7 @@ TCPSessGSSDeinit(void)
maj_stat = gss_release_cred(&min_stat, &gss_server_creds);
if (maj_stat != GSS_S_COMPLETE)
- display_status("releasing credentials", maj_stat, min_stat);
+ gssutil.display_status("releasing credentials", maj_stat, min_stat);
RETiRet;
}
@@ -702,6 +704,8 @@ CODEmodInit_QueryRegCFSLineHdlr
/* request objects we use */
CHKiRet(objUse(tcps_sess, "tcpsrv.so"));
CHKiRet(objUse(tcpsrv, "tcpsrv"));
+ CHKiRet(objUse(gssutil, "gssutil"));
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
/* register config file handlers */
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputgssserverpermitplaintcp", 0, eCmdHdlrBinary,
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index df497632..70a7b3f7 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -38,6 +38,7 @@
#include "cfsysline.h"
#include "module-template.h"
#include "srUtils.h"
+#include "errmsg.h"
MODULE_TYPE_INPUT
@@ -45,6 +46,7 @@ MODULE_TYPE_INPUT
/* Module static data */
DEF_IMOD_STATIC_DATA
+DEFobjCurrIf(errmsg)
static int *udpLstnSocks = NULL; /* Internet datagram sockets, first element is nbr of elements
* read-only after init(), but beware of restart! */
static uchar *pszBindAddr = NULL; /* IP to bind socket to */
@@ -191,7 +193,7 @@ CODESTARTrunInput
} else {
dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN);
if(option_DisallowWarning) {
- logerrorSz("UDP message from disallowed sender %s discarded",
+ errmsg.LogError(NO_ERRCODE, "UDP message from disallowed sender %s discarded",
(char*)fromHost);
}
}
@@ -200,7 +202,7 @@ CODESTARTrunInput
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
dbgprintf("INET socket error: %d = %s.\n", errno, errStr);
- logerror("recvfrom inet");
+ errmsg.LogError(NO_ERRCODE, "recvfrom inet");
/* should be harmless */
sleep(1);
}
@@ -272,6 +274,8 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
+
/* register config file handlers */
CHKiRet(omsdRegCFSLineHdlr((uchar *)"udpserverrun", 0, eCmdHdlrGetWord,
addListner, NULL, STD_LOADABLE_MODULE_ID));
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 1be2e66f..68978231 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -39,6 +39,7 @@
#include "cfsysline.h"
#include "module-template.h"
#include "srUtils.h"
+#include "errmsg.h"
MODULE_TYPE_INPUT
@@ -60,6 +61,7 @@ MODULE_TYPE_INPUT
#endif
/* Module static data */
DEF_IMOD_STATIC_DATA
+DEFobjCurrIf(errmsg)
static int startIndexUxLocalSockets; /* process funix from that index on (used to
* suppress local logging. rgerhards 2005-08-01
@@ -142,7 +144,7 @@ static int create_unix_socket(const char *path)
SUN_LEN(&sunx)) < 0 ||
chmod(path, 0666) < 0) {
snprintf(line, sizeof(line), "cannot create %s", path);
- logerror(line);
+ errmsg.LogError(NO_ERRCODE, "%s", line);
dbgprintf("cannot create %s (%d).\n", path, errno);
close(fd);
return -1;
@@ -169,7 +171,7 @@ static rsRetVal readSocket(int fd, int bParseHost)
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
dbgprintf("UNIX socket error: %d = %s.\n", errno, errStr);
- logerror("recvfrom UNIX");
+ errmsg.LogError(NO_ERRCODE, "recvfrom UNIX");
}
RETiRet;
@@ -300,6 +302,8 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
+
/* initialize funixn[] array */
for(i = 1 ; i < MAXFUNIX ; ++i) {
funixn[i] = NULL;
diff --git a/plugins/omgssapi/Makefile.am b/plugins/omgssapi/Makefile.am
index 3557388c..3ec18282 100644
--- a/plugins/omgssapi/Makefile.am
+++ b/plugins/omgssapi/Makefile.am
@@ -3,4 +3,4 @@ pkglib_LTLIBRARIES = omgssapi.la
omgssapi_la_SOURCES = omgssapi.c
omgssapi_la_CPPFLAGS = -I$(top_srcdir) $(pthreads_cflags) $(mudflap_cflags)
omgssapi_la_LDFLAGS = $(mudflap_libs) -module -avoid-version
-omgssapi_la_LIBADD = $(gss_libs) $(top_builddir)/libgssapi-misc.la
+omgssapi_la_LIBADD = $(gss_libs)
diff --git a/plugins/omgssapi/omgssapi.c b/plugins/omgssapi/omgssapi.c
index 8ca2f879..bb4a2712 100644
--- a/plugins/omgssapi/omgssapi.c
+++ b/plugins/omgssapi/omgssapi.c
@@ -54,6 +54,7 @@
#include "cfsysline.h"
#include "module-template.h"
#include "gss-misc.h"
+#include "errmsg.h"
MODULE_TYPE_OUTPUT
@@ -75,6 +76,8 @@ MODULE_TYPE_OUTPUT
/* internal structures
*/
DEF_OMOD_STATIC_DATA
+DEFobjCurrIf(errmsg)
+DEFobjCurrIf(gssutil)
typedef struct _instanceData {
char f_hname[MAXHOSTNAMELEN+1];
@@ -144,7 +147,7 @@ CODESTARTfreeInstance
if (pData->gss_context != GSS_C_NO_CONTEXT) {
maj_stat = gss_delete_sec_context(&min_stat, &pData->gss_context, GSS_C_NO_BUFFER);
if (maj_stat != GSS_S_COMPLETE)
- display_status("deleting context", maj_stat, min_stat);
+ gssutil.display_status("deleting context", maj_stat, min_stat);
}
/* this is meant to be done when module is unloaded,
but since this module is static...
@@ -217,7 +220,7 @@ static rsRetVal TCPSendGSSInit(void *pvData)
out_tok.length = 0;
if (maj_stat != GSS_S_COMPLETE) {
- display_status("parsing name", maj_stat, min_stat);
+ gssutil.display_status("parsing name", maj_stat, min_stat);
goto fail;
}
@@ -230,7 +233,7 @@ static rsRetVal TCPSendGSSInit(void *pvData)
*sess_flags |= GSS_C_CONF_FLAG;
}
dbgprintf("GSS-API requested context flags:\n");
- display_ctx_flags(*sess_flags);
+ gssutil.display_ctx_flags(*sess_flags);
do {
maj_stat = gss_init_sec_context(&init_sec_min_stat, GSS_C_NO_CREDENTIAL, context,
@@ -241,7 +244,7 @@ static rsRetVal TCPSendGSSInit(void *pvData)
if (maj_stat != GSS_S_COMPLETE
&& maj_stat != GSS_S_CONTINUE_NEEDED) {
- display_status("initializing context", maj_stat, init_sec_min_stat);
+ gssutil.display_status("initializing context", maj_stat, init_sec_min_stat);
goto fail;
}
@@ -251,7 +254,7 @@ static rsRetVal TCPSendGSSInit(void *pvData)
if (out_tok.length != 0) {
dbgprintf("GSS-API Sending init_sec_context token (length: %ld)\n", (long) out_tok.length);
- if (send_token(s, &out_tok) < 0) {
+ if (gssutil.send_token(s, &out_tok) < 0) {
goto fail;
}
}
@@ -259,7 +262,7 @@ static rsRetVal TCPSendGSSInit(void *pvData)
if (maj_stat == GSS_S_CONTINUE_NEEDED) {
dbgprintf("GSS-API Continue needed...\n");
- if (recv_token(s, &in_tok) <= 0) {
+ if (gssutil.recv_token(s, &in_tok) <= 0) {
goto fail;
}
tok_ptr = &in_tok;
@@ -268,7 +271,7 @@ static rsRetVal TCPSendGSSInit(void *pvData)
dbgprintf("GSS-API Provided context flags:\n");
*sess_flags = ret_flags;
- display_ctx_flags(*sess_flags);
+ gssutil.display_ctx_flags(*sess_flags);
dbgprintf("GSS-API Context initialized\n");
gss_release_name(&min_stat, &target_name);
@@ -277,7 +280,7 @@ finalize_it:
RETiRet;
fail:
- logerror("GSS-API Context initialization failed\n");
+ errmsg.LogError(NO_ERRCODE, "GSS-API Context initialization failed\n");
gss_release_name(&min_stat, &target_name);
gss_release_buffer(&min_stat, &out_tok);
if (*context != GSS_C_NO_CONTEXT) {
@@ -310,11 +313,11 @@ static rsRetVal TCPSendGSSSend(void *pvData, char *msg, size_t len)
maj_stat = gss_wrap(&min_stat, *context, (gss_mode == GSSMODE_ENC) ? 1 : 0, GSS_C_QOP_DEFAULT,
&in_buf, NULL, &out_buf);
if (maj_stat != GSS_S_COMPLETE) {
- display_status("wrapping message", maj_stat, min_stat);
+ gssutil.display_status("wrapping message", maj_stat, min_stat);
goto fail;
}
- if (send_token(s, &out_buf) < 0) {
+ if (gssutil.send_token(s, &out_buf) < 0) {
goto fail;
}
gss_release_buffer(&min_stat, &out_buf);
@@ -511,12 +514,12 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
++p; /* eat */
pData->compressionLevel = iLevel;
} else {
- logerrorInt("Invalid compression level '%c' specified in "
+ errmsg.LogError(NO_ERRCODE, "Invalid compression level '%c' specified in "
"forwardig action - NOT turning on compression.",
*p);
}
# else
- logerror("Compression requested, but rsyslogd is not compiled "
+ errmsg.LogError(NO_ERRCODE, "Compression requested, but rsyslogd is not compiled "
"with compression support - request ignored.");
# endif /* #ifdef USE_NETZIP */
} else if(*p == 'o') { /* octet-couting based TCP framing? */
@@ -524,7 +527,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
/* no further options settable */
pData->tcp_framing = TCP_FRAMING_OCTET_COUNTING;
} else { /* invalid option! Just skip it... */
- logerrorInt("Invalid option %c in forwarding action - ignoring.", *p);
+ errmsg.LogError(NO_ERRCODE, "Invalid option %c in forwarding action - ignoring.", *p);
++p; /* eat invalid option */
}
/* the option processing is done. We now do a generic skip
@@ -540,7 +543,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
/* we probably have end of string - leave it for the rest
* of the code to handle it (but warn the user)
*/
- logerror("Option block not terminated in gssapi forward action.");
+ errmsg.LogError(NO_ERRCODE, "Option block not terminated in gssapi forward action.");
}
/* extract the host first (we do a trick - we replace the ';' or ':' with a '\0')
* now skip to port and then template name. rgerhards 2005-07-06
@@ -558,7 +561,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
/* SKIP AND COUNT */;
pData->port = malloc(i + 1);
if(pData->port == NULL) {
- logerror("Could not get memory to store syslog forwarding port, "
+ errmsg.LogError(NO_ERRCODE, "Could not get memory to store syslog forwarding port, "
"using default port, results may not be what you intend\n");
/* we leave f_forw.port set to NULL, this is then handled by
* getFwdSyslogPt().
@@ -576,7 +579,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
if(bErr == 0) { /* only 1 error msg! */
bErr = 1;
errno = 0;
- logerror("invalid selector line (port), probably not doing "
+ errmsg.LogError(NO_ERRCODE, "invalid selector line (port), probably not doing "
"what was intended");
}
}
@@ -647,7 +650,7 @@ static rsRetVal setGSSMode(void __attribute__((unused)) *pVal, uchar *mode)
gss_mode = GSSMODE_ENC;
dbgprintf("GSS-API gssmode set to GSSMODE_ENC\n");
} else {
- logerrorSz("unknown gssmode parameter: %s", (char *) mode);
+ errmsg.LogError(NO_ERRCODE, "unknown gssmode parameter: %s", (char *) mode);
iRet = RS_RET_INVALID_PARAMS;
}
free(mode);
@@ -671,6 +674,9 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(gssutil, "gssutil"));
+
CHKiRet(omsdRegCFSLineHdlr((uchar *)"gssforwardservicename", 0, eCmdHdlrGetWord, NULL, &gss_base_service_name, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"gssmode", 0, eCmdHdlrGetWord, setGSSMode, &gss_mode, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
diff --git a/plugins/omsnmp/omsnmp.c b/plugins/omsnmp/omsnmp.c
index 618a3f10..d7c8950c 100644
--- a/plugins/omsnmp/omsnmp.c
+++ b/plugins/omsnmp/omsnmp.c
@@ -44,12 +44,14 @@
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include "omsnmp.h"
+#include "errmsg.h"
MODULE_TYPE_OUTPUT
/* internal structures
*/
DEF_OMOD_STATIC_DATA
+DEFobjCurrIf(errmsg)
/* Default static snmp OID's */
/*unused
@@ -175,7 +177,7 @@ static rsRetVal omsnmp_initSession(instanceData *pData)
pData->snmpsession = snmp_open(&session);
if (pData->snmpsession == NULL) {
- logerrorVar("omsnmp_initSession: snmp_open to host '%s' on Port '%d' failed\n", pData->szTarget, pData->iPort);
+ errmsg.LogError(NO_ERRCODE, "omsnmp_initSession: snmp_open to host '%s' on Port '%d' failed\n", pData->szTarget, pData->iPort);
/* Stay suspended */
iRet = RS_RET_SUSPENDED;
}
@@ -214,7 +216,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz)
if (!snmp_parse_oid( (char*) pData->szEnterpriseOID, enterpriseoid, &enterpriseoidlen ))
{
strErr = snmp_api_errstring(snmp_errno);
- logerrorVar("omsnmp_sendsnmp: Parsing EnterpriseOID failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr);
+ errmsg.LogError(NO_ERRCODE, "omsnmp_sendsnmp: Parsing EnterpriseOID failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr);
ABORT_FINALIZE(RS_RET_DISABLE_ACTION);
}
@@ -250,7 +252,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz)
if ( snmp_add_var(pdu, objid_snmptrap, sizeof(objid_snmptrap) / sizeof(oid), 'o', (char*) pData->szSnmpTrapOID ) != 0)
{
strErr = snmp_api_errstring(snmp_errno);
- logerrorVar("omsnmp_sendsnmp: Adding trap OID failed '%s' with error '%s' \n", pData->szSnmpTrapOID, strErr);
+ errmsg.LogError(NO_ERRCODE, "omsnmp_sendsnmp: Adding trap OID failed '%s' with error '%s' \n", pData->szSnmpTrapOID, strErr);
ABORT_FINALIZE(RS_RET_DISABLE_ACTION);
}
}
@@ -265,14 +267,14 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz)
if (iErrCode)
{
const char *str = snmp_api_errstring(iErrCode);
- logerrorVar( "omsnmp_sendsnmp: Invalid SyslogMessage OID, error code '%d' - '%s'\n", iErrCode, str );
+ errmsg.LogError(NO_ERRCODE, "omsnmp_sendsnmp: Invalid SyslogMessage OID, error code '%d' - '%s'\n", iErrCode, str );
ABORT_FINALIZE(RS_RET_DISABLE_ACTION);
}
}
else
{
strErr = snmp_api_errstring(snmp_errno);
- logerrorVar("omsnmp_sendsnmp: Parsing SyslogMessageOID failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr);
+ errmsg.LogError(NO_ERRCODE, "omsnmp_sendsnmp: Parsing SyslogMessageOID failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr);
ABORT_FINALIZE(RS_RET_DISABLE_ACTION);
}
@@ -283,7 +285,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz)
{
/* Debug Output! */
int iErrorCode = pData->snmpsession->s_snmp_errno;
- logerrorVar( "omsnmp_sendsnmp: snmp_send failed error '%d', Description='%s'\n", iErrorCode*(-1), api_errors[iErrorCode*(-1)]);
+ errmsg.LogError(NO_ERRCODE, "omsnmp_sendsnmp: snmp_send failed error '%d', Description='%s'\n", iErrorCode*(-1), api_errors[iErrorCode*(-1)]);
/* Clear Session */
omsnmp_exitSession(pData);
@@ -504,6 +506,7 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionsnmptransport", 0, eCmdHdlrGetWord, NULL, &pszTransport, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionsnmptarget", 0, eCmdHdlrGetWord, NULL, &pszTarget, STD_LOADABLE_MODULE_ID));