]>
git.ipfire.org Git - thirdparty/openssl.git/blob - util/wrap.pl.in
5126513d4c3e91a58273f0d425b5bca60ad4dd1d
1 #! {- $config{HASHBANGPERL} -}
7 use File
::Spec
::Functions
;
10 # This method corresponds exactly to 'use OpenSSL::Util',
11 # but allows us to use a platform specific file spec.
15 "'" . abs_path
(catfile
($config{sourcedir
},
16 'util', 'perl', 'OpenSSL', 'Util.pm')) . "'";
18 OpenSSL
::Util
->import();
21 my $there = canonpath
(catdir
(dirname
($0), updir
()));
22 my $std_engines = catdir
($there, 'engines');
23 my $std_providers = catdir
($there, 'providers');
24 my $std_openssl_conf = catdir
($there, 'apps/openssl.cnf');
25 my $unix_shlib_wrap = catfile
($there, 'util/shlib_wrap.sh');
27 if ($ARGV[0] eq '-fips') {
28 $std_openssl_conf = {-
31 "'" . abs_path
(catfile
($config{sourcedir
}, 'test/fips-and-base.cnf')) . "'";
35 my $std_openssl_conf_include = catdir
($there, 'providers');
36 $ENV{OPENSSL_CONF_INCLUDE
} = $std_openssl_conf_include
37 if ($ENV{OPENSSL_CONF_INCLUDE
} // '') eq ''
38 && -d
$std_openssl_conf_include;
41 $ENV{OPENSSL_ENGINES
} = $std_engines
42 if ($ENV{OPENSSL_ENGINES
} // '') eq '' && -d
$std_engines;
43 $ENV{OPENSSL_MODULES
} = $std_providers
44 if ($ENV{OPENSSL_MODULES
} // '') eq '' && -d
$std_providers;
45 $ENV{OPENSSL_CONF
} = $std_openssl_conf
46 if ($ENV{OPENSSL_CONF
} // '') eq '' && -f
$std_openssl_conf;
52 # VMS needs the command to be appropriately quotified
53 @cmd = fixup_cmd
(@ARGV);
54 } elsif (-x
$unix_shlib_wrap) {
55 @cmd = ( $unix_shlib_wrap, @ARGV );
61 # The exec() statement on MSWin32 doesn't seem to give back the exit code
62 # from the call, so we resort to using system() instead.
63 my $waitcode = system @cmd;
65 # According to documentation, -1 means that system() couldn't run the command,
66 # otherwise, the value is similar to the Unix wait() status value
67 # (exitcode << 8 | signalcode)
68 die "wrap.pl: Failed to execute '", join(' ', @cmd), "': $!\n"
71 # When the subprocess aborted on a signal, we simply raise the same signal.
72 kill(($?
& 255) => $$) if ($?
& 255) != 0;
74 # If that didn't stop this script, mimic what Unix shells do, by
75 # converting the signal code to an exit code by setting the high bit.
76 # This only happens on Unix flavored operating systems, the others don't
77 # have this sort of signaling to date, and simply leave the low byte zero.
78 exit(($?
& 255) | 128) if ($?
& 255) != 0;
80 # When not a signal, just shift down the subprocess exit code and use that.
81 my $exitcode = $?
>> 8;
83 # For VMS, perl recommendations is to emulate what the C library exit() does
84 # for all non-zero exit codes, except we set the error severity rather than
86 # Ref: https://perldoc.perl.org/perlport#exit
87 # https://perldoc.perl.org/perlvms#$?
88 if ($^O
eq 'VMS' && $exitcode != 0) {
90 0x35a000 # C facility code
91 + ($exitcode * 8) # shift up to make space for the 3 severity bits
92 + 2 # Severity: E(rror)
93 + 0x10000000; # bit 28 set => the shell stays silent