Skip to content

Commit

Permalink
Merge branch 'Release02x01'
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Nov 15, 2016
2 parents 036f698 + 04fa967 commit 6674b4b
Show file tree
Hide file tree
Showing 28 changed files with 527 additions and 163 deletions.
11 changes: 9 additions & 2 deletions FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm
Expand Up @@ -65,7 +65,13 @@ sub run {
or die "Failed to create FastCGI socket: $!";
}
$args ||= {};
my $r = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, $sock,

# Prepare output handles for FastCGI.
$this->{$_} = IO::Handle->new foreach qw(fhIN fhOUT fhERR);
# This is a little trick to make all `print STDERR' clauses send their
# output to the log file. May not work for spawned processes.
STDERR->fdopen($this->{fhERR}->fileno, "w");
my $r = FCGI::Request( $this->{fhIN}, $this->{fhOUT}, $this->{fhERR}, \%ENV, $sock,
&FCGI::FAIL_ACCEPT_ON_INTR );
my $manager;

Expand Down Expand Up @@ -187,7 +193,8 @@ sub preparePath {
}

sub write {
syswrite STDOUT, $_[1];
my $this = shift;
syswrite $this->{fhOUT}, $_[0];
}

sub closeSocket {
Expand Down
2 changes: 1 addition & 1 deletion MailerContrib/templates/mailnotify.tmpl
Expand Up @@ -67,7 +67,7 @@
%TEXTHEAD%
%TMPL:END%
--------------------------------
%TMPL:DEF{MailNotifyBody}%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%TMPL:DEF{MailNotifyBody}%From: %IF{ "defined WIKIAGENTNAME" then="$percntWIKIAGENTNAME$percnt" else="$percntWIKIWEBMASTERNAME$percnt" }% <%IF{ "defined WIKIAGENTEMAIL" then="$percntWIKIAGENTEMAIL$percnt" else="$percntWIKIWEBMASTER$percnt"}%>
To: %EMAILTO%
Subject: %WIKITOOLNAME%.%WEB% - %MAKETEXT{"Automated notification of topic changes"}%
Auto-Submitted: auto-generated
Expand Down
2 changes: 1 addition & 1 deletion MailerContrib/templates/newsletter.tmpl
Expand Up @@ -2,7 +2,7 @@
Templates for the mails sent out by mailnotify for newsletters.
}%

%TMPL:DEF{"NEWS:header"}%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%TMPL:DEF{"NEWS:header"}%From: %IF{ "defined WIKIAGENTNAME" then="$percntWIKIAGENTNAME$percnt" else="$percntWIKIWEBMASTERNAME$percnt" }% <%IF{ "defined WIKIAGENTEMAIL" then="$percntWIKIAGENTEMAIL$percnt" else="$percntWIKIWEBMASTER$percnt"}%>
To: %EMAILTO%
Subject: %WIKITOOLNAME% %WEB%.%TOPIC%
Auto-Submitted: auto-generated
Expand Down
29 changes: 18 additions & 11 deletions TopicUserMappingContrib/data/System/ManagingUsers.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1457055693" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1479234842" format="1.1" version="1"}%
%META:TOPICPARENT{name="AdminDocumentationCategory"}%
%STARTINCLUDE%
---+ Manage Users
Expand Down Expand Up @@ -88,7 +88,7 @@ Prefix for deleted topic: <input type="text" name="topicPrefix" class="foswikiIn

*Note:* Consider leaving the user topic file in place so their past signatures and revision author entries don't end up looking like AnUncreatedTopic.
If you want to make it clear the user is no longer around, replace the topic content with a note to that effect.
The existence of the <nop>UserName topic should also prevent that username from being re-used, sealing the potential security hole regarding inherited permissions..
The existence of the <nop>UserName topic should also prevent that username from being re-used, sealing the potential security hole regarding inherited permissions.

<div class="foswikiHelp">
%T% See the [[http://foswiki.org/Extensions/AntiWikiSpamPlugin][AntiWikiSpamPlugin]] extension for another method of removing users. It provides a =rest= handler to:
Expand All @@ -108,13 +108,15 @@ Registration can be configured to require a verification via the registered emai
* An email is sent to the email address entered by the new user with a confirmation code.
* The user must enter the confirmation code into a dialog on the wiki to confirm the registration.
* The pending registration lifetime defaults to 6 hours. If the user does not confirm within that time, the pending registration will be removed.
* Registration requests pending verification can be viewed by visiting the System.PendingRegistrationsReport

---+++ Administrative approval of new registrations

Registration can be configured to require approval. ={Register}{NeedApproval}=
* If confirmation is enabled, the email address is verified per the steps in the prior paragraph
* An email is then set to the list of Approvers - ={Register}{Approvers}=
* The approver can then Approve or Deny the registration by following a link in the email.
* Registrations awaiting approval can be viewed and approved from the System.PendingRegistrationsReport

---+++ Registration Email Requirements

Expand All @@ -132,7 +134,7 @@ should use a cron job to clean up expired sessions. The standard maintenance cro

Note that if you are using registration approval by 3rd party reviewers, this timer should most likely be significantly increased. 24 hours = 86400, 3 days = 259200.

Pending registration requests are stored in the ={WorkingDir}/registration_approvals= directory.
Pending registration requests are stored in the ={WorkingDir}/registration_approvals= directory, but are no longer in plain text format. To view the pending registrations see the new System.PendingRegistrations report.

---++ Customizing the User Registration pages
If you modify any of the topic related to User Registration, you should put the modified versions into the %USERSWEB% web. This will make it easier to
Expand Down Expand Up @@ -186,17 +188,22 @@ Multiple categories of users can be supported by:
* And configuring the new registration page to use the new user template.

---++ Customizing registration Emails.
Foswiki's Registration can send 6 emails whose output is governed by templates:
| User registration confirmation | =templates/registerconfirm.tmpl= |
| User registration failed notification | =templates/registerfailedremoved.tmpl= |
| User registration denied notification | =templates/registerdenied.tmpl= |
| Approver registration pending notification | =templates/registerapprove.tmpl= |
| User notification of sucessful registraiton | =templates/registernotify.tmpl= |
| Administrator notification of successful registration | =templates/registernotifyadmin.tmpl= |
Foswiki's Registration can send 7 emails whose output is governed by templates:
| User registration confirmation. (Awaiting email verification). | =templates/registerconfirm.tmpl= |
| User registration failed notification, cleanup was successful. | =templates/registerfailedremoved.tmpl= |
| User registration failed notification, cleanup of partial registration also failed. | =templates/registerfailednotremoved.tmpl= |
| User registration denied notification. | =templates/registerdenied.tmpl= |
| Approver registration pending notification. | =templates/registerapprove.tmpl= |
| User notification of sucessful registraiton. | =templates/registernotify.tmpl= |
| Administrator notification of successful registration. | =templates/registernotifyadmin.tmpl= |

As these are SkinTemplates, they can be customized and selected using the SKIN path setting.
Because there are default =.tmpl= files in the =templates= dir, this cannot use Template topics.

Note: As of Foswiki 2.1.3, the email =From:= address can be different from the WIKIWEBMASTER address, and is configurable using the =bin/configure= tool.
See the "Expert" ={WikiAgentName}= and ={WikiAgentEmail}= settings on the "Mail" section, "Basic Settings and Autoconfiguration" tab.
If these fields are not set, then the WIKIWEBMASTER setting will be used as the =From:= address.

These template files have a specific format that matches the raw format of emails sent via SMTP,
so be careful and test your changes. It is easiest to start by copying the default templates that you
wish to change.: (You don't need to copy every template).
Expand All @@ -215,7 +222,7 @@ To make it possible for users to modify the email contents, you could use a para
statement in your customized version, eg:

<verbatim class="tml">
From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %FIRSTLASTNAME% <%EMAILADDRESS%>
Subject: %MAKETEXT{
"[_1] - Registration for [_2] ([_3])"
Expand Down
4 changes: 2 additions & 2 deletions core/data/Main/SitePreferences.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1437654744" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1479237375" format="1.1" version="1"}%
---+!! %TOPIC%

%ICON{"help"}%
Expand Down Expand Up @@ -39,7 +39,7 @@ Customize your top bar background image and color
---++ Finalisation
=FINALPREFERENCES= locks site-level preferences that are *not* allowed to be overridden by [[%WEBPREFSTOPIC%]] or user preferences:

* Set FINALPREFERENCES = ATTACHFILESIZELIMIT, PREVIEWBGIMAGE, WIKITOOLNAME, WIKIHOMEURL, ALLOWROOTCHANGE, DENYROOTCHANGE, DOCWEB
* Set FINALPREFERENCES = ATTACHFILESIZELIMIT, PREVIEWBGIMAGE, WIKITOOLNAME, WIKIHOMEURL, ALLOWROOTCHANGE, DENYROOTCHANGE, DOCWEB, WIKIWEBMASTER, WIKIWEBMASTERNAME, WIKIAGENTEMAIL, WIKIAGENTNAME

<!-- Keep this as a security measure:

Expand Down
9 changes: 9 additions & 0 deletions core/data/System/VarWIKIAGENTEMAIL.txt
@@ -0,0 +1,9 @@
%META:TOPICINFO{author="ProjectContributor" date="1478916373" format="1.1" version="1"}%
%META:TOPICPARENT{name="Macros"}%
---+ WIKIAGENTEMAIL -- From: email address in emails sent by Foswiki.
---++ Examples
* =%<nop>WIKIAGENTEMAIL%= expands to =%WIKIAGENTEMAIL%=
%STOPINCLUDE%
---++ Related
[[VarWIKIAGENTNAME][WIKIAGENTNAME]], [[VarWIKIWEBMASTER][WIKIWEBMASTER]], [[VarWIKIWEBMASTERNAME][WIKIWEBMASTERNAME]]

9 changes: 9 additions & 0 deletions core/data/System/VarWIKIAGENTNAME.txt
@@ -0,0 +1,9 @@
%META:TOPICINFO{author="ProjectContributor" date="1478916373" format="1.1" version="1"}%
%META:TOPICPARENT{name="Macros"}%
---+ WIKIAGENTNAME -- From: Name used in emails sent by %WIKITOOLNAME%
---++ Examples
* =%<nop>WIKIAGENTNAME%= expands to =%WIKIAGENTNAME%=
%STOPINCLUDE%
---++ Related
[[VarWIKIAGENTEMAIL][WIKIAGENTEMAIL]], [[VarWIKIWEBMASTER][WIKIWEBMASTER]], [[VarWIKIWEBMASTERNAME][WIKIWEBMASTERNAME]]

6 changes: 6 additions & 0 deletions core/lib/Foswiki.pm
Expand Up @@ -419,6 +419,12 @@ BEGIN {
$macros{WIKIUSERSTOPIC} = sub { $Foswiki::cfg{UsersTopicName} };
$macros{WIKIWEBMASTER} = sub { $Foswiki::cfg{WebMasterEmail} };
$macros{WIKIWEBMASTERNAME} = sub { $Foswiki::cfg{WebMasterName} };
$macros{WIKIAGENTEMAIL} = sub {
$Foswiki::cfg{Email}{WikiAgentEmail} || $Foswiki::cfg{WebMasterEmail};
};
$macros{WIKIAGENTNAME} = sub {
$Foswiki::cfg{Email}{WikiAgentName} || $Foswiki::cfg{WebMasterName};
};

# locale setup
#
Expand Down
27 changes: 18 additions & 9 deletions core/lib/Foswiki.spec
Expand Up @@ -1798,14 +1798,26 @@ $Foswiki::cfg{WebMasterName} = 'Wiki Administrator';
# title='Long running: Probes the possible email servers to find most secure connection';\
# wizard='AutoConfigureEmail'; method='autoconfigure'"\
# FEEDBACK="icon='ui-icon-mail-closed';label='Send Test Email';wizard='SendTestEmail'; method='send'"**
# Wiki administrator (webmaster) e-mail address, used as the sender address
# in emails sent by Foswiki. For example =webmaster@example.com=
# Must be a single valid email address.
# This value is displayed using the =<nop>%WIKIWEBMASTER%= macro.
# Wiki administrator (webmaster) e-mail address. It's used as the "Contact" address on web pages and
# is also optionally used as the sender address in emails sent by Foswiki. For example =webmaster@example.com=
# If the Expert setting. ={WikiAgentEmail} is configured, it will be used as the From: address.
# Must be a single valid email address. This value is displayed using the =<nop>%WIKIWEBMASTER%= macro.
# <br/>
# If your server is already configured to send email, press Auto-configure email. If it works, email will be enabled. You can then send a test email to further verify operation.
$Foswiki::cfg{WebMasterEmail} = '';

# **STRING 30 LABEL="Wiki Agent Name" EXPERT**
# Used as part of the From: email address and defaults to ={WebMasterName}= if not configured.
# For use in mails sent by Foswiki. For example: "Wiki Gnome". This value is displayed using the
# =<nop>%WIKIAGENTNAME%= macro.
$Foswiki::cfg{Email}{WikiAgentName} = '';

# **EMAILADDRESS 30 LABEL="Wiki Agent Email" EXPERT**
# Email address used by Foswiki as the From: address for email messages, such as messages from the
# RegistrationAgent. The ={WebMasterEmail}= is used if this item is not configured.
# Configure this entry if your email server refuses to accept messages from and too the same address.
$Foswiki::cfg{Email}{WikiAgentEmail} = '';

# **STRING 30 LABEL="SMTP Host"\
# FEEDBACK="icon='ui-icon-mail-closed';label='Auto-configure Email';\
# title='Long running: Probes the possible email servers to find most secure connection';\
Expand Down Expand Up @@ -1906,17 +1918,15 @@ $Foswiki::cfg{SMTP}{SENDERHOST} = '';
# This verifies the identity of the server to which mail is sent.
$Foswiki::cfg{Email}{SSLVerifyServer} = $FALSE;

# **PATH EXPERT LABEL="Certificate Authorities Filename" \
# **PATH LABEL="Certificate Authorities Filename" \
# FEEDBACK="icon='ui-icon-shuffle';label='Guess certificate locations'; wizard='SSLCertificates'; method='guess_locations'"\
# DISPLAY_IF="{EnableEmail} && /^Net::SMTP/.test({Email}{MailMethod}) && {Email}{SSLVerifyServer}"**
# Specify the file used to verify the server certificate trust chain.
# This is the list of root Certificate authorities that you trust to issue
# certificates. You do not need to include intermediate CAs in this file.
# If you do not specify this or {Email}{SSLCaPath}, system defaults will
# be used.
$Foswiki::cfg{Email}{SSLCaFile} = '';

# **PATH LABEL="Certificate Authorities Directory" EXPERT \
# **PATH LABEL="Certificate Authorities Directory" \
# FEEDBACK="icon='ui-icon-shuffle';label='Guess certificate locations'; wizard='SSLCertificates'; method='guess_locations'"\
# FEEDBACK='label="Validate Contents"; wizard="SSLCertificates"; method="validate";\
# title="Examines every file in the directory and verifies \
Expand All @@ -1925,7 +1935,6 @@ $Foswiki::cfg{Email}{SSLCaFile} = '';
# Specify the directory used to verify the server certificate trust chain.
# This is the list of root Certificate authorities that you trust to issue
# certificates. You do not need to include intermediate CAs in this directory.
# If you do not specify this or {Email}{SSLCaFile}, system defaults will be used.
# Refer to the openssl documentation for the format of this directory.
# Note that it can also contain Certificate Revocation Lists.
$Foswiki::cfg{Email}{SSLCaPath} = '';
Expand Down
138 changes: 138 additions & 0 deletions core/lib/Foswiki/Aux/MuteOut.pm
@@ -0,0 +1,138 @@
# 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 =
( defined $params{outFile} ) ? $params{outFile} : File::Spec->devnull;
my $errFile =
( defined $params{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.
6 changes: 1 addition & 5 deletions core/lib/Foswiki/Configure/Checkers/Email/SSLCaFile.pm
Expand Up @@ -17,10 +17,6 @@ sub check_current_value {

my $file = $this->checkExpandedValue($reporter);
if ($file) {
unless ( $file =~ m,^([\w_./]+)$, ) {
return $this->ERROR("Invalid characters in $file");
}
$file = $1;

if ( -r $file ) {
$reporter->NOTE( "File was last modified "
Expand Down Expand Up @@ -97,7 +93,7 @@ __END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-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.
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Checkers/Email/SSLCaPath.pm
Expand Up @@ -52,7 +52,7 @@ sub check_current_value {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-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.
Expand Down

0 comments on commit 6674b4b

Please sign in to comment.