Skip to content

Commit

Permalink
Item14279: Fix encoding of password in CLI bootstrap
Browse files Browse the repository at this point in the history
Also clarify documentation of utf-8 configuration parameters
from the CLI configure tool.
  • Loading branch information
gac410 committed Jan 17, 2017
1 parent 219bb4d commit 69f877a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 3 additions & 2 deletions core/data/System/CommandAndCGIScripts.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1483547096" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1484612966" format="1.1" version="1"}%
%META:TOPICPARENT{name="DeveloperDocumentationCategory"}%
%STARTINCLUDE%
---+ CGI and Command Line Scripts
Expand Down Expand Up @@ -647,10 +647,11 @@ This is a fully functional command line interface to the Foswiki configuration.

=tools/configure [-search] [-getspec] [-getcfg] [-check] [-wizard] [-method] [-save] [-json] [-trace] [-help] [-noprompt] [-expert]=

Note: if you need to pass in international characters, it needs to be run with the =perl -CA= command argument.
Note: if you need to pass in international characters, it needs to be run with the =perl -CA= command argument. (=perl -CAS= when running a new configuration bootstrap)

| *Function* | *Usage* |
| Bootstrap a new install without helptext | =tools/configure -save -expert= |
| Bootstrap an installation containing international characters | =perl -CAS tools/configure -save= |
| Set multiple variables | =tools/configure -save -set {Password}='newadminpassword' -set {WebMasterEmail}='newadmin@yourco.com'= |
| Check a setting or section of settings. | =tools/configure -check Internationalisation= |
| Run a wizard | =tools/configure -wizard Email -method send_test_email= |
Expand Down
14 changes: 11 additions & 3 deletions core/data/System/InstallationGuide.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1481826890" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1484611418" format="1.1" version="1"}%
%META:TOPICPARENT{name="AdminDocumentationCategory"}%
<noautolink>
---+!! Installation Guide
Expand Down Expand Up @@ -344,6 +344,14 @@ Foswiki 2.0 includes a shell based configuration tool that can be run from a
server command-line login. It will bootstrap the configuration, and prompt
for settings as required. Here is an example of using it for an interactive
command line bootstrap:
<div class="foswikiHelp">
*Note*: If any of your configuration settings use utf-8 characters, (eg. &Uuml;nic&ouml;de) be sure to
run configure with the perl =-CAS= option so that all prompted input is properly encoded.
<verbatim class='bash'>
$ perl -CAS tools/configure -save
</verbatim>
</div>

<verbatim class='bash'>
$ tools/configure -save

Expand Down Expand Up @@ -383,13 +391,13 @@ for more information on setting up Foswiki to use shorter script URLs.

It can also be run in a non-interactive mode, for use in automated deployment
systems.
<verbatim class='bash'>
<pre class='bash'>
tools/configure -save -noprompt
tools/configure -save -set {DefaultUrlHost}='http://mysite.com'
tools/configure -save -set {ScriptUrlPath}='/bin'
tools/configure -save -set {ScriptUrlPaths}{view}=''
tools/configure -save -set {PubUrlPath}='/pub'
tools/configure -save -set {Password}='adminpass' </verbatim>
perl -CA tools/configure -save -set {Password}='&Auml;dm&icirc;nP&auml;ss' </pre>

Any configuration keys may be set using this tool.

Expand Down
12 changes: 10 additions & 2 deletions core/tools/configure
Expand Up @@ -241,7 +241,10 @@ sub _prompt {

$reply = '' unless ( defined $reply );
return if ( $opt && $reply eq 'none' );
eval "\$Foswiki::cfg$keys='$reply'";

# Add keys to the params to be processed by the Save wizard.
# This invokes all needed handlers like ONSAVE vs. modifying the config directly
eval "\$params->{set}{'$keys'} = '$reply'";
if ($@) {
print "Failed to set $keys: "
. Foswiki::Configure::Reporter::stripStacktrace($@);
Expand Down Expand Up @@ -280,7 +283,9 @@ unless ( $Foswiki::cfg{isVALID} ) {
unless ( $params->{expert} || $params->{noprompt} ) {

# Ask for missing parameters that cannot bootstrap in CLI
print "** Enter values for critical configuration items.\n";
print "\n** Enter values for critical configuration items.\n";
print
"** If any input will use utf-8 data (non-ASCII), run as 'perl -CAS tools/configure ...'\n";
print
"** type a new value or hit return to accept the value in brackets.\n";
}
Expand Down Expand Up @@ -343,6 +348,9 @@ unless ( $Foswiki::cfg{isVALID} ) {
}

}
else {
print "** Be sure to run as 'perl -CA tools/configure' if any settings will use utf-8 data\n";
}

if ( $reporter->has_level('errors') ) {
exit 1;
Expand Down

0 comments on commit 69f877a

Please sign in to comment.