minor refactoring (more consistent)

This commit is contained in:
Miroslav Stampar 2011-03-09 12:06:32 +00:00
parent 62e3510387
commit eb1cda7065
2 changed files with 38 additions and 39 deletions

View File

@ -55,40 +55,40 @@ sybaseTypes = {
"20":"image", "20":"image",
} }
mysqlPrivs = ( mysqlPrivs = {
( 1, "select_priv" ), 1:"select_priv",
( 2, "insert_priv" ), 2:"insert_priv",
( 3, "update_priv" ), 3:"update_priv",
( 4, "delete_priv" ), 4:"delete_priv",
( 5, "create_priv" ), 5:"create_priv",
( 6, "drop_priv" ), 6:"drop_priv",
( 7, "reload_priv" ), 7:"reload_priv",
( 8, "shutdown_priv" ), 8:"shutdown_priv",
( 9, "process_priv" ), 9:"process_priv",
( 10, "file_priv" ), 10:"file_priv",
( 11, "grant_priv" ), 11:"grant_priv",
( 12, "references_priv" ), 12:"references_priv",
( 13, "index_priv" ), 13:"index_priv",
( 14, "alter_priv" ), 14:"alter_priv",
( 15, "show_db_priv" ), 15:"show_db_priv",
( 16, "super_priv" ), 16:"super_priv",
( 17, "create_tmp_table_priv" ), 17:"create_tmp_table_priv",
( 18, "lock_tables_priv" ), 18:"lock_tables_priv",
( 19, "execute_priv" ), 19:"execute_priv",
( 20, "repl_slave_priv" ), 20:"repl_slave_priv",
( 21, "repl_client_priv" ), 21:"repl_client_priv",
( 22, "create_view_priv" ), 22:"create_view_priv",
( 23, "show_view_priv" ), 23:"show_view_priv",
( 24, "create_routine_priv" ), 24:"create_routine_priv",
( 25, "alter_routine_priv" ), 25:"alter_routine_priv",
( 26, "create_user_priv" ), 26:"create_user_priv",
) }
pgsqlPrivs = ( pgsqlPrivs = {
( 1, "createdb" ), 1:"createdb",
( 2, "super" ), 2:"super",
( 3, "catupd" ), 3:"catupd",
) }
firebirdPrivs = { firebirdPrivs = {
"S": "SELECT", "S": "SELECT",

View File

@ -463,9 +463,8 @@ class Enumeration:
# In PostgreSQL we get 1 if the privilege is # In PostgreSQL we get 1 if the privilege is
# True, 0 otherwise # True, 0 otherwise
if Backend.getIdentifiedDbms() == DBMS.PGSQL and getUnicode(privilege).isdigit(): if Backend.getIdentifiedDbms() == DBMS.PGSQL and getUnicode(privilege).isdigit():
for position, pgsqlPriv in pgsqlPrivs: if int(privilege) == 1:
if count == position and int(privilege) == 1: privileges.add(pgsqlPrivs[count])
privileges.add(pgsqlPriv)
# In MySQL >= 5.0 and Oracle we get the list # In MySQL >= 5.0 and Oracle we get the list
# of privileges as string # of privileges as string
@ -475,9 +474,9 @@ class Enumeration:
# In MySQL < 5.0 we get Y if the privilege is # In MySQL < 5.0 we get Y if the privilege is
# True, N otherwise # True, N otherwise
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema: elif Backend.getIdentifiedDbms() == DBMS.MYSQL and not kb.data.has_information_schema:
for position, mysqlPriv in mysqlPrivs: if privilege.upper() == "Y":
if count == position and privilege.upper() == "Y": privileges.add(mysqlPrivs[count])
privileges.add(mysqlPriv)
if self.__isAdminFromPrivileges(privileges): if self.__isAdminFromPrivileges(privileges):
areAdmins.add(user) areAdmins.add(user)