|
20 | 20 | #include <iostream>
|
21 | 21 | #include <map>
|
22 | 22 |
|
| 23 | +#include <auth_acls.h> |
| 24 | + |
23 | 25 | #define ERR_FILE 1 // File related error
|
24 | 26 | #define ERR_ENCRYPTION 2 // Encryption related error
|
25 | 27 | #define ERR_SYNTAX 3 // Syntax and parsing related error
|
@@ -64,65 +66,65 @@ class Access_privilege
|
64 | 66 | Access_privilege() : m_priv(0) {}
|
65 | 67 | Access_privilege(uint64_t privileges) : m_priv(privileges) {}
|
66 | 68 | Access_privilege(const Access_privilege &priv) : m_priv(priv.m_priv) {}
|
67 |
| - bool has_select_ac() { return (m_priv & (1L)) > 0; } |
68 |
| - bool has_insert_ac() { return (m_priv & (1L << 1)) > 0; } |
69 |
| - bool has_update_ac() { return (m_priv & (1L << 2)) > 0; } |
70 |
| - bool has_delete_ac() { return (m_priv & (1L << 3)) > 0; } |
71 |
| - bool has_create_ac() { return (m_priv & (1L << 4)) > 0; } |
72 |
| - bool has_drop_ac() { return (m_priv & (1L << 5)) > 0; } |
73 |
| - bool has_relead_ac() { return (m_priv & (1L << 6)) > 0; } |
74 |
| - bool has_shutdown_ac() { return (m_priv & (1L << 7)) > 0; } |
75 |
| - bool has_process_ac() { return (m_priv & (1L << 8)) > 0; } |
76 |
| - bool has_file_ac() { return (m_priv & (1L << 9)) > 0; } |
77 |
| - bool has_grant_ac() { return (m_priv & (1L << 10)) > 0; } |
78 |
| - bool has_references_ac() { return (m_priv & (1L << 11)) > 0; } |
79 |
| - bool has_index_ac() { return (m_priv & (1L << 12)) > 0; } |
80 |
| - bool has_alter_ac() { return (m_priv & (1L << 13)) > 0; } |
81 |
| - bool has_show_db_ac() { return (m_priv & (1L << 14)) > 0; } |
82 |
| - bool has_super_ac() { return (m_priv & (1L << 15)) > 0; } |
83 |
| - bool has_create_tmp_ac() { return (m_priv & (1L << 16)) > 0; } |
84 |
| - bool has_lock_tables_ac() { return (m_priv & (1L << 17)) > 0; } |
85 |
| - bool has_execute_ac() { return (m_priv & (1L << 18)) > 0; } |
86 |
| - bool has_repl_slave_ac() { return (m_priv & (1L << 19)) > 0; } |
87 |
| - bool has_repl_client_ac() { return (m_priv & (1L << 20)) > 0; } |
88 |
| - bool has_create_view_ac() { return (m_priv & (1L << 21)) > 0; } |
89 |
| - bool has_show_view_ac() { return (m_priv & (1L << 22)) > 0; } |
90 |
| - bool has_create_proc_ac() { return (m_priv & (1L << 23)) > 0; } |
91 |
| - bool has_alter_proc_ac() { return (m_priv & (1L << 24)) > 0; } |
92 |
| - bool has_create_user_ac() { return (m_priv & (1L << 25)) > 0; } |
93 |
| - bool has_event_ac() { return (m_priv & (1L << 26)) > 0; } |
94 |
| - bool has_trigger_ac() { return (m_priv & (1L << 27)) > 0; } |
95 |
| - bool has_create_tablespace_ac() { return (m_priv & (1L << 28)) > 0; } |
96 |
| - inline static uint64_t select_ac() { return (1L); } |
97 |
| - inline uint64_t insert_ac() { return (1L << 1); } |
98 |
| - inline uint64_t update_ac() { return (1L << 2); } |
99 |
| - inline uint64_t delete_ac() { return (1L << 3); } |
100 |
| - inline static uint64_t create_ac() { return (1L << 4); } |
101 |
| - inline static uint64_t drop_ac() { return (1L << 5); } |
102 |
| - inline static uint64_t relead_ac() { return (1L << 6); } |
103 |
| - inline static uint64_t shutdown_ac() { return (1L << 7); } |
104 |
| - inline static uint64_t process_ac() { return (1L << 8); } |
105 |
| - inline static uint64_t file_ac() { return (1L << 9); } |
106 |
| - inline static uint64_t grant_ac() { return (1L << 10); } |
107 |
| - inline static uint64_t references_ac() { return (1L << 11); } |
108 |
| - inline static uint64_t index_ac() { return (1L << 12); } |
109 |
| - inline static uint64_t alter_ac() { return (1L << 13); } |
110 |
| - inline static uint64_t show_db_ac() { return (1L << 14); } |
111 |
| - inline static uint64_t super_ac() { return (1L << 15); } |
112 |
| - inline static uint64_t create_tmp_ac() { return (1L << 16); } |
113 |
| - inline static uint64_t lock_tables_ac() { return (1L << 17); } |
114 |
| - inline static uint64_t execute_ac() { return (1L << 18); } |
115 |
| - inline static uint64_t repl_slave_ac() { return (1L << 19); } |
116 |
| - inline static uint64_t repl_client_ac() { return (1L << 20); } |
117 |
| - inline static uint64_t create_view_ac() { return (1L << 21); } |
118 |
| - inline static uint64_t show_view_ac() { return (1L << 22); } |
119 |
| - inline static uint64_t create_proc_ac() { return (1L << 23); } |
120 |
| - inline static uint64_t alter_proc_ac() { return (1L << 24); } |
121 |
| - inline static uint64_t create_user_ac() { return (1L << 25); } |
122 |
| - inline static uint64_t event_ac() { return (1L << 26); } |
123 |
| - inline static uint64_t trigger_ac() { return (1L << 27); } |
124 |
| - inline static uint64_t create_tablespace_ac() { return (1L << 28); } |
125 |
| - inline static uint64_t acl_all() { return 0xfffffff; } |
| 69 | + bool has_select_ac() { return (m_priv & SELECT_ACL) > 0; } |
| 70 | + bool has_insert_ac() { return (m_priv & INSERT_ACL) > 0; } |
| 71 | + bool has_update_ac() { return (m_priv & UPDATE_ACL) > 0; } |
| 72 | + bool has_delete_ac() { return (m_priv & DELETE_ACL) > 0; } |
| 73 | + bool has_create_ac() { return (m_priv & CREATE_ACL) > 0; } |
| 74 | + bool has_drop_ac() { return (m_priv & DROP_ACL) > 0; } |
| 75 | + bool has_relead_ac() { return (m_priv & RELOAD_ACL) > 0; } |
| 76 | + bool has_shutdown_ac() { return (m_priv & SHUTDOWN_ACL) > 0; } |
| 77 | + bool has_process_ac() { return (m_priv & PROCESS_ACL) > 0; } |
| 78 | + bool has_file_ac() { return (m_priv & FILE_ACL) > 0; } |
| 79 | + bool has_grant_ac() { return (m_priv & GRANT_ACL) > 0; } |
| 80 | + bool has_references_ac() { return (m_priv & REFERENCES_ACL) > 0; } |
| 81 | + bool has_index_ac() { return (m_priv & INDEX_ACL) > 0; } |
| 82 | + bool has_alter_ac() { return (m_priv & ALTER_ACL) > 0; } |
| 83 | + bool has_show_db_ac() { return (m_priv & SHOW_DB_ACL) > 0; } |
| 84 | + bool has_super_ac() { return (m_priv & SUPER_ACL) > 0; } |
| 85 | + bool has_create_tmp_ac() { return (m_priv & CREATE_TMP_ACL) > 0; } |
| 86 | + bool has_lock_tables_ac() { return (m_priv & LOCK_TABLES_ACL) > 0; } |
| 87 | + bool has_execute_ac() { return (m_priv & EXECUTE_ACL) > 0; } |
| 88 | + bool has_repl_slave_ac() { return (m_priv & REPL_SLAVE_ACL) > 0; } |
| 89 | + bool has_repl_client_ac() { return (m_priv & REPL_CLIENT_ACL) > 0; } |
| 90 | + bool has_create_view_ac() { return (m_priv & CREATE_VIEW_ACL) > 0; } |
| 91 | + bool has_show_view_ac() { return (m_priv & SHOW_VIEW_ACL) > 0; } |
| 92 | + bool has_create_proc_ac() { return (m_priv & CREATE_PROC_ACL) > 0; } |
| 93 | + bool has_alter_proc_ac() { return (m_priv & ALTER_PROC_ACL) > 0; } |
| 94 | + bool has_create_user_ac() { return (m_priv & CREATE_USER_ACL) > 0; } |
| 95 | + bool has_event_ac() { return (m_priv & EVENT_ACL) > 0; } |
| 96 | + bool has_trigger_ac() { return (m_priv & TRIGGER_ACL) > 0; } |
| 97 | + bool has_create_tablespace_ac() { return (m_priv & CREATE_TABLESPACE_ACL) > 0; } |
| 98 | + inline static uint64_t select_ac() { return SELECT_ACL; } |
| 99 | + inline uint64_t insert_ac() { return INSERT_ACL; } |
| 100 | + inline uint64_t update_ac() { return UPDATE_ACL; } |
| 101 | + inline uint64_t delete_ac() { return DELETE_ACL; } |
| 102 | + inline static uint64_t create_ac() { return CREATE_ACL; } |
| 103 | + inline static uint64_t drop_ac() { return DROP_ACL; } |
| 104 | + inline static uint64_t relead_ac() { return RELOAD_ACL; } |
| 105 | + inline static uint64_t shutdown_ac() { return SHUTDOWN_ACL; } |
| 106 | + inline static uint64_t process_ac() { return PROCESS_ACL; } |
| 107 | + inline static uint64_t file_ac() { return FILE_ACL; } |
| 108 | + inline static uint64_t grant_ac() { return GRANT_ACL; } |
| 109 | + inline static uint64_t references_ac() { return REFERENCES_ACL; } |
| 110 | + inline static uint64_t index_ac() { return INDEX_ACL; } |
| 111 | + inline static uint64_t alter_ac() { return ALTER_ACL; } |
| 112 | + inline static uint64_t show_db_ac() { return SHOW_DB_ACL; } |
| 113 | + inline static uint64_t super_ac() { return SUPER_ACL; } |
| 114 | + inline static uint64_t create_tmp_ac() { return CREATE_TMP_ACL; } |
| 115 | + inline static uint64_t lock_tables_ac() { return LOCK_TABLES_ACL; } |
| 116 | + inline static uint64_t execute_ac() { return EXECUTE_ACL; } |
| 117 | + inline static uint64_t repl_slave_ac() { return REPL_SLAVE_ACL; } |
| 118 | + inline static uint64_t repl_client_ac() { return REPL_CLIENT_ACL; } |
| 119 | + inline static uint64_t create_view_ac() { return CREATE_VIEW_ACL; } |
| 120 | + inline static uint64_t show_view_ac() { return SHOW_VIEW_ACL; } |
| 121 | + inline static uint64_t create_proc_ac() { return CREATE_PROC_ACL; } |
| 122 | + inline static uint64_t alter_proc_ac() { return ALTER_PROC_ACL; } |
| 123 | + inline static uint64_t create_user_ac() { return CREATE_USER_ACL; } |
| 124 | + inline static uint64_t event_ac() { return EVENT_ACL; } |
| 125 | + inline static uint64_t trigger_ac() { return TRIGGER_ACL; } |
| 126 | + inline static uint64_t create_tablespace_ac() { return CREATE_TABLESPACE_ACL; } |
| 127 | + inline static uint64_t acl_all() { return ~NO_ACCESS; } |
126 | 128 | uint64_t to_int() const { return m_priv; };
|
127 | 129 | private:
|
128 | 130 | uint64_t m_priv;
|
|
0 commit comments