Attached is a patch for allowing user changes on the cygwin platform
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()
Please review and apply to cvs if suitable. Thanks in advance.
Stipe
[EMAIL PROTECTED]
-------------------------------------------------------------------
Wapme Systems AG
M�nsterstr. 248
40470 D�sseldorf
Tel: +49-211-74845-0
Fax: +49-211-74845-299
E-Mail: [EMAIL PROTECTED]
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are
diff -ur apache-1.3/src/include/ap_config.h apache-1.3-cygwin/src/include/ap_config.h
--- apache-1.3/src/include/ap_config.h Wed Mar 13 20:05:29 2002
+++ apache-1.3-cygwin/src/include/ap_config.h Tue May 28 11:15:10 2002
@@ -1003,8 +1003,10 @@
#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
diff -ur apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c
--- apache-1.3/src/main/http_main.c Mon May 27 17:39:24 2002
+++ apache-1.3-cygwin/src/main/http_main.c Tue May 28 11:15:10 2002
@@ -3409,6 +3409,13 @@
#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 @@
}
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 @@
* 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 <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
*/
#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 @@
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 @@
}
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 @@
#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[])
{
diff -ur apache-1.3/src/modules/proxy/proxy_cache.c
apache-1.3-cygwin/src/modules/proxy/proxy_cache.c
--- apache-1.3/src/modules/proxy/proxy_cache.c Fri Apr 12 12:34:46 2002
+++ apache-1.3-cygwin/src/modules/proxy/proxy_cache.c Tue May 28 11:15:10 2002
@@ -248,6 +248,14 @@
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");