You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(23) |
Oct
(2) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(4) |
Feb
(11) |
Mar
(1) |
Apr
(104) |
May
(18) |
Jun
(42) |
Jul
|
Aug
(4) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: <al...@us...> - 2003-04-17 17:30:42
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv3952/src/modules Modified Files: im_tcp.c Log Message: conection -> connection Index: im_tcp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_tcp.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- im_tcp.c 16 Apr 2003 11:37:23 -0000 1.47 +++ im_tcp.c 17 Apr 2003 17:30:37 -0000 1.48 @@ -39,7 +39,7 @@ * The main idea is that first a im_tcp module will be called * and it will bind to a port and wait for connections to it. * - * Whenever a conection is established it will add it to an + * Whenever a connection is established it will add it to an * array of file descriptors of connections. * */ @@ -230,7 +230,7 @@ con->next = c->first; c->first = con; - m_dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: new conection from" + m_dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: new connection from" " %s with fd %d\n", con->name, con->fd); /* add to inputs list */ |
From: <al...@us...> - 2003-04-17 17:28:59
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv3150/src/modules Modified Files: om_oracle8i.c Log Message: dprintf -> m_dprintf Index: om_oracle8i.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_oracle8i.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- om_oracle8i.c 17 Apr 2003 17:25:24 -0000 1.2 +++ om_oracle8i.c 17 Apr 2003 17:28:55 -0000 1.3 @@ -187,7 +187,7 @@ *p; int err; - dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_write: entering [%s] [%s]\n", + m_dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_write: entering [%s] [%s]\n", m->msg, f->f_prevline); c = (struct om_oracle8i_ctx *)ctx; @@ -227,7 +227,7 @@ NULL, NULL, NULL, 0, NULL, OCI_DEFAULT))) { c->OCIErrorGet(c->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); - dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " + m_dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " "binding the placeholders for [%s]\n", err_buf); return -1; } @@ -267,7 +267,7 @@ if (OCI_SUCCESS != err) { c->OCIErrorGet(c->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); - dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " + m_dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " "executing statement [%s]\n", err_buf); return -1; @@ -304,7 +304,7 @@ c == NULL || *c != NULL) return (-1); - dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_init: alloc context\n"); + m_dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_init: alloc context\n"); if ((*c = (void *)calloc(1, sizeof (struct om_oracle8i_ctx))) == NULL) return (-1); @@ -332,7 +332,7 @@ ctx->OCIHandleAlloc(ctx->env, &ctx->err, OCI_HTYPE_ERROR, 0, NULL); - dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_init: params %p %s %s \n", + m_dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_init: params %p %s %s \n", ctx->env, ctx->user, ctx->db); if (1 != prepare_query(ctx)) { @@ -409,7 +409,7 @@ load_symbols(struct om_oracle8i_ctx *ctx) { if ((ctx->lib = dlopen("libclntsh.so", DLOPEN_FLAGS)) == NULL) { - dprintf(MSYSLOG_SERIOUS, "om_oracle8i_init: Error loading" + m_dprintf(MSYSLOG_SERIOUS, "om_oracle8i_init: Error loading" " api library, %s\n", dlerror()); return -1; } @@ -439,7 +439,7 @@ || !ctx->OCILogoff || !ctx->OCIStmtPrepare || !ctx->OCIStmtExecute || !ctx->OCIErrorGet || !ctx->OCIBindByName) { - dprintf(MSYSLOG_SERIOUS, + m_dprintf(MSYSLOG_SERIOUS, "om_oracle8i_init: Some required symbols are missing"); return -1; } @@ -509,7 +509,7 @@ (ctx->flags & OM_ORACLE8I_FACILITY)? ":facility, " : "", (ctx->flags & OM_ORACLE8I_PRIORITY)? ":priority, " : ""); - dprintf(MSYSLOG_INFORMATIVE2, "om_oracle8i_write: query [%s]\n", query); + m_dprintf(MSYSLOG_INFORMATIVE2, "om_oracle8i_write: query [%s]\n", query); ctx->OCIHandleAlloc(ctx->env, &ctx->stmt, OCI_HTYPE_STMT, 0, NULL); @@ -518,7 +518,7 @@ if (OCI_SUCCESS != err) { ctx->OCIErrorGet(ctx->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); - dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " + m_dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " "preparing statement [%s]\n", err_buf); return -1; |
From: <al...@us...> - 2003-04-17 17:25:28
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv1190/src/modules Modified Files: om_oracle8i.c Log Message: CoreSDI -> Id 2001 -> 2003 Index: om_oracle8i.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_oracle8i.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- om_oracle8i.c 17 Apr 2003 17:24:30 -0000 1.1 +++ om_oracle8i.c 17 Apr 2003 17:25:24 -0000 1.2 @@ -1,7 +1,6 @@ -/* $CoreSDI: om_oracle8i.c,v 1.7 2003/01/31 19:01:14 jkohen Exp $ */ - +/* $Id$ */ /* - * Copyright (c) 2001, Core SDI S.A., Argentina + * Copyright (c) 2003, Core SDI S.A., Argentina * All rights reserved * * Redistribution and use in source and binary forms, with or without |
From: <al...@us...> - 2003-04-17 17:24:33
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv582/src/modules Added Files: om_oracle8i.c Log Message: oracle 8i module by jkohen@ --- NEW FILE: om_oracle8i.c --- /* $CoreSDI: om_oracle8i.c,v 1.7 2003/01/31 19:01:14 jkohen Exp $ */ /* * Copyright (c) 2001, Core SDI S.A., Argentina * All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither name of the Core SDI S.A. nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * om_oracle8i -- Oracle8i database support Module * * Author: Javier Kohen for Core-SDI SA * Based on om_mysql from Alejo Sanchez * * Future enhancements: * Move the creation of the query together with OCIStmtPrepare to * om_oracle8i_init. Add binding code to om_oracle8i_write just * before OCIStmtExecute. */ #include "config.h" #include <sys/types.h> #if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else # if HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> # endif #endif #include <sys/param.h> #include <signal.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> #include <dlfcn.h> #include "../modules.h" #include "../syslogd.h" #include "sql_misc.h" /* size of query buffer */ #define MAX_QUERY 8192 /* * ARGH! Redeclaring this is painful, man. * Declarations and definitions taken from Oracle8i 8.1.5's oci.h. */ typedef int (* OCIHandleAlloc_t) (const void *parenth, void **hndlpp, uint32_t type, size_t xtramem_sz, void **usrmempp); typedef int (* OCIHandleFree_t) (void *hndlp, uint32_t type); typedef int (* OCILogon_t) (void *envhp, void *errhp, void **svchp, const char *username, uint32_t uname_len, const char *password, uint32_t passwd_len, const char *dbname, uint32_t dbname_len); typedef int (* OCILogoff_t) (void *svchp, void *errhp); typedef int (* OCIEnvCreate_t) (void **envhpp, uint32_t mode, const void *ctxp, const void *(*malocfp) (void *ctxp, size_t size), const void *(*ralocfp) (void *ctxp, void *memptr, size_t newsize), const void (*mfreefp) (void *ctxp, void *memptr), size_t xtramemsz, void **usrmempp); typedef int (* OCIStmtPrepare_t) (void *stmtp, void *errhp, const char *stmt, uint32_t stmt_len, uint32_t language, uint32_t mode); typedef int (* OCIStmtExecute_t) (void *svchp, void *stmtp, void *errhp, uint32_t iters, uint32_t rowoff, const void *snap_in, void *snap_out, uint32_t mode); typedef int (* OCIErrorGet_t) (void *hndlp, uint32_t recordno, void *sqlstate, int32_t *errcodep, char *bufp, uint32_t bufsiz, uint32_t type); typedef int (* OCIBindByName_t) (void *stmtp, void **bindpp, void *errhp, const char *placeholder, uint32_t placeh_len, void *valuep, uint32_t value_sz, uint16_t dty, void *indp, uint16_t *alenp, uint16_t *rcodep, uint32_t maxarr_len, uint32_t *curelep, uint32_t mode); #define OCI_SUCCESS 0 #define OCI_ERROR -1 #define OCI_DEFAULT 0x00 #define OCI_COMMIT_ON_SUCCESS 0x20 #define OCI_HTYPE_ENV 1 #define OCI_HTYPE_ERROR 2 #define OCI_HTYPE_STMT 4 #define OCI_NTV_SYNTAX 1 #define SQLT_STR 5 struct om_oracle8i_ctx { int lost; char *table; char *user; char *passwd; char *db; void *lib; int flags; int loggedon; void *env; void *err; void *svc; void *stmt; OCIEnvCreate_t OCIEnvCreate; OCIHandleAlloc_t OCIHandleAlloc; OCIHandleFree_t OCIHandleFree; OCILogon_t OCILogon; OCILogoff_t OCILogoff; OCIStmtPrepare_t OCIStmtPrepare; OCIStmtExecute_t OCIStmtExecute; OCIErrorGet_t OCIErrorGet; OCIBindByName_t OCIBindByName; }; #define OM_ORACLE8I_FACILITY 0x4 #define OM_ORACLE8I_PRIORITY 0x8 static int parse_arguments(struct om_oracle8i_ctx *ctx, int argc, char **argv); static int load_symbols(struct om_oracle8i_ctx *ctx); static int prepare_query(struct om_oracle8i_ctx *ctx); int om_oracle8i_close(struct filed *, void *); int om_oracle8i_write(struct filed *f, int flags, struct m_msg *m, void *ctx) { struct om_oracle8i_ctx *c; /* These should be preserved between calls, so they can be reused. */ static void *bnd_prio = NULL, *bnd_fac = NULL, *bnd_tstamp = NULL, *bnd_host = NULL, *bnd_msg = NULL; char err_buf[512]; char facility[16], priority[16], tstamp[100], *p; int err; dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_write: entering [%s] [%s]\n", m->msg, f->f_prevline); c = (struct om_oracle8i_ctx *)ctx; if (!c->loggedon) { err = c->OCILogon(c->env, c->err, &c->svc, c->user, strlen(c->user), c->passwd, strlen(c->passwd), c->db, strlen(c->db)); if (OCI_SUCCESS != err) { return -1; } else { c->loggedon = 1; } } /* Bind the placeholders in the INSERT statement. */ if ((c->flags & OM_ORACLE8I_PRIORITY && (err = c->OCIBindByName(c->stmt, &bnd_prio, c->err, ":PRIORITY", -1, priority, sizeof priority, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT))) || (c->flags & OM_ORACLE8I_FACILITY && (err = c->OCIBindByName(c->stmt, &bnd_fac, c->err, ":FACILITY", -1, facility, sizeof facility, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT))) || (err = c->OCIBindByName(c->stmt, &bnd_tstamp, c->err, ":TIMESTAMP", -1, tstamp, sizeof tstamp, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT)) || (err = c->OCIBindByName(c->stmt, &bnd_host, c->err, ":HOST", -1, f->f_prevhost, strlen(f->f_prevhost)+1, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT)) || (err = c->OCIBindByName(c->stmt, &bnd_msg, c->err, ":MESSAGE", -1, m->msg, strlen(m->msg)+1, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT))) { c->OCIErrorGet(c->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " "binding the placeholders for [%s]\n", err_buf); return -1; } /* Assign the proper values to the bound variables. */ if (c->flags & OM_ORACLE8I_FACILITY) { if ((p = decode_val(m->fac << 3, CODE_FACILITY)) != NULL) snprintf(facility, sizeof (facility), "'%s',", p); else snprintf(facility, sizeof (facility), "'%d',", m->fac << 3); } if (c->flags & OM_ORACLE8I_PRIORITY) { if ((p = decode_val(m->pri, CODE_PRIORITY)) != NULL) snprintf(priority, sizeof (priority), "'%s',", p); else snprintf(priority, sizeof (priority), "'%d',", m->pri); } snprintf(tstamp, sizeof tstamp, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d", f->f_tm.tm_year + 1900, f->f_tm.tm_mon + 1, f->f_tm.tm_mday, f->f_tm.tm_hour, f->f_tm.tm_min, f->f_tm.tm_sec); tstamp[sizeof (tstamp) - 1] = '\0'; /* Execute the INSERT statement. */ err = c->OCIStmtExecute(c->svc, c->stmt, c->err, 1, 0, NULL, NULL, OCI_COMMIT_ON_SUCCESS); if (OCI_SUCCESS != err) { c->OCIErrorGet(c->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " "executing statement [%s]\n", err_buf); return -1; } return 1; } /* * INIT -- Initialize om_oracle8i * * Parse options and connect to database * * params: * -u <user> * -p <password> * -b <database_name> * -t <table_name> * -P * -F * */ int om_oracle8i_init(int argc, char **argv, struct filed *f, char *prog, void **c, char **status) { struct om_oracle8i_ctx *ctx; char buf[1024]; char err_buf[512]; int err; if (argv == NULL || *argv == NULL || argc < 2 || f == NULL || c == NULL || *c != NULL) return (-1); dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_init: alloc context\n"); if ((*c = (void *)calloc(1, sizeof (struct om_oracle8i_ctx))) == NULL) return (-1); ctx = (struct om_oracle8i_ctx *)*c; if (1 != load_symbols(ctx)) { free(ctx); return -1; } if (1 != parse_arguments(ctx, argc, argv)) { goto om_oracle8i_init_bad; } err = ctx->OCIEnvCreate(&ctx->env, OCI_DEFAULT, NULL, NULL, NULL, NULL, 0, NULL); if (OCI_SUCCESS != err) { ctx->OCIErrorGet(ctx->env, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ENV); snprintf(buf, sizeof buf, "om_oracle8i_init: Error " "initializing handle [%s]", err_buf); logerror(buf); goto om_oracle8i_init_bad; } ctx->OCIHandleAlloc(ctx->env, &ctx->err, OCI_HTYPE_ERROR, 0, NULL); dprintf(MSYSLOG_INFORMATIVE, "om_oracle8i_init: params %p %s %s \n", ctx->env, ctx->user, ctx->db); if (1 != prepare_query(ctx)) { goto om_oracle8i_init_bad; } snprintf(buf, sizeof (buf), "om_oracle8i: sending " "messages to database %s, table %s.", ctx->db, ctx->table); *status = strdup(buf); /* Connect to the database. */ err = ctx->OCILogon(ctx->env, ctx->err, &ctx->svc, ctx->user, strlen(ctx->user), ctx->passwd, strlen(ctx->passwd), ctx->db, strlen(ctx->db)); if (OCI_SUCCESS != err) { ctx->OCIErrorGet(ctx->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); snprintf(buf, sizeof buf, "om_oracle8i_init: Error " "connecting to db server [%s] user [%s] db [%s]", err_buf, ctx->user, ctx->db); logerror(buf); /* Another Logon operation will be tried when needed. */ } else { ctx->loggedon = 1; } return (1); om_oracle8i_init_bad: if (ctx) { om_oracle8i_close(f, ctx); free(ctx); *c = NULL; } *status = NULL; return (-1); } int om_oracle8i_close(struct filed *f, void *ctx) { struct om_oracle8i_ctx *c = (struct om_oracle8i_ctx *) ctx; if (c->svc) c->OCILogoff(c->svc, c->err); if (c->err) c->OCIHandleFree(c->err, OCI_HTYPE_ERROR); if (c->env) c->OCIHandleFree(c->env, OCI_HTYPE_ENV); if (c->stmt) c->OCIHandleFree(c->stmt, OCI_HTYPE_STMT); if (c->table) free(c->table); if (c->user) free(c->user); if (c->passwd) free(c->passwd); if (c->db) free(c->db); if (c->lib) dlclose(c->lib); return (0); } int load_symbols(struct om_oracle8i_ctx *ctx) { if ((ctx->lib = dlopen("libclntsh.so", DLOPEN_FLAGS)) == NULL) { dprintf(MSYSLOG_SERIOUS, "om_oracle8i_init: Error loading" " api library, %s\n", dlerror()); return -1; } ctx->OCIEnvCreate = (OCIEnvCreate_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIEnvCreate"); ctx->OCIHandleAlloc = (OCIHandleAlloc_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIHandleAlloc"); ctx->OCIHandleFree = (OCIHandleFree_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIHandleFree"); ctx->OCILogon = (OCILogon_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCILogon"); ctx->OCILogoff = (OCILogoff_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCILogoff"); ctx->OCIStmtPrepare = (OCIStmtPrepare_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIStmtPrepare"); ctx->OCIStmtExecute = (OCIStmtExecute_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIStmtExecute"); ctx->OCIErrorGet = (OCIErrorGet_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIErrorGet"); ctx->OCIBindByName = (OCIBindByName_t) dlsym(ctx->lib, SYMBOL_PREFIX "OCIBindByName"); /* Every function is required. */ if (!ctx->OCIEnvCreate || !ctx->OCIHandleAlloc || !ctx->OCIHandleFree || !ctx->OCILogon || !ctx->OCILogoff || !ctx->OCIStmtPrepare || !ctx->OCIStmtExecute || !ctx->OCIErrorGet || !ctx->OCIBindByName) { dprintf(MSYSLOG_SERIOUS, "om_oracle8i_init: Some required symbols are missing"); return -1; } return 1; } int parse_arguments(struct om_oracle8i_ctx *ctx, int argc, char **argv) { int argcnt; int ch; argcnt = 1; /* skip module name */ while ((ch = getxopt(argc, argv, "u!user: p!password:" " d!database: t!table: P!priority F!facility", &argcnt)) != -1) { switch (ch) { case 'u': ctx->user = strdup(argv[argcnt]); break; case 'p': ctx->passwd = strdup(argv[argcnt]); break; case 'd': ctx->db = strdup(argv[argcnt]); break; case 't': ctx->table = strdup(argv[argcnt]); break; case 'P': ctx->flags |= OM_ORACLE8I_PRIORITY; break; case 'F': ctx->flags |= OM_ORACLE8I_FACILITY; break; default: return -1; } argcnt++; } if (ctx->user == NULL || ctx->db == NULL || ctx->table == NULL) return -1; return 1; } int prepare_query(struct om_oracle8i_ctx *ctx) { char query[MAX_QUERY]; char err_buf[512]; int err; int i; i = snprintf(query, sizeof (query), "INSERT INTO %s" " (%s%s TIMESTAMP, HOST, MESSAGE)" " VALUES(%s%s TO_DATE(:timestamp, 'YYYY-MM-DD HH24:MI:SS')," " :host, :message)", ctx->table, (ctx->flags & OM_ORACLE8I_FACILITY)? "FACILITY, " : "", (ctx->flags & OM_ORACLE8I_PRIORITY)? "PRIORITY, " : "", (ctx->flags & OM_ORACLE8I_FACILITY)? ":facility, " : "", (ctx->flags & OM_ORACLE8I_PRIORITY)? ":priority, " : ""); dprintf(MSYSLOG_INFORMATIVE2, "om_oracle8i_write: query [%s]\n", query); ctx->OCIHandleAlloc(ctx->env, &ctx->stmt, OCI_HTYPE_STMT, 0, NULL); err = ctx->OCIStmtPrepare(ctx->stmt, ctx->err, query, i, OCI_NTV_SYNTAX, OCI_DEFAULT); if (OCI_SUCCESS != err) { ctx->OCIErrorGet(ctx->err, 1, NULL, &err, err_buf, sizeof err_buf, OCI_HTYPE_ERROR); dprintf(MSYSLOG_SERIOUS, "om_oracle8i_write: Error " "preparing statement [%s]\n", err_buf); return -1; } return 1; } |
From: <al...@us...> - 2003-04-17 17:24:32
|
Update of /cvsroot/msyslog/syslog/src/examples In directory sc8-pr-cvs1:/tmp/cvs-serv582/src/examples Added Files: syslog.conf.oracle8i Log Message: oracle 8i module by jkohen@ --- NEW FILE: syslog.conf.oracle8i --- # $Id: syslog.conf.oracle8i,v 1.1 2003/04/17 17:24:28 alejo Exp $ # # SECURITY NOTE: # Since msyslog needs here the password to log to Oracle8i, # this file shouldn't be world readable!!! # # Log to server logger.mydomain.edu through Oracle8i *.* %oracle8i -s logger.mydomain.edu -u loguser -p loguserpassword -d syslogDB -t syslogTB |
From: <al...@us...> - 2003-04-17 17:21:56
|
Update of /cvsroot/msyslog/syslog/src/man In directory sc8-pr-cvs1:/tmp/cvs-serv31700/src/man Modified Files: om_mysql.8 Log Message: fixes and improvements on db keys by jkohen@ Index: om_mysql.8 =================================================================== RCS file: /cvsroot/msyslog/syslog/src/man/om_mysql.8,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- om_mysql.8 17 Sep 2002 05:20:27 -0000 1.23 +++ om_mysql.8 17 Apr 2003 17:21:51 -0000 1.24 @@ -74,22 +74,28 @@ The table should have a format like this: .Pp .Bd -literal - CREATE TABLE syslogTB ( - facility char(10), # OPTIONAL field for facility - priority char(10), # OPTIONAL field for priority - date date, # date of this log message - time time, # time of this message - host varchar(128), # host logging - message text, # message - seq int unsigned auto_increment primary key # optional sequence number - ); +CREATE TABLE `syslogTB` ( + `facility` varchar(10) default NULL, #OPTIONAL field for facility + `priority` varchar(10) default NULL, #OPTIONAL field for facility + `date` date default NULL, #date of this log message + `time` time default NULL, #time of this message + `host` varchar(128) default NULL, #host logging + `message` mediumtext, # message + `seq` int(10) unsigned NOT NULL auto_increment, #optional sequence number + PRIMARY KEY (`seq`), + KEY `host` (`host`), + KEY `time` (`time`), + KEY `date` (`date`), + KEY `message` (`message`(1)) +); + .Ed .Pp The field names should be respected. The type of fields .Va host and .Va msg -can be any text format smaller than 128 and 1024 chars respectively. +can be any text format smaller than 128 and 4096 chars respectively. .Pp The field seq may be needed for some .Xr audit 1 |
From: <al...@us...> - 2003-04-17 16:29:47
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv433/src Modified Files: syslogd.c Log Message: proper year detection by jkohen@ Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.243 retrieving revision 1.244 diff -u -d -r1.243 -r1.244 --- syslogd.c 16 Apr 2003 11:37:20 -0000 1.243 +++ syslogd.c 17 Apr 2003 16:29:42 -0000 1.244 @@ -825,38 +825,34 @@ localtime_r(&now, ×tamp); if (!(flags & ADDDATE)) { - int mon, year, mday; + char *p; + /* First, attempt to parse the date as if it contained + the year, which isn't part of the standard syslog + date format. */ - /* save our current year, month and day */ - year = timestamp.tm_year; - mon = timestamp.tm_mon; - mday = timestamp.tm_mday; + p = strptime(msg, "%b %d %H:%M:%S %Y", ×tamp); + if (!p) { + time_t tstamp; - /* now get message time (wich has no year!) */ - strptime(msg, "%b %d %H:%M:%S", ×tamp); + /* The year of the message is unknown at this point. + If the resulting date is in the future, assume + it actually is from last year. */ - /* - * Is message from december 31 of last year and it is now january 1 - * beware: tm_mon [0-11] - * tm_mday [1-31] - * tm_year is years since 1900 - * all this is really braindead/ugly IMNSHO - */ - if (timestamp.tm_mon == 11 && mon == 0 && - timestamp.tm_mday == 31 && mday == 1) - --year; /* our year is wrong */ + p = strptime(msg, "%b %d %H:%M:%S", ×tamp); + tstamp = mktime(×tamp); - /* - * XXX we are still not contemplating if the message has - * completely different dates than ours, and just giving them - * our current year - */ + if (difftime(tstamp, now) > 0) + timestamp.tm_year--; + } - timestamp.tm_year = year; + if (p) { /* If this fails we're probably in trouble. */ + p++; /* Point to the beginning of the message. */ - msg += 16; - msglen -= 16; + msglen -= (unsigned int) (p - msg); + msg = p; + } } + /* extract facility and priority level */ fac = (flags & MARK) ? LOG_NFACILITIES : LOG_FAC(pri); prilev = LOG_PRI(pri); |
From: <al...@us...> - 2003-04-17 15:37:34
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv3028 Modified Files: configure configure.in Log Message: autoconf stuff: cleanup, add snmp module, add oracle8i module from jkohen@ Index: configure =================================================================== RCS file: /cvsroot/msyslog/syslog/configure,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- configure 4 Apr 2003 18:37:21 -0000 1.94 +++ configure 17 Apr 2003 15:37:24 -0000 1.95 @@ -695,6 +695,9 @@ --without-tcp Use tcp input and output modules. Activated by default. + --without-oracle8i + Use Oracle8i output module. Activated by default. + --without-mysql Use mysql MySQL output module. Activated by default. @@ -713,6 +716,8 @@ --without-regex [...3213 lines suppressed...] { (exit 1); exit 1; }; } echo $f;; @@ -5758,7 +5881,7 @@ echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5761: error: cannot find input file: $f" >&5 + { { echo "$as_me:5884: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -5875,7 +5998,7 @@ rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:5878: $ac_file is unchanged" >&5 + { echo "$as_me:6001: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ Index: configure.in =================================================================== RCS file: /cvsroot/msyslog/syslog/configure.in,v retrieving revision 1.157 retrieving revision 1.158 diff -u -d -r1.157 -r1.158 --- configure.in 4 Apr 2003 18:37:27 -0000 1.157 +++ configure.in 17 Apr 2003 15:37:27 -0000 1.158 @@ -77,12 +77,6 @@ fi AC_DEFINE_UNQUOTED(INSTALL_LIBDIR, "$prefix/lib/alat") -AC_MSG_CHECKING(wheter optreset is needed) -AC_TRY_LINK([#include <unistd.h>], - [extern int optreset; optreset = 1;], - [AC_DEFINE(HAVE_OPTRESET) AC_MSG_RESULT(yes)], - AC_MSG_RESULT(no)) - AC_MSG_CHECKING(pidfile directory) for dir in "/var/run" "/etc" @@ -92,7 +86,7 @@ fi done AC_MSG_RESULT(root-mode pid file will go in $dir) -AC_DEFINE_UNQUOTED(PID_DIR, "$dir") +AC_DEFINE(PID_DIR, "$dir", [This is not an original description]) dnl search mandir for non bsd systems for MANDIR in "/usr/share/man" "/usr/man" @@ -107,7 +101,7 @@ AC_MSG_CHECKING(wether netdb.h requires _USE_IRS) if grep _USE_IRS /usr/include/netdb.h >/dev/null ;then - AC_DEFINE(_USE_IRS) + AC_DEFINE(_USE_IRS, 1, [This is not an original description]) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) @@ -115,7 +109,7 @@ AC_MSG_CHECKING(if sigaltstack uses stack_t structure) AC_EGREP_HEADER(stack_t, [signal.h],[ - AC_DEFINE(SIGALTSTACK_WITH_STACK_T) + AC_DEFINE(SIGALTSTACK_WITH_STACK_T, 1, [This is not an original description]) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) @@ -148,26 +142,26 @@ UNAME=`uname` if test "$UNAME" = "OpenBSD" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) - AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "_") + AC_DEFINE(SYMBOL_PREFIX, "_") SHARED_PARAMS="-Bshareable" DCCFLAGS="-fPIC" elif test "$UNAME" = "Linux" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY | RTLD_GLOBAL) - AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "") + AC_DEFINE(SYMBOL_PREFIX, "") MAIN_CPPFLAGS="-Xlinker -E"; SHARED_PARAMS="-Bshareable" DCCFLAGS="" AC_DEFINE(_GNU_SOURCE, 1) elif test "$UNAME" = "SunOS" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) - AC_DEFINE(_REENTRANT) - AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "") + AC_DEFINE(_REENTRANT, 1) + AC_DEFINE(SYMBOL_PREFIX, "") SHARED_PARAMS="-G" DCCFLAGS="-fPIC" elif test "$UNAME" = "IRIX" -o "$UNAME" = "IRIX64" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) - AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "") - AC_DEFINE(INET6) + AC_DEFINE(SYMBOL_PREFIX, "") + AC_DEFINE(INET6, 1) CFLAGS="-D_BSD_SIGNALS" if test "x$GCC" == "xyes" then @@ -181,8 +175,8 @@ SHARED_PARAMS="-shared -soname $MLIBNAME -all" elif test "$UNAME" = "AIX" ; then AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY | RTLD_GLOBAL) - AC_DEFINE(NEEDS_DLOPEN_NULL) - AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "") + AC_DEFINE(NEEDS_DLOPEN_NULL, 1) + AC_DEFINE(SYMBOL_PREFIX, "") DCCFLAGS="-shared" SHARED_PARAMS="-lc -bI:libmsyslog.imp -bexpall -bnoentry -brtl" cat > src/modules/libmsyslog.imp <<-EOF @@ -198,7 +192,7 @@ SYSLOGD_LIBS="$SYSLOGD_LIBS -Wl,-bexpall" else AC_MSG_WARN(cannot determine system type falling to defaults) - AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "") + AC_DEFINE(SYMBOL_PREFIX, "") AC_DEFINE(DLOPEN_FLAGS, RTLD_LAZY) SHARED_PARAMS="-Bshareable" fi @@ -229,7 +223,7 @@ if test "X$temp_res" = "Xyes" ; then MSRCS="$MSRCS im_bsd.c"; MANPAGES="$MANPAGES im_bsd.8"; - AC_DEFINE(HAVE_BSD_IMODULE) + AC_DEFINE(HAVE_BSD_IMODULE, 1) fi AC_ARG_WITH(linux, @@ -239,13 +233,13 @@ if test "$with_linux" = "yes" ; then MSRCS="$MSRCS im_linux.c" MANPAGES="$MANPAGES im_linux.8" - AC_DEFINE(HAVE_LINUX_IMODULE) + AC_DEFINE(HAVE_LINUX_IMODULE, 1) fi ],[ AC_CHECK_HEADER(sys/klog.h, [ MSRCS="$MSRCS im_linux.c" MANPAGES="$MANPAGES im_linux.8" - AC_DEFINE(HAVE_LINUX_IMODULE) + AC_DEFINE(HAVE_LINUX_IMODULE, 1) ]) ]) @@ -274,7 +268,7 @@ ]) if test "X$temp_res" = "Xyes" ; then MSRCS="$MSRCS im_unix.c" - AC_DEFINE(HAVE_UNIX_IMODULE) + AC_DEFINE(HAVE_UNIX_IMODULE, 1) MANPAGES="$MANPAGES im_unix.8" fi temp_res="yes"; @@ -285,7 +279,7 @@ ],[ temp_res="$with_file"; ]) if test "X$temp_res" = "Xyes" ; then MSRCS="$MSRCS im_file.c" - AC_DEFINE(HAVE_FILE_IMODULE) + AC_DEFINE(HAVE_FILE_IMODULE, 1) MANPAGES="$MANPAGES im_file.8" fi @@ -295,7 +289,7 @@ ],[ temp_res="$with_serial"; ]) if test "X$temp_res" = "Xyes" ; then MSRCS="$MSRCS im_serial.c" - AC_DEFINE(HAVE_FILE_IMODULE) + AC_DEFINE(HAVE_FILE_IMODULE, 1) MANPAGES="$MANPAGES im_serial.8" fi @@ -308,13 +302,13 @@ # if test "$with_doors" = "yes" ; then # MSRCS="$MSRCS im_doors.c" # MANPAGES="$MANPAGES im_doors.8" -# AC_DEFINE(HAVE_LINUX_IMODULE) +# AC_DEFINE(HAVE_LINUX_IMODULE, 1) # fi # ],[ # AC_CHECK_HEADER(sys/klog.h, [ # MSRCS="$MSRCS im_doors.c" # MANPAGES="$MANPAGES im_doors.8" -# AC_DEFINE(HAVE_LINUX_IMODULE) +# AC_DEFINE(HAVE_LINUX_IMODULE, 1) # ]) # ]) @@ -340,7 +334,7 @@ MLIBS="$MLIBS -lpthread" MANPAGES="$MANPAGES im_streams.8" SYSLOGD_LIBS="$SYSLOGD_LIBS -lthread -ldoor" - AC_DEFINE(HAVE_STREAMS_IMODULE) + AC_DEFINE(HAVE_STREAMS_IMODULE, 1) fi AC_MSG_CHECKING(for streams module) AC_MSG_RESULT($temp_res) @@ -375,9 +369,23 @@ if test "$temp_res" = "yes" ; then AC_EGREP_HEADER(sa_len, [#include <sys/socket.h> ], - AC_DEFINE(HAVE_SOCKADDR_SA_LEN)) + AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1)) fi +AC_ARG_WITH(oracle, +[ --without-oracle8i + Use Oracle8i output module. Activated by default. +],[ + if test $with_oracle8i = "yes" ; then + MSRCS="$MSRCS om_oracle8i.c" + MANPAGES="$MANPAGES om_oracle8i.8" + fi +],[ + MSRCS="$MSRCS om_oracle8i.c" + MANPAGES="$MANPAGES om_oracle8i.8" + USESQL="yes" +]) + AC_ARG_WITH(mysql, [ --without-mysql Use mysql MySQL output module. Activated by default. @@ -460,23 +468,23 @@ HASH_SRCS="../peo/hash.c"; HASH_SRCS_MODULES="../peo/hash.c"; HASH_OBJS_MODULES="../peo/hash.o"; - AC_CHECK_FUNC(MD5Init, AC_DEFINE(HAVE_MD5), + AC_CHECK_FUNC(MD5Init, AC_DEFINE(HAVE_MD5, 1), HASH_SRCS="$HASH_SRCS ../peo/md5c.c"; HASH_SRCS_MODULES="$HASH_SRCS_MODULES ../peo/md5c.c"; HASH_OBJS_MODULES="$HASH_OBJS_MODULES ../peo/md5c.o"; ) - AC_CHECK_FUNC(SHA1Init, AC_DEFINE(HAVE_SHA1), + AC_CHECK_FUNC(SHA1Init, AC_DEFINE(HAVE_SHA1, 1), HASH_SRCS="$HASH_SRCS ../peo/sha1.c"; HASH_SRCS_MODULES="$HASH_SRCS_MODULES ../peo/sha1.c"; HASH_OBJS_MODULES="$HASH_OBJS_MODULES ../peo/sha1.o"; ) - AC_CHECK_FUNC(RMD160Init, AC_DEFINE(HAVE_RMD160), + AC_CHECK_FUNC(RMD160Init, AC_DEFINE(HAVE_RMD160, 1), HASH_SRCS="$HASH_SRCS ../peo/rmd160.c"; HASH_SRCS_MODULES="$HASH_SRCS_MODULES ../peo/rmd160.c"; HASH_OBJS_MODULES="$HASH_OBJS_MODULES ../peo/rmd160.o"; ) if test -r /dev/srandom ; then - AC_DEFINE(HAVE_SRANDOM) + AC_DEFINE(HAVE_SRANDOM, 1) fi fi @@ -495,6 +503,26 @@ ]) ]) +AC_ARG_WITH([snmp], + AC_HELP_STRING([--with-snmp], [use SNMP (default is YES, if available)]), + [ac_cv_use_snmp=$withval], [ac_cv_use_snmp=yes]) +AC_CACHE_CHECK([whether to use SNMP], [ac_cv_use_snmp], [ac_cv_use_snmp=yes]) + +if test "$ac_cv_use_snmp" == yes; then + # Let's assume libcrypto is available, for now. + libs_save="$LIBS" + AC_CHECK_LIB(snmp, snmp_sess_init, [], [], [-lcrypto]) + LIBS="$libs_save" + AC_CHECK_HEADERS([net-snmp/net-snmp-config.h ucd-snmp/ucd-snmp-config.h]) +fi + +if test "$ac_cv_lib_snmp_snmp_sess_init" == yes \ + -a \( "$ac_cv_header_net_snmp_net_snmp_config_h" == yes \ + -o "$ac_cv_header_ucd_snmp_ucd_snmp_config_h" == yes \); then + EXTRA_MODULES="$extra_modules om_snmptrap" +fi + + AC_CACHE_SAVE AC_CHECK_TYPES(socklen_t,,,[#include <stdio.h> @@ -527,6 +555,7 @@ AC_SUBST(MAIN_CPPFLAGS) AC_SUBST(MSYSLOG_DAEMON_NAME) AC_SUBST(MSYSLOG_VERSION) +AC_SUBST(EXTRA_MODULES) dnl AC_SUBST(SYMBOL_PREFIX) |
From: <al...@us...> - 2003-04-16 12:06:24
|
Update of /cvsroot/msyslog/syslog/packaging/OpenBSD/pkg In directory sc8-pr-cvs1:/tmp/cvs-serv32297/packaging/OpenBSD/pkg Modified Files: Tag: v1_08g PLIST Log Message: 1.08g now Index: PLIST =================================================================== RCS file: /cvsroot/msyslog/syslog/packaging/OpenBSD/pkg/Attic/PLIST,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.1.4.1 diff -u -d -r1.1.2.1 -r1.1.2.1.4.1 --- PLIST 11 Apr 2003 16:42:49 -0000 1.1.2.1 +++ PLIST 16 Apr 2003 12:06:21 -0000 1.1.2.1.4.1 @@ -1,5 +1,5 @@ @comment $CoreSDI: PLIST.in,v 1.1 2002/02/06 20:17:14 claudio Exp $ -lib/alat/libmsyslog.so.1.08e +lib/alat/libmsyslog.so.1.08g man/cat5/syslog.conf.cat5 man/cat8/im_bsd.cat8 man/cat8/im_file.cat8 |
From: <al...@us...> - 2003-04-16 12:05:49
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv31338/src/modules Modified Files: Tag: v1_08g im_tcp.c Log Message: from 1.08 and current: fix bug removing last connection (yes, commiting to release id tags is ugly, it shouldn't be done this way) Index: im_tcp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_tcp.c,v retrieving revision 1.31.2.2 retrieving revision 1.31.2.2.2.1 diff -u -d -r1.31.2.2 -r1.31.2.2.2.1 --- im_tcp.c 11 Apr 2003 18:55:20 -0000 1.31.2.2 +++ im_tcp.c 16 Apr 2003 12:05:44 -0000 1.31.2.2.2.1 @@ -89,7 +89,6 @@ struct im_tcp_ctx { socklen_t addrlen; struct tcp_conn *first; - struct tcp_conn *last; int flags; }; @@ -222,12 +221,8 @@ } /* add to queue */ - if (c->last == NULL) { - c->first = con; - } else { - c->last->next = con; - } - c->last = con; + con->next = c->first; + c->first = con; dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: new conection from" @@ -257,7 +252,7 @@ n = read(con->fd, im->im_buf, sizeof(im->im_buf) - 1); if (n == 0) { - struct tcp_conn *prev; + struct tcp_conn **prev; dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: conetion from %s" " closed\n", con->name); @@ -267,14 +262,14 @@ /* connection closed, remove its tcp_con struct */ close (con->fd); - if (con == c->first) { - c->first = con->next; - if (con == c->last) - c->last = NULL; - } else { - for(prev = c->first; prev->next != con; - prev = prev->next); - prev->next = con->next; + /* remove node */ + for (prev = &c->first; *prev != NULL ; prev = &(*prev)->next) { + + if (*prev == con) { + + *prev = con->next; + break; + } } if (con->saveline[0] != '\0') |
From: <al...@us...> - 2003-04-16 12:01:27
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv29934a/src/modules Modified Files: Tag: v1_08 im_tcp.c Log Message: fix error removing last open connection Index: im_tcp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_tcp.c,v retrieving revision 1.31.2.2 retrieving revision 1.31.2.3 diff -u -d -r1.31.2.2 -r1.31.2.3 --- im_tcp.c 11 Apr 2003 18:55:20 -0000 1.31.2.2 +++ im_tcp.c 16 Apr 2003 12:01:22 -0000 1.31.2.3 @@ -89,7 +89,6 @@ struct im_tcp_ctx { socklen_t addrlen; struct tcp_conn *first; - struct tcp_conn *last; int flags; }; @@ -222,12 +221,8 @@ } /* add to queue */ - if (c->last == NULL) { - c->first = con; - } else { - c->last->next = con; - } - c->last = con; + con->next = c->first; + c->first = con; dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: new conection from" @@ -257,7 +252,7 @@ n = read(con->fd, im->im_buf, sizeof(im->im_buf) - 1); if (n == 0) { - struct tcp_conn *prev; + struct tcp_conn **prev; dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: conetion from %s" " closed\n", con->name); @@ -267,14 +262,14 @@ /* connection closed, remove its tcp_con struct */ close (con->fd); - if (con == c->first) { - c->first = con->next; - if (con == c->last) - c->last = NULL; - } else { - for(prev = c->first; prev->next != con; - prev = prev->next); - prev->next = con->next; + /* remove node */ + for (prev = &c->first; *prev != NULL ; prev = &(*prev)->next) { + + if (*prev == con) { + + *prev = con->next; + break; + } } if (con->saveline[0] != '\0') |
From: <al...@us...> - 2003-04-16 11:59:53
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv29338/src/modules Modified Files: Tag: v1_08 im_bsd.c Log Message: fix strncat missing termination Index: im_bsd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_bsd.c,v retrieving revision 1.82.2.4 retrieving revision 1.82.2.5 diff -u -d -r1.82.2.4 -r1.82.2.5 --- im_bsd.c 11 Apr 2003 18:55:20 -0000 1.82.2.4 +++ im_bsd.c 16 Apr 2003 11:59:48 -0000 1.82.2.5 @@ -94,8 +94,10 @@ int i, c; strncpy(ret->im_msg, _PATH_UNIX, sizeof(ret->im_msg) - 1); - strncat(ret->im_msg, ": ", sizeof (ret->im_msg) -1 - - strlen(ret->im_msg); + ret->im_msg[sizeof (ret->im_msg) - 1] = '\0'; + + strncat(ret->im_msg, ": ", sizeof (ret->im_msg) - 1 + - strlen(ret->im_msg)); lp = ret->im_msg + strlen(ret->im_msg); |
From: <al...@us...> - 2003-04-16 11:37:55
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv18954/src Modified Files: modules.c syslogd.c syslogd.h Log Message: use new macros for free() and close() to avoid common mistakes handling file descriptors and pointers Index: modules.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules.c,v retrieving revision 1.171 retrieving revision 1.172 diff -u -d -r1.171 -r1.172 --- modules.c 15 Apr 2003 17:16:40 -0000 1.171 +++ modules.c 16 Apr 2003 11:37:20 -0000 1.172 @@ -250,7 +250,7 @@ if (im_prev == I && im_prev->im_next == NULL) { im_prev->im_fd = -1; } else if (im_prev->im_next == im) { - free (im); + FREE_PTR(im); im_prev->im_next = NULL; } } @@ -259,8 +259,8 @@ if (argv != NULL) { char *f; - for (i = 0; (f = argv[i]) != NULL ; i++) free(f); - free(argv); + for (i = 0; (f = argv[i]) != NULL ; i++) FREE_PTR(f); + FREE_PTR(argv); } return (ret); @@ -403,7 +403,7 @@ m_dprintf(MSYSLOG_INFORMATIVE, "omodule_create: all done for output " "module %s\n", argv[0]); - free(line); + FREE_PTR(line); return (1); @@ -411,7 +411,7 @@ m_dprintf(MSYSLOG_SERIOUS, "%s", err_buf); - if (line) free(line); + FREE_PTR(line); /* free allocated module */ if (f->f_omod == om) { @@ -421,7 +421,7 @@ om_prev->om_next = NULL; } - if (om) free(om); + FREE_PTR(om); return (-1); } @@ -480,14 +480,14 @@ if ((argc % OMODULE_ARGV_MAX) == 18) if ( (*ret = (char **)realloc(*ret, sizeof(char *) * (argc + 20))) == NULL) { - free(line); + FREE_PTR(line); return (-1); } if (*ret != NULL) (*ret)[argc] = NULL; } - free(line); + FREE_PTR(line); return (argc); } @@ -529,7 +529,7 @@ i->im_next = NULL; } - free(im); + FREE_PTR(im); m_dprintf(MSYSLOG_SERIOUS, "addImodule: couldn't config %s input module\n", buf); @@ -592,7 +592,7 @@ o->om_next = NULL; } - free(om); + FREE_PTR(om); return (NULL); } @@ -620,7 +620,7 @@ return (-1); } - free(om->om_name); + FREE_PTR(om->om_name); return (1); } @@ -684,7 +684,7 @@ dlclose(im->h); - free(im); + FREE_PTR(im); } if (last) { @@ -719,7 +719,7 @@ last->om_next = om->om_next; dlclose(om->h); - free(om); + FREE_PTR(om); } if (last != NULL) { Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.242 retrieving revision 1.243 diff -u -d -r1.242 -r1.243 --- syslogd.c 16 Apr 2003 11:35:30 -0000 1.242 +++ syslogd.c 16 Apr 2003 11:37:20 -0000 1.243 @@ -440,7 +440,7 @@ dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); if (fd > 2) - close(fd); + CLOSE_FD(fd); } } gethostname(LocalHostName, sizeof(LocalHostName)); @@ -482,7 +482,7 @@ sa.sa_flags = SA_NOCLDSTOP | SA_RESTART | SA_ONSTACK; if (sigaltstack(&alt_stack, NULL) < 0 || sigaction(SIGTSTP, &sa, NULL) < 0) { - free(alt_stack.ss_sp); + FREE_PTR(alt_stack.ss_sp); perror(strerror(errno)); exit(-1); } @@ -885,12 +885,9 @@ (*consfile.f_omod->om_func->om_close) (&consfile, consfile.f_omod->ctx); if (consfile.f_omod) { - if (consfile.f_omod->ctx) - free(consfile.f_omod->ctx); - if (consfile.f_omod->status) - free(consfile.f_omod->status); - free(consfile.f_omod); - consfile.f_omod = NULL; + FREE_PTR(consfile.f_omod->ctx); + FREE_PTR(consfile.f_omod->status); + FREE_PTR(consfile.f_omod); } } sigprocmask(SIG_SETMASK, &omask, NULL); @@ -1145,8 +1142,8 @@ for (im = &Inputs; im; im = im->im_next) if (im->im_func && im->im_func->im_close) (*im->im_func->im_close) (im); - else if (im->im_fd) - close(im->im_fd); + else + CLOSE_FD(im->im_fd); if (!Debug && (DaemonFlags == SYSLOGD_LOCKED_PIDFILE)) { struct flock fl; @@ -1215,19 +1212,16 @@ /* free om_ctx om_func and stuff */ om_next = om->om_next; - if (om->ctx) - free(om->ctx); - if (om->status) - free(om->status); - free(om); + FREE_PTR(om->ctx); + FREE_PTR(om->status); + FREE_PTR(om); } next = f->f_next; - if (f->f_program) - free(f->f_program); + FREE_PTR(f->f_program); - free(f); + FREE_PTR(f); } #ifdef REOPEN_MAIN_LIBRARY_ON_HUP @@ -1354,10 +1348,8 @@ if (cfline(cline, f, prog) == 1) { *nextp = f; nextp = &f->f_next; - } else { - free(f); - f = NULL; - } + } else + FREE_PTR(f); } /* close the configuration file */ Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.114 retrieving revision 1.115 diff -u -d -r1.114 -r1.115 --- syslogd.h 15 Apr 2003 17:17:09 -0000 1.114 +++ syslogd.h 16 Apr 2003 11:37:21 -0000 1.115 @@ -293,7 +293,10 @@ # endif /* SYSLOG_NAMES */ #endif /* typedef of /usr/include/syslog.h */ - - + +#define CLOSE_FD(cfd) { if (cfd != -1) { close(cfd); cfd = -1; } } +#define FREE_PTR(p) { if (p != NULL) { free(p); p = NULL; } } + + #endif /* HAVE_CODE */ |
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv18954/src/modules Modified Files: im_bsd.c im_file.c im_linux.c im_serial.c im_streams.c im_tcp.c im_udp.c im_unix.c ip_misc.c om_classic.c om_directory.c om_mysql.c om_peo.c om_pgsql.c om_refract.c om_regex.c om_snmptrap.c om_tcp.c om_udp.c ttymsg.c Log Message: use new macros for free() and close() to avoid common mistakes handling file descriptors and pointers Index: im_bsd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_bsd.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- im_bsd.c 4 Apr 2003 18:25:55 -0000 1.88 +++ im_bsd.c 16 Apr 2003 11:37:21 -0000 1.89 @@ -137,8 +137,8 @@ int im_bsd_close (struct i_module *im) { - if (im->im_fd >= 0) - close(im->im_fd); + + CLOSE_FD(im->im_fd); return (0); } Index: im_file.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_file.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- im_file.c 4 Apr 2003 20:06:51 -0000 1.10 +++ im_file.c 16 Apr 2003 11:37:22 -0000 1.11 @@ -396,8 +396,8 @@ if (c->name != NULL) free(c->name); if (c->path != NULL) free(c->path); - if (I->im_ctx != NULL) free(I->im_ctx); - if (I->im_fd >= 0) close(I->im_fd); + FREE_PTR(I->im_ctx); + CLOSE_FD(I->im_fd); return (0); } Index: im_linux.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_linux.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- im_linux.c 17 Sep 2002 05:20:27 -0000 1.57 +++ im_linux.c 16 Apr 2003 11:37:22 -0000 1.58 @@ -377,7 +377,10 @@ im_linux_close (struct i_module *im) { ksym_close(); -return (close(im->im_fd)); + + CLOSE_FD(im->im_fd); + + return(0); } Index: im_serial.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_serial.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- im_serial.c 22 Feb 2003 03:40:58 -0000 1.4 +++ im_serial.c 16 Apr 2003 11:37:23 -0000 1.5 @@ -357,8 +357,8 @@ if (c->name != NULL) free(c->name); if (c->path != NULL) free(c->path); - if (im->im_ctx != NULL) free(im->im_ctx); - if (im->im_fd >= 0) close(im->im_fd); + FREE_PTR(im->im_ctx); + CLOSE_FD(im->im_fd); return (0); } Index: im_streams.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_streams.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- im_streams.c 17 Sep 2002 05:20:27 -0000 1.21 +++ im_streams.c 16 Apr 2003 11:37:23 -0000 1.22 @@ -105,8 +105,11 @@ ioctbuf.ic_cmd = I_CONSLOG; /* why I_CONSLOG? */ if (ioctl (I->im_fd, I_STR, &ioctbuf) == -1) { + m_dprintf(MSYSLOG_SERIOUS, "ioctl(%s): %s\n", c->path, strerror (errno)); - close (I->im_fd); + + CLOSE_FD(I->im_fd); + return (-1); } watch_fd_input('p', I->im_fd , I); @@ -208,14 +211,14 @@ int im_streams_close (struct i_module *im) { - struct im_streams_ctx *c = (im_streams_ctx *) im->ctx; + struct im_streams_ctx *c = (im_streams_ctx *) im->ctx; - if (c->path != NULL) free(c->path); - if (im->ctx != NULL) free(im->ctx); + FREE_PTR(c->path); + FREE_PTR(im->ctx); - close (im->im_fd); + CLOSE_FD(im->im_fd); -return(1); + return(0); } Index: im_tcp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_tcp.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- im_tcp.c 16 Apr 2003 10:29:05 -0000 1.46 +++ im_tcp.c 16 Apr 2003 11:37:23 -0000 1.47 @@ -155,7 +155,7 @@ break; default: m_dprintf(MSYSLOG_SERIOUS, "im_tcp_init: parsing error [%c]\n", ch); - free(c); + FREE_PTR(c); return (-1); } } @@ -165,7 +165,7 @@ m_dprintf(MSYSLOG_SERIOUS, "im_tcp_init: error with listen_tcp(%s,%s,%d) %s\n", host, port, c->addrlen, strerror(errno)); - free(c); + FREE_PTR(c); return (-1); } @@ -219,7 +219,7 @@ if ((con->fd = accept_tcp(infd, c->addrlen, con->name, sizeof(con->name), con->port, sizeof(con->port))) < 0) { m_dprintf(MSYSLOG_SERIOUS, "im_tcp_read: couldn't accept\n"); - free (con); + FREE_PTR(con); return (-1); } @@ -263,7 +263,7 @@ unwatch_fd_input('p', con->fd); /* connection closed, remove its tcp_con struct */ - close (con->fd); + CLOSE_FD(con->fd); /* remove node */ for (prev = &c->first; *prev != NULL ; prev = &(*prev)->next) { @@ -279,7 +279,7 @@ if (con->saveline[0] != '\0') printline(ret->im_host, con->saveline, strlen(con->saveline), 0); - free(con); + FREE_PTR(con); return (0); } @@ -447,14 +447,15 @@ /* close all connections */ for (con = c->first; con; con = cnext) { - if (con->fd > -1) - close(con->fd); + CLOSE_FD(con->fd); cnext = con->next; - free(con); + FREE_PTR(con); } im->im_ctx = NULL; /* close listening socket */ -return (close(im->im_fd)); + CLOSE_FD(im->im_fd); + + return (0); } Index: im_udp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_udp.c,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- im_udp.c 4 Apr 2003 17:22:24 -0000 1.82 +++ im_udp.c 16 Apr 2003 11:37:23 -0000 1.83 @@ -141,7 +141,7 @@ default: m_dprintf(MSYSLOG_SERIOUS, "im_udp_init: parsing error" " [%c]\n", ch); - free(c); + FREE_PTR(c); return (-1); } } @@ -150,7 +150,7 @@ m_dprintf(MSYSLOG_SERIOUS, "im_udp_init: error creating " "input socket for host [%s] and port [%s]", host, port); - free(c); + FREE_PTR(c); return (-1); } @@ -244,7 +244,7 @@ im_udp_close(struct i_module *im) { - close(im->im_fd); + CLOSE_FD(im->im_fd); return (0); } Index: im_unix.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_unix.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- im_unix.c 4 Apr 2003 20:09:11 -0000 1.57 +++ im_unix.c 16 Apr 2003 11:37:23 -0000 1.58 @@ -152,8 +152,9 @@ int im_unix_close( struct i_module *im) { - close(im->im_fd); -return (0); + + CLOSE_FD(im->im_fd); + return (0); } Index: ip_misc.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/ip_misc.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- ip_misc.c 7 Jan 2003 21:56:07 -0000 1.27 +++ ip_misc.c 16 Apr 2003 11:37:23 -0000 1.28 @@ -364,8 +364,8 @@ if ( (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &n, sizeof(n)) != 0) || (connect(fd, sa, salen) != 0) ) { - close(fd); /* couldn't set option or connect */ - fd = -1; + + CLOSE_FD(fd); /* couldn't set option or connect */ } free(sa); @@ -396,11 +396,11 @@ SO_REUSEADDR, &r, sizeof(r)) != 0) || (bind(fd, sa, *addrlenp) != 0) || (listen(fd, LISTENQ) != 0) ) { - close(fd); /* couldn't set option or connect */ - fd = -1; + + CLOSE_FD(fd); /* couldn't set option or connect */ } - free(sa); + FREE_PTR(sa); return (fd); } @@ -426,7 +426,7 @@ if ((connfd = accept(fd, connsa, (socklen_t *) &addrlen)) != -1) (void) resolv_addr(connsa, addrlen, host, hlen, port, plen); - free(connsa); + FREE_PTR(connsa); return (connfd); } @@ -461,7 +461,7 @@ if (addrlen != NULL) *addrlen = salen; if (addr != NULL) *addr = sa; - else free(sa); /* sa FREED HERE */ + else FREE_PTR(sa); /* sa FREED HERE */ return socket_fd; } @@ -502,7 +502,7 @@ if ((rlen = recvfrom(fd, msg, mlen - 1, 0, sa, &salen)) < 1) { - free(sa); + FREE_PTR(sa); return (-1); } @@ -513,7 +513,7 @@ else resolv_addr(sa, salen, host, hlen, port, plen); - free(sa); + FREE_PTR(sa); return (rlen); } Index: om_classic.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_classic.c,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- om_classic.c 4 Apr 2003 20:12:37 -0000 1.93 +++ om_classic.c 16 Apr 2003 11:37:23 -0000 1.94 @@ -227,7 +227,7 @@ if (c->f_type == F_PIPE && e == EAGAIN) break; - close(c->fd); + CLOSE_FD(c->fd); /* * Check for errors on TTY's due to loss of tty @@ -310,21 +310,26 @@ if (argc > 2) { if (strncmp(argv[1], "-t", 2)) { + m_dprintf(MSYSLOG_SERIOUS, "om_classic_init: incorrect" " parameter %s, should be '-t'\n", argv[1]); - free(*ctx); - *ctx = NULL; + + FREE_PTR(*ctx); + return (-1); } /* look for entry # in table */ for (i = 0; TypeNames[i] && strncmp(TypeNames[i], argv[2], strlen(argv[2])); i++); + if (TypeNames[i] == NULL) { + m_dprintf(MSYSLOG_SERIOUS, "om_classic_init: couldn't" " determine type %s\n", argv[2]); - free(*ctx); - *ctx = NULL; + + FREE_PTR(*ctx); + return (-1); } @@ -352,7 +357,9 @@ } memmove(&c->f_un.f_forw.f_addr, sa, salen); - free(sa); + + FREE_PTR(sa); + c->f_type = F_FORW; snprintf(statbuf, sizeof(statbuf), "om_classic: " "forwarding messages through UDP to host %s", @@ -385,10 +392,12 @@ } if (c->fd < 0 && ! global->flist_des) { + m_dprintf(MSYSLOG_CRITICAL, "om_classic_init: error " "opening log file: %s\n", p); - free(*ctx); - *ctx = NULL; + + FREE_PTR(*ctx); + return (-1); } @@ -448,8 +457,7 @@ c = (struct om_classic_ctx *) ctx; - if (c->fd > -1) - close(c->fd); + CLOSE_FD(c->fd); return (0); } Index: om_directory.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_directory.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- om_directory.c 26 Sep 2002 18:32:26 -0000 1.5 +++ om_directory.c 16 Apr 2003 11:37:23 -0000 1.6 @@ -149,7 +149,7 @@ /* write to the file */ write(filedes, msg->msg, strlen(msg->msg) > MAXMSG? MAXMSG : strlen(msg->msg)); - close( filedes ); + CLOSE_FD( filedes ); /* unlock the file by changing its permission to allow reading */ chmod( filename, S_IRUSR|S_IRGRP ); Index: om_mysql.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_mysql.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- om_mysql.c 4 Apr 2003 19:16:48 -0000 1.85 +++ om_mysql.c 16 Apr 2003 11:37:23 -0000 1.86 @@ -265,9 +265,12 @@ ctx = (struct om_mysql_ctx *) *c; if ((ctx->lib = dlopen("libmysqlclient.so", DLOPEN_FLAGS)) == NULL) { + m_dprintf(MSYSLOG_SERIOUS, "om_mysql_init: Error loading" " api library, %s\n", dlerror()); - free(ctx); + + FREE_PTR(ctx); + return (-1); } @@ -281,9 +284,12 @@ SYMBOL_PREFIX "mysql_query")) || !(ctx->mysql_close = (void (*)(void *)) dlsym(ctx->lib, SYMBOL_PREFIX "mysql_close")) ) { + m_dprintf(MSYSLOG_SERIOUS, "om_mysql_init: Error resolving" " api symbols, %s\n", dlerror()); - free(ctx); + + FREE_PTR(ctx); + return (-1); } @@ -374,9 +380,10 @@ om_mysql_init_bad: if (ctx) { + om_mysql_close(f, ctx); - free(ctx); - *c = NULL; + + FREE_PTR(ctx); } *status = NULL; @@ -394,16 +401,11 @@ (c->mysql_close)(c->h); - if (c->table) - free(c->table); - if (c->host) - free(c->host); - if (c->user) - free(c->user); - if (c->passwd) - free(c->passwd); - if (c->db) - free(c->db); + FREE_PTR(c->table); + FREE_PTR(c->host); + FREE_PTR(c->user); + FREE_PTR(c->passwd); + FREE_PTR(c->db); if (c->lib) dlclose(c->lib); Index: om_peo.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_peo.c,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- om_peo.c 17 Sep 2002 05:20:28 -0000 1.77 +++ om_peo.c 16 Apr 2003 11:37:23 -0000 1.78 @@ -113,7 +113,7 @@ } bzero(key, sizeof(key)); if ( (keylen = read(fd, key, 40)) < 0) { - close(fd); + CLOSE_FD(fd); m_dprintf(MSYSLOG_SERIOUS, "om_peo_write: reading form: %s:" " %s\n", c->keyfile, strerror(errno)); return (-1); @@ -122,7 +122,7 @@ /* Open macfile and write mac'ed msg */ if (c->macfile) { if ( (mfd = open(c->macfile, O_WRONLY, 0)) < 0) { - close(fd); + CLOSE_FD(fd); m_dprintf(MSYSLOG_SERIOUS, "om_peo_write: opening " "macfile: %s: %s\n", c->macfile, strerror(errno)); @@ -132,7 +132,7 @@ write(mfd, mkey, mac2(key, keylen, m, len, mkey)); m_dprintf(MSYSLOG_INFORMATIVE, "om_peo_write: write to macfile" " ok\n"); - close(mfd); + CLOSE_FD(mfd); } /* Generate new key and save it on keyfile */ @@ -140,14 +140,14 @@ ftruncate(fd, (off_t)0); newkeylen = mac(c->hash_method, key, keylen, m, len, newkey); if (newkeylen == -1) { - close(fd); + CLOSE_FD(fd); m_dprintf(MSYSLOG_INFORMATIVE, "om_peo_write: generating " "key[i+1]: keylen = %i: %s\n", newkeylen, strerror(errno)); return (-1); } write(fd, newkey, newkeylen); - close(fd); + CLOSE_FD(fd); return (1); } @@ -169,9 +169,8 @@ release(void) { if (keyfile != default_keyfile) - free(keyfile); - if (macfile != NULL) - free(macfile); + FREE_PTR(keyfile); + FREE_PTR(macfile); } int @@ -247,7 +246,7 @@ return (-1); } } else - close(mfd); + CLOSE_FD(mfd); } /* save data on context */ @@ -281,9 +280,8 @@ m_dprintf(MSYSLOG_INFORMATIVE, "om_peo_close\n"); if (c->keyfile != default_keyfile) - free(c->keyfile); - if (c->macfile != NULL) - free(c->macfile); + FREE_PTR(c->keyfile); + FREE_PTR(c->macfile); return (0); } Index: om_pgsql.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_pgsql.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- om_pgsql.c 17 Sep 2002 05:20:28 -0000 1.53 +++ om_pgsql.c 16 Apr 2003 11:37:24 -0000 1.54 @@ -163,7 +163,7 @@ if ((ctx->lib = dlopen("libpq.so", DLOPEN_FLAGS)) == NULL) { m_dprintf(MSYSLOG_SERIOUS, "om_pgsql_init: Error loading" " api library, %s\n", dlerror()); - free(ctx); + FREE_PTR(ctx); return (-1); } @@ -189,7 +189,7 @@ SYMBOL_PREFIX "PQfinish"))) { m_dprintf(MSYSLOG_SERIOUS, "om_pgsql_init: Error resolving" " api symbols, %s\n", dlerror()); - free(ctx); + FREE_PTR(ctx); return (-1); } @@ -244,7 +244,7 @@ m_dprintf(MSYSLOG_SERIOUS, "om_pgsql_init: Error missing " "params!\n"); dlclose(ctx->lib); - free(ctx); + FREE_PTR(ctx); return (-1); } @@ -260,7 +260,7 @@ ctx->PQerrorMessage(h)); (ctx->PQfinish)(h); dlclose(ctx->lib); - free(ctx); + FREE_PTR(ctx); return (-1); } @@ -426,8 +426,7 @@ (c->PQfinish)(((struct om_pgsql_ctx *)ctx)->h); } - if (c->table) - free(c->table); + FREE_PTR(c->table); return (0); } Index: om_refract.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_refract.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- om_refract.c 7 Jan 2003 21:56:08 -0000 1.7 +++ om_refract.c 16 Apr 2003 11:37:24 -0000 1.8 @@ -120,7 +120,7 @@ "bad argument to -p option [%s], should be numeric refraction period", argv[argcnt]); m_dprintf(MSYSLOG_SERIOUS, "%s\n", statbuf); *status = strdup(statbuf); - free(*context); + FREE_PTR(*context); return(-1); } @@ -134,7 +134,7 @@ "bad argument to -r option [%s], should be numeric, rules fired count", argv[argcnt]); m_dprintf(MSYSLOG_SERIOUS, "%s\n", statbuf); *status = strdup(statbuf); - free(*context); + FREE_PTR(*context); return(-1); } ctx->filter_bitstring |= OM_FILTER_RULES; @@ -147,7 +147,7 @@ "bad argument to -c option [%s], should be numeric firing count", argv[argcnt]); m_dprintf(MSYSLOG_SERIOUS, "%s\n", statbuf); *status = strdup(statbuf); - free(*context); + FREE_PTR(*context); return(-1); } break; @@ -156,7 +156,7 @@ snprintf(statbuf, sizeof(statbuf), "om_refract_init: bad option [%c]", ch); m_dprintf(MSYSLOG_SERIOUS, "%s\n", statbuf); *status = strdup(statbuf); - free(*context); + FREE_PTR(*context); return (-1); } } Index: om_regex.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_regex.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- om_regex.c 4 Apr 2003 20:14:50 -0000 1.51 +++ om_regex.c 16 Apr 2003 11:37:24 -0000 1.52 @@ -523,9 +523,9 @@ if (c->msg_no_subst) { int ix; char *string = *(c->msg_non_subst); - for(ix = c->msg_no_subst ; ix >= 0 ; --ix) - free(string++); - free(c->msg_non_subst); + for(ix = c->msg_no_subst ; ix >= 0 ; --ix, string++) + FREE_PTR(string); + FREE_PTR(c->msg_non_subst); } if (c->msg_subexp_no) free(c->msg_subexp_no); Index: om_snmptrap.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_snmptrap.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- om_snmptrap.c 15 Apr 2003 17:32:42 -0000 1.1 +++ om_snmptrap.c 16 Apr 2003 11:37:24 -0000 1.2 @@ -145,7 +145,7 @@ if (c == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_init: " "Can't create context: %s.\n", strerror(errno)); - free(buf); + FREE_PTR(buf); return (-1); } @@ -254,12 +254,12 @@ *ctx = (void *)c; *status = strdup(statbuf); - free(buf); + FREE_PTR(buf); return (1); fail: - free(c); - free(buf); + FREE_PTR(c); + FREE_PTR(buf); return (-1); } Index: om_tcp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_tcp.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- om_tcp.c 17 Sep 2002 05:20:28 -0000 1.28 +++ om_tcp.c 16 Apr 2003 11:37:24 -0000 1.29 @@ -149,11 +149,11 @@ default: m_dprintf(MSYSLOG_SERIOUS, "om_tcp_init: parsing error" " [%c]\n", ch); - if (c->host) - free(c->host); - if (c->port) - free(c->port); - free(*ctx); + + FREE_PTR(c->host); + FREE_PTR(c->port); + FREE_PTR(*ctx); + return (-1); } argcnt++; @@ -265,8 +265,8 @@ c->port, c->inc - 1); /* just in case */ - if (c->fd > -1); - close(c->fd); + CLOSE_FD(c->fd); + if ( ((c->fd = connect_tcp(c->host, c->port)) < 0) || (c->savelen && (write(c->fd, c->saved, c->savelen) != c->savelen)) || (write(c->fd, line, l) != l) ) { @@ -277,9 +277,8 @@ "in %i seconds\n", c->msec - (c->msec / c->inc)); c->savet = t; - if (c->fd) - close(c->fd); - c->fd = -1; + + CLOSE_FD(c->fd); place_signal(SIGPIPE, sigsave); @@ -325,15 +324,12 @@ struct om_tcp_ctx *c; c = (struct om_tcp_ctx *) ctx; - if (c->host) - free(c->host); - if (c->port) - free(c->port); - if (c->fd); - close (c->fd); - if (c->saved); - free(c->saved); + FREE_PTR(c->host); + FREE_PTR(c->port); + + CLOSE_FD(c->fd); + FREE_PTR(c->saved); return (1); } Index: om_udp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/om_udp.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- om_udp.c 17 Sep 2002 05:20:28 -0000 1.6 +++ om_udp.c 16 Apr 2003 11:37:25 -0000 1.7 @@ -135,11 +135,10 @@ default: m_dprintf(MSYSLOG_SERIOUS, "om_udp_init: parsing error" " [%c]\n", ch); - if (c->host) - free(c->host); - if (c->port) - free(c->port); - free(*ctx); + + FREE_PTR(c->host); + FREE_PTR(c->port); + FREE_PTR(*ctx); return (-1); } @@ -221,14 +220,11 @@ c = (struct om_udp_ctx *) ctx; - if (c->host) - free(c->host); - if (c->port) - free(c->port); - if (c->addr) - free(c->addr); + FREE_PTR(c->host); + FREE_PTR(c->port); + FREE_PTR(c->addr); - close(c->fd); + CLOSE_FD(c->fd); return (1); } Index: ttymsg.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/ttymsg.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ttymsg.c 10 Jul 2001 21:58:14 -0000 1.9 +++ ttymsg.c 16 Apr 2003 11:37:25 -0000 1.10 @@ -147,18 +147,18 @@ int cpid, off = 0; if (forked) { - (void) close(fd); + close(fd); _exit(1); } cpid = fork(); if (cpid < 0) { (void) snprintf(errbuf, sizeof(errbuf), "fork: %s", strerror(errno)); - (void) close(fd); + close(fd); return (errbuf); } if (cpid) { /* parent */ - (void) close(fd); + close(fd); return (NULL); } forked++; @@ -176,7 +176,7 @@ */ if (errno == ENODEV || errno == EIO) break; - (void) close(fd); + close(fd); if (forked) _exit(1); (void) snprintf(errbuf, sizeof(errbuf), @@ -184,7 +184,8 @@ return (errbuf); } - (void) close(fd); + close(fd); + if (forked) _exit(0); return (NULL); |
From: <al...@us...> - 2003-04-16 11:35:39
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv18054/src Modified Files: syslogd.c Log Message: dprintf -> m_dprintf bad alejo@, should check it compiles before commit! Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.241 retrieving revision 1.242 diff -u -d -r1.241 -r1.242 --- syslogd.c 15 Apr 2003 17:17:08 -0000 1.241 +++ syslogd.c 16 Apr 2003 11:35:30 -0000 1.242 @@ -1861,14 +1861,14 @@ if (!found_host || msg[n2] == '\0') return (-1); - dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: before: [%s]\n", msg); + m_dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: before: [%s]\n", msg); /* remove host from message */ while (msg[n2] != '\0') msg[n1++] = msg[n2++]; msg[n1] = '\0'; - dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: after: [%s]\n", msg); + m_dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: after: [%s]\n", msg); return (1); } |
From: <al...@us...> - 2003-04-16 10:34:10
|
Update of /cvsroot/msyslog/msyslog-event/src In directory sc8-pr-cvs1:/tmp/cvs-serv23120/src Modified Files: msyslog.h Log Message: fix FD_CLOSE Index: msyslog.h =================================================================== RCS file: /cvsroot/msyslog/msyslog-event/src/msyslog.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- msyslog.h 25 Feb 2003 00:01:30 -0000 1.3 +++ msyslog.h 16 Apr 2003 10:34:06 -0000 1.4 @@ -64,7 +64,7 @@ #define MAX_STACK_SIZE 100 -#define FD_CLOSE(cfd) {if (cfd == -1) close(cfd); cfd = -1; } +#define FD_CLOSE(cfd) {if (cfd != -1) { close(cfd); cfd = -1; } } #define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) |
From: <al...@us...> - 2003-04-16 10:29:14
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv17397/modules Modified Files: im_tcp.c Log Message: fix list handling prev code would never remove the last item inserted Index: im_tcp.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_tcp.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- im_tcp.c 4 Apr 2003 17:22:24 -0000 1.45 +++ im_tcp.c 16 Apr 2003 10:29:05 -0000 1.46 @@ -266,9 +266,14 @@ close (con->fd); /* remove node */ - for (prev = &c->first; *prev != NULL ; prev = &(*prev)->next) - if ((*prev)->next == con) - (*prev)->next = con->next; + for (prev = &c->first; *prev != NULL ; prev = &(*prev)->next) { + + if (*prev == con) { + + *prev = con->next; + break; + } + } /* complete and print any previous partial message */ if (con->saveline[0] != '\0') |
From: <al...@us...> - 2003-04-15 17:32:47
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv5861/modules Added Files: om_snmptrap.c Log Message: move to correct place --- NEW FILE: om_snmptrap.c --- /* $Id: om_snmptrap.c,v 1.1 2003/04/15 17:32:42 alejo Exp $ */ /* * Copyright (c) 2002, Core SDI S.A., Argentina * All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither name of the Core SDI S.A. nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * om_snmptrap - Modular Syslog 1.xx module used to generate SNMP traps. * Author: Hernan Gips <ch...@co...> */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> #include "../../config.h" #include "../../modules.h" #include "../../syslogd.h" #include <ucd-snmp/asn1.h> #include <ucd-snmp/mib.h> #include <ucd-snmp/parse.h> #include <ucd-snmp/ucd-snmp-config.h> #include <ucd-snmp/ucd-snmp-includes.h> #include <ucd-snmp/system.h> #ifndef DEFAULT_HOST #define DEFAULT_HOST "127.0.0.1" #endif #ifndef DEFAULT_PORT #define DEFAULT_PORT SNMP_TRAP_PORT #endif #ifndef DEFAULT_COMMUNITY #define DEFAULT_COMMUNITY "private" #endif #ifndef DEFAULT_GENERIC_TRAP #define DEFAULT_GENERIC_TRAP SNMP_TRAP_ENTERPRISESPECIFIC #endif #ifndef DEFAULT_SPECIFIC_TRAP #define DEFAULT_SPECIFIC_TRAP 0 #endif extern char *__progname; struct om_snmptrap_ctx { char host[MAXHOSTNAMELEN]; uint16_t port; char community[COMMUNITY_MAX_LEN]; oid trap_oid[MAX_OID_LEN]; size_t trap_oid_len; int generic_type; int specific_type; oid var_oid[MAX_OID_LEN]; size_t var_oid_len;; }; /* * om_snmptrap_init: * %snmptrap [-h host] [-p port] [-c community] -t trap_oid * [-g generic_type] [-s specific_type] [var_oid] * * host Trap server (default 127.0.0.1) * port Trap port (default 162) * community Community (default 'private') * trap_oid The trap oid * generic_type The generic trap type (default 6: ENTERPRISE SPECIFIC) * specific_type The specific trap type (default: 0) * var_oid An extra variable sent with the trap. Its content * will be the syslog message. */ int om_snmptrap_init(int argc, char **argv, struct filed *f, char *prog, void **ctx, char **status) { extern int optreset; /* Present on some BSD based systems */ extern int optind; struct om_snmptrap_ctx *c; unsigned char statbuf[256], *buf; size_t buflen, bufolen; int ch; dprintf(MSYSLOG_INFORMATIVE, "om_snmptrap_init: Entering, " "callded by %s.\n", prog); /* By the doubts :) */ if (argv == NULL || *argv == NULL || argc == 0 || f == NULL || ctx == NULL) { errno = EINVAL; return (-1); } /* Create a temporal buffer */ buflen = 256; buf = (unsigned char *)malloc(buflen * sizeof(unsigned char)); if (buf == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_init: %s.\n", strerror(errno)); return (-1); } /* Create the snmptrap context */ c = (struct om_snmptrap_ctx *)malloc(sizeof(struct om_snmptrap_ctx)); if (c == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_init: " "Can't create context: %s.\n", strerror(errno)); free(buf); return (-1); } /* * Initialize snmp related functions * see mib_api(3) and snmp_agent_api(3) */ init_mib(); read_all_mibs(); init_snmp(__progname); /* Set default context values */ strlcpy(c->host, DEFAULT_HOST, sizeof(c->host)); c->port = DEFAULT_PORT; strlcpy(c->community, DEFAULT_COMMUNITY, sizeof(c->community)); c->trap_oid_len = 0; c->generic_type = DEFAULT_GENERIC_TRAP; c->specific_type = DEFAULT_SPECIFIC_TRAP; c->var_oid_len = 0; /* Parse the command line */ optreset = 1; /* Present on some BSD based systems */ optind = 1; while ((ch = getopt(argc, argv, "c:g:h:p:s:t:")) != -1) switch (ch) { case 'c': /* Community */ if (strcmp(optarg, "private") && strcmp(optarg, "public")) dprintf(MSYSLOG_WARNING, "om_snmptrap_init: " "Invalid -c value '%s'. Ignoring, using " "default.\n", optarg); else strlcpy(c->community, optarg, sizeof(c->community)); break; case 'g': /* Generic Trap Type */ c->generic_type = (unsigned char)strtoul(optarg, NULL, 10); break; case 'h': /* Host */ strlcpy(c->host, optarg, sizeof(c->host)); break; case 'p': /* Port */ c->port = (uint16_t)strtoul(optarg, NULL, 10); break; case 's': /* Specific Trap Type */ c->specific_type = (unsigned char)strtoul(optarg, NULL, 10); break; case 't': /* Trap Object Identifier */ c->trap_oid_len = MAX_OID_LEN; if (snmp_parse_oid(optarg, c->trap_oid, &c->trap_oid_len) == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_init: " "Can't the parse the trap oid: %s: %s.\n", optarg, snmp_api_errstring(snmp_errno)); goto fail; } break; default: dprintf(MSYSLOG_WARNING, "om_snmptrap_init: Invalid " "command line option: -%c. Ignoring.\n", ch); } /* The Trap Object Identifier is mandatory (-t option) */ if (c->trap_oid_len == 0) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_init: " "Missing trap object identifier (option -t).\n"); goto fail; } /* Get optional list of variables */ if (argc - optind) { c->var_oid_len = MAX_OID_LEN; if (snmp_parse_oid(argv[optind], c->var_oid, &c->var_oid_len) == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_init: " "Can't parse variable oid: %s: %s.\n", argv[argc - optind - 1], snmp_api_errstring(snmp_errno)); goto fail; } optind++; } if (argc - optind) dprintf(MSYSLOG_WARNING, "om_snmptrap_init: Extra invalid " "arguments. Ignored.\n"); bufolen = 0; sprint_realloc_objid(&buf, &buflen, &bufolen, 1, c->trap_oid, c->trap_oid_len); snprintf(statbuf, sizeof(statbuf), "om_snmptrap: host=%s, port=%d, " "community=%s, trap_oid=%s, generic_type=%d, specific_type=%d\n", c->host, c->port, c->community, buf, c->generic_type, c->specific_type); *ctx = (void *)c; *status = strdup(statbuf); free(buf); return (1); fail: free(c); free(buf); return (-1); } int om_snmptrap_close(struct filed *f, void *ctx) { return (0); } int om_snmptrap_write(struct filed *f, int flags, struct m_msg *msg, void *ctx) { struct snmp_session session, *ss; struct sockaddr_in *agent_addr; struct snmp_pdu *pdu; struct om_snmptrap_ctx *c; c = (struct om_snmptrap_ctx *)ctx; /* Identify an SNMP session */ snmp_sess_init(&session); session.version = SNMP_VERSION_1; session.peername = c->host; session.remote_port = c->port; session.community = c->community; session.community_len = strlen(session.community); /* Open the SNMP session */ ss = snmp_open(&session); if (ss == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_write: Can't create " "session to host %s, port %d: %s.\n", c->host, c->port, snmp_api_errstring(snmp_errno)); return (-1); } /* Create a PDU for the TRAP */ pdu = snmp_pdu_create(SNMP_MSG_TRAP); if (pdu == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_write: Can't create " "pdu: %s.\n", snmp_api_errstring(snmp_errno)); return (-1); } pdu->enterprise = (oid *)malloc(sizeof(oid) * c->trap_oid_len); if (pdu->enterprise == NULL) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_write: %s.\n", strerror(errno)); snmp_free_pdu(pdu); return (-1); } memcpy(pdu->enterprise, c->trap_oid, sizeof(oid) * c->trap_oid_len); pdu->enterprise_length = c->trap_oid_len; pdu->trap_type = c->generic_type; pdu->specific_type = c->specific_type; pdu->time = get_uptime(); agent_addr = (struct sockaddr_in *)&pdu->agent_addr; agent_addr->sin_family = AF_INET; agent_addr->sin_addr.s_addr = get_myaddr(); /* Add the optional variable to the PDU */ if (c->var_oid_len) if (snmp_add_var(pdu, c->var_oid, c->var_oid_len, 's', msg->msg) != 0) dprintf(MSYSLOG_CRITICAL, "om_snmptrap_write: " "Can't add variable to the pdu, trap will be" "sent without it to host %s, port %s: %s.\n", c->host, c->port, snmp_api_errstring(snmp_errno)); if (snmp_send(ss, pdu) == 0) { dprintf(MSYSLOG_CRITICAL, "om_snmptrap_write: " "Can't send trap to host %s, port %d: %s.\n", c->host, c->port, snmp_api_errstring(snmp_errno)); snmp_free_pdu(pdu); snmp_close(ss); return (-1); } dprintf(MSYSLOG_INFORMATIVE, "om_snmptrap_write: " "Trap sent to host %s, port %d.\n", c->host, c->port); /* The pdu is freed by the library (see snmp_send(3)) */ snmp_close(ss); return (1); } |
From: <al...@us...> - 2003-04-15 17:32:44
|
Update of /cvsroot/msyslog/syslog/src/modules/om_snmptrap In directory sc8-pr-cvs1:/tmp/cvs-serv5861/modules/om_snmptrap Removed Files: Makefile om_snmptrap.8 om_snmptrap.c Log Message: move to correct place --- Makefile DELETED --- --- om_snmptrap.8 DELETED --- --- om_snmptrap.c DELETED --- |
From: <al...@us...> - 2003-04-15 17:32:44
|
Update of /cvsroot/msyslog/syslog/src/man In directory sc8-pr-cvs1:/tmp/cvs-serv5861/man Added Files: om_snmptrap.8 Log Message: move to correct place --- NEW FILE: om_snmptrap.8 --- .\" $Id: om_snmptrap.8,v 1.1 2003/04/15 17:32:40 alejo Exp $ .\" .\" Copyright (c) 2001, 2002 CORE SDI S.A., Buenos Aires, Argentina. .\" All rights reserved. .\" .\" THIS IS UNPUBLISHED PROPIETARY SOURCE CODE OF CORE SDI S.A. .\" .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES .\" ARE DISCLAIMED. IN NO EVENT SHALL CORE SDI S.A. BE LIABLE FOR ANY DIRECT, .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES .\" RESULTING FROM THE USE OR MISUSE OF ANY RECOMPILATION OF THIS SOURCE .\" CODE NOT PROVIDED BY CORE SDI S.A. .\" .Dd Mar 8, 2002 .Dt OM_SNMPTRAP 8 SMM .Os none .Sh NAME .Nm om_snmptrap .Nd msyslog-1.x output module used to generate SNMP traps .Sh SYNOPSIS .Nm .Op Fl h Ar host .Op Fl p Ar port .Op Fl c Ar community .Fl t Ar trap_oid .Op Fl g Ar generic_type .Op Fl s Ar specific_trap .Op Ar var_oid .Sh DESCRIPTION The .Nm msyslog-1.x output module allows the generation of SNMP TRAPS. The options are as follows: .Bl -tag -width Ds .It Fl h Ar host Specifies the remote host where the snmp trap is sent; the default is .Em 127.0.0.1 . .It Fl p Ar port Specifies the port where the remote host is listening for incoming snmp traps; the default is .Em 162 . .It Fl c Ar community Specifies the SNMPv1 community; the default is .Em private . .It Fl t Ar trap_oid This argument is mandatory and specifies the trap OID (object identifier). .It Fl g Ar generic_type Specifies generic trap TYPE; the default is .Em 6 (ENTERPRISE SPECIFIC trap). .It Fl s Ar specific_type Specifies the specific trap TYPE; the default is .Em 0 . .It Ar var_oid This arguments specifies de variable OID; when an snmp trap is generated, the module asigns the msyslog message to this object identifier. .El .Sh EXAMPLES If you want to generate an ``enterprises.pepeAndCo.invalidHost'' trap and specific trap ``1'' each time the syslog receives a message from a host whose name is ``untrusted'' then, the follwing line should be added into the .Xr syslog.conf 5 file: .Bd -literal -offset indent *.* %regex -h "untrusted" %snmptrap -t enterprises.pepeAndCo.invalidHost -s 1 .Ed .Pp If you want the syslog message being assigned to the "enterprises.pepeAndCo.invalidHost.message" variable, then the following line should be specified: .Bd -literal -offset indent *.* %regex -h "untrusted" %snmptrap -t enterprises.pepeAndCo.invalidHost -s 1 enterprises.pepeAndCo.invalidHost.message .Ed .Sh AUTHORS .Bl -bullet .It Claudio Castiglia <cl...@co...> .It Hernan Gips <ch...@co...> .El .Sh SEE ALSO .Xr snmpd 1 , .Xr snmptrap 1 , .Xr syslog.conf 5 , .Xr om_regex 8 , .Xr msyslogd 8 , .Xr syslogd 8 , .Xr snmptrapd 8 . |
From: <al...@us...> - 2003-04-15 17:17:14
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv30127 Modified Files: syslogd.c syslogd.h Log Message: extract_hostname() by jkohen@ Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.240 retrieving revision 1.241 diff -u -d -r1.240 -r1.241 --- syslogd.c 5 Apr 2003 01:57:52 -0000 1.240 +++ syslogd.c 15 Apr 2003 17:17:08 -0000 1.241 @@ -232,6 +232,18 @@ struct i_module **unpoll_fd_modules = NULL; /* an array of pointers */ int unpoll_fd_cnt = 0; +#define MIN_HOST_BUF 90 + +static const char *hostname_tmpl[] = { + "<%*d>%*3s %*d %*d:%*d:%*d %*d %n%89s %n", /* w/year */ + "<%*d>%*3s %*d %*d:%*d:%*d %n%89s %n", + "%*3s %*d %*d:%*d:%*d %*d %n%89s %n", /* w/year */ + "%*3s %*d %*d:%*d:%*d %n%89s %n", + "%n%89s %n", +}; +#define NR_HOSTNAME_TEMPLATES (sizeof (hostname_tmpl) / sizeof (hostname_tmpl[0])) + + int main(int argc, char **argv) { @@ -1825,4 +1837,38 @@ ret = vfprintf(stderr, fmt, var); va_end(var); return (ret); +} + +int +extract_hostname(char *msg, char *buf, size_t buf_size) +{ + int found_host; + int n1, n2; + int i; + + if (buf_size < MIN_HOST_BUF) + return (-1); + + found_host = 0; + + for (i = 0; i < NR_HOSTNAME_TEMPLATES; i++) { + if (1 == sscanf(msg, hostname_tmpl[i], &n1, buf, &n2)) { + found_host = 1; + break; + } + } + + if (!found_host || msg[n2] == '\0') + return (-1); + + dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: before: [%s]\n", msg); + + /* remove host from message */ + while (msg[n2] != '\0') + msg[n1++] = msg[n2++]; + msg[n1] = '\0'; + + dprintf(MSYSLOG_INFORMATIVE, "im_tcp_read: after: [%s]\n", msg); + + return (1); } Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.113 retrieving revision 1.114 diff -u -d -r1.113 -r1.114 --- syslogd.h 5 Apr 2003 00:06:03 -0000 1.113 +++ syslogd.h 15 Apr 2003 17:17:09 -0000 1.114 @@ -79,6 +79,7 @@ int m_dprintf(int, char const *, ...); /* level, format, ... */ int getxopt(int, char *[], char *, int *); /* argc, argv, opts, startarg */ +int extract_hostname(char *, char *, size_t); #define MSYSLOG_CRITICAL 10 #define MSYSLOG_SERIOUS 20 |
From: <al...@us...> - 2003-04-15 17:16:46
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv29790 Modified Files: modules.c Log Message: report dynamic lib errors, by jkohen@ Index: modules.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules.c,v retrieving revision 1.170 retrieving revision 1.171 diff -u -d -r1.170 -r1.171 --- modules.c 17 Sep 2002 05:20:26 -0000 1.170 +++ modules.c 15 Apr 2003 17:16:40 -0000 1.171 @@ -153,8 +153,11 @@ m_dprintf(MSYSLOG_INFORMATIVE, "get_symbol: " "Trying to open %s... ", extlib); *h = dlopen(extlib, DLOPEN_FLAGS); - m_dprintf(MSYSLOG_INFORMATIVE, "%s\n", - (*h == NULL) ? "failed" : "ok"); + if (*h == NULL) + m_dprintf(MSYSLOG_INFORMATIVE, + "failed [%s]\n", dlerror()); + else + m_dprintf(MSYSLOG_INFORMATIVE, "ok"); } } } |
From: <al...@us...> - 2003-04-11 19:56:18
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv27894 Modified Files: Tag: v1_08 configure configure.in Log Message: bump to 1.08g Index: configure =================================================================== RCS file: /cvsroot/msyslog/syslog/configure,v retrieving revision 1.86.2.3 retrieving revision 1.86.2.4 diff -u -d -r1.86.2.3 -r1.86.2.4 --- configure 11 Apr 2003 16:36:20 -0000 1.86.2.3 +++ configure 11 Apr 2003 19:56:05 -0000 1.86.2.4 @@ -3567,7 +3567,7 @@ CFLAGS="$CFLAGS -Wall" fi -MSYSLOG_VERSION="1.08e" +MSYSLOG_VERSION="1.08g" cat >>confdefs.h <<EOF #define MSYSLOG_VERSION_STR "$MSYSLOG_VERSION" Index: configure.in =================================================================== RCS file: /cvsroot/msyslog/syslog/configure.in,v retrieving revision 1.146.2.3 retrieving revision 1.146.2.4 diff -u -d -r1.146.2.3 -r1.146.2.4 --- configure.in 11 Apr 2003 16:36:25 -0000 1.146.2.3 +++ configure.in 11 Apr 2003 19:56:07 -0000 1.146.2.4 @@ -61,7 +61,7 @@ CFLAGS="$CFLAGS -Wall" fi -MSYSLOG_VERSION="1.08e" +MSYSLOG_VERSION="1.08g" AC_DEFINE_UNQUOTED(MSYSLOG_VERSION_STR, "$MSYSLOG_VERSION") echo msyslog version... $MSYSLOG_VERSION |
From: <al...@us...> - 2003-04-11 19:55:40
|
Update of /cvsroot/msyslog/syslog In directory sc8-pr-cvs1:/tmp/cvs-serv27691 Modified Files: Tag: v1_08g configure.in configure Log Message: bump to 1.08g Index: configure.in =================================================================== RCS file: /cvsroot/msyslog/syslog/configure.in,v retrieving revision 1.146.2.3 retrieving revision 1.146.2.3.4.1 diff -u -d -r1.146.2.3 -r1.146.2.3.4.1 --- configure.in 11 Apr 2003 16:36:25 -0000 1.146.2.3 +++ configure.in 11 Apr 2003 19:55:32 -0000 1.146.2.3.4.1 @@ -61,7 +61,7 @@ CFLAGS="$CFLAGS -Wall" fi -MSYSLOG_VERSION="1.08e" +MSYSLOG_VERSION="1.08g" AC_DEFINE_UNQUOTED(MSYSLOG_VERSION_STR, "$MSYSLOG_VERSION") echo msyslog version... $MSYSLOG_VERSION Index: configure =================================================================== RCS file: /cvsroot/msyslog/syslog/configure,v retrieving revision 1.86.2.3 retrieving revision 1.86.2.3.4.1 diff -u -d -r1.86.2.3 -r1.86.2.3.4.1 --- configure 11 Apr 2003 16:36:20 -0000 1.86.2.3 +++ configure 11 Apr 2003 19:55:33 -0000 1.86.2.3.4.1 @@ -3567,7 +3567,7 @@ CFLAGS="$CFLAGS -Wall" fi -MSYSLOG_VERSION="1.08e" +MSYSLOG_VERSION="1.08g" cat >>confdefs.h <<EOF #define MSYSLOG_VERSION_STR "$MSYSLOG_VERSION" |
From: <al...@us...> - 2003-04-11 19:53:41
|
Update of /cvsroot/msyslog/syslog/src/modules In directory sc8-pr-cvs1:/tmp/cvs-serv26870/src/modules Modified Files: Tag: v1_08g im_bsd.c Log Message: typo, missing ")" while there -1 -> - 1 Index: im_bsd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules/im_bsd.c,v retrieving revision 1.82.2.4.2.1 retrieving revision 1.82.2.4.2.2 diff -u -d -r1.82.2.4.2.1 -r1.82.2.4.2.2 --- im_bsd.c 11 Apr 2003 19:04:17 -0000 1.82.2.4.2.1 +++ im_bsd.c 11 Apr 2003 19:53:37 -0000 1.82.2.4.2.2 @@ -96,8 +96,8 @@ strncpy(ret->im_msg, _PATH_UNIX, sizeof(ret->im_msg) - 1); ret->im_msg[sizeof (ret->im_msg) - 1] = '\0'; - strncat(ret->im_msg, ": ", sizeof (ret->im_msg) -1 - - strlen(ret->im_msg); + strncat(ret->im_msg, ": ", sizeof (ret->im_msg) - 1 + - strlen(ret->im_msg)); lp = ret->im_msg + strlen(ret->im_msg); |