rpms/zabbix/F-11 zabbix-1.6.8-cloexec.patch, NONE, 1.1 zabbix.spec, 1.41, 1.42

Dan Horák sharkcz at fedoraproject.org
Mon Feb 1 14:51:47 UTC 2010


Author: sharkcz

Update of /cvs/pkgs/rpms/zabbix/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18932

Modified Files:
	zabbix.spec 
Added Files:
	zabbix-1.6.8-cloexec.patch 
Log Message:
* Mon Feb  1 2010 Dan Horák <dan[at]danny.cz> - 1.6.8-2
- close fd on exec (#559221)


zabbix-1.6.8-cloexec.patch:
 zbxcomms/comms.c |   28 ++++++++++++++++++++++++----
 zbxnix/pid.c     |    6 +++++-
 2 files changed, 29 insertions(+), 5 deletions(-)

--- NEW FILE zabbix-1.6.8-cloexec.patch ---
diff -up zabbix-1.6.8/src/libs/zbxcomms/comms.c.cloexec zabbix-1.6.8/src/libs/zbxcomms/comms.c
--- zabbix-1.6.8/src/libs/zbxcomms/comms.c.cloexec	2009-12-07 13:49:44.000000000 +0100
+++ zabbix-1.6.8/src/libs/zbxcomms/comms.c	2010-02-01 14:56:41.000000000 +0100
@@ -52,6 +52,10 @@
 
 #endif /* _WINDOWS */
 
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
+
 /******************************************************************************
  *                                                                            *
  * Function: zbx_tcp_strerror                                                 *
@@ -342,11 +346,15 @@ int	zbx_tcp_connect(zbx_sock_t *s,
 		goto out;
 	}
 
-	if (ZBX_SOCK_ERROR == (s->socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol))) {
+	if (ZBX_SOCK_ERROR == (s->socket = socket(ai->ai_family, ai->ai_socktype | SOCK_CLOEXEC, ai->ai_protocol))) {
 		zbx_set_tcp_strerror("Cannot create socket [%s]:%d [%s]", ip, port ,strerror_from_system(zbx_sock_last_error()));
 		goto out;
 	}
 
+#if ! SOCK_CLOEXEC
+	fcntl(s->socket, F_SETFD, FD_CLOEXEC);
+#endif
+
 	if (NULL != source_ip)
 	{
 		memset(&hints, 0x00, sizeof(struct addrinfo));
@@ -424,11 +432,15 @@ int	zbx_tcp_connect(zbx_sock_t *s,
 	servaddr_in.sin_addr.s_addr	= ((struct in_addr *)(hp->h_addr))->s_addr;
 	servaddr_in.sin_port		= htons(port);
 
-	if (ZBX_SOCK_ERROR == (s->socket = socket(AF_INET,SOCK_STREAM,0))) {
+	if (ZBX_SOCK_ERROR == (s->socket = socket(AF_INET,SOCK_STREAM | SOCK_CLOEXEC,0))) {
 		zbx_set_tcp_strerror("Cannot create socket [%s:%d] [%s]", ip, port ,strerror_from_system(zbx_sock_last_error()));
 		return	FAIL;
 	}
 
+#if ! SOCK_CLOEXEC
+	fcntl(s->socket, F_SETFD, FD_CLOEXEC);
+#endif
+
 	if (NULL != source_ip)
 	{
 		source_addr.sin_family		= AF_INET;
@@ -610,11 +622,15 @@ int zbx_tcp_listen(
 		if((current_ai->ai_family != PF_INET) && (current_ai->ai_family != PF_INET6))
 			continue;
 
-		if((s->sockets[s->num_socks] = socket(current_ai->ai_family, current_ai->ai_socktype, current_ai->ai_protocol)) == ZBX_SOCK_ERROR) {
+		if((s->sockets[s->num_socks] = socket(current_ai->ai_family, current_ai->ai_socktype | SOCK_CLOEXEC, current_ai->ai_protocol)) == ZBX_SOCK_ERROR) {
 			zbx_set_tcp_strerror("socket() failed with error %d: %s", zbx_sock_last_error(), strerror_from_system(zbx_sock_last_error()));
 			continue;
 		}
 
+#if ! SOCK_CLOEXEC
+		fcntl(s->sockets[s->num_socks], F_SETFD, FD_CLOEXEC);
+#endif
+
 		/* Enable address reuse */
 		/* This is to immediately use the address even if it is in TIME_WAIT state */
 		/* http://www-128.ibm.com/developerworks/linux/library/l-sockpit/index.html */
@@ -665,12 +681,16 @@ int zbx_tcp_listen(
 
 	zbx_tcp_clean(s);
 
-	if(ZBX_SOCK_ERROR == (s->socket = socket(AF_INET,SOCK_STREAM,0)))
+	if(ZBX_SOCK_ERROR == (s->socket = socket(AF_INET,SOCK_STREAM | SOCK_CLOEXEC,0)))
 	{
 		zbx_set_tcp_strerror("Cannot create socket [%s:%u] [%s]", listen_ip, listen_port, strerror_from_system(zbx_sock_last_error()));
 		goto out;
 	}
 
+#if ! SOCK_CLOEXEC
+	fcntl(s->socket, F_SETFD, FD_CLOEXEC);
+#endif
+
 	/* Enable address reuse */
 	/* This is to immediately use the address even if it is in TIME_WAIT state */
 	/* http://www-128.ibm.com/developerworks/linux/library/l-sockpit/index.html */
diff -up zabbix-1.6.8/src/libs/zbxnix/pid.c.cloexec zabbix-1.6.8/src/libs/zbxnix/pid.c
--- zabbix-1.6.8/src/libs/zbxnix/pid.c.cloexec	2009-12-07 13:49:44.000000000 +0100
+++ zabbix-1.6.8/src/libs/zbxnix/pid.c	2010-02-01 13:09:11.000000000 +0100
@@ -83,7 +83,11 @@ int	create_pid_file(const char *pidfile)
 	/* lock file */
 	fdpid = fileno(fpid);
 #ifdef HAVE_FCNTL_H
-	if(-1 != fdpid) fcntl(fdpid, F_SETLK, &fl);
+	if(-1 != fdpid)
+	{
+		fcntl(fdpid, F_SETLK, &fl);
+		fcntl(fdpid, F_SETFD, FD_CLOEXEC);
+	}
 #else
 	if(-1 != fdpid) flock(fdpid, LOCK_EX);
 #endif /* HAVE_FCNTL_H */


Index: zabbix.spec
===================================================================
RCS file: /cvs/pkgs/rpms/zabbix/F-11/zabbix.spec,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -p -r1.41 -r1.42
--- zabbix.spec	31 Dec 2009 17:19:53 -0000	1.41
+++ zabbix.spec	1 Feb 2010 14:51:47 -0000	1.42
@@ -7,7 +7,7 @@
 
 Name:           zabbix
 Version:        1.6.8
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Open-source monitoring solution for your IT infrastructure
 
 Group:          Applications/Internet
@@ -21,6 +21,8 @@ Source4:        zabbix-proxy.init
 Source5:        zabbix-logrotate.in
 # local rules for config files
 Patch0:         zabbix-1.6.4-web-config.patch
+# close fd on exec - https://bugzilla.redhat.com/show_bug.cgi?id=559221
+Patch1:         zabbix-1.6.8-cloexec.patch
 
 Buildroot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -235,6 +237,7 @@ Zabbix web frontend for SQLite
 %prep
 %setup0 -q
 %patch0 -p1
+%patch1 -p1 -b .cloexec
 
 chmod -R a+rX .
 
@@ -549,6 +552,9 @@ fi
 
 
 %changelog
+* Mon Feb  1 2010 Dan Horák <dan[at]danny.cz> - 1.6.8-2
+- close fd on exec (#559221)
+
 * Thu Dec 31 2009 Dan Horák <dan[at]danny.cz> - 1.6.8-1
 - Update to 1.6.8
 - Upstream changelog: http://www.zabbix.com/rn1.6.8.php



More information about the scm-commits mailing list