ben 98/09/19 12:15:45
Modified: apache-nspr Configuration.ben HOWTOBUILD apache-nspr/include util_script.h apache-nspr/main util.c util_script.c apache-nspr/modules/standard mod_cgi.c Log: Use new NSPR chdir API. Revive ap_chdir_file(). Revision Changes Path 1.2 +8 -2 apache-2.0/apache-nspr/Configuration.ben Index: Configuration.ben =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/Configuration.ben,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Configuration.ben 1998/09/05 16:18:55 1.1 +++ Configuration.ben 1998/09/19 19:15:42 1.2 @@ -1,7 +1,13 @@ +# WTF? Those crazy Mozilla guys seem to have hardwired it? Why? +#NSPR=/home/ben/work/mozilla/dist/FreeBSD2.2.7_DBG.OBJ +#NSPR=/home/ben/work/apache-2.0/dist/FreeBSD2.2.7_DBG.OBJ + EXTRA_CFLAGS=-Wall -Wshadow -Wmissing-prototypes -pipe -fno-common -DNSPR -EXTRA_LDFLAGS=-g -L/home/ben/work/apache-2.0/dist/FreeBSD2.2.7_DBG.OBJ/lib +EXTRA_LDFLAGS=-g -L/home/ben/work/mozilla/dist/FreeBSD2.2.7_DBG.OBJ/lib -R/home/ben/work/mozilla/dist/FreeBSD2.2.7_DBG.OBJ/lib +#EXTRA_LDFLAGS=-g -L/home/ben/work/apache-2.0/dist/FreeBSD2.2.7_DBG.OBJ/lib EXTRA_LIBS=-lnspr21 -EXTRA_INCLUDES=-I/home/ben/work/apache-2.0/dist/FreeBSD2.2.7_DBG.OBJ/include +EXTRA_INCLUDES=-I/home/ben/work/mozilla/dist/FreeBSD2.2.7_DBG.OBJ/include +#EXTRA_INCLUDES=-I/home/ben/work/apache-2.0/dist/FreeBSD2.2.7_DBG.OBJ/include CC=gcc OPTIM=-O2 -g #RANLIB= 1.2 +10 -3 apache-2.0/apache-nspr/HOWTOBUILD Index: HOWTOBUILD =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/HOWTOBUILD,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HOWTOBUILD 1998/09/05 16:18:56 1.1 +++ HOWTOBUILD 1998/09/19 19:15:42 1.2 @@ -1,11 +1,18 @@ This is a temporary note for developers during the 2.0 development process. +N.B.: The version of NSPR included in Apache 2.0 is no longer sufficient. Use +the latest version from Mozilla. + First, build nspr: + +cvs -d :pserver:[EMAIL PROTECTED]:/cvsroot co mozilla/nsprpub + +(I've forgotten the password - see http://www.mozilla.org). -cd .../apache-2.0/pubnspr -make (or gmake) +cd mozilla/nsprpub +make (or gmake) (use -DBUILD_OPT=1 to build optimised) -This produces a directory .../apache-2.0/dist/<platform>_DBG.OBJ, containing +This produces a directory .../mozilla/dist/<platform>_DBG.OBJ, containing include and lib. Tweak .../apache-2.0/apache-nspr/Configuration to reflect this path (use full pathnames). Note that Configuration.tmpl is currently bullshit - use one of Configuration.ben or Configuration.dean as a basis (note that Dean 1.3 +1 -0 apache-2.0/apache-nspr/include/util_script.h Index: util_script.h =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/include/util_script.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_script.h 1998/06/30 08:57:06 1.2 +++ util_script.h 1998/09/19 19:15:43 1.3 @@ -80,6 +80,7 @@ API_EXPORT(void) ap_send_size(size_t size, request_rec *r); API_EXPORT(PRProcess *) ap_spawn_cgi(request_rec *r, char *argv0, char **env, int shellcmd, const PRProcessAttr *); +API_EXPORT(int) ap_chdir_file_attr(PRProcessAttr *attr, const char *file); #ifdef __cplusplus } 1.3 +1 -3 apache-2.0/apache-nspr/main/util.c Index: util.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/util.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util.c 1998/06/30 08:57:08 1.2 +++ util.c 1998/09/19 19:15:44 1.3 @@ -72,6 +72,7 @@ #include "http_conf_globals.h" /* for user_id & group_id */ #include "http_log.h" +#include <unistd.h> #include <prsystem.h> /* A bunch of functions in util.c scan strings looking for certain characters. @@ -461,8 +462,6 @@ API_EXPORT(void) ap_chdir_file(const char *file) { - /* XXX: ap_chdir_file needs to be rethought for NSPR */ -#if 0 const char *x; char buf[HUGE_STRING_LEN]; @@ -477,7 +476,6 @@ } /* XXX: well, this is a silly function, no method of reporting an * error... ah well. */ -#endif } API_EXPORT(char *) ap_getword_nc(pool *atrans, char **line, char stop) 1.3 +17 -0 apache-2.0/apache-nspr/main/util_script.c Index: util_script.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/main/util_script.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util_script.c 1998/06/30 08:57:08 1.2 +++ util_script.c 1998/09/19 19:15:44 1.3 @@ -627,3 +627,20 @@ } return (pid); } + +API_EXPORT(int) ap_chdir_file_attr(PRProcessAttr *attr, const char *file) +{ + const char *x; + char buf[HUGE_STRING_LEN]; + + x = strrchr(file, '/'); + if (x == NULL) { + PR_ProcessAttrSetCurrentDirectory(attr, file); + } + else if (x - file < sizeof(buf) - 1) { + memcpy(buf, file, x - file); + buf[x - file] = '\0'; + PR_ProcessAttrSetCurrentDirectory(attr, buf); + } + return 1; /* success */ +} 1.3 +5 -4 apache-2.0/apache-nspr/modules/standard/mod_cgi.c Index: mod_cgi.c =================================================================== RCS file: /export/home/cvs/apache-2.0/apache-nspr/modules/standard/mod_cgi.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mod_cgi.c 1998/06/30 08:57:09 1.2 +++ mod_cgi.c 1998/09/19 19:15:45 1.3 @@ -362,10 +362,11 @@ } attr = PR_NewProcessAttr(); - PR_SetStdioRedirect(attr, PR_StandardInput, child_in); - PR_SetStdioRedirect(attr, PR_StandardOutput, child_out); - PR_SetStdioRedirect(attr, PR_StandardError, r->server->error_log); - /* XXX: this is where we would tell NSPR to do a chdir() in the child */ + PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, child_in); + PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, child_out); + PR_ProcessAttrSetStdioRedirect(attr, PR_StandardError, + r->server->error_log); + ap_chdir_file_attr(attr, r->filename); pid = ap_spawn_cgi(r, argv0, env, 0, attr); if (pid == NULL) {