From 1d96a98daf4ac4c4ec9e664e328f1aac4bf6af9e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 27 Jul 2007 16:55:40 +0000 Subject: - added omsr object (objomsr.c, objomsr.h) - template request for output modules - changed doAction() interface - templates and output string generation for doActon() is now fully --- ommysql.c | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) (limited to 'ommysql.c') diff --git a/ommysql.c b/ommysql.c index 67803b5c..d5c327c1 100644 --- a/ommysql.c +++ b/ommysql.c @@ -321,16 +321,14 @@ rsRetVal writeMySQL(register selector_t *f, uchar *psz, instanceData *pData) BEGINdoAction CODESTARTdoAction dprintf("\n"); - iRet = writeMySQL(f, pMsg, pData); + iRet = writeMySQL(f, ppString[0], pData); ENDdoAction BEGINparseSelectorAct int iMySQLPropErr = 0; - char szTemplateName[128]; CODESTARTparseSelectorAct - p = *pp; - +CODE_STD_STRING_REQUESTparseSelectorAct(1) /* yes, the if below is redundant, but I need it now. Will go away as * the code further changes. -- rgerhards, 2007-07-25 */ @@ -341,8 +339,7 @@ CODESTARTparseSelectorAct switch (*p) { - case '>': - /* rger 2004-10-28: added support for MySQL + case '>': /* rger 2004-10-28: added support for MySQL * >server,dbname,userid,password * rgerhards 2005-08-12: changed rsyslogd so that * if no DB is selected and > is used, an error @@ -376,34 +373,15 @@ CODESTARTparseSelectorAct iMySQLPropErr++; if(getSubString(&p, pData->f_dbpwd, _DB_MAXPWDLEN+1, ';')) iMySQLPropErr++; - if(*p == '\n' || *p == '\0') { - /* assign default format if none given! */ - szTemplateName[0] = '\0'; - } else { - /* we have a template specifier! */ - if((iRet = cflineParseTemplateName(&p, szTemplateName, - sizeof(szTemplateName) / sizeof(char))) != RS_RET_OK) - break; - } - - if(szTemplateName[0] == '\0') - strcpy(szTemplateName, " StdDBFmt"); - - if((iRet = cflineSetTemplateAndIOV(f, szTemplateName)) != RS_RET_OK) - break; - - dprintf(" template '%s'\n", szTemplateName); - - /* If db used, the template have to use the SQL option. - This is for your own protection (prevent sql injection). */ - if (f->f_pTpl->optFormatForSQL == 0) { - iRet = RS_RET_NO_SQL_STRING; - logerror("DB logging disabled. You have to use" - " the SQL or stdSQL option in your template!\n"); - break; - } + /* now check for template + * We specify that the SQL option must be present in the template. + * This is for your own protection (prevent sql injection). + */ + if((iRet = cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_RQD_TPL_OPT_SQL, (uchar*) " StdSQLFmt")) + != RS_RET_OK) + return iRet; - /* If we dedect invalid properties, we disable logging, + /* If we detect invalid properties, we disable logging, * because right properties are vital at this place. * Retries make no sense. */ -- cgit