summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2004-11-17 14:32:37 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2004-11-17 14:32:37 +0000
commitad0011c81447641474216f306ae1b4709c22ea6c (patch)
tree573330802dd5c0eacf8e1abc6b96f0c4dc9b5094
parent33579ae6eccde4593c17909ef7b065ec8f32e563 (diff)
downloadrsyslog-ad0011c81447641474216f306ae1b4709c22ea6c.tar.gz
rsyslog-ad0011c81447641474216f306ae1b4709c22ea6c.tar.xz
rsyslog-ad0011c81447641474216f306ae1b4709c22ea6c.zip
begin templates
-rw-r--r--CHANGES35
-rw-r--r--Makefile7
-rw-r--r--syslogd.c52
-rw-r--r--template.c35
-rw-r--r--template.h15
5 files changed, 103 insertions, 41 deletions
diff --git a/CHANGES b/CHANGES
index 25a50edc..b4cd28b8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,32 +1,5 @@
-Version 1.4.1
+Version 0.1.0
- . klogd will set the console log level only if `-c' is given on the
- commandline, not overwriting local settings in `/etc/sysctl.conf'.
- . Bugfix: klogd will use SOCK_DGRM as well, re-enables kernel logging
- . Bugfix: Don't make syslogd fail with broken `-a'
- . Bugfix: klogd will skip zero bytes and not enter a busy loop anymore
- . Thomas Roessler <roessler@does-not-exist.org>
- - Patch to prevent LogLine() from being invoked with a negative
- counter as an argument.
-
-Version 1.4
-
- . Skip newline when reading in klog messages
- . Use lseek64() instead of llseek() which is deprecated these days
- . Close symbol file before returning with 0 when an error occurred
- while reading it. This will enable systems to umount that
- partition with no open file descriptor left over.
- . Solar Designer <solar@false.com>
- - printline() fixes
- - priority decoding fix
- . Daniel Jacobowitz <dan@debian.org>
- - printchopped() fix
- . Keith Owens <kaos@ocs.com.au>
- - Fixed bug that caused klogd to die if there is no sym_array available.
- - When symbols are expanded, print the line twice. Once with
- addresses converted to symbols, once with the raw text. Allows
- external programs such as ksymoops do their own processing on the
- original data.
- . Olaf Kirch <okir@caldera.de>
- - Remove Unix Domain Sockets and switch to Datagram Unix Sockets
- . Several bugfixes and improvements, please refer to the .c files
+ . This version builds on the sysklogd-1.4.1 package. If you are interested
+ in the original package, please look at its description. This
+ version here is forked because we intend to do major changes.
diff --git a/Makefile b/Makefile
index fb62a954..6a31576d 100644
--- a/Makefile
+++ b/Makefile
@@ -63,7 +63,7 @@ test: syslog_tst ksym oops_test tsyslogd
install: install_man install_exec
-syslogd: syslogd.o pidfile.o
+syslogd: syslogd.o pidfile.o template.o
${CC} ${LDFLAGS} -o syslogd syslogd.o pidfile.o ${LIBS}
klogd: klogd.o syslog.o pidfile.o ksym.o ksym_mod.o
@@ -79,7 +79,10 @@ tsyslogd: syslogd.c version.h
tklogd: klogd.c syslog.c ksym.c ksym_mod.c version.h
$(CC) $(CFLAGS) -g -DTESTING $(KLOGD_FLAGS) -o tklogd klogd.c syslog.c ksym.c ksym_mod.c
-syslogd.o: syslogd.c version.h
+template.o: template.c template.h
+ ${CC} ${CFLAGS} ${SYSLOGD_FLAGS} $(DEB) -c template.c
+
+syslogd.o: syslogd.c version.h template.h
${CC} ${CFLAGS} ${SYSLOGD_FLAGS} $(DEB) -c syslogd.c
syslog.o: syslog.c
diff --git a/syslogd.c b/syslogd.c
index 2cf892e2..47c26986 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -585,6 +585,8 @@ static char sccsid[] = "@(#)rsyslogd.c 0.1 (Adiscon) 11/08/2004";
#include <paths.h>
#endif
+#include "template.h"
+
#ifdef WITH_DB
#define _DB_MAXDBLEN 128 /* maximum number of db */
#define _DB_MAXUNAMELEN 128 /* maximum number of user name */
@@ -1170,7 +1172,7 @@ static int srSLMGParseTIMESTAMP3164(struct syslogTime *pTime, unsigned char* psz
* returns the size of the timestamp written in bytes (without
* the string termnator). If 0 is returend, an error occured.
*/
-int formatTimestamp(struct syslogTime *ts, char* pBuf, size_t iLenBuf)
+int formatTimestamp3164(struct syslogTime *ts, char* pBuf, size_t iLenBuf)
{
static char* monthNames[13] = {"ERR", "Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul",
@@ -2523,7 +2525,7 @@ void writeFile(struct filed *f)
v->iov_base = " ";
v->iov_len = 1;
v++;
- v->iov_len = formatTimestamp(&f->f_pMsg->tTIMESTAMP,
+ v->iov_len = formatTimestamp3164(&f->f_pMsg->tTIMESTAMP,
szTIMESTAMP, sizeof(szTIMESTAMP) / sizeof(char));
v->iov_base = szTIMESTAMP;
v++;
@@ -2614,7 +2616,6 @@ void fprintlog(f, flags)
struct hostent *hp;
#endif
-dprintf("fprintlog\n");
msg = f->f_pMsg->pszMSG;
dprintf("Called fprintlog, ");
@@ -3150,10 +3151,34 @@ void doexit(sig)
}
#endif
+/* Parse and interpret a system-directive in the config line
+ * A system directive is one that starts with a "$" sign. It offers
+ * extended configuration parameters.
+ * 2004-11-17 rgerhards
+ */
+void cfsysline(char *p)
+{
+ char szCmd[32];
+
+ assert(p != NULL);
+ dprintf("cfsysline --> %s", p);
+ if(getSubString(&p, szCmd, sizeof(szCmd) / sizeof(char), ' ') != 0) {
+ dprintf("Invalid $-configline - could not extract command - line ignored\n");
+ return;
+ }
+
+ /* check the command and carry out processing */
+ if(!strcmp(szCmd, "template")) {
+ } else { /* invalid command! */
+ dprintf("Invalid command in $-configline: '%s' - line ignored\n", szCmd);
+ return;
+ }
+}
+
+
/*
* INIT -- Initialize syslogd from configuration table
*/
-
void init()
{
register int i, lognum;
@@ -3274,9 +3299,14 @@ void init()
* check for end-of-section, comments, strip off trailing
* spaces and newline character.
*/
- for (p = cline; isspace(*p); ++p);
+ for (p = cline; isspace(*p); ++p) /*SKIP SPACES*/;
if (*p == '\0' || *p == '#')
continue;
+
+ if(*p == '$') {
+ cfsysline(++p);
+ continue;
+ }
#if CONT_LINE
strcpy(cline, p);
#endif
@@ -3417,6 +3447,14 @@ void init()
/*
* Crack a configuration file line
+ * rgerhards 2004-11-17: well, I somewhat changed this function. It now does NOT
+ * handle config lines in general, but only lines that reflect actual filter
+ * pairs (the original syslog message line format). Extended lines (those starting
+ * with "$" have been filtered out by the caller and are passed to another function.
+ * Please note, however, that I needed to make changes in the line syntax to support
+ * assignment of format definitions to a file. So it is not (yet) 100% transparent.
+ * Eventually, we can overcome this limitation by prfexing the actual acton indicator
+ * (e.g. "/file..") by something (e.g. "$/file..") - but for now, we just modify it...
*/
void cfline(line, f)
@@ -3434,8 +3472,6 @@ void cfline(line, f)
#ifdef SYSLOG_INET
struct hostent *hp;
#endif
-#ifdef WITH_DB
-#endif
char buf[MAXLINE];
char xbuf[200];
@@ -3866,7 +3902,7 @@ void writeMySQL(register struct filed *f)
* \param pDst Pointer to the destination array of characters
* \param DstSize Maximum numbers of characters to store
* \param cSep Separator char
- * \ret int Returns 0 if no error occur
+ * \ret int Returns 0 if no error occured
*/
int getSubString(char **ppSrc, char *pDst, size_t DstSize, char cSep)
{
diff --git a/template.c b/template.c
new file mode 100644
index 00000000..f882ea56
--- /dev/null
+++ b/template.c
@@ -0,0 +1,35 @@
+/* This is the template processing code of rsyslog.
+ * Please see syslogd.c for license information.
+ * This code is placed under the GPL.
+ * begun 2004-11-17 rgerhards
+ */
+#include <stdio.h>
+#include <malloc.h>
+#include "template.h"
+
+static struct template *tplRoot = NULL; /* the root of the templat list */
+static struct template *tplLast = NULL; /* points to the last element of the template list */
+
+/* Constructs a template entry. Returns pointer to it
+ * or NULL (if it fails).
+ */
+struct template* tplConstruct(void)
+{
+ struct template *pTpl;
+ if((pTpl = malloc(sizeof(struct template))) == NULL)
+ return NULL;
+
+ pTpl->pszName = NULL;
+ pTpl->pszTemplate = NULL;
+
+ if(tplLast == NULL)
+ { /* we are the first element! */
+ tplRoot = tplLast = pTpl;
+ }
+
+ return(pTpl);
+}
+
+/*
+ * vi:set ai:
+ */
diff --git a/template.h b/template.h
new file mode 100644
index 00000000..8f96c43b
--- /dev/null
+++ b/template.h
@@ -0,0 +1,15 @@
+/* This is the header for template processing code of rsyslog.
+ * Please see syslogd.c for license information.
+ * This code is placed under the GPL.
+ * begun 2004-11-17 rgerhards
+ */
+struct template {
+ char *pszName;
+ char *pszTemplate;
+};
+
+struct template* tplConstruct(void);
+
+/*
+ * vi:set ai:
+ */