-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item14205: Merge branch 'Item14205' into Release02x01
Resolves several issue around autoconfigure of email - CA Certificates were not being picked up for validation - Wizards were not useable from CLI - Wizards could not capture STDERR under fcgi - STARTTLS connections were always failing on latest IO::Socket::SSL - Checkers for CA files were failing with invalid characteres in filename. - The CA Certificates wizard was not looking for file system locations It integrates a new STDERR / STDOUT capture module written for the OO Foswiki branch. It is simple, but does a better job of releasing the capture at end.
- Loading branch information
Showing
12 changed files
with
431 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
package Foswiki::Aux::MuteOut; | ||
use strict; | ||
use warnings; | ||
|
||
=begin TML | ||
---+!! Package Foswiki::Aux::MuteOut | ||
Very simplistic redirection of STDERR/STDOUT. | ||
---++ SYNOPSIS | ||
Simply avoid any output: | ||
<verbatim> | ||
use Foswiki::Aux::MuteOut; | ||
sub proc { | ||
my ($dir) = @_; | ||
my $rc = system "ls -la $dir"; | ||
print STDERR "RC=", $rc; | ||
} | ||
my $mute = Foswiki::Aux::MuteOut->new; | ||
# Nothing will be displayed by proc() | ||
$mute->exec(\&proc, "/etc"); | ||
</verbatim> | ||
Capture output into files: | ||
<verbatim> | ||
my $capture = Foswiki::Aux::MuteOut->new( | ||
outFile => 'stdout.txt', | ||
errFile => 'stderr.txt', | ||
); | ||
# The output will end up in corresponding files. | ||
$capture->exec(\&proc, "/etc"); | ||
</verbatim> | ||
---++ DESCRIPTION | ||
Redirections are restored when the object destroyed. | ||
=cut | ||
|
||
sub new { | ||
my $class = shift; | ||
my %params = @_; | ||
|
||
$class = ref($class) || $class; | ||
|
||
my ( $oldOut, $oldErr, $rc ); | ||
|
||
my $outFile = $params{outFile} // File::Spec->devnull; | ||
my $errFile = $params{errFile} // File::Spec->devnull; | ||
|
||
unless ( open $oldOut, ">&", STDOUT ) { | ||
Foswiki::Aux::Dependencies::_msg( "Cannot dup STDOUT: " . $! ); | ||
return undef; | ||
} | ||
unless ( open $oldErr, ">&", STDERR ) { | ||
Foswiki::Aux::Dependencies::_msg( "Cannot dup STDERR: " . $! ); | ||
return undef; | ||
} | ||
unless ( open STDOUT, ">", $outFile ) { | ||
Foswiki::Aux::Dependencies::_msg( "Failed to redirect STDOUT: " . $! ); | ||
} | ||
unless ( open STDERR, ">", $errFile ) { | ||
Foswiki::Aux::Dependencies::_msg( "Failed to redirect STDERR: " . $! ); | ||
} | ||
|
||
my $obj = bless { | ||
oldOut => $oldOut, | ||
oldErr => $oldErr, | ||
outFile => $outFile, | ||
errFile => $errFile, | ||
}, $class; | ||
|
||
return $obj; | ||
} | ||
|
||
sub exec { | ||
my $this = shift; | ||
my ($sub) = shift; | ||
|
||
my @rc; | ||
my $wantarray = wantarray; | ||
if ($wantarray) { | ||
@rc = $sub->(@_); | ||
} | ||
elsif ( defined $wantarray ) { | ||
$rc[0] = $sub->(@_); | ||
} | ||
else { | ||
$sub->(@_); | ||
} | ||
|
||
return $wantarray ? @rc : $rc[0]; | ||
} | ||
|
||
sub DESTROY { | ||
my $this = shift; | ||
|
||
unless ( open STDOUT, ">&", $this->{oldOut} ) { | ||
Foswiki::Aux::Dependencies::_msg( "Failed to restore STDOUT: " . $! ); | ||
} | ||
unless ( open STDERR, ">&", $this->{oldErr} ) { | ||
Foswiki::Aux::Dependencies::_msg( "Failed to restore STDERR: " . $! ); | ||
} | ||
} | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2016 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.