diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-09-20 07:22:31 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-09-20 07:22:31 +0000 |
| commit | 40eefc99771470ab8b9d33e2d75eb3874e2148a4 (patch) | |
| tree | f03e41ff6d5df31064ce7553e11e3d09960f288d /include/security.c | |
| parent | 3a57d012db94da6692a2f031ed5118c4336f853d (diff) | |
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@2065 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include/security.c')
| -rw-r--r-- | include/security.c | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/include/security.c b/include/security.c deleted file mode 100644 index 49a32301..00000000 --- a/include/security.c +++ /dev/null @@ -1,99 +0,0 @@ -/* -** ZABBIX -** Copyright (C) 2000-2005 SIA Zabbix -** -** 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 <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -#include <string.h> - -#include <errno.h> - -/* config.h is required for socklen_t (undefined under Solaris) */ -#include "config.h" -#include "common.h" -#include "log.h" - -/****************************************************************************** - * * - * Function: check_security * - * * - * Purpose: check if connection initiator is in list of IP addresses * - * * - * Parameters: sockfd - socker descriptor * - * ip_list - comma-delimited list of IP addresses * - * allow_if_empty - allow connection if no IP given * - * * - * Return value: SUCCEED - connection allowed * - * FAIL - connection is not allowed * - * * - * Author: Alexei Vladishev * - * * - * Comments: * - * * - ******************************************************************************/ -int check_security(int sockfd, char *ip_list, int allow_if_empty) -{ - char *sname; - struct sockaddr_in name; - int i; - char *s; - - char tmp[MAX_STRING_LEN]; - - zabbix_log( LOG_LEVEL_DEBUG, "In check_security()"); - - if( (1 == allow_if_empty) && (strlen(ip_list)==0) ) - { - return SUCCEED; - } - - i=sizeof(name); - -/* if(getpeername(sockfd, (struct sockaddr *)&name, (size_t *)&i) == 0)*/ - if(getpeername(sockfd, (struct sockaddr *)&name, (socklen_t *)&i) == 0) - { - i=sizeof(struct sockaddr_in); - - sname=inet_ntoa(name.sin_addr); - - zabbix_log( LOG_LEVEL_DEBUG, "Connection from [%s]. Allowed servers [%s] ",sname, ip_list); - - strscpy(tmp,ip_list); - s=(char *)strtok(tmp,","); - while(s!=NULL) - { - if(strcmp(sname, s)==0) - { - return SUCCEED; - } - s=(char *)strtok(NULL,","); - } - } - else - { - zabbix_log( LOG_LEVEL_WARNING, "Error getpeername [%s]",strerror(errno)); - zabbix_log( LOG_LEVEL_WARNING, "Connection rejected"); - return FAIL; - } - zabbix_log( LOG_LEVEL_WARNING, "Connection from [%s] rejected. Allowed server is [%s] ",sname, ip_list); - return FAIL; -} |
