httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r240044 - in /httpd/httpd/trunk: CHANGES modules/generators/mod_cgid.c
Date Thu, 25 Aug 2005 11:51:29 GMT
Author: colm
Date: Thu Aug 25 04:51:24 2005
New Revision: 240044

URL: http://svn.apache.org/viewcvs?rev=240044&view=rev
Log:

Append the .PID to the ScriptSock filename. This change ensures that multiple
running instances of httpd will not clobber each others script sockets. 

Because a different socket will be created for each instance, this change also
unlinks the script-socket on exit, to prevent pollution. 

unlink() happens from within the parent process, since the change in userid's
means the cgid process likely won't have the correct permissions.


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/generators/mod_cgid.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?rev=240044&r1=240043&r2=240044&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Aug 25 04:51:24 2005
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_cgid: Append .PID to the script socket filename and remove the
+     script socket on exit. [Colm MacCarthaigh]
+
   *) prefork and worker MPM's: Prevent children from holding open listening
      ports upon graceful restart. PR28167. 
      [Colm MacCarthaigh, Brian Pinkerton <bp thinkpink.com>]

Modified: httpd/httpd/trunk/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/generators/mod_cgid.c?rev=240044&r1=240043&r2=240044&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgid.c Thu Aug 25 04:51:24 2005
@@ -268,6 +268,15 @@
              * up when pconf gets cleaned up
              */
             kill(proc->pid, SIGHUP); /* send signal to daemon telling it to die */
+
+            /* Remove the cgi socket, we must do it here in order to try and
+             * guarantee the same permissions as when the socket was created.
+             */
+            if (unlink(sockname) < 0 && errno != ENOENT) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL,
+                             "Couldn't unlink unix domain socket %s",
+                             sockname);
+            }
             break;
     }
 }
@@ -582,13 +591,6 @@
     apr_signal(SIGCHLD, SIG_IGN); 
     apr_signal(SIGHUP, daemon_signal_handler);
 
-    if (unlink(sockname) < 0 && errno != ENOENT) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
-                     "Couldn't unlink unix domain socket %s",
-                     sockname);
-        /* just a warning; don't bail out */
-    }
-
     if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
         ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server, 
                      "Couldn't create unix domain socket");
@@ -818,7 +820,8 @@
 static int cgid_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
                            apr_pool_t *ptemp)
 {
-    sockname = DEFAULT_SOCKET;
+    sockname = apr_psprintf(pconf, "%s.%" APR_PID_T_FMT, DEFAULT_SOCKET, 
+                            getpid());
     return OK;
 }
 
@@ -932,8 +935,10 @@
     if (err != NULL) {
         return err;
     }
-
-    sockname = ap_server_root_relative(cmd->pool, arg); 
+    
+    /* Make sure the pid is appended to the sockname */
+    sockname = apr_psprintf(cmd->pool, "%s.%" APR_PID_T_FMT, arg, getpid());
+    sockname = ap_server_root_relative(cmd->pool, sockname); 
 
     if (!sockname) {
         return apr_pstrcat(cmd->pool, "Invalid ScriptSock path",



Mime
View raw message