| 2678 | */ |
| 2679 | |
| 2680 | static bool acl_load(THD *thd, const Grant_tables& tables) |
| 2681 | { |
| 2682 | READ_RECORD read_record_info; |
| 2683 | DBUG_ENTER("acl_load"); |
| 2684 | |
| 2685 | SCOPE_CLEAR(thd->variables.sql_mode, MODE_PAD_CHAR_TO_FULL_LENGTH); |
| 2686 | |
| 2687 | const Host_table& host_table= tables.host_table(); |
| 2688 | init_sql_alloc(key_memory_acl_mem, &acl_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); |
| 2689 | if (host_table.table_exists()) // "host" table may not exist (e.g. in MySQL 5.6.7+) |
| 2690 | { |
| 2691 | if (host_table.init_read_record(&read_record_info)) |
| 2692 | DBUG_RETURN(true); |
| 2693 | while (!(read_record_info.read_record())) |
| 2694 | { |
| 2695 | ACL_HOST host; |
| 2696 | update_hostname(&host.host, get_field(&acl_memroot, host_table.host())); |
| 2697 | StringBuffer<SAFE_NAME_LEN> dbstr; |
| 2698 | host_table.db()->val_str(&dbstr); |
| 2699 | if (dbstr.length()) |
| 2700 | { |
| 2701 | const LEX_STRING dbls= make_and_check_db_name(&acl_memroot, dbstr); |
| 2702 | if (!(host.db= dbls.str)) |
| 2703 | continue; // EOM or a bad database name |
| 2704 | /* |
| 2705 | Issue a warning if lower case conversion happened |
| 2706 | and it changed the database name. |
| 2707 | */ |
| 2708 | if (lower_case_table_names && cmp(dbls, dbstr.to_lex_cstring())) |
| 2709 | sql_print_warning("'host' entry '%s|%s' had database in mixed " |
| 2710 | "case that has been forced to lowercase because " |
| 2711 | "lower_case_table_names is set. It will not be " |
| 2712 | "possible to remove this privilege using REVOKE.", |
| 2713 | host.host.hostname, host.db); |
| 2714 | } |
| 2715 | else |
| 2716 | host.db= const_cast<char*>(host_not_specified.str); |
| 2717 | host.access= host_table.get_access(); |
| 2718 | host.access= fix_rights_for_db(host.access); |
| 2719 | host.sort= get_magic_sort("hd", host.host.hostname, host.db); |
| 2720 | if (opt_skip_name_resolve && |
| 2721 | hostname_requires_resolving(host.host.hostname)) |
| 2722 | { |
| 2723 | sql_print_warning("'host' entry '%s|%s' " |
| 2724 | "ignored in --skip-name-resolve mode.", |
| 2725 | host.host.hostname, host.db); |
| 2726 | continue; |
| 2727 | } |
| 2728 | #ifndef TO_BE_REMOVED |
| 2729 | if (host_table.num_fields() == 8) |
| 2730 | { // Without grant |
| 2731 | if (host.access & CREATE_ACL) |
| 2732 | host.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL; |
| 2733 | } |
| 2734 | #endif |
| 2735 | (void) push_dynamic(&acl_hosts,(uchar*) &host); |
| 2736 | } |
| 2737 | my_qsort((uchar*) dynamic_element(&acl_hosts, 0, ACL_HOST*), |
no test coverage detected