]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Attached is a patch for allowing user changes on the cygwin platform
authorJim Jagielski <jim@apache.org>
Mon, 3 Jun 2002 12:28:27 +0000 (12:28 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 3 Jun 2002 12:28:27 +0000 (12:28 +0000)
and a #define wrapper for the timeout singal we use to kill of pending
open childs that do not react on "usual" signals.

The signalling issue seems to be a problem on the Cygwin platform, but
it's abstracted, so other platforms may benefit from it. Again,
nothing else is changed in behaviour.

Changes are:

  * src/include/ap_config.h: added the system uid for Cygwin that is
the "root" user on Cygwin

  * src/main/http_main.c: some cygwin specific #defines around
setpgrp() and getuid() calls. Adding the #define SIG_TIMEOUT_KILL to
define which singal should be used to kill of timed out childs.
Defaulting to the know value for all other plaforms.

  * src/modules/proxy/proxy_cache.c: cygwin specific #define around
setpgrp()

PR:
Obtained from:
Submitted by: Stipe Tolj <tolj@wapme-systems.de>
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@95482 13f79535-47bb-0310-9956-ffa450edef68

src/include/ap_config.h
src/main/http_main.c
src/modules/proxy/proxy_cache.c

index 47ed51996115a1ed362dae979f3eba80173142b6..81a8ca5995215919bf5493855cdc60750d5474a5 100644 (file)
@@ -1003,8 +1003,10 @@ typedef int rlim_t;
 #define NEED_HASHBANG_EMUL
 
 #elif defined(CYGWIN)               /* Cygwin 1.x POSIX layer for Win32 */
+#define SYSTEM_UID 18
 #define JMP_BUF jmp_buf
 #define NO_KILLPG
+#define NO_SETSID
 #define USE_LONGJMP
 #define GDBM_STATIC
 #define HAVE_MMAP 1
index f464d43071cb7eafc1a2fe448fc4072d279a6afe..ce369c328b4fe3abfee9b8118c8df1a95a9d248c 100644 (file)
@@ -3409,6 +3409,13 @@ static void detach(void)
 #elif defined(MPE)
     /* MPE uses negative pid for process group */
     pgrp = -getpid();
+#elif defined(CYGWIN)
+    /* Cygwin does not take any argument for setpgrp() */
+    if ((pgrp = setpgrp()) == -1) {
+        perror("setpgrp");
+        fprintf(stderr, "%s: setpgrp failed\n", ap_server_argv0);
+        exit(1);
+    }
 #else
     if ((pgrp = setpgrp(getpid(), 0)) == -1) {
        perror("setpgrp");
@@ -4225,8 +4232,15 @@ static void child_main(int child_num_arg)
     }
     GETUSERMODE();
 #else
-    /* Only try to switch if we're running as root */
+    /* 
+     * Only try to switch if we're running as root
+     * In case of Cygwin we have the special super-user named SYSTEM
+     */
+#ifdef CYGWIN
+    if (getuid() == SYSTEM_UID && (
+#else
     if (!geteuid() && (
+#endif
 #ifdef _OSD_POSIX
        os_init_job_environment(server_conf, ap_user_name, one_process) != 0 || 
 #endif
@@ -4798,13 +4812,16 @@ static int hold_off_on_exponential_spawning;
  * is greater then ap_daemons_max_free. Usually we will use SIGUSR1
  * to gracefully shutdown, but unfortunatly some OS will need other 
  * signals to ensure that the child process is terminated and the 
- * scoreboard pool is not growing to infinity. This effect has been
- * seen at least on Cygwin 1.x. -- Stipe Tolj <tolj@wapme-systems.de>
+ * scoreboard pool is not growing to infinity. Also set the signal we
+ * use to kill of childs that exceed timeout. This effect has been
+* seen at least on Cygwin 1.x. -- Stipe Tolj <tolj@wapme-systems.de>
  */
 #if defined(CYGWIN)
 #define SIG_IDLE_KILL SIGKILL
+#define SIG_TIMEOUT_KILL SIGUSR2
 #else
 #define SIG_IDLE_KILL SIGUSR1
+#define SIG_TIMEOUT_KILL SIGALRM
 #endif
 
 static void perform_idle_server_maintenance(void)
@@ -4876,7 +4893,7 @@ static void perform_idle_server_maintenance(void)
                else if (ps->last_rtime + ss->timeout_len < now) {
                    /* no progress, and the timeout length has been exceeded */
                    ss->timeout_len = 0;
-                   kill(ps->pid, SIGALRM);
+                   kill(ps->pid, SIG_TIMEOUT_KILL);
                }
            }
 #endif
@@ -5492,8 +5509,16 @@ int REALMAIN(int argc, char *argv[])
        }
        GETUSERMODE();
 #else
-       /* Only try to switch if we're running as root */
+    /* 
+     * Only try to switch if we're running as root
+     * In case of Cygwin we have the special super-user named SYSTEM
+     * with a pre-defined uid.
+     */
+#ifdef CYGWIN
+    if ((getuid() == SYSTEM_UID) && setuid(ap_user_id) == -1) {
+#else
        if (!geteuid() && setuid(ap_user_id) == -1) {
+#endif
            ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf,
                        "setuid: unable to change to uid: %ld",
                        (long) ap_user_id);
@@ -7686,7 +7711,7 @@ __declspec(dllimport)
 #endif
 
 
-int ap_main(int argc, char *argv[]); /* Load time linked from libhttpd.dll */
+int ap_main(int argc, char *argv[]); /* Load time linked from cyghttpd.dll */
 
 int main(int argc, char *argv[])
 {
index 390488438c1f9fb5c8ae527f1c90d6136052835b..ff2bb0681f2aeccc6a4518a4b6cb043945f9d541 100644 (file)
@@ -248,6 +248,14 @@ static void detached_proxy_garbage_coll(request_rec *r)
                         ap_server_argv0);
                 exit(1);
             }
+#elif defined(CYGWIN)
+            /* Cygwin does not take any argument for setpgrp() */
+            if ((pgrp = setpgrp()) == -1) {
+                perror("setpgrp");
+                fprintf(stderr, "%S: setpgrp failed\n",
+                        ap_server_argv0);
+                exit(1);
+            }
 #else
             if ((pgrp = setpgrp(getpid(), 0)) == -1) {
                 perror("setpgrp");