[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mailman-cvs
Subject:    [Mailman-checkins] CVS: mailman/src common.c,1.23,1.24
From:       Barry Warsaw <bwarsaw () users ! sourceforge ! net>
Date:       2000-09-27 20:02:10
[Download RAW message or body]

Update of /cvsroot/mailman/mailman/src
In directory slayer.i.sourceforge.net:/tmp/cvs-serv11800

Modified Files:
	common.c 
Log Message:
run_script(): Generalize the filtering out of environment variables.
We now discard $PYTHONHOME and $PATH as well as the previously
discarded $PYTHONPATH (which we later hand craft).  Just a bit of
extra paranoia.


Index: common.c
===================================================================
RCS file: /cvsroot/mailman/mailman/src/common.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** common.c	2000/08/02 03:22:37	1.23
--- common.c	2000/09/27 20:02:07	1.24
***************
*** 132,135 ****
--- 132,148 ----
  
  
+ /* list of environment variables which are removed from the given
+  * environment.  Some may or may not be hand crafted and passed into
+  * the execv'd environment.
+  */
+ static char* killenvars[] = {
+ 	"PYTHONPATH=",
+ 	"PYTHONHOME=",
+ 	"PATH=",
+ 	NULL
+ };
+     
+ 
+ 
  /* Run a Python script out of the script directory
   *
***************
*** 148,152 ****
  	char** newenv;
  	char** newargv;
!     
  	/* We need to set the real gid to the effective gid because there are
  	 * some Linux systems which do not preserve the effective gid across
--- 161,165 ----
  	char** newenv;
  	char** newargv;
! 
  	/* We need to set the real gid to the effective gid because there are
  	 * some Linux systems which do not preserve the effective gid across
***************
*** 179,188 ****
  	newenv = (char**)malloc(sizeof(char*) * (envcnt + 2));
  
! 	/* filter out any existing PYTHONPATH in the environment */
! 	for (i = 0, j = 0; i < envcnt; i++)
! 		if (strncmp(envstr, env[i], envlen)) {
! 			newenv[j] = env[i];
! 			j++;
  		}
  
  	/* Tack on our own version of PYTHONPATH, which should contain only
--- 192,209 ----
  	newenv = (char**)malloc(sizeof(char*) * (envcnt + 2));
  
! 	/* filter out any troublesome environment variables */
! 	for (i = 0, j = 0; i < envcnt; i++) {
! 		char** k = &killenvars[0];
! 		int keep = 1;
! 		while (*k) {
! 			if (!strncmp(*k, env[i], strlen(*k))) {
! 				keep = 0;
! 				break;
! 			}
! 			*k++;
  		}
+ 		if (keep)
+ 			newenv[j++] = env[i];
+ 	}
  
  	/* Tack on our own version of PYTHONPATH, which should contain only


_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
http://www.python.org/mailman/listinfo/mailman-checkins

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic