提交 950698bd authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Disable transparent database creation from H2 Console when remote access in enabled

上级 7ebacff9
......@@ -485,7 +485,8 @@ Auto-creation of databases can be disabled, see
</p>
<p>
H2 Console does not allow creation of databases by default unless a browser window is opened by Console during its
startup or from its icon in the system tray. A context menu of the tray icon can also be used to create a new database.
startup or from its icon in the system tray and remote access is not enabled.
A context menu of the tray icon can also be used to create a new database.
</p>
<h2 id="using_server">Using the Server</h2>
......
......@@ -273,8 +273,10 @@ public class WebServer implements Service {
* @param key key, or null
*/
public void setKey(String key) {
if (!allowOthers) {
this.key = key;
}
}
@Override
public void init(String... args) {
......@@ -509,6 +511,9 @@ public class WebServer implements Service {
}
void setAllowOthers(boolean b) {
if (b) {
key = null;
}
allowOthers = b;
}
......
......@@ -90,7 +90,7 @@ public class Console extends Tool implements ShutdownHandler {
boolean tcpShutdown = false, tcpShutdownForce = false;
String tcpPassword = "";
String tcpShutdownServer = "";
boolean ifExists = false;
boolean ifExists = false, webAllowOthers = false;
for (int i = 0; args != null && i < args.length; i++) {
String arg = args[i];
if (arg == null) {
......@@ -112,6 +112,7 @@ public class Console extends Tool implements ShutdownHandler {
webStart = true;
} else if ("-webAllowOthers".equals(arg)) {
// no parameters
webAllowOthers = true;
} else if ("-webDaemon".equals(arg)) {
// no parameters
} else if ("-webSSL".equals(arg)) {
......@@ -200,7 +201,8 @@ public class Console extends Tool implements ShutdownHandler {
if (webStart) {
try {
String webKey = ifExists ? null : StringUtils.convertBytesToHex(MathUtils.secureRandomBytes(32));
String webKey = ifExists || webAllowOthers ? null
: StringUtils.convertBytesToHex(MathUtils.secureRandomBytes(32));
web = Server.createWebServer(args, webKey);
web.setShutdownHandler(this);
web.start();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论