Skip to content

Commit 7915c28

Browse files
committed
Access the installer via public_html
1 parent 8ff6b3e commit 7915c28

File tree

8 files changed

+33
-34
lines changed

8 files changed

+33
-34
lines changed

index.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@
234234
}
235235

236236
// check if installer is still active
237-
if ($RCMAIL->config->get('enable_installer') && is_readable('./installer/index.php')) {
237+
if ($RCMAIL->config->get('enable_installer') && is_readable(__DIR__ . '/public_html/installer.php')) {
238238
$RCMAIL->output->add_footer(html::div(['id' => 'login-addon', 'style' => "background:#ef9398; border:2px solid #dc5757; padding:0.5em; margin:2em auto; width:50em"],
239-
html::tag('h2', ['style' => "margin-top:0.2em"], "Installer script is still accessible") .
240-
html::p(null, "The install script of your Roundcube installation is still stored in its default location!") .
241-
html::p(null, "Please <b>remove</b> the whole <tt>installer</tt> folder from the Roundcube directory because
242-
these files may expose sensitive configuration data like server passwords and encryption keys
243-
to the public. Make sure you cannot access the <a href=\"./installer/\">installer script</a> from your browser.")
239+
html::tag('h2', ['style' => "margin-top:0.2em"], "The Installer is still accessible") .
240+
html::p(null, "The install script of your Roundcube installation is still available to everyone!") .
241+
html::p(null, "Please <b>remove</b> the <tt>public_html/installer.php</tt> file from the Roundcube directory because
242+
it may expose sensitive configuration data like server passwords and encryption keys
243+
to the public. Make sure you cannot access <a href=\"installer.php\">the script</a> from your browser.")
244244
));
245245
}
246246

installer/check.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
if (!class_exists('rcmail_install', false) || !isset($RCI)) {
18-
exit("Not allowed! Please open installer/index.php instead.");
18+
exit("Not allowed! Please use installer.php instead.");
1919
}
2020

2121
$required_php_exts = [
@@ -97,7 +97,7 @@
9797
];
9898

9999
?>
100-
<form action="index.php" method="get">
100+
<form action="?" method="get">
101101

102102
<?php
103103
echo '<input type="hidden" name="_step" value="' . ($RCI->configured ? 3 : 2) . '" />';

installer/config.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
if (!class_exists('rcmail_install', false) || !isset($RCI)) {
18-
exit("Not allowed! Please open installer/index.php instead.");
18+
exit("Not allowed! Please use installer.php instead.");
1919
}
2020

2121
// allow the current user to get to the next step
@@ -39,7 +39,7 @@
3939
$save_button = '';
4040
if (($dir = sys_get_temp_dir()) && @is_writable($dir)) {
4141
echo '<iframe name="getconfig" style="display:none"></iframe>';
42-
echo '<form id="getconfig_form" action="index.php" method="get" target="getconfig" style="display:none">';
42+
echo '<form id="getconfig_form" action="?" method="get" target="getconfig" style="display:none">';
4343
echo '<input name="_getconfig" value="2" /></form>';
4444

4545
$button_txt = html::quote('Save in ' . $dir);
@@ -49,7 +49,7 @@
4949
echo '<p class="notice">Copy or download the following configuration and save it';
5050
echo ' as <tt><b>config.inc.php</b></tt> within the <tt>' . RCUBE_CONFIG_DIR . '</tt> directory of your Roundcube installation.<br/>';
5151
echo ' Make sure that there are no characters before the <tt>&lt;?php</tt> bracket when saving the file.';
52-
echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" />';
52+
echo '&nbsp;<input type="button" onclick="location.href=\'?_getconfig=1\'" value="Download" />';
5353
echo $save_button;
5454

5555
if ($RCI->legacy_config) {
@@ -66,14 +66,14 @@
6666
echo '<p class="hint">Of course there are more options to configure.
6767
Have a look at the defaults.inc.php file or visit <a href="https://github.com/roundcube/roundcubemail/wiki/Configuration" target="_blank">Howto_Config</a> to find out.</p>';
6868

69-
echo '<p><input type="button" onclick="location.href=\'./index.php?_step=3\'" value="CONTINUE" /></p>';
69+
echo '<p><input type="button" onclick="location.href=\'?_step=3\'" value="CONTINUE" /></p>';
7070

7171
// echo '<style type="text/css"> .configblock { display:none } </style>';
7272
echo "\n<hr style='margin-bottom:1.6em' />\n";
7373
}
7474

7575
?>
76-
<form action="index.php" method="post">
76+
<form action="?" method="post">
7777
<input type="hidden" name="_step" value="2" />
7878

7979
<fieldset>

installer/index.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
// go to 'check env' step if we have a local configuration
8888
if ($RCI->configured && empty($_REQUEST['_step'])) {
89-
header("Location: ./?_step=1");
89+
header("Location: ?_step=1");
9090
exit;
9191
}
9292

@@ -97,15 +97,15 @@
9797
<title>Roundcube Webmail Installer</title>
9898
<meta name="Robots" content="noindex,nofollow" />
9999
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
100-
<link rel="stylesheet" type="text/css" href="styles.css" />
101-
<script type="text/javascript" src="client.js"></script>
100+
<link rel="stylesheet" type="text/css" href="static.php/installer/styles.css" />
101+
<script type="text/javascript" src="static.php/installer/client.js"></script>
102102
</head>
103103

104104
<body>
105105

106106
<div id="banner">
107107
<div class="banner-bg"></div>
108-
<div class="banner-logo"><a href="http://roundcube.net"><img src="images/roundcube_logo.png" width="210" height="55" border="0" alt="Roundcube - open source webmail software" /></a></div>
108+
<div class="banner-logo"><a href="http://roundcube.net"><img src="static.php/installer/images/roundcube_logo.png" width="210" height="55" border="0" alt="Roundcube - open source webmail software" /></a></div>
109109
</div>
110110

111111
<div id="topnav">
@@ -140,9 +140,9 @@
140140
<ol id="progress">
141141
<?php
142142
$include_steps = [
143-
1 => './check.php',
144-
2 => './config.php',
145-
3 => './test.php',
143+
1 => __DIR__ . '/check.php',
144+
2 => __DIR__ . '/config.php',
145+
3 => __DIR__ . '/test.php',
146146
];
147147

148148
if (!in_array($RCI->step, array_keys($include_steps))) {
@@ -151,7 +151,7 @@
151151

152152
foreach (['Check environment', 'Create config', 'Test config'] as $i => $item) {
153153
$j = $i + 1;
154-
$link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step=' . $j . '">' . rcube::Q($item) . '</a>' : rcube::Q($item);
154+
$link = ($RCI->step >= $j || $RCI->configured) ? '<a href="?_step=' . $j . '">' . rcube::Q($item) . '</a>' : rcube::Q($item);
155155
printf('<li class="step%d%s">%s</li>', $j + 1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
156156
}
157157
?>

installer/test.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
if (!class_exists('rcmail_install', false) || !isset($RCI)) {
18-
exit("Not allowed! Please open installer/index.php instead.");
18+
exit("Not allowed! Please use installer.php instead.");
1919
}
2020

2121
?>
@@ -172,7 +172,7 @@
172172
$db_read = $DB->query("SELECT count(*) FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'users'));
173173
if ($DB->is_error()) {
174174
$RCI->fail('DB Schema', "Database not initialized");
175-
echo '<form action="index.php?_step=3" method="post">'
175+
echo '<form action="?_step=3" method="post">'
176176
. '<p><input type="submit" name="initdb" value="Initialize database" /></p>'
177177
. '</form>';
178178

@@ -185,7 +185,7 @@
185185
$select = $RCI->versions_select(['name' => 'version']);
186186
$select->add('0.9 or newer', '');
187187

188-
echo '<form action="index.php?_step=3" method="post">'
188+
echo '<form action="?_step=3" method="post">'
189189
. '<p class="suggestion">You should run the update queries to get the schema fixed.'
190190
. '<br/><br/>Version to update from: ' . $select->show('')
191191
. '&nbsp;<input type="submit" name="updatedb" value="Update" /></p>'
@@ -304,7 +304,7 @@
304304

305305
?>
306306

307-
<form action="index.php?_step=3" method="post">
307+
<form action="?_step=3" method="post">
308308

309309
<h3>Test SMTP config</h3>
310310

@@ -406,7 +406,7 @@
406406

407407
</form>
408408

409-
<form action="index.php?_step=3" method="post">
409+
<form action="?_step=3" method="post">
410410

411411
<h3>Test IMAP config</h3>
412412

@@ -489,12 +489,12 @@
489489

490490
<p class="warning">
491491

492-
After completing the installation and the final tests please <b>remove</b> the whole
493-
installer folder from the document root of the webserver or make sure that
492+
After completing the installation and the final tests please <b>remove</b> the
493+
installer.php file from the document root of the webserver or make sure that
494494
<tt>enable_installer</tt> option in <tt>config.inc.php</tt> is disabled.<br />
495495
<br />
496496

497-
These files may expose sensitive configuration data like server passwords and encryption keys
498-
to the public. Make sure you cannot access this installer from your browser.
497+
The installer may expose sensitive configuration data like server passwords and encryption keys
498+
to the public. Make sure you cannot access it from your browser.
499499

500500
</p>

public_html/plugins

-1
This file was deleted.

public_html/skins

-1
This file was deleted.

public_html/static.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,17 @@
4949
* @const array Path prefixes to look for the requested files
5050
*/
5151
const ALLOWED_PATHS = [
52+
'installer/',
5253
'plugins/',
5354
'program/',
5455
'skins/',
5556
];
5657

5758
define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
5859

59-
$path = $_SERVER['PATH_INFO'];
60+
$path = validateStaticFile($_SERVER['PATH_INFO']);
6061

61-
if (!($path = validateStaticFile($path))) {
62+
if (!$path) {
6263
header('HTTP/1.1 404 Not Found');
6364
exit;
6465
}

0 commit comments

Comments
 (0)