summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--Makefile.am2
-rw-r--r--msg.c1
-rw-r--r--msg.h2
-rw-r--r--omshell.c66
-rw-r--r--omshell.h34
-rw-r--r--syslogd.c10
-rw-r--r--syslogd.h2
-rw-r--r--template.h4
9 files changed, 118 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 409131bb..c34347c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@ Version 1.17.2 (rgerhards), 2007-07-2?
RFC 3164 format in templates
- did some preparation in msg.c for advanced multithreading - placed the
hooks, but not yet any active code
+- worked further on modularization
---------------------------------------------------------------------------
Version 1.17.1 (rgerhards), 2007-07-20
- fixed a bug that caused make install to install rsyslogd and rklogd under
diff --git a/Makefile.am b/Makefile.am
index e4d7ff24..01dce97c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,7 @@ rfc3195d_SOURCES=rfc3195d.c rsyslog.h
man_MANS = rfc3195d.8 rklogd.8 rsyslogd.8 rsyslog.conf.5
-rsyslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h template.h outchannel.h syslogd.h stringbuf.h parse.h srUtils.h liblogging-stub.h net.h msg.c msg.h
+rsyslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h template.h outchannel.h syslogd.h stringbuf.h parse.h srUtils.h liblogging-stub.h net.h msg.c msg.h omshell.c omshell.h
rsyslogd_CPPFLAGS=$(mysql_includes)
rsyslogd_LDADD=$(mysql_libs) $(zlib_libs) $(pthreads_libs)
diff --git a/msg.c b/msg.c
index ae0e47e2..8a02b02e 100644
--- a/msg.c
+++ b/msg.c
@@ -36,7 +36,6 @@
#include <ctype.h>
#include "rsyslog.h"
#include "syslogd.h"
-#include "template.h"
#include "srUtils.h"
#include "msg.h"
diff --git a/msg.h b/msg.h
index 1a54a86c..7b3cbd46 100644
--- a/msg.h
+++ b/msg.h
@@ -24,6 +24,8 @@
#ifndef MSG_H_INCLUDED
#define MSG_H_INCLUDED 1
+#include "template.h"
+
/* rgerhards 2004-11-08: The following structure represents a
* syslog message.
*
diff --git a/omshell.c b/omshell.c
new file mode 100644
index 00000000..fb49e964
--- /dev/null
+++ b/omshell.c
@@ -0,0 +1,66 @@
+/* omshell.c
+ * This is the implementation of the build-in shell output module.
+ *
+ * shell support was initially written by bkalkbrenner 2005-09-20
+ *
+ * File begun on 2007-07-20 by RGerhards (extracted from syslogd.c)
+ * This file is under development and has not yet arrived at being fully
+ * self-contained and a real object. So far, it is mostly an excerpt
+ * of the "old" message code without any modifications. However, it
+ * helps to have things at the right place one we go to the meat of it.
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "rsyslog.h"
+#include "syslogd.h"
+#include "syslogd-types.h"
+#include "srUtils.h"
+#include "omshell.h"
+
+
+/* call the shell action
+ * returns 0 if it succeeds, something else otherwise
+ */
+int doActionShell(selector_t *f, time_t now)
+{
+ uchar *psz;
+
+ /* TODO: using f->f_un.f_file.f_name is not clean from the point of
+ * modularization. We'll change that as we go ahead with modularization.
+ * rgerhards, 2007-07-20
+ */
+ f->f_time = now; /* TODO: find out, if we can not simply replace this with time(NULL) */
+ dprintf("\n");
+ iovCreate(f);
+ psz = (uchar*) iovAsString(f);
+ if(execProg((uchar*) f->f_un.f_file.f_fname, 1, (uchar*) psz) == 0)
+ logerrorSz("Executing program '%s' failed", f->f_un.f_file.f_fname);
+
+ return 0;
+}
+
+/*
+ * vi:set ai:
+ */
diff --git a/omshell.h b/omshell.h
new file mode 100644
index 00000000..1ffbec44
--- /dev/null
+++ b/omshell.h
@@ -0,0 +1,34 @@
+/* omshell.c
+ * These are the definitions for the build-in shell output module.
+ *
+ * File begun on 2007-07-13 by RGerhards (extracted from syslogd.c)
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#ifndef ACTSHELL_H_INCLUDED
+#define ACTSHELL_H_INCLUDED 1
+
+/* prototypes */
+
+int doActionShell(selector_t *f, time_t now);
+
+#endif /* #ifndef ACTSHELL_H_INCLUDED */
+/*
+ * vi:set ai:
+ */
diff --git a/syslogd.c b/syslogd.c
index c3784846..a103e04b 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -239,6 +239,7 @@
#include "parse.h"
#include "srUtils.h"
#include "msg.h"
+#include "omshell.h"
/* We define our own set of syslog defintions so that we
* do not need to rely on (possibly different) implementations.
@@ -5713,6 +5714,8 @@ void fprintlog(register selector_t *f)
#endif
case F_SHELL: /* shell support by bkalkbrenner 2005-09-20 */
+ doActionShell(f, now);
+#if 0
/* TODO: using f->f_un.f_file.f_name is not clean from the point of
* modularization. We'll change that as we go ahead with modularization.
* rgerhards, 2007-07-20
@@ -5723,6 +5726,7 @@ void fprintlog(register selector_t *f)
psz = iovAsString(f);
if(execProg((uchar*) f->f_un.f_file.f_fname, 1, (uchar*) psz) == 0)
logerrorSz("Executing program '%s' failed", f->f_un.f_file.f_fname);
+#endif
break;
} /* switch */
@@ -9042,7 +9046,7 @@ int main(int argc, char **argv)
funix[i] = -1;
}
- while ((ch = getopt(argc, argv, "46Aa:dehi:f:l:m:nop:r::s:t:u:vwx")) != EOF)
+ while ((ch = getopt(argc, argv, "46Aa:dehi:f:l:m:nop:r::s:t:u:vwx")) != EOF) {
switch((char)ch) {
case '4':
family = PF_INET;
@@ -9159,10 +9163,12 @@ int main(int argc, char **argv)
case 'x': /* disable dns for remote messages */
DisableDNS = 1;
break;
- case '?':
+ case '?':
default:
usage();
}
+ }
+
if ((argc -= optind))
usage();
diff --git a/syslogd.h b/syslogd.h
index c07e9b86..55ed1547 100644
--- a/syslogd.h
+++ b/syslogd.h
@@ -35,6 +35,8 @@ void getCurrTime(struct syslogTime *t);
int formatTimestampToMySQL(struct syslogTime *ts, char* pDst, size_t iLenDst);
int formatTimestamp3339(struct syslogTime *ts, char* pBuf, size_t iLenBuf);
int formatTimestamp3164(struct syslogTime *ts, char* pBuf, size_t iLenBuf);
+void iovCreate(selector_t *f);
+char *iovAsString(selector_t *f);
extern int glblHadMemShortage; /* indicates if we had memory shortage some time during the run */
extern syslogCODE rs_prioritynames[];
diff --git a/template.h b/template.h
index 6ff5c17a..3667173b 100644
--- a/template.h
+++ b/template.h
@@ -4,6 +4,9 @@
* begun 2004-11-17 rgerhards
*/
+#ifndef TEMPLATE_H_INCLUDED
+#define TEMPLATE_H_INCLUDED 1
+
#ifdef FEATURE_REGEXP
/* Include regular expressions */
#include <regex.h>
@@ -71,6 +74,7 @@ void tplDeleteNew(void);
void tplPrintList(void);
void tplLastStaticInit(struct template *tpl);
+#endif /* #ifndef TEMPLATE_H_INCLUDED */
/*
* vi:set ai:
*/