Auxiliary function for constructing a user list string. This function is used for error reporting and logging. @param thd Thread context @param str A String to store the user list. @param user A LEX_USER which will be appended into user list. @param comma If TRUE, append a ',' before the the user. @param ident If TRUE, append ' IDENTIFIED BY/WITH...' after the user,
| 7906 | if the given user has credentials set with 'IDENTIFIED BY/WITH' |
| 7907 | */ |
| 7908 | void append_user(THD *thd, String *str, LEX_USER *user, bool comma= true, |
| 7909 | bool ident= false) |
| 7910 | { |
| 7911 | String from_user(user->user.str, user->user.length, system_charset_info); |
| 7912 | String from_plugin(user->plugin.str, user->plugin.length, system_charset_info); |
| 7913 | String from_auth(user->auth.str, user->auth.length, system_charset_info); |
| 7914 | String from_host(user->host.str, user->host.length, system_charset_info); |
| 7915 | |
| 7916 | if (comma) |
| 7917 | str->append(','); |
| 7918 | append_query_string(thd, system_charset_info, &from_user, str); |
| 7919 | str->append(STRING_WITH_LEN("@")); |
| 7920 | append_query_string(thd, system_charset_info, &from_host, str); |
| 7921 | |
| 7922 | if (ident) |
| 7923 | { |
| 7924 | if (user->plugin.str && (user->plugin.length > 0) && |
| 7925 | memcmp(user->plugin.str, native_password_plugin_name.str, |
| 7926 | user->plugin.length) && |
| 7927 | memcmp(user->plugin.str, old_password_plugin_name.str, |
| 7928 | user->plugin.length)) |
| 7929 | { |
| 7930 | /** |
| 7931 | The plugin identifier is allowed to be specified, |
| 7932 | both with and without quote marks. We log it with |
| 7933 | quotes always. |
| 7934 | */ |
| 7935 | str->append(STRING_WITH_LEN(" IDENTIFIED WITH ")); |
| 7936 | append_query_string(thd, system_charset_info, &from_plugin, str); |
| 7937 | |
| 7938 | if (user->auth.str && (user->auth.length > 0)) |
| 7939 | { |
| 7940 | str->append(STRING_WITH_LEN(" AS ")); |
| 7941 | append_query_string(thd, system_charset_info, &from_auth, str); |
| 7942 | } |
| 7943 | } |
| 7944 | else if (user->password.str) |
| 7945 | { |
| 7946 | str->append(STRING_WITH_LEN(" IDENTIFIED BY PASSWORD '")); |
| 7947 | if (user->uses_identified_by_password_clause) |
| 7948 | { |
| 7949 | str->append(user->password.str, user->password.length); |
| 7950 | str->append("'"); |
| 7951 | } |
| 7952 | else |
| 7953 | { |
| 7954 | /* |
| 7955 | Password algorithm is chosen based on old_passwords variable or |
| 7956 | TODO the new password_algorithm variable. |
| 7957 | It is assumed that the variable hasn't changed since parsing. |
| 7958 | */ |
| 7959 | if (thd->variables.old_passwords == 0) |
| 7960 | { |
| 7961 | /* |
| 7962 | my_make_scrambled_password_sha1() requires a target buffer size of |
| 7963 | SCRAMBLED_PASSWORD_CHAR_LENGTH + 1. |
| 7964 | The extra character is for the probably originate from either '\0' |
| 7965 | or the initial '*' character. |
no test coverage detected