From 77ce8b2a15495f7144e806e0747cb13e2ab7fe27 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 30 Apr 2021 09:24:32 +0000 Subject: lei_curl: improve correctness of LD_PRELOAD check LD_PRELOAD sent by a client can't affect lei-daemon. --- lib/PublicInbox/Config.pm | 1 + lib/PublicInbox/LeiCurl.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 016f50ec..3f0f5a01 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -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] ] } diff --git a/lib/PublicInbox/LeiCurl.pm b/lib/PublicInbox/LeiCurl.pm index 69c64cdf..ce57e796 100644 --- a/lib/PublicInbox/LeiCurl.pm +++ b/lib/PublicInbox/LeiCurl.pm @@ -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 -- cgit v1.2.3-24-ge0c7