Update of /cvsroot/benson/benson3/src
In directory sc8-pr-cvs1:/tmp/cvs-serv10656
Modified Files:
Makefile.in acknowledge.c alertlist.c bensond.c bn_monitor.c
bn_network.c bsm.c btrap.c stack.c stack.h utils.c
Log Message:
Fixed a whole lot of warnings.
Index: Makefile.in
===================================================================
RCS file: /cvsroot/benson/benson3/src/Makefile.in,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** Makefile.in 30 Sep 2003 04:43:38 -0000 1.46
--- Makefile.in 8 Nov 2003 20:43:19 -0000 1.47
***************
*** 54,58 ****
$(CC) $(CFLAGS) $(CPPFLAGS) -o btrap btrap.c libbenson.a $(LIBNETCLIENT) $(LIBS)
! ack: libbenson.a $(LIBPERL) $(LIBNETWORK)
$(CC) $(CFLAGS) $(CPPFLAGS) -o ack acknowledge.c libbenson.a $(LIBNETCLIENT) $(LIBS)
--- 54,58 ----
$(CC) $(CFLAGS) $(CPPFLAGS) -o btrap btrap.c libbenson.a $(LIBNETCLIENT) $(LIBS)
! ack: libbenson.a $(LIBPERL) $(LIBNETWORK) acknowledge.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o ack acknowledge.c libbenson.a $(LIBNETCLIENT) $(LIBS)
Index: acknowledge.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/acknowledge.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** acknowledge.c 8 Oct 2003 02:59:12 -0000 1.8
--- acknowledge.c 8 Nov 2003 20:43:19 -0000 1.9
***************
*** 7,12 ****
--- 7,40 ----
#include "benson/benson.h"
+ #include "benson/cfgctl.h"
#include "network/network.h"
+ void usage(char *command, int verbose)
+ {
+ if(verbose) {
+ printf("Benson Distributed Monitoring System (%s %s)\n", PACKAGE, VERSION);
+ printf("Copyright (C) 1999, 2000, 2001, 2002, 2003 Bob Tribit\n\n");
+ printf("This program is distributed in the hope that it will be useful,\n");
+ printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
+ printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
+ printf("GNU General Public License for more details.\n\n");
+ }
+ printf("Usage: %s [options] agent subsystem\n", command);
+ printf("Acknowledges an alert by agent and subsystem in the Benson collector system.\n");
+ printf("NOTE: Can still be acknowledged with identity, requires -i flag though\n\n");
+ #ifdef HAVE_SSL
+ printf(" -c cert.pem path to this agents SSL certificate\n");
+ printf(" -k key.pem path to this agents SSL key\n");
+ #endif
+ printf(" -s srcaddr source address for trap\n");
+ printf(" -d destaddr destination address for trap\n");
+ printf(" -i identity benson trap identity\n");
+ printf(" -v verbose output\n");
+ printf(" -V display version information\n\n");
+ printf("Report bugs to <ben...@ne...>\n");
+
+ }
+
+
int main(int argc, char *argv[], char *env[]) {
int index = 0;
***************
*** 16,27 ****
int version = 0;
int port = 0;
! int have_source = 0, have_destination = 0;
char temp[DVALUE_LENGTH];
char source[AGT_MAXSIZE], destination[DST_MAXSIZE];
char identity[ID_MAXSIZE];
char certfile[FILE_MAXSIZE], keyfile[FILE_MAXSIZE];
- char config_file[FILE_MAXSIZE];
! while((c = getopt(argc,argv,"Vvd:s:c:k:")) != -1) {
switch(c)
{
--- 44,55 ----
int version = 0;
int port = 0;
! int have_source = 0, have_destination = 0, have_identity;
char temp[DVALUE_LENGTH];
char source[AGT_MAXSIZE], destination[DST_MAXSIZE];
char identity[ID_MAXSIZE];
+ char agent[AGT_MAXSIZE], subsystem[SUB_MAXSIZE];
char certfile[FILE_MAXSIZE], keyfile[FILE_MAXSIZE];
! while((c = getopt(argc,argv,"Vvd:s:c:k:i:")) != -1) {
switch(c)
{
***************
*** 42,45 ****
--- 70,77 ----
have_destination = 1;
break;
+ case 'i':
+ safe_insert(identity, optarg, ID_MAXSIZE);
+ have_identity = 1;
+ break;
case 'v':
verbose = 1;
***************
*** 54,70 ****
if(!verbose) {
freopen("/dev/null", "a+", stderr);
}
if((rc = load_config()) == ERROR) {
! printf("Error loading configuration file.\n");
! exit(EXIT_FAILURE);
! }
! if((rc = cfg_helper(FIND, "Port", temp)) == ERROR) {
! printf("Configuraton file does not specify a Port and I'm not going to guess.\n");
! exit(EXIT_FAILURE);
} else {
! port = atoi(temp);
}
--- 86,112 ----
+ if(version) {
+ printf("%s %s\n", PACKAGE, VERSION);
+ exit(EXIT_SUCCESS);
+ }
+
if(!verbose) {
freopen("/dev/null", "a+", stderr);
}
+
if((rc = load_config()) == ERROR) {
! if(!have_destination && !have_source) {
! printf("Error loading configuration file.\n");
! exit(EXIT_FAILURE);
! }
! port = 9021;
} else {
! if((rc = cfg_helper(FIND, "Port", temp)) == ERROR) {
! printf("Configuraton file does not specify a Port and I'm not going to guess.\n");
! exit(EXIT_FAILURE);
! } else {
! port = atoi(temp);
! }
}
***************
*** 97,110 ****
}
! if(version)
! {
! printf("%s %s\n", PACKAGE, VERSION);
! exit(0);
! }
! if((argc - optind) == 1)
{
index = optind;
! strncpy(identity, argv[index++], ID_MAXSIZE-1);
! identity[ID_MAXSIZE-1] = '\0';
if(verbose) {
--- 139,150 ----
}
!
! if((argc - optind) == 2)
{
index = optind;
! strncpy(agent, argv[index++], AGT_MAXSIZE-1);
! agent[AGT_MAXSIZE-1] = '\0';
! strncpy(subsystem, argv[index++], SUB_MAXSIZE-1);
! subsystem[SUB_MAXSIZE-1] = '\0';
if(verbose) {
***************
*** 112,140 ****
printf("Destination: %s\n", destination);
printf("Identity: %s\n", identity);
}
! if((rc = bn_acknowledge(destination, port, source, identity)) == ERROR) {
printf("bn_acknowledge() failed.\n");
exit(EXIT_FAILURE);
}
} else {
! if(verbose) {
! printf("Benson Distributed Monitoring System (%s %s)\n", PACKAGE, VERSION);
! printf("Copyright (C) 1999, 2000, 2001, 2002 Bob Tribit\n\n");
! printf("This program is distributed in the hope that it will be useful,\n");
! printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
! printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
! printf("GNU General Public License for more details.\n\n");
! }
! printf("Usage: %s [options] identity\n", argv[0]);
! printf("Acknowledges an alert by ID in the Benson collector system.\n\n");
! #ifdef HAVE_SSL
! printf(" -c cert.pem path to this agents SSL certificate\n");
! printf(" -k key.pem path to this agents SSL key\n");
! #endif
! printf(" -s srcaddr source address for trap\n");
! printf(" -d destaddr destination address for trap\n");
! printf(" -v verbose output\n");
! printf(" -V display version information\n\n");
! printf("Report bugs to <ben...@ne...>\n");
}
--- 152,164 ----
printf("Destination: %s\n", destination);
printf("Identity: %s\n", identity);
+ printf("Agent: %s\n", agent);
+ printf("Subsystem: %s\n", subsystem);
}
! if((rc = bn_ack_v32(destination, port, source, identity, agent, subsystem)) == ERROR) {
printf("bn_acknowledge() failed.\n");
exit(EXIT_FAILURE);
}
} else {
! usage(argv[0], verbose);
}
Index: alertlist.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/alertlist.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** alertlist.c 8 Oct 2003 04:35:32 -0000 1.11
--- alertlist.c 8 Nov 2003 20:43:19 -0000 1.12
***************
*** 7,12 ****
--- 7,14 ----
#include "benson/benson.h"
+ #include "benson/cfgctl.h"
#include "network/network.h"
+
int main(int argc, char *argv[], char *env[]) {
int index = 0;
***************
*** 20,24 ****
char source[AGT_MAXSIZE], destination[DST_MAXSIZE];
char certfile[FILE_MAXSIZE], keyfile[FILE_MAXSIZE];
- char config_file[FILE_MAXSIZE];
--- 22,25 ----
Index: bensond.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/bensond.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** bensond.c 11 May 2003 08:02:04 -0000 1.30
--- bensond.c 8 Nov 2003 20:43:19 -0000 1.31
***************
*** 6,10 ****
*/
! #include <benson/benson.h>
int
--- 6,11 ----
*/
! #include "benson/benson.h"
! #include "benson/cfgctl.h"
int
***************
*** 12,16 ****
char *path;
int size = 0;
! char trace[255];
size = strlen(BENSON_HOME);
size += strlen("/sbin/");
--- 13,17 ----
char *path;
int size = 0;
! // char trace[255];
size = strlen(BENSON_HOME);
size += strlen("/sbin/");
Index: bn_monitor.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/bn_monitor.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** bn_monitor.c 28 Sep 2003 22:26:28 -0000 1.8
--- bn_monitor.c 8 Nov 2003 20:43:19 -0000 1.9
***************
*** 12,17 ****
unsigned char config_file[256];
unsigned char error_logfile[256];
- pid_t pid;
- int rc;
// Make me a daemon, baby
--- 12,15 ----
Index: bn_network.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/bn_network.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** bn_network.c 11 May 2003 08:02:05 -0000 1.36
--- bn_network.c 8 Nov 2003 20:43:19 -0000 1.37
***************
*** 28,32 ****
int bn_network_daemon() {
- pid_t pid;
int rc;
unsigned char error_logfile[256];
--- 28,31 ----
Index: bsm.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/bsm.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** bsm.c 8 Oct 2003 03:34:10 -0000 1.8
--- bsm.c 8 Nov 2003 20:43:19 -0000 1.9
***************
*** 12,16 ****
#ifndef CANT_BUILD_SERVER
#include <benson/bsm.h>
!
#define MAX_TITEMS 50
--- 12,16 ----
#ifndef CANT_BUILD_SERVER
#include <benson/bsm.h>
! #include <benson/utils.h>
#define MAX_TITEMS 50
***************
*** 28,33 ****
/* Allocate process local memory, so reservations can be made. */
! if(!(init_items = (bsm_titem *)malloc(size))) {
! perror("bsm_prepare(): malloc() failed");
return ERROR;
}
--- 28,33 ----
/* Allocate process local memory, so reservations can be made. */
! if(!(init_items = (bsm_titem *)ibn_malloc(size))) {
! perror("bsm_prepare(): ibn_malloc() failed");
return ERROR;
}
***************
*** 51,56 ****
int data_size = 0;
int allocated_titems = 0;
- bsm_hdr *header;
- bsm_titem *table_ptr;
/* Find the number of allocated items */
--- 51,54 ----
***************
*** 100,104 ****
}
! free(init_items);
return GOOD;
}
--- 98,102 ----
}
! ibn_free(init_items);
return GOOD;
}
Index: btrap.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/btrap.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** btrap.c 8 Oct 2003 04:35:32 -0000 1.20
--- btrap.c 8 Nov 2003 20:43:19 -0000 1.21
***************
*** 7,10 ****
--- 7,11 ----
#include <benson/benson.h>
+ #include <benson/cfgctl.h>
#include "network/network.h"
//#include <benson/perl_util.h>
***************
*** 22,26 ****
char severity[SEV_MAXSIZE], subsystem[SUB_MAXSIZE], message[MSG_MAXSIZE];
char certfile[FILE_MAXSIZE], keyfile[FILE_MAXSIZE];
- char config_file[FILE_MAXSIZE];
while((c = getopt(argc,argv,"Vvd:s:c:k:")) != -1) {
--- 23,26 ----
Index: stack.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/stack.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** stack.c 7 Oct 2003 01:11:54 -0000 1.2
--- stack.c 8 Nov 2003 20:43:19 -0000 1.3
***************
*** 1,2 ****
--- 1,3 ----
+ #include <benson/benson.h>
#include "stack.h"
***************
*** 14,18 ****
int stack_push(stack_ctx *current_ctx, void *item)
{
! int ctr = 0;
snode *ptr;
int snode_size = sizeof(snode);
--- 15,19 ----
int stack_push(stack_ctx *current_ctx, void *item)
{
! int ctr = 1;
snode *ptr;
int snode_size = sizeof(snode);
***************
*** 27,36 ****
current_ctx->first_node->node_construct = item;
} else {
! ptr = current_ctx->first_node;
! while(ptr->next != NULL) {
! ptr = ptr->next;
ctr++;
}
! // fixme check for error
ptr->next = (snode *)ibn_malloc(snode_size);
ptr = ptr->next;
--- 28,39 ----
current_ctx->first_node->node_construct = item;
} else {
! for(ptr=current_ctx->first_node;ptr->next != NULL;ptr = ptr->next) {
ctr++;
}
!
! if(ctr >= current_ctx->max_items) {
! return -1;
! }
!
ptr->next = (snode *)ibn_malloc(snode_size);
ptr = ptr->next;
***************
*** 38,47 ****
}
! return 0;
}
void *stack_pop(stack_ctx *current_ctx)
{
! snode *ptr, *prev_ptr;
void *item;
--- 41,51 ----
}
! return GOOD;
}
void *stack_pop(stack_ctx *current_ctx)
{
! snode *ptr;
! snode *prev_ptr = NULL;
void *item;
***************
*** 50,60 ****
}
! prev_ptr = ptr = current_ctx->first_node;
! printf("%p\n", ptr);
! while(ptr->next != NULL) {
! prev_ptr = ptr;
! ptr = ptr->next;
! printf("%p\n", ptr);
}
item = ptr->node_construct;
--- 54,61 ----
}
! for(ptr=current_ctx->first_node;ptr->next != NULL;ptr = ptr->next) {
! prev_ptr = ptr;
}
+
item = ptr->node_construct;
***************
*** 63,67 ****
ibn_free(ptr);
! prev_ptr->next = NULL;
return item;
--- 64,73 ----
ibn_free(ptr);
! if(ptr == current_ctx->first_node) {
! current_ctx->first_node = NULL;
! } else {
! assert(prev_ptr == NULL);
! prev_ptr->next = NULL;
! }
return item;
***************
*** 73,80 ****
if(current_ctx->first_node == NULL) {
! return ERROR;
}
! ptr = current_ctx->first_node;
while(ptr->next != NULL) {
prev_ptr = ptr;
--- 79,86 ----
if(current_ctx->first_node == NULL) {
! return GOOD;
}
! ptr=current_ctx->first_node;
while(ptr->next != NULL) {
prev_ptr = ptr;
***************
*** 84,89 ****
}
! memset(ptr, 0, sizeof(snode));
! ibn_free(ptr);
return GOOD;
--- 90,95 ----
}
! memset(current_ctx, 0, sizeof(stack_ctx));
! ibn_free(current_ctx);
return GOOD;
Index: stack.h
===================================================================
RCS file: /cvsroot/benson/benson3/src/stack.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** stack.h 27 Sep 2003 18:25:53 -0000 1.1
--- stack.h 8 Nov 2003 20:43:19 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
#include <stdio.h>
+ #include <assert.h>
#include <benson/const.h>
Index: utils.c
===================================================================
RCS file: /cvsroot/benson/benson3/src/utils.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** utils.c 8 Oct 2003 04:16:37 -0000 1.17
--- utils.c 8 Nov 2003 20:43:19 -0000 1.18
***************
*** 21,25 ****
current_size = maxsize;
}
! snprintf(d, maxsize, "%s\0", s);
}
--- 21,25 ----
current_size = maxsize;
}
! snprintf(d, maxsize, "%s", s);
}
***************
*** 118,122 ****
{
int rc;
! if (rc = semop(semid, sops, nsops) == -1) {
fprintf(stderr, "ibn_semop() error: %s\n", strerror(errno));
return ERROR;
--- 118,122 ----
{
int rc;
! if ((rc = semop(semid, sops, nsops)) == -1) {
fprintf(stderr, "ibn_semop() error: %s\n", strerror(errno));
return ERROR;
|