]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei up: localize %ENV in redispatch
authorEric Wong <e@80x24.org>
Mon, 13 Sep 2021 20:53:53 +0000 (20:53 +0000)
committerEric Wong <e@80x24.org>
Mon, 13 Sep 2021 21:11:15 +0000 (21:11 +0000)
We need to restore %ENV of script/lei in case another
lei client has a different %ENV than what daemon has.

lib/PublicInbox/LeiUp.pm

index be476427bc64f4598c0c6a2dc104d5cf9dde244f..a16117c9b604ea5b304d3cb5217b15cfd263cc8f 100644 (file)
@@ -55,13 +55,14 @@ sub up1 ($$) {
 sub up1_redispatch {
        my ($lei, $out, $op_p) = @_;
        my $l = bless { %$lei }, ref($lei);
-       $l->{opt} = { %{$l->{opt}} };
+       $l->{opt} = { %{$l->{opt}} }; # deep copy
        delete $l->{sock}; # do not close
        $l->{''} = $op_p; # daemon only ($l => $lei => script/lei)
 
        # make close($l->{1}) happy in lei->dclose
        open my $fh, '>&', $l->{1} or return $l->child_error(0, "dup: $!");
        local $PublicInbox::LEI::current_lei = $l;
+       local %ENV = %{$l->{env}};
        $l->{1} = $fh;
        eval {
                $l->qerr("# updating $out");