summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--NEWS4
-rw-r--r--syslogd.c52
-rw-r--r--version.h2
4 files changed, 49 insertions, 11 deletions
diff --git a/AUTHORS b/AUTHORS
index 89d2ccfe..3a442127 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,3 +6,5 @@ Andres Riancho (andres-dot-riancho-at-gmail-dot-com)
(alias APR in code files)
- supplied regexp functionality for the property replacer - a great feature.
thanks!
+Bjoern Kalkbrenner
+ - provided code for the "execute shell script" action
diff --git a/NEWS b/NEWS
index 50ba2abc..39820b40 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------
+Version 1.10.1 (RGer), 2005-09-2?
+- added the ability to execute a shell script as an action.
+ Thanks to Bjoern Kalkbrenner for providing the code!
+---------------------------------------------------------------------------
Version 1.10.0 (RGer), 2005-09-20
REMINDER: 1.10 is the first unstable version if the 1.x series!
- added the capability to filter on any property in selector lines
diff --git a/syslogd.c b/syslogd.c
index e53d84f6..53d29511 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -573,10 +573,12 @@ int repeatinterval[] = { 30, 60 }; /* # of secs before flush */
#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 */
char *TypeNames[] = {
"UNUSED", "FILE", "TTY", "CONSOLE",
"FORW", "USERS", "WALL", "FORW(SUSPENDED)",
- "FORW(UNKNOWN)", "PIPE", "MYSQL", "DISCARD"
+ "FORW(UNKNOWN)", "PIPE", "MYSQL", "DISCARD",
+ "SHELL"
};
struct filed *Files = NULL;
@@ -3959,11 +3961,12 @@ again:
* This whole function is probably about to change once we have the
* message abstraction.
*/
-void fprintlog(f, flags)
- register struct filed *f;
- int flags;
+void fprintlog(register struct filed *f, int flags)
{
char *msg;
+ char *psz; /* for shell support */
+ int esize; /* for shell support */
+ char *exec; /* for shell support */
#ifdef SYSLOG_INET
register int l;
time_t fwd_suspend;
@@ -4129,6 +4132,25 @@ void fprintlog(f, flags)
writeMySQL(f);
break;
#endif
+
+ case F_SHELL: /* shell support by bkalkbrenner 2005-09-20 */
+ f->f_time = now;
+ iovCreate(f);
+ psz = iovAsString(f);
+ l = f->f_iLenpsziov;
+ if (l > MAXLINE)
+ l = MAXLINE;
+ esize = strlen(f->f_un.f_fname) + strlen(psz) + 4;
+ exec = (char*) calloc(1, esize * sizeof(char));
+ strcpy(exec,f->f_un.f_fname);
+ strcat(exec," \"");
+ strcat(exec,psz);
+ strcat(exec,"\"");
+ dprintf("Executing \"%s\"\n",exec);
+ system(exec); /* rgerhards: TODO: need to change this for root jail support! */
+ free(exec);
+ break;
+
} /* switch */
if (f->f_type != F_FORW_UNKN)
f->f_prevcount = 0;
@@ -4889,6 +4911,10 @@ void init()
printf(" (unused)");
break;
+ case F_SHELL:
+ printf("%s", f->f_un.f_fname);
+ break;
+
case F_FORW:
case F_FORW_SUSP:
case F_FORW_UNKN:
@@ -5681,30 +5707,36 @@ rsRetVal cfline(char *line, register struct filed *f)
/* 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 != 1)
- {
+ if (f->f_pTpl->optFormatForSQL != 1) {
f->f_type = F_UNUSED;
logerror("DB logging disabled. You have to use"
" the SQL option in your template!\n");
break;
-
}
/* If we dedect invalid properties, we disable logging,
* because right properties are vital at this place.
- * Retrials make no sens.
+ * Retries make no sense.
*/
if (iMySQLPropErr) {
f->f_type = F_UNUSED;
dprintf("Trouble with MySQL conncetion properties.\n"
"MySQL logging disabled.\n");
- }
- else {
+ } else {
initMySQL(f);
}
#endif /* #ifdef WITH_DB */
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;
+ }
+ break;
+
default:
dprintf ("users: %s\n", p); /* ASP */
f->f_type = F_USERS;
diff --git a/version.h b/version.h
index afa52177..2cbe0878 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
#define VERSION "1.10"
-#define PATCHLEVEL "0"
+#define PATCHLEVEL "1"