cvs commit: ALFS/nALFS/src/handlers stage.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Mon Nov 3 06:28:14 PST 2003


kpfleming    03/11/03 07:28:14

  Modified:    nALFS/src/handlers stage.c
  Log:
  make <stageinfo> handling conform to DTD specification: process <root>, then <user>, then <environment>
  clear environment after successful chroot() (again according to DTD specification)
  
  Revision  Changes    Path
  1.8       +24 -16    ALFS/nALFS/src/handlers/stage.c
  
  Index: stage.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/stage.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- stage.c	30 Oct 2003 05:45:35 -0000	1.7
  +++ stage.c	3 Nov 2003 14:28:14 -0000	1.8
  @@ -46,6 +46,8 @@
   #include "nalfs-core.h"
   #include "backend.h"
   
  +extern char **environ;
  +
   
   static INLINE int set_supplementary_groups(const char *user, gid_t gid)
   {
  @@ -288,36 +290,42 @@
   	if (pid == 0) { /* Child. */
   		Start_receiving_sigio();
   
  -		if (environment_el) {
  -			set_environment(environment_el);
  -		}
  -
  -		if (user) {
  -			Nprint_h("Changing to user \"%s\".", user);
  -
  -			if (change_to_user(user) == -1) {
  -				xfree(user);
  -				xfree(root);
  -				exit(EXIT_FAILURE);
  -			}
  -
  -			xfree(user);
  -		}
  -
   		if (root) {
   			Nprint_h("Changing root directory to \"%s\".", root);
   
   			if (change_current_dir(root)) {
  +				xfree(user);
   				xfree(root);
   				exit(EXIT_FAILURE);
   			}
   			if (chroot(root)) {
   				Nprint_h_err("    %s", strerror(errno));
  +				xfree(user);
   				xfree(root);
   				exit(EXIT_FAILURE);
   			}
   
   			xfree(root);
  +
  +			/* clear the environment after successful chroot */
  +
  +			environ = NULL;
  +		}
  +
  +		if (user) {
  +			Nprint_h("Changing to user \"%s\".", user);
  +
  +			if (change_to_user(user) == -1) {
  +				xfree(user);
  +				xfree(root);
  +				exit(EXIT_FAILURE);
  +			}
  +
  +			xfree(user);
  +		}
  +
  +		if (environment_el) {
  +			set_environment(environment_el);
   		}
   
   		exit(execute_children(el));
  
  
  



More information about the alfs-log mailing list