From 2bcb104ad94d3cd07a1b9e228feab7259756c53c Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Sun, 24 Feb 2008 21:46:13 +0100 Subject: [PATCH] Dpkg::IPC: new option to clean the environment * scripts/Dpkg/IPC.pm (fork_and_exec): New delete_env option that allows to remove environment variable within the child process. --- scripts/Dpkg/IPC.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm index bcd5ff6e..6184c14d 100644 --- a/scripts/Dpkg/IPC.pm +++ b/scripts/Dpkg/IPC.pm @@ -111,6 +111,11 @@ calling exec. Hash reference. The child process will populate %ENV with the items of the hash before calling exec. This allows exporting environment variables. +=item delete_env + +Array reference. The child process will remove all environment variables +listed in the array before calling exec. + =back =cut @@ -142,6 +147,10 @@ sub _sanity_check_opts { error("parameter env must be a hash reference"); } + if (exists $opts{"delete_env"} and ref($opts{"delete_env"}) ne 'ARRAY') { + error("parameter delete_env must be an array reference"); + } + return %opts; } @@ -188,6 +197,9 @@ sub fork_and_exec { $ENV{$_} = $opts{"env"}{$_}; } } + if ($opts{"delete_env"}) { + delete $ENV{$_} foreach (@{$opts{"delete_env"}}); + } # Change the current directory if ($opts{"chdir"}) { chdir($opts{"chdir"}) || syserr(_g("chdir to %s"), $opts{"chdir"}); -- 2.39.5