BASH PATCH REPORT ================= Bash-Release: 4.0 Patch-ID: bash40-029 Bug-Reported-by: Christian Krause Bug-Reference-ID: Thu, 25 Jun 2009 21:47:59 +0200 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2009-06/msg00078.html Bug-Description: Previous versions of bash accepted strings in the initial environment that were not valid shell variable assignments, usually because the names were invalid, but still created shell variables from them and passed them to child processes in the environment. Bash-4.0 ignores those names and does not pass them to child processes. Some users and automated processes depend on invalid variables being ignored and passed to child processes. This patch makes bash continue to ignore the invalid names, but pass them to child processes in the export environment. Patch: *** ../bash-4.0-patched/variables.c 2009-01-04 14:32:46.000000000 -0500 --- variables.c 2009-06-29 09:17:20.000000000 -0400 *************** *** 253,256 **** --- 255,259 ---- static int visible_var __P((SHELL_VAR *)); static int visible_and_exported __P((SHELL_VAR *)); + static int export_environment_candidate __P((SHELL_VAR *)); static int local_and_exported __P((SHELL_VAR *)); static int variable_in_context __P((SHELL_VAR *)); *************** *** 376,383 **** # endif #endif else if (legal_identifier (name)) { temp_var = bind_variable (name, string, 0); ! VSETATTR (temp_var, (att_exported | att_imported)); array_needs_making = 1; } --- 379,393 ---- # endif #endif + #if 0 else if (legal_identifier (name)) + #else + else + #endif { temp_var = bind_variable (name, string, 0); ! if (legal_identifier (name)) ! VSETATTR (temp_var, (att_exported | att_imported)); ! else ! VSETATTR (temp_var, (att_exported | att_imported | att_invisible)); array_needs_making = 1; } *************** *** 3083,3086 **** --- 3098,3111 ---- } + /* Candidate variables for the export environment are either valid variables + with the export attribute or invalid variables inherited from the initial + environment and simply passed through. */ + static int + export_environment_candidate (var) + SHELL_VAR *var; + { + return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var))); + } + /* Return non-zero if VAR is a local variable in the current context and is exported. */ *************** *** 3439,3443 **** --- 3464,3472 ---- SHELL_VAR **vars; + #if 0 vars = map_over (visible_and_exported, vcxt); + #else + vars = map_over (export_environment_candidate, vcxt); + #endif if (vars == 0) *** ../bash-4.0/patchlevel.h 2009-01-04 14:32:40.000000000 -0500 --- patchlevel.h 2009-02-22 16:11:31.000000000 -0500 *************** *** 26,30 **** looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 28 #endif /* _PATCHLEVEL_H_ */ --- 26,30 ---- looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 29 #endif /* _PATCHLEVEL_H_ */