Imported Upstream version 2.15

This commit is contained in:
Mario Fetka
2016-06-24 12:21:25 +02:00
commit 1efb03f433
44 changed files with 20140 additions and 0 deletions

70
include/acl.h Normal file
View File

@@ -0,0 +1,70 @@
/*-
* acl.c - header file for acl.c
* Copyright (c) 2011 Kaspersky Lab ZAO
* Last Modified: 08-10-2011 by Konstantin Malov with Oleg Koreshkov's help
*
* License: GPL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef ACL_H_INCLUDED
#define ACL_H_INCLUDED 1
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <netdb.h>
#include <syslog.h>
#include <stdarg.h>
#define CHAR_TO_NUMBER(c) ((c) - '0')
struct ip_acl {
int family;
struct in_addr addr;
struct in_addr mask;
struct in6_addr addr6;
struct in6_addr mask6;
struct ip_acl *next;
};
struct dns_acl {
char domain[255];
struct dns_acl *next;
};
/* Poiters to head ACL structs */
static struct ip_acl *ip_acl_head, *ip_acl_prev;
static struct dns_acl *dns_acl_head, *dns_acl_prev;
/* Functions */
void parse_allowed_hosts(char *allowed_hosts);
int add_ipv4_to_acl(char *ipv4);
int add_ipv6_to_acl(char *ipv6);
int add_domain_to_acl(char *domain);
//int is_an_allowed_host(struct in_addr);
int is_an_allowed_host(int, void *);
unsigned int prefix_from_mask(struct in_addr mask);
void show_acl_lists(void);
#endif /* ACL_H_INCLUDED */

92
include/common.h Normal file
View File

@@ -0,0 +1,92 @@
/************************************************************************
*
* COMMON.H - NRPE Common Include File
* Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
* Last Modified: 09-06-2013
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************/
#include "config.h"
#define PROGRAM_VERSION "2.15"
#define MODIFICATION_DATE "09-06-2013"
#define OK 0
#define ERROR -1
#define TRUE 1
#define FALSE 0
#define STATE_UNKNOWN 3 /* service state return codes */
#define STATE_CRITICAL 2
#define STATE_WARNING 1
#define STATE_OK 0
#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */
#define DEFAULT_CONNECTION_TIMEOUT 300 /* timeout if daemon is waiting for connection more than this time */
#define MAX_INPUT_BUFFER 2048 /* max size of most buffers we use */
#define MAX_FILENAME_LENGTH 256
#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */
#define NRPE_HELLO_COMMAND "_NRPE_CHECK"
#define MAX_COMMAND_ARGUMENTS 16
/**************** PACKET STRUCTURE DEFINITION **********/
#define QUERY_PACKET 1 /* id code for a packet containing a query */
#define RESPONSE_PACKET 2 /* id code for a packet containing a response */
#define NRPE_PACKET_VERSION_3 3 /* packet version identifier */
#define NRPE_PACKET_VERSION_2 2
#define NRPE_PACKET_VERSION_1 1 /* older packet version identifiers (no longer supported) */
#define MAX_PACKETBUFFER_LENGTH 1024 /* max amount of data we'll send in one query/response */
typedef struct packet_struct{
int16_t packet_version;
int16_t packet_type;
u_int32_t crc32_value;
int16_t result_code;
char buffer[MAX_PACKETBUFFER_LENGTH];
}packet;
/**************** OPERATING SYSTEM SPECIFIC DEFINITIONS **********/
#if defined(__sun) || defined(__hpux)
# ifndef LOG_AUTHPRIV
# define LOG_AUTHPRIV LOG_AUTH
# endif
# ifndef LOG_FTP
# define LOG_FTP LOG_DAEMON
# endif
#elif _AIX
# include <sys/select.h>
# ifndef LOG_FTP
# define LOG_FTP LOG_DAEMON
# endif
#endif

263
include/config.h.in Normal file
View File

@@ -0,0 +1,263 @@
/************************************************************************
*
* NRPE Common Header File
* Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
* Last Modified: 11-23-2007
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************/
#ifndef _CONFIG_H
#define _CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#define DEFAULT_SERVER_PORT @nrpe_port@ /* default port to use */
#define NRPE_LOG_FACILITY @log_facility@
#undef ENABLE_COMMAND_ARGUMENTS
#undef ENABLE_BASH_COMMAND_SUBSTITUTION
#undef socklen_t
#undef HAVE_GETOPT_LONG
#undef HAVE_LIBWRAP
#undef STDC_HEADERS
#undef HAVE_STRDUP
#undef HAVE_STRSTR
#undef HAVE_STRTOUL
#undef HAVE_INITGROUPS
#undef HAVE_CLOSESOCKET
#undef SIZEOF_INT
#undef SIZEOF_SHORT
#undef SIZEOF_LONG
/* stupid stuff for u_int32_t */
#undef U_INT32_T_IS_USHORT
#undef U_INT32_T_IS_UINT
#undef U_INT32_T_IS_ULONG
#undef U_INT32_T_IS_UINT32_T
#ifdef U_INT32_T_IS_USHORT
typedef unsigned short u_int32_t;
#endif
#ifdef U_INT32_T_IS_ULONG
typedef unsigned long u_int32_t;
#endif
#ifdef U_INT32_T_IS_UINT
typedef unsigned int u_int32_t;
#endif
#ifdef U_INT32_T_IS_UINT32_t
typedef uint32_t u_int32_t;
#endif
/* stupid stuff for int32_t */
#undef INT32_T_IS_SHORT
#undef INT32_T_IS_INT
#undef INT32_T_IS_LONG
#ifdef INT32_T_IS_USHORT
typedef short int32_t;
#endif
#ifdef INT32_T_IS_ULONG
typedef long int32_t;
#endif
#ifdef INT32_T_IS_UINT
typedef int int32_t;
#endif
/***** ASPRINTF() AND FRIENDS *****/
#undef HAVE_VSNPRINTF
#undef HAVE_SNPRINTF
#undef HAVE_ASPRINTF
#undef HAVE_VASPRINTF
#undef HAVE_C99_VSNPRINTF
#undef HAVE_VA_COPY
#undef HAVE___VA_COPY
#define SOCKET_SIZE_TYPE ""
#define GETGROUPS_T ""
#define RETSIGTYPE ""
#undef HAVE_GETOPT_H
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#undef HAVE_STRINGS_H
#undef HAVE_STRING_H
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_STRINGS_H
#include <string.h>
#endif
#undef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#undef HAVE_SIGNAL_H
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#undef HAVE_SYSLOG_H
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#undef HAVE_SYS_STAT_H
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#undef HAVE_FCNTL_H
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#undef HAVE_SYS_TYPES_H
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#undef HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
#undef HAVE_ERRNO_H
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
/* needed for the time_t structures we use later... */
#undef TIME_WITH_SYS_TIME
#undef HAVE_SYS_TIME_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
#undef HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
/* Define to 'int' if <sys/socket.h> does not define */
#undef socklen_t
#undef HAVE_SOCKET_H
#ifdef HAVE_SOCKET_H
#include <socket.h>
#endif
#undef HAVE_TCPD_H
#ifdef HAVE_TCPD_H
#include <tcpd.h>
#endif
#undef HAVE_NETINET_IN_H
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#undef HAVE_ARPA_INET_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#undef HAVE_NETDB_H
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#undef HAVE_CTYPE_H
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#undef HAVE_PWD_H
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#undef HAVE_GRP_H
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#undef HAVE_DIRENT_H
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#undef HAVE_SSL
#ifdef HAVE_SSL
#include <rsa.h>
#include <crypto.h>
#include <dh.h>
#include <pem.h>
#include <ssl.h>
#include <err.h>
#include <rand.h>
#endif
#undef HAVE_KRB5_H
#ifdef HAVE_KRB5_H
#include <krb5.h>
#endif
#undef HAVE_INTTYPES_H
#undef HAVE_STDINT_H
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#else
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#endif
#endif

25
include/dh.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef HEADER_DH_H
#include <openssl/dh.h>
#endif
DH *get_dh512()
{
static unsigned char dh512_p[]={
0xDA,0xD8,0xF0,0xA2,0x9A,0x64,0xC2,0x9F,0x22,0x9D,0x47,0xA1,
0xB2,0xED,0xD6,0x89,0xB5,0x46,0x6D,0x4E,0x1F,0x14,0xF4,0xF4,
0xEB,0xCA,0x4D,0x41,0x89,0x60,0x0D,0x1F,0xB3,0x50,0xC4,0x54,
0xE1,0x60,0xB5,0xDD,0x57,0x0C,0xF9,0xF5,0x19,0x73,0x6C,0x0C,
0x45,0x33,0xA9,0xC1,0xD7,0xF3,0x27,0x68,0xEE,0xDA,0x8C,0x4A,
0x1C,0x52,0xA1,0x9B,
};
static unsigned char dh512_g[]={
0x02,
};
DH *dh;
if ((dh=DH_new()) == NULL) return(NULL);
dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
if ((dh->p == NULL) || (dh->g == NULL))
{ DH_free(dh); return(NULL); }
return(dh);
}

65
include/nrpe.h Normal file
View File

@@ -0,0 +1,65 @@
/************************************************************************
*
* NRPE.H - NRPE Include File
* Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
* Last Modified: 08-10-2011 by Konstantin Malov
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
************************************************************************/
/*
* 08-10-2011 IPv4 subnetworks support added.
* Main change in nrpe.c is that is_an_allowed_host() moved to acl.c
*
*/
/**************** COMMAND STRUCTURE DEFINITION **********/
typedef struct command_struct{
char *command_name;
char *command_line;
struct command_struct *next;
}command;
int process_arguments(int,char **);
void wait_for_connections(void);
void handle_connection(int);
int read_config_file(char *);
int read_config_dir(char *);
int get_log_facility(char *);
int add_command(char *,char *);
command *find_command(char *);
void sighandler(int);
int drop_privileges(char *,char *);
int check_privileges(void);
int write_pid_file(void);
int remove_pid_file(void);
void free_memory(void);
int validate_request(packet *);
int contains_nasty_metachars(char *);
int process_macros(char *,char *,int);
int my_system(char *,int,int *,char *,int); /* executes a command via popen(), but also protects against timeouts */
void my_system_sighandler(int); /* handles timeouts when executing commands via my_system() */
void my_connection_sighandler(int); /* handles timeouts of connection */
void sighandler(int);
void child_sighandler(int);

63
include/utils.h Normal file
View File

@@ -0,0 +1,63 @@
/************************************************************************************************
*
* UTILS.H - NRPE Utilities Include File
*
* License: GPL
* Copyright (c) 1999-2006 Ethan Galstad (nagios@nagios.org)
*
* Last Modified: 12-11-2006
*
* Description:
*
* This file contains common include files and function definitions used in many of the plugins.
*
* License Information:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
************************************************************************************************/
#ifndef _UTILS_H
#define _UTILS_H
#include "../include/config.h"
void generate_crc32_table(void);
unsigned long calculate_crc32(char *, int);
void randomize_buffer(char *,int);
int my_tcp_connect(char *,int,int *);
int my_connect(const char *, struct sockaddr_storage *, u_short, int,
const char *);
void add_listen_addr(struct addrinfo **, int, char *, int);
void strip(char *);
int sendall(int,char *,int *);
int recvall(int,char *,int *,int);
char *my_strsep(char **,const char *);
void display_license(void);
#endif