7 use File::Spec::Functions;
9 my $there = canonpath(catdir(dirname($0), updir()));
10 my $std_engines = catdir($there, 'engines');
11 my $std_providers = catdir($there, 'providers');
12 my $std_openssl_conf = catdir($there, 'apps/openssl.cnf');
13 my $unix_shlib_wrap = catfile($there, 'util/shlib_wrap.sh');
15 $ENV{OPENSSL_ENGINES} = $std_engines
16 if ($ENV{OPENSSL_ENGINES} // '') eq '' && -d $std_engines;
17 $ENV{OPENSSL_MODULES} = $std_providers
18 if ($ENV{OPENSSL_MODULES} // '') eq '' && -d $std_providers;
19 $ENV{OPENSSL_CONF} = $std_openssl_conf
20 if ($ENV{OPENSSL_CONF} // '') eq '' && -f $std_openssl_conf;
25 if (-x $unix_shlib_wrap) {
26 @cmd = ( $unix_shlib_wrap, @ARGV );
32 # The exec() statement on MSWin32 doesn't seem to give back the exit code
33 # from the call, so we resort to using system() instead.
34 my $waitcode = system @cmd;
36 # According to documentation, -1 means that system() couldn't run the command,
37 # otherwise, the value is similar to the Unix wait() status value
38 # (exitcode << 8 | signalcode)
39 die "wrap.pl: Failed to execute '", join(' ', @cmd), "': $!\n"
42 # When the subprocess aborted on a signal, mimic what Unix shells do, by
43 # converting the signal code to an exit code by setting the high bit.
44 # This only happens on Unix flavored operating systems, the others don't
45 # have this sort of signaling to date, and simply leave the low byte zero.
46 exit(($? & 255) | 128) if ($? & 255) != 0;
48 # When not a signal, just shift down the subprocess exit code and use that.