summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--omdiscard.c1
-rw-r--r--omfile.c33
-rw-r--r--ommysql.c9
-rw-r--r--omshell.c5
-rw-r--r--omusrmsg.c7
-rw-r--r--syslogd-types.h13
-rw-r--r--syslogd.c8
7 files changed, 32 insertions, 44 deletions
diff --git a/omdiscard.c b/omdiscard.c
index 52f1b938..b12474c5 100644
--- a/omdiscard.c
+++ b/omdiscard.c
@@ -82,7 +82,6 @@ CODESTARTparseSelectorAct
if(*p == '~') {
/* TODO: check the rest of the selector line - error reporting */
dprintf("discard\n");
- f->f_type = F_DISCARD;
} else {
iRet = RS_RET_CONFLINE_UNPROCESSED;
}
diff --git a/omfile.c b/omfile.c
index b7b64ade..40885dac 100644
--- a/omfile.c
+++ b/omfile.c
@@ -1,7 +1,7 @@
/* omfile.c
* This is the implementation of the build-in file output module.
*
- * Handles: F_CONSOLE, F_TTY, F_FILE, F_PIPE
+ * Handles: eTypeCONSOLE, eTypeTTY, eTypeFILE, eTypePIPE
*
* NOTE: read comments in module-template.h to understand how this file
* works!
@@ -55,6 +55,12 @@
*/
typedef struct _instanceData {
char f_fname[MAXFNAME];/* file or template name (display only) */
+ enum {
+ eTypeFILE,
+ eTypeTTY,
+ eTypeCONSOLE,
+ eTypePIPE
+ } fileType;
struct template *pTpl; /* pointer to template object */
char bDynamicName; /* 0 - static name, 1 - dynamic name (with properties) */
int fCreateMode; /* file creation mode for open() */
@@ -130,7 +136,7 @@ static rsRetVal cflineParseOutchannel(selector_t *f, instanceData *pData, uchar*
* emulate things for the time being. When everything runs, we can
* extend it...
*/
- f->f_type = F_FILE;
+ pData->fileType = eTypeFILE;
++p; /* skip '$' */
i = 0;
@@ -514,14 +520,14 @@ again:
/* If a named pipe is full, just ignore it for now
- mrn 24 May 96 */
- if (f->f_type == F_PIPE && e == EAGAIN)
+ if (pData->fileType == eTypePIPE && e == EAGAIN)
return RS_RET_OK;
/* If the filesystem is filled up, just ignore
* it for now and continue writing when possible
* based on patch for sysklogd by Martin Schulze on 2007-05-24
*/
- if (f->f_type == F_FILE && e == ENOSPC)
+ if (pData->fileType == eTypeFILE && e == ENOSPC)
return RS_RET_OK;
(void) close(f->f_file);
@@ -529,7 +535,7 @@ again:
* Check for EBADF on TTY's due to vhangup()
* Linux uses EIO instead (mrn 12 May 96)
*/
- if ((f->f_type == F_TTY || f->f_type == F_CONSOLE)
+ if ((pData->fileType == eTypeTTY || pData->fileType == eTypeCONSOLE)
#ifdef linux
&& e == EIO) {
#else
@@ -596,15 +602,17 @@ CODESTARTparseSelectorAct
/* yes, the if below is redundant, but I need it now. Will go away as
* the code further changes. -- rgerhards, 2007-07-25
*/
- if(*p == '$' || *p == '?' || *p == '|' || *p == '/') {
+ if(*p == '$' || *p == '?' || *p == '|' || *p == '/' || *p == '-') {
if((iRet = createInstance(&pData)) != RS_RET_OK)
return iRet;
+dprintf("parseSelActFile 1\n");
} else {
/* this is not clean, but we need it for the time being
* TODO: remove when cleaning up modularization
*/
return RS_RET_CONFLINE_UNPROCESSED;
}
+dprintf("parseSelActFile 2\n");
if (*p == '-') {
syncfile = 0;
@@ -672,6 +680,13 @@ CODESTARTparseSelectorAct
case '|':
case '/':
+ /* rgerhards, 2007-0726: first check if file or pipe */
+ if(*p == '|') {
+ pData->fileType = eTypePIPE;
+ ++p;
+ } else {
+ pData->fileType = eTypeFILE;
+ }
/* rgerhards 2004-11-17: from now, we need to have different
* processing, because after the first comma, the template name
* to use is specified. So we need to scan for the first coma first
@@ -684,7 +699,7 @@ CODESTARTparseSelectorAct
f->f_flags |= SYNC_FILE;
pData->bDynamicName = 0;
pData->fCreateMode = fCreateMode; /* preserve current setting */
- if(f->f_type == F_PIPE) {
+ if(pData->fileType == eTypePIPE) {
f->f_file = open(pData->f_fname, O_RDWR|O_NONBLOCK);
} else {
f->f_file = open(pData->f_fname, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY,
@@ -698,11 +713,11 @@ CODESTARTparseSelectorAct
break;
}
if (isatty(f->f_file)) {
- f->f_type = F_TTY;
+ pData->fileType = eTypeTTY;
untty();
}
if (strcmp((char*) p, ctty) == 0)
- f->f_type = F_CONSOLE;
+ pData->fileType = eTypeCONSOLE;
break;
default:
iRet = RS_RET_CONFLINE_UNPROCESSED;
diff --git a/ommysql.c b/ommysql.c
index 2db0940c..0dac4b77 100644
--- a/ommysql.c
+++ b/ommysql.c
@@ -89,11 +89,9 @@ static void closeMySQL(instanceData *pData)
BEGINfreeInstance
CODESTARTfreeInstance
- switch (f->f_type) {
-# ifdef WITH_DB
- closeMySQL(pData);
-# endif
- }
+# ifdef WITH_DB
+ closeMySQL(pData);
+# endif
ENDfreeInstance
@@ -357,7 +355,6 @@ CODESTARTparseSelectorAct
logerror("write to database action in config file, but rsyslogd compiled without "
"database functionality - ignored");
#else /* WITH_DB defined! */
- f->f_type = F_MYSQL;
p++;
/* Now we read the MySQL connection properties
diff --git a/omshell.c b/omshell.c
index b6aed55b..b1a77aca 100644
--- a/omshell.c
+++ b/omshell.c
@@ -106,10 +106,7 @@ CODESTARTparseSelectorAct
case '^': /* bkalkbrenner 2005-09-20: execute shell command */
dprintf("exec\n");
++p;
- if((iRet = cflineParseFileName(f, p, (uchar*) pData->progName)) == RS_RET_OK)
- if (f->f_type == F_FILE) {
- f->f_type = F_SHELL;
- }
+ iRet = cflineParseFileName(f, p, (uchar*) pData->progName);
break;
default:
iRet = RS_RET_CONFLINE_UNPROCESSED;
diff --git a/omusrmsg.c b/omusrmsg.c
index 384dd9b5..82f23af2 100644
--- a/omusrmsg.c
+++ b/omusrmsg.c
@@ -58,6 +58,7 @@
/* internal structures
*/
typedef struct _instanceData {
+ int bIsWall; /* 1- is wall, 0 - individual users */
char uname[MAXUNAMES][UNAMESZ+1];
} instanceData;
@@ -194,7 +195,7 @@ static void wallmsg(selector_t *f, instanceData *pData)
continue;
/* should we send the message to this user? */
- if (f->f_type == F_USERS) {
+ if (pData->bIsWall == 0) {
for (i = 0; i < MAXUNAMES; i++) {
if (!pData->uname[i][0]) {
i = MAXUNAMES;
@@ -262,7 +263,7 @@ CODESTARTparseSelectorAct
if(*p == '*') { /* wall */
dprintf ("write-all");
- f->f_type = F_WALL;
+ pData->bIsWall = 1; /* write to all users */
if(*(p+1) == ';') {
/* we have a template specifier! */
p += 2; /* eat "*;" */
@@ -282,7 +283,7 @@ CODESTARTparseSelectorAct
* loadBuildInModules() in syslogd.c
*/
dprintf ("users: %s\n", p); /* ASP */
- f->f_type = F_USERS;
+ pData->bIsWall = 0; /* write to individual users */
for (i = 0; i < MAXUNAMES && *p && *p != ';'; i++) {
for (q = p; *q && *q != ',' && *q != ';'; )
q++;
diff --git a/syslogd-types.h b/syslogd-types.h
index 09e66d1c..ef333b3d 100644
--- a/syslogd-types.h
+++ b/syslogd-types.h
@@ -115,19 +115,6 @@ struct syslogTime {
/* values for f_type in struct filed below*/
-/* gone away #define F_UNUSED 0 */ /* unused entry */
-#define F_FILE 1 /* regular file */
-#define F_TTY 2 /* terminal */
-#define F_CONSOLE 3 /* console terminal */
-#define F_FORW 4 /* remote machine */
-#define F_USERS 5 /* list of users */
-#define F_WALL 6 /* everyone logged on */
-#define F_FORW_SUSP 7 /* suspended host forwarding */
-#define F_FORW_UNKN 8 /* unknown host forwarding */
-#define F_PIPE 9 /* named pipe */
-#define F_MYSQL 10 /* MySQL database */
-#define F_DISCARD 11 /* discard event (do not process any further selector lines) */
-#define F_SHELL 12 /* execute a shell */
/* This structure represents the files that will have log
* copies printed.
diff --git a/syslogd.c b/syslogd.c
index dadb2c3d..57932485 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -4498,14 +4498,6 @@ rsRetVal cflineParseFileName(selector_t *f, uchar* p, uchar *pFileName)
rsRetVal iRet = RS_RET_OK;
char szTemplateName[128]; /* should be more than sufficient */
- /* TODO: below is problematic from modularization standpoint */
- if(*p == '|') {
- f->f_type = F_PIPE;
- ++p;
- } else {
- f->f_type = F_FILE;
- }
-
pName = pFileName;
i = 1; /* we start at 1 so that we reseve space for the '\0'! */
while(*p && *p != ';' && i < MAXFNAME) {