summaryrefslogtreecommitdiff
path: root/sql/sql_acl.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.6' into 10.7Oleksandr Byelkin2022-10-291-6/+8
|\
| * Merge 10.5 into 10.6Marko Mäkelä2022-10-251-6/+8
| |\ | | | | | | | | | | | | | | | To prevent ASAN heap-use-after-poison in the MDEV-16549 part of ./mtr --repeat=6 main.derived the initialization of Name_resolution_context was cleaned up.
| | * Merge 10.4 into 10.5Marko Mäkelä2022-10-251-6/+8
| | |\
| | | * Merge 10.3 into 10.4Marko Mäkelä2022-10-251-6/+8
| | | |\
| | | | * MDEV-29851 Cached role privileges are not invalidated when neededSergei Golubchik2022-10-221-0/+3
| | | | | | | | | | | | | | | | | | | | GRANT ROLE can update db-level privileges -> must invalidate acl_cache
| | | | * remove two acl_cache->clear()Sergei Golubchik2022-10-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * to "clear hostname cache" one needs to use hostname_cache->clear() * no need to clear acl_cache for SET DEFAULT ROLE
| | | | * Use OPENSSL_free instead of free to avoid instance crashHaidong Ji2022-10-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenSSL handles memory management using **OPENSSL_xxx** API[^1]. For allocation, there is `OPENSSL_malloc`. To free it, `OPENSSL_free` should be called. We've been lucky that OPENSSL (and wolfSSL)'s implementation allowed the usage of `free` for memory cleanup. However, other OpenSSL forks, such as AWS-LC[^2], is not this forgiving. It will cause a server crash. Test case `openssl_1` provides good coverage for this issue. If a user is created using: `grant select on test.* to user1@localhost require SUBJECT "...";` user1 will crash the instance during connection under AWS-LC. There have been numerous OpenSSL forks[^3]. Due to FIPS[^4] and other related regulatory requirements, MariaDB will be built using them. This fix will increase MariaDB's adaptability by using more compliant and generally accepted API. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. [^1]: https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_malloc.html [^2]: https://github.com/awslabs/aws-lc [^3]: https://en.wikipedia.org/wiki/OpenSSL#Forks [^4]: https://en.wikipedia.org/wiki/FIPS_140-2
* | | | | Merge branch '10.6' into 10.7Oleksandr Byelkin2022-10-041-6/+7
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into 10.6Sergei Golubchik2022-10-021-6/+7
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5Sergei Golubchik2022-10-021-6/+7
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.3' into 10.4Sergei Golubchik2022-10-011-6/+7
| | | |\ \ | | | | |/
| | | | * MDEV-28548: ER_TABLEACCESS_DENIED_ERROR is missing information about DBAnel Husakovic2022-09-301-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added missing information about database of corresponding table for various types of commands - Update some typos - Reviewed by: <vicentiu@mariadb.org>
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-09-211-35/+50
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-09-201-35/+50
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-09-201-35/+50
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2022-09-201-35/+50
| | | |\ \ | | | | |/
| | | | * MDEV-29509 execute granted indirectly (via roles) doesn't always workVicențiu Ciorbaru2022-09-141-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue manifests due to a bug in mysql_routine_grant. This was a side effect of e46eea8660fb which fixed the problem of not giving appropriate error message (ER_NONEXISTING_PROC_GRANT) when a routine grant existed due to role inheritance. When granting a routine privilege, it is possible to have a GRANT_NAME entry already created from an inherited role, but with it's init_privs set to 0. In this case we must not create a *new* grant entry, but we must edit this grant entry to set its init_privs. Note that this case was already covered by MDEV-29458, however due to a forgotten "flush privileges;" the actual code path never got hit. Remove the flush privilege command as it was never intended to be there in the first place.
| | | | * cleanup: indentation and whitespace fixesVicențiu Ciorbaru2022-09-141-12/+11
| | | | |
| | | | * MDEV-29458: Role grant commands do not propagate all grantsVicențiu Ciorbaru2022-09-141-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was an issue in updating in-memory role datastructures when propagating role grants. The issue is that changing a particular role's privilege (on any privilege level, global, database, etc.) was done such that it overwrote the entire set of bits for that particular level of privileges. For example: grant select on *.* to r1 -> sets the access bits to r1 to select, regardless of what bits were present for role r1 (inherited from any other roles). Before this fix, the rights of role r1 were propagated to any roles r1 was granted to, however the propagated rights did *not* include the complete rights r1 inherited from its own grants. For example: grant r2 to r1; grant select on *.* to r2; grant insert on *.* to r1; # This command completely disregards the # select privilege from r2. In order to correct this, ensure that before rights are propagated onwards, that the current's role rights have been updated from its grants. Additionally, the patch exposed a flaw in the DROP ROLE code. When deleting a role we removed all its previous grants, but what remained was the actual links of roles granted to the dropped role. Having these links present when propagating grants meant that we would have leftover ACL_xxx entries. Ensure that the links are removed before propagating grants.
| | | | * MDEV-29465: Inherited columns privs for roles wrongly set mysql.tables_priv ↵Vicențiu Ciorbaru2022-09-141-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | column There was a bug in the ACL internal data structures GRANT_TABLE and GRANT_COLUMN. The semantics are: GRANT_TABLE::init_cols and GRANT_COLUMN::init_privs represent the bits that correspond to the privilege bits stored in the physical tables. The other struct members GRANT_TABLE::cols and GRANT_COLUMN::privs represent the actual access bits, as they may be modified through role grants. The error in logic was mixing the two fields and thus we ended up storing the logical access bits in the physical tables, instead of the physical (init_xxx) bits. This caused subsequent DBUG_ASSERT failures when dropping the involved roles.
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-09-071-1/+3
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-09-071-1/+3
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-09-071-1/+3
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2022-09-071-1/+3
| | | |\ \ | | | | |/
| | | | * MDEV-28530: Revoking privileges from a non-existing user on a master breaks ↵Brandon Nesterenko2022-09-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | replication on the slave in the presence of replication filters Problem: ======== Replication can break while applying a query log event if its respective command errors on the primary, but is ignored by the replication filter within Grant_tables on the replica. The bug reported by MDEV-28530 shows this with REVOKE ALL PRIVILEGES using a non-existent user. The primary will binlog the REVOKE command with an error code, and the replica will think the command executed with success because the replication filter will ignore the command while accessing the Grant_tables classes. When the replica performs an error check, it sees the difference between the error codes, and replication breaks. Solution: ======== If the replication filter check done by Grant_tables logic ignores the tables, reset thd->slave_expected_error to 0 so that Query_log_event::do_apply_event() can be made aware that the underlying query was ignored when it compares errors. Note that this bug also effects DROP USER if not all users exist in the provided list, and the patch fixes and tests this case. Reviewed By: ============ andrei.elkin@mariadb.com
* | | | | Merge 10.6 into 10.7Jan Lindström2022-09-051-0/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Jan Lindström2022-09-051-0/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Jan Lindström2022-09-051-0/+1
| | |\ \ \ | | | |/ /
| | | * | Reduce compilation dependencies on wsrep_mysqld.hDaniele Sciascia2022-08-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Making changes to wsrep_mysqld.h causes large parts of server code to be recompiled. The reason is that wsrep_mysqld.h is included by sql_class.h, even tough very little of wsrep_mysqld.h is needed in sql_class.h. This commit introduces a new header file, wsrep_on.h, which is meant to be included from sql_class.h, and contains only macros and variable declarations used to determine whether wsrep is enabled. Also, header wsrep.h should only contain definitions that are also used outside of sql/. Therefore, move WSREP_TO_ISOLATION* and WSREP_SYNC_WAIT macros to wsrep_mysqld.h. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-08-301-15/+79
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-08-251-15/+79
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-08-251-15/+79
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2022-08-251-15/+79
| | | |\ \ | | | | |/
| | | | * MDEV-28294: set default role bypasses Replicate_Wild_Ignore_Table: mysql.%Brandon Nesterenko2022-08-221-12/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: ======== When replicating SET DEFAULT ROLE, the pre-update check (i.e. that in set_var_default_role::check()) tries to validate the existence of the given rules/user even when the targeted tables are ignored. When previously issued CREATE USER/ROLE commands are ignored by the replica because of the replication filtering rules, this results in an error because the targeted data does not exist. Solution: ======== Before checking that the given roles/user exist of a SET DEFAULT ROLE command, first ensure that the mysql.user and mysql.roles_mapping tables are not excluded by replication filters. Reviewed By: ============ Andrei Elkin <andrei.elkin@mariadb.com> Sergei Golubchik <serg@mariadb.com>
* | | | | Merge branch '10.6' into 10.7Oleksandr Byelkin2022-08-081-19/+20
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into bb-10.6-releaseOleksandr Byelkin2022-08-031-19/+20
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5Oleksandr Byelkin2022-08-031-19/+20
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.3' into 10.4Oleksandr Byelkin2022-08-021-19/+20
| | | |\ \ | | | | |/
| | | | * MDEV-29131 Assertion `status == 0' failed when renaming user after deleting ↵Sergei Golubchik2022-07-291-17/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | table roles_mapping if mysql.roles_mapping table doesn't exist (it's optional, after all), we still update in-memory structures to keep them consistent
| | | | * MDEV-26647 (plugin name) Include password validation plugin information in ↵Oleksandr Byelkin2022-07-271-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the error message if the SQL statement is not satisfied password policy Add plugin name to the error message.
* | | | | Merge branch '10.6' into 10.7Oleksandr Byelkin2022-02-041-55/+65
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into 10.6Oleksandr Byelkin2022-02-031-55/+65
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5Oleksandr Byelkin2022-02-011-55/+65
| | |\ \ \ | | | |/ /
| | | * | MDEV-27341 Use SET PASSWORD to change PAM serviceSergei Golubchik2022-01-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SET PASSWORD = PASSWORD('foo') would fail for pam plugin with ERROR HY000: SET PASSWORD is ignored for users authenticating via pam plugin but SET PASSWORD = 'foo' would not. Now it will.
| | | * | MDEV-26339 Account specifics to be handled before proxyingSergei Golubchik2022-01-171-55/+59
| | | | |
* | | | | MDEV-26221: DYNAMIC_ARRAY use size_t for sizesSergei Golubchik2021-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix test failures on rpm-centos73-ppc64 followup for 401ff6994d84
* | | | | Merge 10.6 into 10.7Marko Mäkelä2021-10-221-206/+222
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2021-10-211-203/+220
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2021-10-211-203/+220
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2021-10-211-192/+185
| | | |\ \ | | | | |/