cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject [2/4] git commit: fixes create/update/drop other keyspaces when system keyspace is used, introduced by CASSANDRA-3759
Date Tue, 24 Jan 2012 20:29:28 GMT
fixes create/update/drop other keyspaces when system keyspace is used, introduced by CASSANDRA-3759


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b318404e
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b318404e
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b318404e

Branch: refs/heads/trunk
Commit: b318404e539bf82197211ef931a78463944dcf6c
Parents: 7c37454
Author: Pavel Yaskevich <povel.y@gmail.com>
Authored: Tue Jan 24 23:05:21 2012 +0200
Committer: Pavel Yaskevich <povel.y@gmail.com>
Committed: Tue Jan 24 23:22:32 2012 +0200

----------------------------------------------------------------------
 .../org/apache/cassandra/cql/QueryProcessor.java   |    2 ++
 .../org/apache/cassandra/service/ClientState.java  |    4 ----
 .../apache/cassandra/thrift/CassandraServer.java   |    3 +++
 .../apache/cassandra/thrift/ThriftValidation.java  |    6 ++++++
 4 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b318404e/src/java/org/apache/cassandra/cql/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/QueryProcessor.java b/src/java/org/apache/cassandra/cql/QueryProcessor.java
index 8e90e06..b037d17 100644
--- a/src/java/org/apache/cassandra/cql/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql/QueryProcessor.java
@@ -750,6 +750,7 @@ public class QueryProcessor
             case CREATE_KEYSPACE:
                 CreateKeyspaceStatement create = (CreateKeyspaceStatement)statement.statement;
                 create.validate();
+                ThriftValidation.validateKeyspaceNotSystem(create.getName());
                 clientState.hasKeyspaceSchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                 
@@ -893,6 +894,7 @@ public class QueryProcessor
 
             case DROP_KEYSPACE:
                 String deleteKeyspace = (String)statement.statement;
+                ThriftValidation.validateKeyspaceNotSystem(deleteKeyspace);
                 clientState.hasKeyspaceSchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b318404e/src/java/org/apache/cassandra/service/ClientState.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/ClientState.java b/src/java/org/apache/cassandra/service/ClientState.java
index ea1af50..bc8e16f 100644
--- a/src/java/org/apache/cassandra/service/ClientState.java
+++ b/src/java/org/apache/cassandra/service/ClientState.java
@@ -122,10 +122,6 @@ public class ClientState
     public void hasKeyspaceSchemaAccess(Permission perm) throws InvalidRequestException
     {
         validateLogin();
-        
-        // hardcode disallowing messing with system keyspace
-        if (keyspace != null && keyspace.equalsIgnoreCase(Table.SYSTEM_TABLE) &&
perm == Permission.WRITE)
-            throw new InvalidRequestException("system keyspace is not user-modifiable");
 
         resourceClear();
         Set<Permission> perms = DatabaseDescriptor.getAuthority().authorize(user, resource);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b318404e/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index dc257e5..7650553 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -925,6 +925,7 @@ public class CassandraServer implements Cassandra.Iface
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("add_keyspace");
+        ThriftValidation.validateKeyspaceNotSystem(ks_def.name);
         state().hasKeyspaceSchemaAccess(Permission.WRITE);
         validateSchemaAgreement();
         ThriftValidation.validateKeyspaceNotYetExisting(ks_def.name);
@@ -971,6 +972,7 @@ public class CassandraServer implements Cassandra.Iface
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("drop_keyspace");
+        ThriftValidation.validateKeyspaceNotSystem(keyspace);
         state().hasKeyspaceSchemaAccess(Permission.WRITE);
         validateSchemaAgreement();
         
@@ -999,6 +1001,7 @@ public class CassandraServer implements Cassandra.Iface
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("update_keyspace");
+        ThriftValidation.validateKeyspaceNotSystem(ks_def.name);
         state().hasKeyspaceSchemaAccess(Permission.WRITE);
         ThriftValidation.validateTable(ks_def.name);
         if (ks_def.getCf_defs() != null && ks_def.getCf_defs().size() > 0)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b318404e/src/java/org/apache/cassandra/thrift/ThriftValidation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
index 388769a..ee1f662 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
@@ -737,4 +737,10 @@ public class ThriftValidation
                                                                 ksName));
         }
     }
+
+    public static void validateKeyspaceNotSystem(String modifiedKeyspace) throws InvalidRequestException
+    {
+        if (modifiedKeyspace.equalsIgnoreCase(Table.SYSTEM_TABLE))
+            throw new InvalidRequestException("system keyspace is not user-modifiable");
+    }
 }


Mime
View raw message