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 $ENV{OPENSSL_ENGINES} = $std_engines
28 if ($ENV{OPENSSL_ENGINES} // '') eq '' && -d $std_engines;
29 $ENV{OPENSSL_MODULES} = $std_providers
30 if ($ENV{OPENSSL_MODULES} // '') eq '' && -d $std_providers;
31 $ENV{OPENSSL_CONF} = $std_openssl_conf
32 if ($ENV{OPENSSL_CONF} // '') eq '' && -f $std_openssl_conf;
38 # VMS needs the command to be appropriately quotified
39 @cmd = fixup_cmd(@ARGV);
40 } elsif (-x $unix_shlib_wrap) {
41 @cmd = ( $unix_shlib_wrap, @ARGV );
47 # The exec() statement on MSWin32 doesn't seem to give back the exit code
48 # from the call, so we resort to using system() instead.
49 my $waitcode = system @cmd;
51 # According to documentation, -1 means that system() couldn't run the command,
52 # otherwise, the value is similar to the Unix wait() status value
53 # (exitcode << 8 | signalcode)
54 die "wrap.pl: Failed to execute '", join(' ', @cmd), "': $!\n"
57 # When the subprocess aborted on a signal, mimic what Unix shells do, by
58 # converting the signal code to an exit code by setting the high bit.
59 # This only happens on Unix flavored operating systems, the others don't
60 # have this sort of signaling to date, and simply leave the low byte zero.
61 exit(($? & 255) | 128) if ($? & 255) != 0;
63 # When not a signal, just shift down the subprocess exit code and use that.
64 my $exitcode = $? >> 8;
66 # For VMS, perl recommendations is to emulate what the C library exit() does
67 # for all non-zero exit codes, except we set the error severity rather than
69 # Ref: https://perldoc.perl.org/perlport#exit
70 # https://perldoc.perl.org/perlvms#$?
71 if ($^O eq 'VMS' && $exitcode != 0) {
73 0x35a000 # C facility code
74 + ($exitcode * 8) # shift up to make space for the 3 severity bits
75 + 2 # Severity: E(rror)
76 + 0x10000000; # bit 28 set => the shell stays silent