1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-21 08:42:23 +00:00

- Update to 0.0.33.

PR:		ports/157488
Submitted by:	Ryan Steinmetz <rpsfa@rit.edu>
Approved by:	maintainer timeout
This commit is contained in:
Wesley Shields 2011-06-15 13:51:06 +00:00
parent 5b067436f4
commit 606a979463
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=275624
6 changed files with 42 additions and 150 deletions

View File

@ -6,7 +6,7 @@
#
PORTNAME= nagircbot
PORTVERSION= 0.0.20
PORTVERSION= 0.0.33
CATEGORIES= net-mgmt irc
MASTER_SITES= http://www.vanheusden.com/nagircbot/
EXTRACT_SUFX= .tgz

View File

@ -1,2 +1,2 @@
SHA256 (nagircbot-0.0.20.tgz) = 22164ff2290c4bf2bebda60d5c09438f61e1973529d03a53bebd3bb36e43fc59
SIZE (nagircbot-0.0.20.tgz) = 17548
SHA256 (nagircbot-0.0.33.tgz) = 7a7c63a409bdad125b19ec852a772746eda2b1feef71bbdf58bd2a2c785a0887
SIZE (nagircbot-0.0.33.tgz) = 20085

View File

@ -1,19 +1,15 @@
--- Makefile.orig Mon Nov 27 06:21:58 2006
+++ Makefile Sat Apr 28 14:14:16 2007
@@ -1,9 +1,10 @@
VERSION=0.0.20
--- Makefile.orig 2011-01-18 05:39:10.000000000 -0500
+++ Makefile 2011-05-31 22:06:29.000000000 -0400
@@ -3,7 +3,7 @@
VERSION=0.0.33
DEBUG= -g -D_DEBUG #-fprofile-arcs -ftest-coverage # -pg -g
-CXXFLAGS+=-Wall -O2 -DVERSION=\"${VERSION}\" $(DEBUG)
+CXXFLAGS+=-DUSE_MMAP -Wall -O2 -DVERSION=\"${VERSION}\" $(DEBUG)
CFLAGS+=${CXXFLAGS}
-LDFLAGS+=$(DEBUG) -lstdc++
+LDFLAGS+=$(DEBUG) -lstdc++ -lutil
+PREFIX?=/usr/local
LDFLAGS+=$(DEBUG) -lcrypto -lssl -lstdc++
OBJS=error.o log.o utils.o br.o pl.o anna.o
@@ -13,7 +14,7 @@
@@ -15,7 +15,7 @@
$(CC) -Wall -W $(OBJS) $(LDFLAGS) -o nagircbot
install: nagircbot

View File

@ -1,75 +1,45 @@
--- anna.cpp.orig Mon Nov 27 06:21:58 2006
+++ anna.cpp Sat Apr 28 19:27:02 2007
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <signal.h>
#include <pwd.h>
+#include <sys/param.h>
+#include <libutil.h>
#include "utils.h"
#include "pl.h"
@@ -19,6 +21,7 @@
#include "error.h"
--- anna.cpp.orig 2011-01-18 05:39:10.000000000 -0500
+++ anna.cpp 2011-05-31 22:45:11.000000000 -0400
@@ -23,6 +23,7 @@
#include "ssl.h"
#include "log.h"
}
+#include "anna.h"
#define S_DISCONNECTED 1
#define S_CONNECTED 2
@@ -39,6 +42,7 @@
@@ -43,6 +44,7 @@
int minimum_time_for_successfull_login = 25; // one needs to be on-channel for at least 5 seconds to be considered a successfull login
int join_timeout = 5; // it should take no longer then 5 seconds to join a channel, otherwhise: abort connection and retry
int max_n_join_tries = 2; // try 2 times to get on a channel
+int throttle_delay = 1; // don't send more than one message per 1 seconds
char *server = "localhost:6667"; /* default irc server */
char *channel = "#nagircbot"; /* default channel to connect to */
char *nick = "nagircbot";
@@ -56,7 +60,7 @@
int max_time_last_host_update = 300, max_time_oldest_host_update = 3600, max_time_last_host_check = 300, max_time_oldest_host_check = 3 * 86400, max_time_last_service_check = 20 * 60, max_time_oldest_service_check = 3 * 86400, max_time_oldest_next_service_check = 20 * 60;
char *nick_prefix = ""; /* prefix text for all messages sent to channel */
@@ -53,7 +55,7 @@
int one_line = 1;
char *username = "Nagios IRC Bot " VERSION ", (C) www.vanheusden.com"; /* complete username */
int verbose = 255; /* default is log everything */
-char *statuslog = "/usr/local/nagios/var/status.log";
+char *statuslog = "/var/spool/nagios/status.dat";
int statuslog_version = 2;
int statuslog_location = L_FILE;
char use_colors = 0;
@@ -174,6 +176,13 @@
char *state_str[4] = { " OK ", "WARN", "CRIT", " ?? " };
-char *color_str[4] = { mystrdup("_3,1 "), mystrdup("_8,1 "), mystrdup("_4,1 "), mystrdup("_11,1 ") }; /* FIXME */
+char *color_str[4] = { mystrdup("_9,1 "), mystrdup("_8,1 "), mystrdup("_4,1 "), mystrdup("_11,1 ") }; /* FIXME */
struct stats *prev = NULL;
int n_prev = 0;
char topic[4096] = { 0 };
@@ -105,13 +109,18 @@
if (irc_set_nick(fd, nick) == -1)
return -1;
+ /* "Currently this requires that clients send a PASS command before sending
+ * the NICK/USER combination and servers *must* send a PASS command before
+ * any SERVER command." */
+ if (password != NULL) {
+ if (send_irc(fd, "PASS %s", password) == -1)
+ return -1;
+ }
+
/* FIXME: localhost must be, ehr, local host */
if (send_irc(fd, "USER %s \"localhost\" \"%s\" :%s", user, server, username) == -1)
return -1;
- if (password != NULL && send_irc(fd, "PASS %s", password) == -1)
- return -1;
-
return 0;
}
@@ -153,6 +162,12 @@
int irc_privmsg(int fd, char *channel, char *msg)
int irc_privmsg(server_t server_conn, char *channel, char *msg)
{
+ static time_t last_msg = time(NULL);
+ time_t diff = time(NULL) - last_msg;
+ if (diff < throttle_delay) {
+ sleep(throttle_delay - diff);
+ }
+ time(&last_msg);
return send_irc(fd, "PRIVMSG %s :%s", channel, msg);
+ static time_t last_msg = time(NULL);
+ time_t diff = time(NULL) - last_msg;
+ if (diff < throttle_delay) {
+ sleep(throttle_delay - diff);
+ }
+ time(&last_msg);
+
return send_irc(server_conn, "PRIVMSG %s :%s", channel, msg);
}
@@ -166,7 +181,7 @@
@@ -192,7 +201,7 @@
/* open file or connection to nagios status socket */
if (is_file == 1) /* file */
@ -78,7 +48,7 @@
else
fd = connect_to(statuslog);
if (fd == -1)
@@ -416,7 +431,7 @@
@@ -490,7 +499,7 @@
if (verbose > 1) dolog("reload_statuslog started");
if (statuslog_location == L_FILE) /* file */
@ -87,65 +57,3 @@
else
fd_sl = connect_to(statuslog);
@@ -712,6 +727,7 @@
printf("-z user user to run as\n");
printf("-H show only state type 'HARD' (default)\n");
printf("-S show also state type 'SOFT'\n");
+ printf("-P file store the pid in a file\n");
}
int main(int argc, char *argv[])
@@ -724,14 +740,19 @@
time_t time_join_channel_started = (time_t)0;
time_t time_tcp_connected = (time_t)0;
int join_tries = 0;
- char *runas = NULL;
+ char *runas = NULL, *pidfile = NULL;
+ pid_t otherpid;
+
color_str[0][0] = color_str[1][0] = color_str[2][0] = color_str[3][0] = 3;
- while((c = getopt(argc, argv, "xXF:f:i:hHSs:c:Ctn:u:U:p:T:mvdVz:")) != -1)
+ while((c = getopt(argc, argv, "xXP:F:f:i:hHSs:c:Ctn:u:U:p:T:mvdVz:")) != -1)
{
switch(c)
{
+ case 'P':
+ pidfile = optarg;
+ break;
case 'z':
runas = optarg;
break;
@@ -867,6 +888,14 @@
}
}
+ pfh = pidfile_open(pidfile, 0600, &otherpid);
+ if (pfh == NULL) {
+ if (errno == EEXIST)
+ error_exit("Daemon already running, pid: %d.", otherpid);
+ /* If we cannot create pidfile from other reasons, only warn. */
+ dolog("Cannot open or create pidfile");
+ }
+
if (do_fork)
{
if (daemon(0, 0) == -1)
@@ -875,6 +904,9 @@
}
}
+ pidfile_write(pfh);
+
+
signal(SIGPIPE, SIG_IGN);
for(;;)
@@ -1056,5 +1088,6 @@
}
}
+ pidfile_remove(pfh);
return 0;
}

View File

@ -1,15 +1,14 @@
--- br.h.orig Mon Nov 27 06:21:58 2006
+++ br.h Sat Apr 28 13:45:23 2007
@@ -16,6 +16,8 @@
*
*/
--- br.h.orig 2011-01-18 05:39:10.000000000 -0500
+++ br.h 2011-05-31 22:12:14.000000000 -0400
@@ -1,5 +1,7 @@
/* (C) 2006-2010 by folkert@vanheusden.com GPLv2 applies */
+#include <sys/types.h>
+
/* code taken from linux kernel */
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
#define __builtin_expect(x, expected_value) (x)
@@ -33,7 +35,7 @@
@@ -17,7 +19,7 @@
char *buffer;
long long int buffer_length, buffer_pointer;
char *mmap_addr, *cur_offset;
@ -18,7 +17,7 @@
int number_of_bytes_in_buffer(void);
int read_into_buffer(void);
@@ -46,5 +48,5 @@
@@ -30,5 +32,5 @@
char * read_line(void);

View File

@ -7,14 +7,3 @@
+#include <sys/param.h>
+#include <libutil.h>
+#include "anna.h"
void error_exit(char *format, ...)
{
@@ -17,6 +20,7 @@
fprintf(stderr, "%s: errno=%d (if applicable)\n", buffer, errno);
syslog(LOG_ERR, "'%s': %m", buffer);
+ pidfile_remove(pfh);
exit(EXIT_FAILURE);
}