Date: Wed, 1 Jun 2011 02:50:51 GMT From: Ryan Steinmetz <rpsfa@rit.edu> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/157488: [update] net-mgmt/nagircbot to 0.0.33 Message-ID: <201106010250.p512opVN007501@red.freebsd.org> Resent-Message-ID: <201106010300.p5130McI079288@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 157488 >Category: ports >Synopsis: [update] net-mgmt/nagircbot to 0.0.33 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Wed Jun 01 03:00:22 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Ryan Steinmetz >Release: 8.2-RELEASE >Organization: Rochester Institute of Technology >Environment: >Description: Update to 0.0.33: -improved irc protocol handling - should now be compatible with more IRC servers -link-failure fix -added SSL support and nick highlighting -one can now choose to only emit 'CRITICAL'-statuses and/or filter statusses by regular expression, nagios 3.0 fixes -now sends password before nick, as specified by irc rfc - this fixes login problems with certain irc servers -fixed a memoryleak that only occurred with Nagios 3.0 -added Nagios 3.0 support, stability fixes -added switch for letting nagircbot using a password when entering a channel, also added code which implements a keep alive >How-To-Repeat: >Fix: Patch attached with submission follows: diff -urN /usr/ports/net-mgmt/nagircbot/Makefile nagircbot/Makefile --- /usr/ports/net-mgmt/nagircbot/Makefile 2009-01-06 12:59:14.000000000 -0500 +++ nagircbot/Makefile 2011-05-31 22:03:48.000000000 -0400 @@ -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 diff -urN /usr/ports/net-mgmt/nagircbot/distinfo nagircbot/distinfo --- /usr/ports/net-mgmt/nagircbot/distinfo 2011-03-20 08:53:57.000000000 -0400 +++ nagircbot/distinfo 2011-05-31 22:04:00.000000000 -0400 @@ -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 diff -urN /usr/ports/net-mgmt/nagircbot/files/patch-Makefile nagircbot/files/patch-Makefile --- /usr/ports/net-mgmt/nagircbot/files/patch-Makefile 2007-07-06 03:15:08.000000000 -0400 +++ nagircbot/files/patch-Makefile 2011-05-31 22:07:09.000000000 -0400 @@ -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 diff -urN /usr/ports/net-mgmt/nagircbot/files/patch-anna.cpp nagircbot/files/patch-anna.cpp --- /usr/ports/net-mgmt/nagircbot/files/patch-anna.cpp 2007-07-06 03:15:08.000000000 -0400 +++ nagircbot/files/patch-anna.cpp 2011-05-31 22:45:40.000000000 -0400 @@ -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 *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; - } + 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 @@ -@@ -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; - } diff -urN /usr/ports/net-mgmt/nagircbot/files/patch-br.h nagircbot/files/patch-br.h --- /usr/ports/net-mgmt/nagircbot/files/patch-br.h 2007-07-06 03:15:08.000000000 -0400 +++ nagircbot/files/patch-br.h 2011-05-31 22:12:43.000000000 -0400 @@ -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); diff -urN /usr/ports/net-mgmt/nagircbot/files/patch-error.c nagircbot/files/patch-error.c --- /usr/ports/net-mgmt/nagircbot/files/patch-error.c 2007-07-06 03:15:08.000000000 -0400 +++ nagircbot/files/patch-error.c 2011-05-31 22:25:56.000000000 -0400 @@ -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); - } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106010250.p512opVN007501>