[Nagios-devel] [PATCH] ipv6 patch for nrpe
Posted: Mon May 02, 2011 2:33 pm
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi,
We have prepared attached patch that allows nrpe & check_nrpe to support
ipv6 and it also add a '-b' commandline argument to select the source add=
ress.
It has been running here for a few weeks now so it seems it's pretty stab=
le.
Most of the code is 'inspired' by openssh, so you may find similarities.
It has successfully been compiled on a number of Linux distros, as well a=
s a
recent version of FreeBSD.
I have seen the post from Kristian Lyngst=F8l in March last only today, s=
o
we may be doing the same thing. As Kristian seems to be more ambitious
than I am to clean up the code, maybe this patch can help to get the serv=
er-
part in place en to get it upstream some day.
In the mean time this patch adds ipv6 capabilities to nrpe & check_nrpe
for anyone who has an interest in it.
--=20
Leo Baltus, internetbeheerder /\
NPO ICT Internet Services /NPO/\
Sumatralaan 45, 1217 GP Hilversum, Filmcentrum, west \ /\/
[email protected], 035-6773555 \/
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="nrpe-2.12-bind-ipv6.patch"
diff -ruN nrpe-2.12.org/include/utils.h nrpe-2.12/include/utils.h
--- nrpe-2.12.org/include/utils.h 2006-12-12 03:04:00.000000000 +0100
+++ nrpe-2.12/include/utils.h 2011-04-13 12:09:35.879689827 +0200
@@ -41,9 +41,9 @@
void randomize_buffer(char *,int);
int my_tcp_connect(char *,int,int *);
-int my_connect(char *,int,int *,char *);
+int my_connect(const char *host, struct sockaddr_storage * hostaddr, u_short port, int address_family, const char *bind_address);
-int my_inet_aton(register const char *,struct in_addr *);
+void add_listen_addr(struct addrinfo **listen_addrs, int address_family, char *addr, int port);
void strip(char *);
diff -ruN nrpe-2.12.org/src/check_nrpe.c nrpe-2.12/src/check_nrpe.c
--- nrpe-2.12.org/src/check_nrpe.c 2008-03-10 22:04:43.000000000 +0100
+++ nrpe-2.12/src/check_nrpe.c 2011-04-13 10:40:08.646591612 +0200
@@ -24,8 +24,11 @@
#define DEFAULT_NRPE_COMMAND "_NRPE_CHECK" /* check version of NRPE daemon */
-int server_port=DEFAULT_SERVER_PORT;
+u_short server_port=DEFAULT_SERVER_PORT;
char *server_name=NULL;
+char *bind_address=NULL;
+struct sockaddr_storage hostaddr;
+int address_family=AF_UNSPEC;
char *command_name=NULL;
int socket_timeout=DEFAULT_SOCKET_TIMEOUT;
int timeout_return_code=STATE_CRITICAL;
@@ -38,7 +41,6 @@
int show_version=FALSE;
#ifdef HAVE_SSL
-SSL_METHOD *meth;
SSL_CTX *ctx;
SSL *ssl;
int use_ssl=TRUE;
@@ -84,12 +86,15 @@
if(result!=OK || show_help==TRUE){
- printf("Usage: check_nrpe -H [-n] [-u] [-p ] [-t ] [-c ] [-a ]\n");
+ printf("Usage: check_nrpe -H [ -b ] [-4] [-6] [-n] [-u] [-p ] [-t ] [-c ] [-a ]\n");
printf("\n");
printf("Options:\n");
printf(" -n = Do no use SSL\n");
printf(" -u = Make socket timeouts return an UNKNOWN state instead of CRITICAL\n");
- printf(" = The address of the host running the NRPE daemon\n");
+ printf(" = The address of the NRPE daemon\n");
+ printf(" = bind to local address\n");
+ printf(" -4 = user ipv4 only\n");
+ printf(" -6 = user ipv6 only\n");
printf(" [port] = The port on which the daemon is running (default=%d)\n",DEFAULT_SERVER_PORT);
printf(" [timeout] = Number of seconds before connection times out (default=%d)\n",DEFAULT_SOCKET_TIMEOUT);
printf(" [command] = The name of the command that the remote daemon should run\n");
@@ -123,9 +128,8 @@
if(use_ssl==TRUE){
SSL_library_init();
SSLeay_add_ssl_algorithms();
- meth=SSLv23_client_method();
SSL_load_error_strings();
- if((ctx=SSL_CTX_new(meth))==NULL){
+ if((ctx=SSL_CTX_new(SSLv23_client_method()))==NULL){
printf("CHECK_NRPE: Error - could not create SSL context.\n");
exit(STATE_CRITICAL);
}
@@ -143,7 +147,10
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]