httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p.@sweng.stortek.com
Subject [PATCH] OS/390 vs. CGI
Date Wed, 24 Nov 1999 02:41:24 GMT
POSIX, the whole POSIX, and nothing but POSIX.  Httpd makes a couple
assumptions that are unsupported by POSIX and ANSI respectively,
and which cause cgi-bin to malfunction on OS/390.  Descriptions are
in comments in the attached patch, which I submit more for review than
as a serious candidate for integration.  I need, for example, to ponder
whether it's appropriate to use malloc(), or to learn and use ap_palloc().

-- gil
-- 
StorageTek
INFORMATION made POWERFUL
========================================================================
diff -bru orig/apache_1.3.9/src/main/util_script.c apache_1.3.9/src/main/util_script.c
--- orig/apache_1.3.9/src/main/util_script.c	Thu Aug 12 12:34:15 1999
+++ apache_1.3.9/src/main/util_script.c	Tue Nov 23 19:16:25 1999
@@ -155,18 +155,37 @@
     return res;
 }
 
+#ifdef   OS390
+/* ANSI C 4.10.4.4 states "The string pointed to ... may be modified
+ * by a subsequent call to getenv.  OS/390 does this.  Sigh.
+ */
+char *ap_getenv(char **u, const char *s)
+{
+    char *t;
+
+    if (t = getenv(s)) {
+        if (*u) free(*u);
+        *u = malloc(strlen(t)+1);
+        return strcpy(*u, t);
+    }
+    return NULL;
+}
+#else  /*OS390*/
+#define ap_getenv(u, s) getenv((s))
+#endif /*OS390*/
+
 API_EXPORT(char **) ap_create_environment(pool *p, table *t)
 {
     array_header *env_arr = ap_table_elts(t);
     table_entry *elts = (table_entry *) env_arr->elts;
     char **env = (char **) ap_palloc(p, (env_arr->nelts + 2) * sizeof(char *));
     int i, j;
-    char *tz;
+    static char *tz = NULL;
     char *whack;
 
     j = 0;
     if (!ap_table_get(t, "TZ")) {
-	tz = getenv("TZ");
+	tz = ap_getenv(&tz, "TZ");
 	if (tz != NULL) {
 	    env[j++] = ap_pstrcat(p, "TZ=", tz, NULL);
 	}
@@ -200,6 +219,7 @@
     conn_rec *c = r->connection;
     const char *rem_logname;
     char *env_path;
+    static char *path = NULL;
 #ifdef WIN32
     char *env_temp;
 #endif
@@ -250,7 +270,7 @@
 	}
     }
 
-    if (!(env_path = getenv("PATH"))) {
+    if (!(env_path = ap_getenv(&path, "PATH"))) {
 	env_path = DEFAULT_PATH;
     }
 
@@ -1125,6 +1145,15 @@
 
 	else if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) {
 	    execle(r->filename, argv0, NULL, env);
+#ifdef   OS390
+/* POSIX requires only the exec*p() forms to autoexec shell scripts.
+ * OS/390 does not extend beyond the POSIX requirement.
+ */
+            if (errno == ENOEXEC) {
+	    execle(SHELL_PATH, argv0, r->filename, NULL, env);
+                execlp(r->filename, argv0, NULL);
+            }
+#endif /*OS390*/
 	}
 
 	else {

Mime
View raw message