google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

No admin rights user can't connect to clustered database. #201

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1. create clustered database.

java -cp d:\temp\h2-1.2.135.jar org.h2.tools.Server -tcp -tcpPort 9101 -
baseDir D:\temp\server1
java -cp d:\temp\h2-1.2.135.jar org.h2.tools.Server -tcp -tcpPort 9102 -
baseDir D:\temp\server2
java -cp d:\temp\h2-1.2.135.jar org.h2.tools.CreateCluster -urlSource 
jdbc:h2:tcp://localhost:9101/testdb -urlTarget 
jdbc:h2:tcp://localhost:9102/testdb -user admin -password admin -
serverList localhost:9101,localhost:9102

2. connect to database and create user who has no admin rights.

java -cp d:\temp\h2-1.2.135.jar org.h2.tools.Shell -url 
jdbc:h2:tcp://localhost:9101,localhost:9102/testdb -user admin -password 
admin

sql> create user test password 'test';

3. connect to clusterd database by test user

java -cp d:\temp\h2-1.2.135.jar org.h2.tools.CreateCluster -urlSource 
jdbc:h2:tcp://localhost:9101/testdb -urlTarget 
jdbc:h2:tcp://localhost:9102/testdb -user test -password test -serverList 
localhost:9101,localhost:9102

Exception in thread "main" org.h2.jdbc.JdbcSQLException: 
この操作には管理権限
が
必要です
Admin rights are required for this operation; SQL statement:
SET CLUSTER 'localhost:9101,localhost:9102' [90040-135]
        at org.h2.message.DbException.getJdbcSQLException
(DbException.java:327)
        at org.h2.message.DbException.get(DbException.java:167)
        at org.h2.message.DbException.get(DbException.java:144)
        at org.h2.message.DbException.get(DbException.java:133)
        at org.h2.engine.User.checkAdmin(User.java:195)
        at org.h2.command.dml.Set.update(Set.java:84)
        at org.h2.command.CommandContainer.update(CommandContainer.java:70)
        at org.h2.command.Command.executeUpdate(Command.java:199)
        at org.h2.engine.Engine.openSession(Engine.java:164)
        at org.h2.engine.Engine.getSession(Engine.java:125)
        at org.h2.server.TcpServerThread.run(TcpServerThread.java:118)
        at java.lang.Thread.run(Thread.java:619)

        at org.h2.engine.SessionRemote.done(SessionRemote.java:528)
        at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
        at org.h2.engine.SessionRemote.connectServer
(SessionRemote.java:325)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer
(SessionRemote.jav
a:223)
        at org.h2.engine.SessionRemote.createSession
(SessionRemote.java:217)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:111)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:95)
        at org.h2.Driver.connect(Driver.java:58)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at org.h2.tools.Shell.runTool(Shell.java:140)
        at org.h2.tools.Shell.main(Shell.java:78)

What is the expected output? What do you see instead?

Even no admin rights user should be able to connect to clusterd database. 

What version of the product are you using? On what operating system, file
system, and virtual machine?

h2-1.2.135
java version "1.6.0_18"
Windows XP

Do you know a workaround?

I don't know.

How important/urgent is the problem for you?

important

In your view, is this a defect or a feature request?

defect

Please provide any additional information below.

Original issue reported on code.google.com by litail...@gmail.com on 20 May 2010 at 6:58

GoogleCodeExporter commented 9 years ago
sorry. step3 is:

D:\temp>java -cp d:\temp\h2-1.2.135.jar org.h2.tools.Shell -url jdbc:h2:tcp://lo
calhost:9101,localhost:9102/testdb -user test -password test
Exception in thread "main" org.h2.jdbc.JdbcSQLException: 
この操作には管理権限が
必要です
Admin rights are required for this operation; SQL statement:
SET CLUSTER 'localhost:9101,localhost:9102' [90040-135]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
        at org.h2.message.DbException.get(DbException.java:167)
        at org.h2.message.DbException.get(DbException.java:144)
        at org.h2.message.DbException.get(DbException.java:133)
        at org.h2.engine.User.checkAdmin(User.java:195)
        at org.h2.command.dml.Set.update(Set.java:84)
        at org.h2.command.CommandContainer.update(CommandContainer.java:70)
        at org.h2.command.Command.executeUpdate(Command.java:199)
        at org.h2.engine.Engine.openSession(Engine.java:164)
        at org.h2.engine.Engine.getSession(Engine.java:125)
        at org.h2.server.TcpServerThread.run(TcpServerThread.java:118)
        at java.lang.Thread.run(Thread.java:619)

        at org.h2.engine.SessionRemote.done(SessionRemote.java:528)
        at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
        at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:325)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.jav
a:223)
        at org.h2.engine.SessionRemote.createSession(SessionRemote.java:217)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:111)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:95)
        at org.h2.Driver.connect(Driver.java:58)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at org.h2.tools.Shell.runTool(Shell.java:140)
        at org.h2.tools.Shell.main(Shell.java:78)

Original comment by litail...@gmail.com on 20 May 2010 at 11:20

GoogleCodeExporter commented 9 years ago
You are right, this doesn't work currently. I will remove the admin check
in Set.update(), case SetTypes.CLUSTER in the next version.

Thanks for reporting!

Original comment by thomas.t...@gmail.com on 28 May 2010 at 1:53

GoogleCodeExporter commented 9 years ago
This should be fixed now in version 1.2.137

Original comment by thomas.t...@gmail.com on 6 Jun 2010 at 10:50