chiark / gitweb /
Disable all exported shell functions
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 25 Sep 2014 12:24:50 +0000 (13:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 25 Sep 2014 14:28:32 +0000 (15:28 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/patches/0001-Disable-all-exported-shell-functions.dpatch [new file with mode: 0644]
debian/rules

diff --git a/debian/patches/0001-Disable-all-exported-shell-functions.dpatch b/debian/patches/0001-Disable-all-exported-shell-functions.dpatch
new file mode 100644 (file)
index 0000000..7f22ffd
--- /dev/null
@@ -0,0 +1,44 @@
+#! /bin/sh -e
+
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+    pdir="-d $3"
+elif [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch) patch $pdir -f --no-backup-if-mismatch -p1 < $0;;
+    -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p1 < $0;;
+    *)
+       echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+       exit 1
+esac
+exit 0
+
+# DP: [PATCH] Disable all exported shell functions.
+
+diff --git a/variables.c b/variables.c
+index 92a5a10..fe0832e 100644
+--- a/variables.c
++++ b/variables.c
+@@ -347,6 +347,7 @@ initialize_shell_variables (env, privmode)
+       temp_var = (SHELL_VAR *)NULL;
++#if 0 /* Disable exporting shell functions because they are mad. */
+       /* If exported function, define it now.  Don't import functions from
+        the environment in privileged mode. */
+       if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
+@@ -380,6 +381,9 @@ initialize_shell_variables (env, privmode)
+             report_error (_("error importing function definition for `%s'"), name);
+           }
+       }
++#else
++      if (0) ; /* needed for syntax */
++#endif
+ #if defined (ARRAY_VARS)
+ #  if ARRAY_EXPORT
+       /* Array variables may not yet be exported. */
+-- 
+1.7.10.4
+
index e599db78cacd4c364744b67b42b7a46103df273c..83465b0d7e1c82ed6fe6ad9b6a002b52add2d4f0 100755 (executable)
@@ -523,6 +523,7 @@ debian_patches = \
        exec-redirections-man \
        bash-aliases-repeat \
        builtins-declare-fix \
+       0001-Disable-all-exported-shell-functions \
 
 ifeq ($(with_gfdl),yes)
   debian_patches += \