Commit graph

2522 commits

Author SHA1 Message Date
Jan Lindström
f946192e6f MDEV-25258 : SET PASSWORD command fail with wsrep api
Problem was that we should skip strict password validation on
applier nodes similarly as is done for slave nodes.
2021-04-28 11:11:25 +03:00
Sergei Golubchik
fc0d9a470c MDEV-22966 Server crashes or hangs with SET ROLE when started with skip-grant-tables 2021-01-11 21:54:47 +01:00
Anel Husakovic
1ccd1daaff MDEV-24289: show grants missing with grant option
Reviewed by:serg@mariadb.com
2020-11-26 18:10:40 +01:00
Anel Husakovic
4e987b1c6b MDEV-22313: Neither SHOW CREATE USER nor SHOW GRANTS prints a user's default role
Reviewed-by: serg@mariadb.com
2020-10-24 16:32:07 +02:00
Oleksandr Byelkin
ef7cb0a0b5 Merge branch '10.1' into 10.2 2020-08-02 11:05:29 +02:00
Sergei Golubchik
09ec8e2e22 improve the error message for a dropped current role 2020-07-30 23:50:56 +02:00
Sergei Golubchik
4635218cb0 MDEV-22521 Server crashes in traverse_role_graph_up or Assertion `user' fails in traverse_role_graph_impl 2020-07-30 23:50:56 +02:00
Sergei Golubchik
e54a7ac1b3 MDEV-23010 UPDATE privilege at Database and Table level fail to update with SELECT command denied to user
check both column- and table-level grants when looking for SELECT
privilege on UPDATE statement.
2020-07-29 14:56:24 +02:00
Sergei Golubchik
2ba70f69fd cleanup: reduce code duplication 2020-07-29 14:56:24 +02:00
Vicențiu Ciorbaru
8c67ffffe8 Merge branch '10.1' into 10.2 2020-06-11 22:35:30 +03:00
Alexander Barkov
de20091f5c MDEV-22755 CREATE USER leads to indirect SIGABRT in __stack_chk_fail () from fill_schema_user_privileges + *** stack smashing detected *** (on optimized builds)
The code erroneously used buff[100] in a fiew places to make
a GRANTEE value in the form:
  'user'@'host'

Fix:
- Fixing the code to use (USER_HOST_BUFF_SIZE + 6) instead of 100.
- Adding a DBUG_ASSERT to make sure the buffer is enough
- Wrapping the code into a class Grantee_str, to reuse it easier in 4 places.
2020-06-11 09:57:05 +04:00
Marko Mäkelä
d72eebaa3d Merge 10.1 into 10.2 2020-06-01 09:33:03 +03:00
Anel Husakovic
a1b3bebe1f fix pre-definition for embedded server for find_user_or_anon()
Pre-definitions are allowed for non-embedded.
Failur catched with:
```
cmake ../../10.1 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++-9
-DCMAKE_C_COMPILER=gcc-9 -DWITH_EMBEDDED_SERVER=ON -DCMAKE_BUILD_TYPE=Debug
-DPLUGIN_{ARCHIVE,TOKUDB,MROONGA,OQGRAPH,ROCKSDB,PERFSCHEMA,SPIDER,SPHINX}=N
-DMYSQL_MAINTAINER_MODE=ON -DNOT_FOR_DISTRIBUTION=ON
```
Alternative fix would be
```
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -201,8 +201,10 @@ LEX_STRING current_user= { C_STRING_WITH_LEN("*current_user") };
 LEX_STRING current_role= { C_STRING_WITH_LEN("*current_role") };
 LEX_STRING current_user_and_current_role= { C_STRING_WITH_LEN("*current_user_and_current_role") };

+#ifndef EMBEDDED_LIBRARY
 class ACL_USER;
 static ACL_USER *find_user_or_anon(const char *host, const char *user, const char *ip);
+#endif
```
2020-05-28 20:18:25 +02:00
Anel Husakovic
957cb7b7ba MDEV-22312: Bad error message for SET DEFAULT ROLE when user account is not granted the role
- `SET DEFAULT ROLE xxx [FOR yyy]` should say:
  "User yyy has not been granted a role xxx" if:
    - The current user (not the user `yyy` in the FOR clause) can see the
    role xxx. It can see the role if:
      * role exists in `mysql.roles_mappings` (traverse the graph),
      * If the current user has read access on `mysql.user` table - in
    that case, it can see all roles, granted or not.
    - Otherwise it should be "Invalid role specification".

In other words, it should not be possible to use `SET DEFAULT ROLE` to discover whether a specific role exist or not.
2020-05-28 17:08:40 +02:00
Oleksandr Byelkin
3a1716a7e7 Merge branch '10.1' into 10.2 2020-01-20 16:15:05 +01:00
Oleksandr Byelkin
f31bf6f094 Merge branch '5.5' into 10.1 2020-01-19 12:22:12 +01:00
Sergei Golubchik
4d1c1b23e1 Bug#29630767 - USE OF UNINITIALIZED VALUE IN LIBMYSQL (CLIENT.CC FUNCTION RUN_PLUGIN_AUTH) 2020-01-18 00:05:16 +01:00
Oleksandr Byelkin
cf8c2a3c3b Merge branch '10.1' into 10.2 2019-07-26 07:03:39 +02:00
Oleksandr Byelkin
ae476868a5 Merge branch '5.5' into 10.1 2019-07-25 13:27:11 +02:00
Anel Husakovic
ee555f8fc5 MDEV-19948 SHOW GRANTS return privileges individually update in 10.2 2019-07-24 23:27:10 -07:00
Sergei Golubchik
82563c5fc0 MDEV-20110 don't try to load client plugins with invalid names
reported by lixtelnis
2019-07-21 19:47:44 +02:00
Eugene Kosov
d36c107a6b imporve clang build
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug

Maintainer mode makes all warnings errors. This patch fix warnings. Mostly about
deprecated `register` keyword.

Too much warnings came from Mroonga and I gave up on it.
2019-06-25 13:21:36 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
Vicențiu Ciorbaru
5543b75550 Update FSF Address
* Update wrong zip-code
2019-05-11 21:29:06 +03:00
Oleksandr Byelkin
8cbb14ef5d Merge branch '10.1' into 10.2 2019-05-04 17:04:55 +02:00
Vladislav Vaintroub
7590861779 MDEV-19276 during connect, write error log warning for ER_DBACCESS_DENIED_ERROR,
if log_warnings > 1.

This makes ER_DBACCESS_DENIED_ERROR handling the same as we do for other
"access denied"
2019-04-28 12:49:59 +02:00
Sergei Golubchik
2ce52790ff Merge branch '5.5' into 10.1 2019-04-26 14:02:37 +02:00
Sergei Golubchik
da0e00e710 Bug#28986737: RENAMING AND REPLACING MYSQL.USER TABLE CAN LEAD TO A SERVER CRASH 2019-04-25 21:43:31 +02:00
Sergei Golubchik
822071ca5b MDEV-18241 Downgrade from 10.4 to 10.3 crashes
privilege tables can never be views or temporary tables,
don't even try to open them, if they are.
2019-04-24 11:15:38 +02:00
Sergei Golubchik
66099b8f2d cleanup 2019-04-24 11:15:38 +02:00
Marko Mäkelä
dbc716675b Merge 10.1 into 10.2 2019-04-03 10:32:21 +03:00
Sergei Golubchik
65d758aa89 MDEV-18298 Crashes server with segfault during role grants
it was supposed to be `*(p-1)` not `*p-1`
(the crash happens if `*p==0`)
2019-04-02 18:22:37 +02:00
Sergei Golubchik
f1134d5676 post-merge: gcc 8 warnings
note: Inherit String from Sql_alloc,
to get operators new and new[] in sync

in rocksdb gcc was complaining that non-lvalue was cast to const.
2019-03-15 21:00:50 +01:00
Sergei Golubchik
0508d327ae Merge branch '10.1' into 10.2 2019-03-15 21:00:41 +01:00
Sergei Golubchik
3d2d060b62 fix gcc 8 compiler warnings
There were two newly enabled warnings:
1. cast for a function pointers. Affected sql_analyse.h, mi_write.c
   and ma_write.cc, mf_iocache-t.cc, mysqlbinlog.cc, encryption.cc, etc

2. memcpy/memset of nontrivial structures. Fixed as:
* the warning disabled for InnoDB
* TABLE, TABLE_SHARE, and TABLE_LIST got a new method reset() which
  does the bzero(), which is safe for these classes, but any other
  bzero() will still cause a warning
* Table_scope_and_contents_source_st uses `TABLE_LIST *` (trivial)
  instead of `SQL_I_List<TABLE_LIST>` (not trivial) so it's safe to
  bzero now.
* added casts in debug_sync.cc and sql_select.cc (for JOIN)
* move assignment method for MDL_request instead of memcpy()
* PARTIAL_INDEX_INTERSECT_INFO::init() instead of bzero()
* remove constructor from READ_RECORD() to make it trivial
* replace some memcpy() with c++ copy assignments
2019-03-14 16:33:17 +01:00
Sergei Golubchik
a62e9a83c0 MDEV-15945 --ps-protocol does not test some queries
Make mysqltest to use --ps-protocol more

use prepared statements for everything that server supports
with the exception of CALL (for now).

Fix discovered test failures and bugs.

tests:
* PROCESSLIST shows Execute state, not Query
* SHOW STATUS increments status variables more than in text protocol
* multi-statements should be avoided (see tests with a wrong delimiter)
* performance_schema events have different names in --ps-protocol
* --enable_prepare_warnings

mysqltest.cc:
* make sure run_query_stmt() doesn't crash if there's
  no active connection (in wait_until_connected_again.inc)
* prepare all statements that server supports

protocol.h
* Protocol_discard::send_result_set_metadata() should not send
  anything to the client.

sql_acl.cc:
* extract the functionality of getting the user for SHOW GRANTS
  from check_show_access(), so that mysql_test_show_grants() could
  generate the correct column names in the prepare step

sql_class.cc:
* result->prepare() can fail, don't ignore its return value
* use correct number of decimals for EXPLAIN columns

sql_parse.cc:
* discard profiling for SHOW PROFILE. In text protocol it's done in
  prepare_schema_table(), but in --ps it is called on prepare only,
  so nothing was discarding profiling during execute.
* move the permission checking code for SHOW CREATE VIEW to
  mysqld_show_create_get_fields(), so that it would be called during
  prepare step too.
* only set sel_result when it was created here and needs to be
  destroyed in the same block. Avoid destroying lex->result.
* use the correct number of tables in check_show_access(). Saying
  "as many as possible" doesn't work when first_not_own_table isn't
  set yet.

sql_prepare.cc:
* use correct user name for SHOW GRANTS columns
* don't ignore verbose flag for SHOW SLAVE STATUS
* support preparing REVOKE ALL and ROLLBACK TO SAVEPOINT
* don't ignore errors from thd->prepare_explain_fields()
* use select_send result for sending ANALYZE and EXPLAIN, but don't
  overwrite lex->result, because it might be needed to issue execute-time
  errors (select_dumpvar - too many rows)

sql_show.cc:
* check grants for SHOW CREATE VIEW here, not in mysql_execute_command

sql_view.cc:
* use the correct function to check privileges. Old code was doing
  check_access() for thd->security_ctx, which is invoker's sctx,
  not definer's sctx. Hide various view related errors from the invoker.

sql_yacc.yy:
* initialize lex->select_lex for LOAD, otherwise it'll contain garbage
  data that happen to fail tests with views in --ps (but not otherwise).
2019-03-12 13:10:49 +01:00
Jan Lindström
f65f40bb35 Merge remote-tracking branch 'origin/10.1' into 10.2 2019-02-28 13:08:11 +02:00
Vladislav Vaintroub
d9f7b6be5a MDEV-17942 fixup : protect rebuild_check_host() / rebuild_role_grants() with acl_cache->lock mutex 2019-02-20 22:35:21 +01:00
Vladislav Vaintroub
a2f82b649d MDEV-17942 Assertion `found' failed in remove_ptr_from_dynarray after failed CREATE OR REPLACE
Failed CREATE OR REPLACE for existing user removes that user
from acl_users array. Thus dependend structures (roles, check_host) must
be rebuilt.
2019-02-20 16:23:10 +01:00
Marko Mäkelä
25161e6219 Merge 10.1 into 10.2 2019-01-24 14:43:29 +02:00
Sergei Golubchik
c2a4bfad22 MDEV-18119 upgrading from 10.3 to 10.4 can result in the password for a user to be wiped out
10.1 part: SHOW CREATE USER didn't show the password, if plugin was set,
but authentication_string was not
2019-01-23 17:34:22 +01:00
Sachin
79078167c3 MDEV-17753 ALTER USER fail to replicate
Change mysql_alter_user to log alter user command.
2019-01-13 20:59:45 +05:30
Marko Mäkelä
b7a9563b21 Merge 10.1 into 10.2 2018-12-21 09:43:35 +02:00
Sergei Golubchik
8ede9b3ae5 MDEV-17975 Assertion ! is_set()' or !is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon REVOKE under LOCK TABLE
open_grant_tables() returns -1/0/1, where -1 is an error, while 1 is not.
Don't store it's return value in bool
2018-12-20 08:39:54 +01:00
Marko Mäkelä
5e5deabdbc Merge 10.1 into 10.2 2018-12-07 13:41:10 +02:00
Sergei Golubchik
6491c591b2 Merge branch '10.0' into 10.1 2018-12-06 15:08:42 +01:00
Sergei Golubchik
daca7e70d7 MDEV-17898 FLUSH PRIVILEGES crashes server with segfault
merge_role_db_privileges() was remembering pointers into Dynamic_array
acl_dbs, and later was using them, while pushing more elements into the
array. But pushing can cause realloc, and it can invalidate all pointers.

Fix: remember and use indexes of elements, not pointers.
2018-12-06 14:22:07 +01:00
Sergei Golubchik
8a37ce0767 cleanup: DYNAMIC_ARRAY -> Dynamic_array<ACL_DB> acl_dbs 2018-12-06 14:22:07 +01:00
Marko Mäkelä
32062cc61c Merge 10.1 into 10.2 2018-11-06 08:41:48 +02:00