Commit graph

85577 commits

Author SHA1 Message Date
Vicențiu Ciorbaru
df16e75983 Updated acl_roles_set_role-simple test to use default sql syntax.
Also called show grants before and after set role. Unfortunately the role
privileges printing are not implemented yet.
2013-10-17 20:45:39 -07:00
Vicențiu Ciorbaru
5470c200d5 Added testcase for the command SET ROLE.
The testcase checks to see if the privileges are set accordingly to a newly
created user. This is the most general usecase.
2013-10-17 20:45:25 -07:00
Vicențiu Ciorbaru
d96e7fa765 Added testcase for acl_roles.
The testcase checks to see if the create user command sets the is_role column
to 'N' by default
2013-10-17 20:45:11 -07:00
Vicențiu Ciorbaru
45903359bf Fixed USER INVALID error when using anonymous user to login and calling
SET ROLE NONE;
2013-10-17 20:45:00 -07:00
Vicențiu Ciorbaru
cf9ebd72c4 Refactored find_mpvio_user. The loop that searches for the user is now a
separate function.
2013-10-17 20:44:51 -07:00
Vicențiu Ciorbaru
e8d6425875 Renamed find_acl_user -> find_user_no_anon 2013-10-17 20:39:43 -07:00
Vicențiu Ciorbaru
db25d8f977 Modified set_role_var to implement both a role check in the check() function,
as well as only set privileges in the update() function.
2013-10-17 20:39:23 -07:00
Sergei Golubchik
494f011799 fix the code to compile 2013-10-17 20:38:49 -07:00
Vicențiu Ciorbaru
7d4bfba91a Added error message for invalid role 2013-10-17 15:14:11 -07:00
Vicențiu Ciorbaru
0254c9a4bd Added the SET ROLE command to the grammar 2013-10-17 15:11:29 -07:00
Vicențiu Ciorbaru
6062e87f54 Created new set_var_role class to handle the SET ROLE command 2013-10-17 15:11:21 -07:00
Vicențiu Ciorbaru
7ec24435b3 Added acl_setrole function. The function enables/disables role privileges to
the current user via the current security_context
2013-10-17 15:11:13 -07:00
Vicențiu Ciorbaru
6680bb14a4 Removed no longer used label 2013-10-17 15:11:05 -07:00
Vicențiu Ciorbaru
096e7aa1e0 Fix bug with inserting _pointers_ to ACL_USER in the DYNAMIC_ARRAY of granted
roles
2013-10-17 15:10:57 -07:00
Vicențiu Ciorbaru
0d103a6f62 Add a check if user_to is valid to handle_roles_mappings_table 2013-10-17 15:10:49 -07:00
Vicențiu Ciorbaru
fb3e3b9440 Fixed typo 2013-10-17 15:10:40 -07:00
Vicențiu Ciorbaru
22ca077ac4 Removed all tabs from sql_acl.h. Replaced with spaces 2013-10-17 15:10:32 -07:00
Vicențiu Ciorbaru
565c6c5a1f Cascading updates for roles_mappings are now fully functional.
Renaming a user via RENAME USER command causes either the user columns
to update, or the role columns.
2013-10-17 15:10:24 -07:00
Vicențiu Ciorbaru
6bddb93e3c Implemented half of handle_roles_mappings_table.
The function now handles user updates/deletions correctly.
2013-10-17 15:10:15 -07:00
Vicențiu Ciorbaru
13a1f6fd72 Changed a call to handle_roles_mappings_table: first parameter is now more readable 2013-10-17 15:10:07 -07:00
Vicențiu Ciorbaru
9506a07159 Added debug info to rebuild_roles_mappings
Also fixed a bug regarding the HASH iteration. It previously got
the stop condition from a different hashtable and this caused errors
when the hash sizes were different.
2013-10-17 15:09:58 -07:00
Vicențiu Ciorbaru
0a9428cffc Added debug warning to add_role_user_mapping. 2013-10-17 15:09:50 -07:00
Vicențiu Ciorbaru
df53ed13ac Renamed variables in init_role_grant_pair to make the code more
consistent.
2013-10-17 15:09:39 -07:00
Vicențiu Ciorbaru
2f94e542bd Whitespace + comment fix 2013-10-17 15:09:31 -07:00
Vicențiu Ciorbaru
7842ef3052 Added logic to handle the in-memory roles_mappings struct in handle_data_struct.
The logic is not complete yet.
2013-10-17 15:09:22 -07:00
Vicențiu Ciorbaru
de472770d3 Removed no longer needed hash_walk_action. The function was used to delete
no longer valid entries in the roles_mappings HASH. This job will be delegated
to handle_grant_* functions
2013-10-17 15:09:14 -07:00
Vicențiu Ciorbaru
6988e6c56a The acl_roles_mappings in-memory structure holds the following invariant:
It will only hold _valid_ entries for as long as it held in memory. Any change
regarding acl_users or acl_roles in memory should update the structure
immediately. This is why the rebuild_roles_mappings no longer removes invalid
entries.

In order to keep things consistent with the existing code, the following jobs
are assigned to each function:

The role of rebuild_roles_mappings is to recreate the links between users and
roles. Any other updates are to be done in the functions:

handle_grant_*

This change prepares the code for the next step, which is cascading updates.
2013-10-17 15:09:06 -07:00
Vicențiu Ciorbaru
ba43f3551b Refactored some code in acl_load to make use of the new init_role_grant_pair
function
2013-10-17 15:06:39 -07:00
Vicențiu Ciorbaru
f8d944a6a0 Added a init_role_mapping function to be used for later 2013-10-17 15:06:29 -07:00
Vicențiu Ciorbaru
573c73225e open_grant_tables now also opens roles_mapping table 2013-10-17 15:06:20 -07:00
Vicențiu Ciorbaru
071c4ce88b Removed no longer needed RoleHostFK as it is not used to link to a Role.
Also removed code that loads that column into memory.
2013-10-17 15:06:09 -07:00
Vicențiu Ciorbaru
ee1e66468f Removed no longer required TODO 2013-10-17 15:05:06 -07:00
Vicențiu Ciorbaru
5acc057879 Roles mappings are now being kept consistent when acl_users gets modified.
No cascading changes take place during a user rename. This needs to be
addressed.
2013-10-17 15:03:58 -07:00
Vicențiu Ciorbaru
e876aa2b3b Fixed memory leak caused by user deletion, aswell as invalid free caused by
user creation.
2013-10-17 15:03:49 -07:00
Vicențiu Ciorbaru
7e18b8f1d6 Moved comment in code to correct place for rebuild_role_grants 2013-10-17 15:03:40 -07:00
Vicențiu Ciorbaru
de523f7fad Refactored function to allow for better code clarity. 2013-10-17 15:03:30 -07:00
Vicențiu Ciorbaru
887a1ac862 Implemented Roles Mappings association between users and roles.
No more memory leaks in the code.
2013-10-17 15:03:21 -07:00
Vicențiu Ciorbaru
deffce1ace Free some memory leaks
Still problems with hashtable acl_roles
Need to create a copy of grant_roles, currently it uses the same buffer
2013-10-17 15:03:12 -07:00
Vicențiu Ciorbaru
89229fb71c Added a delete_function for DYNAMIC_ARRAY.
The function calls delete_dynamic, after if calls a free function on every
array element.
2013-10-17 15:03:04 -07:00
Vicențiu Ciorbaru
9e7228dc4a Added implementation for DYNAMIC_ARRAY in ACL_USER
TODO:
Memory allocated for the array is never freed
2013-10-17 15:02:55 -07:00
Vicențiu Ciorbaru
69a3deb58e Modify mysql.user table to contain a is_user column. 2013-10-17 15:02:47 -07:00
Vicențiu Ciorbaru
ba42300be0 Stripped whitespaces on all lines from sql/sql_acl.cc 2013-10-17 15:02:38 -07:00
Vicențiu Ciorbaru
71a504ca16 Whitespace fixes 2013-10-17 15:02:29 -07:00
Vicențiu Ciorbaru
dc4126657f Refactored ACL_USER:
Changed ACL_USER.user from char * to LEX_STRING.
Refactored every section that made use of ACL_USER.user as a char*.

This was done so as to be able to quickly check the hash_key of the acl_user.
2013-10-17 15:02:18 -07:00
Vicențiu Ciorbaru
fdc1669793 Fixed memory leaks.
role_grants is no longer used as it will be added to the ACL_USER class
2013-10-17 15:00:30 -07:00
Vicențiu Ciorbaru
aa465ac3ba Removed redundant #include "sql_hset.h"
It was a leftover from attempting to use Hash_set
2013-10-17 14:58:37 -07:00
Vicențiu Ciorbaru
dd5a98da35 Fixed key search in HASH table 2013-10-17 14:58:07 -07:00
Vicențiu Ciorbaru
e0c908ebe7 Changed acl_roles to be stored into a HASH.
There is an issue with correct searching of keys in the HASH.
2013-10-17 14:57:58 -07:00
Vicențiu Ciorbaru
334860cccf Added roles mapping internal structure creation
TODO: Free structures on flush
2013-10-17 14:57:49 -07:00
Vicențiu Ciorbaru
875617c089 Added separation between roles and users in the mysql.user table 2013-10-17 14:57:39 -07:00