randy 96/07/21 13:03:51
Modified: src mod_cgi.c mod_include.c util_script.c
util_script.h
Log:
Centralize exec() functionality.
Reviewed by: Robert Thau, Ben Laurie
Revision Changes Path
1.11 +1 -42 apache/src/mod_cgi.c
Index: mod_cgi.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_cgi.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C3 -r1.10 -r1.11
*** mod_cgi.c 1996/06/17 20:43:47 1.10
--- mod_cgi.c 1996/07/21 20:03:42 1.11
***************
*** 144,191 ****
cleanup_for_exec();
! #ifdef __EMX__
! if((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0)) {
! int emxloop;
! char *emxtemp;
!
! /* For OS/2 place the variables in the current
! enviornment then it will be inherited. This way
! the program will also get all of OS/2's other SETs. */
! for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
! putenv(emxtemp);
!
! if (strstr(strupr(r->filename), ".CMD") > 0) {
! /* Special case to allow use of REXX commands as scripts. */
! os2pathname(r->filename);
! execl("CMD.EXE", "CMD.EXE", "/C", r->filename, NULL);
! } else {
! execl(r->filename, argv0, NULL);
! }
! } else {
! int emxloop;
! char *emxtemp;
!
! /* For OS/2 place the variables in the current
! enviornment then it will be inherited. This way
! the program will also get all of OS/2's other SETs. */
! for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
! putenv(emxtemp);
!
! if (strstr(strupr(r->filename), ".CMD") > 0) {
! /* Special case to allow use of REXX commands as scripts. */
! os2pathname(r->filename);
! execv("CMD.EXE", create_argv_cmd(r->pool, argv0, r->args,
r->filename));
! } else {
! execv(r->filename, create_argv(r->pool, argv0, r->args));
! }
! }
! #else
! if((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0))
! execle(r->filename, argv0, NULL, env);
! else
! execve(r->filename, create_argv(r->pool, argv0, r->args), env);
! #endif
/* Uh oh. Still here. Where's the kaboom? There was supposed to be an
* EARTH-shattering kaboom!
--- 144,150 ----
cleanup_for_exec();
! call_exec(r, argv0, env, 0);
/* Uh oh. Still here. Where's the kaboom? There was supposed to be an
* EARTH-shattering kaboom!
1.10 +2 -2 apache/src/mod_include.c
Index: mod_include.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_include.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C3 -r1.9 -r1.10
*** mod_include.c 1996/06/07 21:15:33 1.9
--- mod_include.c 1996/07/21 20:03:43 1.10
***************
*** 479,486 ****
fprintf (dbg, "Attempting to exec '%s'\n", s);
#endif
cleanup_for_exec();
! execle(SHELL_PATH, SHELL_PATH, "-c", s, NULL,
! create_environment (r->pool, env));
/* Oh, drat. We're still here. The log file descriptors are closed,
* so we have to whimper a complaint onto stderr...
--- 479,486 ----
fprintf (dbg, "Attempting to exec '%s'\n", s);
#endif
cleanup_for_exec();
! /* set shellcmd flag to pass arg to SHELL_PATH */
! call_exec(r, s, create_environment (r->pool, env), 1);
/* Oh, drat. We're still here. The log file descriptors are closed,
* so we have to whimper a complaint onto stderr...
1.13 +88 -0 apache/src/util_script.c
Index: util_script.c
===================================================================
RCS file: /export/home/cvs/apache/src/util_script.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C3 -r1.12 -r1.13
*** util_script.c 1996/06/03 12:04:20 1.12
--- util_script.c 1996/07/21 20:03:45 1.13
***************
*** 362,364 ****
--- 362,452 ----
}
#endif
+
+ void call_exec (request_rec *r, char *argv0, char **env, int shellcmd)
+ {
+
+ #ifdef RLIMIT_CPU
+ struct rlimit cpulim = { 9, 10 };
+ #endif
+
+ #ifdef RLIMIT_DATA
+ struct rlimit datalim = { 2000000, 2500000 };
+ #endif
+
+ #ifdef RLIMIT_NPROC
+ struct rlimit proclim = { 20, 40 };
+ #endif
+
+ #ifdef RLIMIT_VMEM
+ struct rlimit vmlim = { 2000000, 2500000 };
+ #endif
+
+ #ifdef RLIMIT_CPU
+ setrlimit (RLIMIT_CPU, &cpulim);
+ #endif
+
+ #ifdef RLIMIT_DATA
+ setrlimit (RLIMIT_DATA, &datalim);
+ #endif
+
+ #ifdef RLIMIT_NPROC
+ setrlimit (RLIMIT_NPROC, &proclim);
+ #endif
+
+ #ifdef RLIMIT_VMEM
+ setrlimit (RLIMIT_VMEM, &vmlim);
+ #endif
+
+
+ #ifdef __EMX__
+ if ((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0)) {
+ int emxloop;
+ char *emxtemp;
+
+ /* For OS/2 place the variables in the current
+ enviornment then it will be inherited. This way
+ the program will also get all of OS/2's other SETs. */
+ for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
+ putenv(emxtemp);
+
+ if (strstr(strupr(r->filename), ".CMD") > 0) {
+ /* Special case to allow use of REXX commands as scripts. */
+ os2pathname(r->filename);
+ execl("CMD.EXE", "CMD.EXE", "/C", r->filename, NULL);
+ }
+ else {
+ execl(r->filename, argv0, NULL);
+ }
+ }
+ else {
+ int emxloop;
+ char *emxtemp;
+
+ /* For OS/2 place the variables in the current
+ enviornment then it will be inherited. This way
+ the program will also get all of OS/2's other SETs. */
+ for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
+ putenv(emxtemp);
+
+ if (strstr(strupr(r->filename), ".CMD") > 0) {
+ /* Special case to allow use of REXX commands as scripts. */
+ os2pathname(r->filename);
+ execv("CMD.EXE", create_argv_cmd(r->pool, argv0, r->args,
r->filename));
+ }
+ else
+ execv(r->filename, create_argv(r->pool, argv0, r->args));
+ }
+ #else
+
+ if (shellcmd)
+ execle(SHELL_PATH, SHELL_PATH, "-c", argv0, NULL, env);
+
+ else if((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0))
+ execle(r->filename, argv0, NULL, env);
+
+ else
+ execve(r->filename, create_argv(r->pool, argv0, r->args), env);
+
+ #endif
+ }
1.4 +1 -0 apache/src/util_script.h
Index: util_script.h
===================================================================
RCS file: /export/home/cvs/apache/src/util_script.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C3 -r1.3 -r1.4
*** util_script.h 1996/03/01 02:50:55 1.3
--- util_script.h 1996/07/21 20:03:46 1.4
***************
*** 61,64 ****
--- 61,65 ----
void add_common_vars(request_rec *r);
int scan_script_header(request_rec *r, FILE *f);
void send_size(size_t size, request_rec *r);
+ void call_exec (request_rec *r, char *argv0, char **env, int shellcmd);