| 2906 | */ |
| 2907 | |
| 2908 | static bool |
| 2909 | update_user_table(THD *thd, TABLE *table, |
| 2910 | const char *host, const char *user, |
| 2911 | const char *new_password, uint new_password_len, |
| 2912 | enum mysql_user_table_field password_field, |
| 2913 | bool password_expired, bool is_user_table_positioned) |
| 2914 | { |
| 2915 | char user_key[MAX_KEY_LENGTH]; |
| 2916 | int error; |
| 2917 | DBUG_ENTER("update_user_table"); |
| 2918 | DBUG_PRINT("enter",("user: %s host: %s",user,host)); |
| 2919 | |
| 2920 | /* ALTER USER PASSWORD EXPIRE makes no sense on old system tables */ |
| 2921 | if (table->s->fields <= MYSQL_USER_FIELD_PASSWORD_EXPIRED && |
| 2922 | password_expired) |
| 2923 | { |
| 2924 | my_error(ER_BAD_FIELD_ERROR, MYF(0), "password_expired", "mysql.user"); |
| 2925 | DBUG_RETURN(1); |
| 2926 | } |
| 2927 | |
| 2928 | /* |
| 2929 | If this function is reached through change_password, the user record is |
| 2930 | already available and hence need not be read again. |
| 2931 | */ |
| 2932 | |
| 2933 | if (!is_user_table_positioned) |
| 2934 | { |
| 2935 | table->use_all_columns(); |
| 2936 | DBUG_ASSERT(host != '\0'); |
| 2937 | table->field[MYSQL_USER_FIELD_HOST]->store(host, (uint) strlen(host), |
| 2938 | system_charset_info); |
| 2939 | table->field[MYSQL_USER_FIELD_USER]->store(user, (uint) strlen(user), |
| 2940 | system_charset_info); |
| 2941 | key_copy((uchar *) user_key, table->record[0], table->key_info, |
| 2942 | table->key_info->key_length); |
| 2943 | |
| 2944 | if (table->file->ha_index_read_idx_map(table->record[0], 0, |
| 2945 | (uchar *) user_key, HA_WHOLE_KEY, |
| 2946 | HA_READ_KEY_EXACT)) |
| 2947 | { |
| 2948 | my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), |
| 2949 | MYF(0)); /* purecov: deadcode */ |
| 2950 | DBUG_RETURN(1); /* purecov: deadcode */ |
| 2951 | } |
| 2952 | } |
| 2953 | store_record(table,record[1]); |
| 2954 | |
| 2955 | /* |
| 2956 | When the flag is on we're inside ALTER TABLE ... PASSWORD EXPIRE and we |
| 2957 | have no password to update. |
| 2958 | */ |
| 2959 | if (!password_expired) |
| 2960 | { |
| 2961 | if (table->s->fields >= (uint) password_field) |
| 2962 | table->field[(uint) password_field]->store(new_password, new_password_len, |
| 2963 | system_charset_info); |
| 2964 | else |
| 2965 | { |
no outgoing calls
no test coverage detected