From d9653ad08ffd2e8578aac00777cd610fce1f05c1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 24 Jul 2007 06:25:48 +0000 Subject: moved selector action config parsing for shell action to omshell --- omshell.c | 35 +++++++++++++++++++++++++++++++++++ omshell.h | 1 + syslogd.c | 14 +------------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/omshell.c b/omshell.c index 05d61a9e..9ea80a0c 100644 --- a/omshell.c +++ b/omshell.c @@ -61,6 +61,41 @@ int doActionShell(selector_t *f) return 0; } + +/* try to process a selector action line. Checks if the action + * applies to this module and, if so, processed it. If not, it + * is left untouched. The driver will then call another module + */ +rsRetVal parseSelectorActShell(uchar **pp, selector_t *f) +{ + uchar *p; + rsRetVal iRet = RS_RET_CONFLINE_PROCESSED; + + assert(pp != NULL); + assert(f != NULL); + + p = *pp; + + switch (*p) + { + case '^': /* bkalkbrenner 2005-09-20: execute shell command */ + dprintf("exec\n"); + ++p; + cflineParseFileName(f, p); + if (f->f_type == F_FILE) { + f->f_type = F_SHELL; + f->doAction = doActionShell; + } + default: + iRet = RS_RET_CONFLINE_UNPROCESSED; + break; + } + + if(iRet == RS_RET_CONFLINE_PROCESSED) + *pp = p; + return iRet; +} + /* query an entry point */ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)()) diff --git a/omshell.h b/omshell.h index fa146eb8..7e3937b3 100644 --- a/omshell.h +++ b/omshell.h @@ -27,6 +27,7 @@ /* prototypes */ int doActionShell(selector_t *f); rsRetVal modInitShell(int iIFVersRequested, int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)()); +rsRetVal parseSelectorActShell(uchar **pp, selector_t *f); #endif /* #ifndef ACTSHELL_H_INCLUDED */ /* diff --git a/syslogd.c b/syslogd.c index c2224561..537df108 100644 --- a/syslogd.c +++ b/syslogd.c @@ -5094,37 +5094,25 @@ static rsRetVal cfline(char *line, register selector_t *f) case '@': parseSelectorActFwd(&p, f); break; - case '$': case '?': case '|': case '/': parseSelectorActFile(&p, f); break; - case '*': parseSelectorActUsrMsg(&p, f); break; - case '~': /* rgerhards 2005-09-09: added support for discard */ dprintf ("discard\n"); f->f_type = F_DISCARD; break; - case '>': parseSelectorActMySQL(&p, f); break; - case '^': /* bkalkbrenner 2005-09-20: execute shell command */ - dprintf("exec\n"); - ++p; - cflineParseFileName(f, p); - if (f->f_type == F_FILE) { - f->f_type = F_SHELL; - f->doAction = doActionShell; - } + parseSelectorActShell(&p, f); break; - default: parseSelectorActUsrMsg(&p, f); } -- cgit