mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-18 02:50:43 +01:00
moved part of the shell action to its own module
This commit is contained in:
parent
66214d45c7
commit
4d53a1e6a3
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
1
msg.c
1
msg.c
@ -36,7 +36,6 @@
|
||||
#include <ctype.h>
|
||||
#include "rsyslog.h"
|
||||
#include "syslogd.h"
|
||||
#include "template.h"
|
||||
#include "srUtils.h"
|
||||
#include "msg.h"
|
||||
|
||||
|
||||
2
msg.h
2
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.
|
||||
*
|
||||
|
||||
66
omshell.c
Normal file
66
omshell.c
Normal file
@ -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:
|
||||
*/
|
||||
34
omshell.h
Normal file
34
omshell.h
Normal file
@ -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:
|
||||
*/
|
||||
10
syslogd.c
10
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();
|
||||
|
||||
|
||||
@ -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[];
|
||||
|
||||
@ -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:
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user