]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_curl: improve correctness of LD_PRELOAD check
authorEric Wong <e@80x24.org>
Fri, 30 Apr 2021 09:24:32 +0000 (09:24 +0000)
committerEric Wong <e@80x24.org>
Fri, 30 Apr 2021 19:59:43 +0000 (19:59 +0000)
LD_PRELOAD sent by a client can't affect lei-daemon.

lib/PublicInbox/Config.pm
lib/PublicInbox/LeiCurl.pm

index 016f50eca3a8428237f3bb0813e214199783c43d..3f0f5a0195d76e1d77e03f3e33f87342d59e92c9 100644 (file)
@@ -12,6 +12,7 @@ use strict;
 use v5.10.1;
 use PublicInbox::Inbox;
 use PublicInbox::Spawn qw(popen_rd);
+our $LD_PRELOAD = $ENV{LD_PRELOAD}; # only valid at startup
 
 sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] }
 
index 69c64cdfb0a5cd90d36ae6273961a96a2bdb73ca..ce57e7963ae98743440e58f64640f10661ff9cb4 100644 (file)
@@ -55,7 +55,7 @@ sub torsocks { # useful for "git clone" and "git fetch", too
        $opt->{torsocks} = 'false' if $opt->{'no-torsocks'};
        my $torsocks = $opt->{torsocks} //= 'auto';
        if ($torsocks eq 'auto' && substr($uri->host, -6) eq '.onion' &&
-                       (($lei->{env}->{LD_PRELOAD}//'') !~ /torsocks/)) {
+               ($PublicInbox::Config::LD_PRELOAD//'') !~ m!/libtorsocks\b!) {
                # "auto" continues anyways if torsocks is missing;
                # a proxy may be specified via CLI, curlrc,
                # environment variable, or even firewall rule