From: Eric Wong Date: Tue, 29 Apr 2025 20:47:46 +0000 (+0000) Subject: spawn: avoid string eval for optional BSD::Resource X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcf8b34c072bcc2381e2b70aa7aba17fe954b0d9;p=thirdparty%2Fpublic-inbox.git spawn: avoid string eval for optional BSD::Resource BSD::Resource has had a get_rlimits() sub for a while to return a hashref to non-Inline::C users. So favor using that after `require' rather than a string eval which can't be checked for syntax-only errors. --- diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index c832db591..1d9f9b76b 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -384,9 +384,12 @@ sub spawn ($;$$) { my $rlim = []; foreach my $l (@RLIMITS) { my $v = $opt->{$l} // next; - my $r = $RLIMITS{$l} // - eval "require BSD::Resource; BSD::Resource::$l();" // - do { + my $r = $RLIMITS{$l} // eval { + require BSD::Resource; + my $rl = BSD::Resource::get_rlimits(); + @RLIMITS{@RLIMITS} = @$rl{@RLIMITS}; + $RLIMITS{$l}; + } // do { warn "$l undefined by BSD::Resource: $@\n"; next; };