]> Sergey Matveev's repositories - public-inbox.git/commitdiff
test_common: reset umask on non-forking run_script
authorEric Wong <e@80x24.org>
Thu, 23 Sep 2021 05:53:01 +0000 (05:53 +0000)
committerEric Wong <e@80x24.org>
Thu, 23 Sep 2021 06:21:11 +0000 (06:21 +0000)
public-inbox-init sets umask for git <2.1.0, so our fork+exec
replacement needs to restore the original umask of the "parent".

lib/PublicInbox/TestCommon.pm

index 92a7db36969559f28e358d616c032e84daa24faa..aff34853a88886180849fb35412534ea417f08ca 100644 (file)
@@ -316,6 +316,7 @@ sub run_script ($;$$) {
        } else { # localize and run everything in the same process:
                # note: "local *STDIN = *STDIN;" and so forth did not work in
                # old versions of perl
+               my $umask = umask;
                local %ENV = $env ? (%ENV, %$env) : %ENV;
                local @SIG{keys %SIG} = map { undef } values %SIG;
                local $SIG{FPE} = 'IGNORE'; # Perl default
@@ -333,6 +334,7 @@ sub run_script ($;$$) {
                die "fchdir(restore): $!" if $cwdfh && !chdir($cwdfh);
                _undo_redirects($orig_io);
                select STDOUT;
+               umask($umask);
        }
 
        # slurp the redirects back into user-supplied strings