From 9f8f691304329618556c8c33dfc0b30cd10fcf26 Mon Sep 17 00:00:00 2001 From: David Galos Date: Thu, 25 Sep 2014 13:27:43 -0400 Subject: [PATCH 1/4] add a flag to enable or disable function import on startup --- configure.in | 6 ++++++ variables.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/configure.in b/configure.in index d7e0998..c48bf07 100644 --- a/configure.in +++ b/configure.in @@ -186,6 +186,7 @@ opt_single_longdoc_strings=yes opt_casemod_attrs=yes opt_casemod_expansions=yes opt_extglob_default=no +opt_function_export=yes dnl options that affect how bash is compiled and linked opt_static_link=no @@ -206,6 +207,7 @@ if test $opt_minimal_config = yes; then opt_net_redirs=no opt_progcomp=no opt_separate_help=no opt_multibyte=yes opt_cond_regexp=no opt_coproc=no opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no + opt_function_export=no fi AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval) @@ -241,6 +243,7 @@ AC_ARG_ENABLE(single-help-strings, AC_HELP_STRING([--enable-single-help-strings] AC_ARG_ENABLE(strict-posix-default, AC_HELP_STRING([--enable-strict-posix-default], [configure bash to be posix-conformant by default]), opt_strict_posix=$enableval) AC_ARG_ENABLE(usg-echo-default, AC_HELP_STRING([--enable-usg-echo-default], [a synonym for --enable-xpg-echo-default]), opt_xpg_echo=$enableval) AC_ARG_ENABLE(xpg-echo-default, AC_HELP_STRING([--enable-xpg-echo-default], [make the echo builtin expand escape sequences by default]), opt_xpg_echo=$enableval) +AC_ARG_ENABLE(function-export, AC_HELP_STRING([--enable-function-export], [allow bash to treat certain environment variables as functions]), opt_function_export=$enableval) dnl options that alter how bash is compiled and linked AC_ARG_ENABLE(mem-scramble, AC_HELP_STRING([--enable-mem-scramble], [scramble memory on calls to malloc and free]), opt_memscramble=$enableval) @@ -333,6 +336,9 @@ fi if test $opt_casemod_expansions = yes; then AC_DEFINE(CASEMOD_EXPANSIONS) fi +if test $opt_function_export = yes; then +AC_DEFINE(FUNCTION_EXPORT) +fi if test $opt_memscramble = yes; then AC_DEFINE(MEMSCRAMBLE) diff --git a/variables.c b/variables.c index 92a5a10..f33f66c 100644 --- a/variables.c +++ b/variables.c @@ -349,7 +349,11 @@ initialize_shell_variables (env, privmode) /* If exported function, define it now. Don't import functions from the environment in privileged mode. */ +#if defined (FUNCTION_EXPORT) if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4)) +#else + if (0) +#endif { string_length = strlen (string); temp_string = (char *)xmalloc (3 + string_length + char_index); -- 2.1.0.rc2.206.gedb03e5