jfclere 2002/11/21 08:23:59 Modified: jk/native2/common jk_channel_socket.c jk_channel_un.c jk_logger_file.c Log: Add FD_CLOEXEC to prevent log file and sockets beeing opened in a son process. Submitted by Martin Kraemer. Revision Changes Path 1.45 +5 -0 jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c Index: jk_channel_socket.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- jk_channel_socket.c 7 Nov 2002 16:46:28 -0000 1.44 +++ jk_channel_socket.c 21 Nov 2002 16:23:59 -0000 1.45 @@ -364,6 +364,11 @@ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,(char *)&set,sizeof(set)); } +#if defined(F_SETFD) && defined(FD_CLOEXEC) + /* Protect the socket so that it will not be inherited by child processes */ + fcntl(sock, F_SETFD, FD_CLOEXEC); +#endif + if( ch->mbean->debug > 0 ) env->l->jkLog(env, env->l, JK_LOG_DEBUG, "channelSocket.connect(), sock = %d\n", sock); 1.14 +6 -0 jakarta-tomcat-connectors/jk/native2/common/jk_channel_un.c Index: jk_channel_un.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_un.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- jk_channel_un.c 8 Jul 2002 13:41:13 -0000 1.13 +++ jk_channel_un.c 21 Nov 2002 16:23:59 -0000 1.14 @@ -79,6 +79,7 @@ #include "jk_global.h" #include <string.h> +#include <fcntl.h> #include "jk_registry.h" #ifdef HAVE_UNIXSOCKETS @@ -275,6 +276,11 @@ return JK_ERR; } } + +#if defined(F_SETFD) && defined(FD_CLOEXEC) + /* Protect the socket so that it will not be inherited by child processes */ + fcntl(unixsock, F_SETFD, FD_CLOEXEC); +#endif if( ch->mbean->debug > 0 ) env->l->jkLog(env, env->l, JK_LOG_DEBUG, 1.36 +8 -1 jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c Index: jk_logger_file.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- jk_logger_file.c 4 Oct 2002 16:08:19 -0000 1.35 +++ jk_logger_file.c 21 Nov 2002 16:23:59 -0000 1.36 @@ -67,6 +67,7 @@ #include "jk_map.h" #include "jk_logger.h" #include <stdio.h> +#include <fcntl.h> #include "jk_registry.h" @@ -172,6 +173,12 @@ "Can't open log file %s\n", _this->name ); return JK_ERR; } +#if defined(F_SETFD) && defined(FD_CLOEXEC) + /* Protect the log file + * so that it will not be inherited by child processes + */ + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); +#endif _this->logger_private = f; } _this->jkLog(env, _this,JK_LOG_INFO,
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>