MySQL 9.1.0
Source Code Documentation
|
#include "validate_password_imp.h"
#include <assert.h>
#include <string.h>
#include <algorithm>
#include <atomic>
#include <fstream>
#include <iomanip>
#include <set>
#include <sstream>
#include <unordered_set>
#include "mysql/components/library_mysys/my_memory.h"
#include "mysql/components/services/mysql_rwlock.h"
#include "mysql/components/services/psi_memory.h"
#include "mysql/components/services/registry.h"
#include "mysqld_error.h"
#include "option_usage.h"
#include "scope_guard.h"
Macros | |
#define | PSI_NOT_INSTRUMENTED 0 |
#define | array_elements(A) ((size_t)(sizeof(A) / sizeof(A[0]))) |
Typedefs | |
typedef std::string | string_type |
typedef std::set< string_type > | set_type |
Enumerations | |
enum | password_policy_enum { PASSWORD_POLICY_LOW , PASSWORD_POLICY_MEDIUM , PASSWORD_POLICY_STRONG , PASSWORD_POLICY_LOW , PASSWORD_POLICY_MEDIUM , PASSWORD_POLICY_STRONG } |
Functions | |
static void | init_validate_password_psi_keys () |
std::atomic< bool > | is_initialized (false) |
static void | dictionary_activate (set_type *dict_words) |
Activate the new dictionary. More... | |
static void | read_dictionary_file () |
static void | free_dictionary_file () |
static int | validate_dictionary_check (my_h_string password) |
static bool | my_memcmp_reverse (const char *a, size_t a_len, const char *b, size_t b_len) |
Compare a sequence of bytes in "a" with the reverse sequence of bytes of "b". More... | |
static bool | is_valid_user (Security_context_handle ctx, const char *buffer, int length, const char *field_name) |
Validate a user name from the security context. More... | |
static bool | is_valid_password_by_user_name (void *thd, my_h_string password) |
Check if the password is not the user name. More... | |
static void | readjust_validate_password_length () |
Check and readjust effective value of validate_password_length. More... | |
static void | dictionary_update (MYSQL_THD, SYS_VAR *, void *var_ptr, const void *save) |
static void | length_update (MYSQL_THD, SYS_VAR *, void *var_ptr, const void *save) |
static int | validate_password_policy_strength (void *thd, my_h_string password, int policy) |
int | register_status_variables () |
int | register_system_variables () |
int | unregister_status_variables () |
int | unregister_system_variables () |
bool | log_service_init () |
logger services initialization method for Component used when loading the Component. More... | |
bool | log_service_deinit () |
logger services de-initialization method for Component used when unloading the Component. More... | |
static mysql_service_status_t | validate_password_init () |
Initialization entry method for Component used when loading the Component. More... | |
static mysql_service_status_t | validate_password_deinit () |
De-initialization method for Component used when unloading the Component. More... | |
PROVIDES_SERVICE (validate_password, validate_password) | |
PROVIDES_SERVICE (validate_password, validate_password_changed_characters) | |
END_COMPONENT_PROVIDES () | |
REQUIRES_SERVICE_PLACEHOLDER (log_builtins) | |
REQUIRES_SERVICE_PLACEHOLDER (log_builtins_string) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_character_access) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_factory) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_case) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_converter) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_iterator) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_ctype) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_string_value) | |
REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_register) | |
REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_unregister) | |
REQUIRES_SERVICE_PLACEHOLDER (status_variable_registration) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_thd_security_context) | |
REQUIRES_SERVICE_PLACEHOLDER (mysql_security_context_options) | |
REQUIRES_SERVICE_PLACEHOLDER (registry_registration) | |
REQUIRES_SERVICE_PLACEHOLDER_AS (registry, mysql_service_registry_no_lock) | |
REQUIRES_SERVICE_PLACEHOLDER_AS (registry_registration, mysql_service_registration_no_lock) | |
REQUIRES_SERVICE (log_builtins) | |
REQUIRES_SERVICE (log_builtins_string) | |
REQUIRES_SERVICE (mysql_string_character_access) | |
REQUIRES_SERVICE (mysql_string_factory) | |
REQUIRES_SERVICE (mysql_string_case) | |
REQUIRES_SERVICE (mysql_string_converter) | |
REQUIRES_SERVICE (mysql_string_iterator) | |
REQUIRES_SERVICE (mysql_string_ctype) | |
REQUIRES_SERVICE (mysql_string_value) | |
REQUIRES_SERVICE (component_sys_variable_register) | |
REQUIRES_SERVICE (component_sys_variable_unregister) | |
REQUIRES_SERVICE (status_variable_registration) | |
REQUIRES_SERVICE (mysql_thd_security_context) | |
REQUIRES_SERVICE (mysql_security_context_options) | |
REQUIRES_SERVICE (registry_registration) | |
REQUIRES_SERVICE_IMPLEMENTATION_AS (registry_registration, mysql_minimal_chassis_no_lock, mysql_service_registration_no_lock) | |
REQUIRES_SERVICE_IMPLEMENTATION_AS (registry, mysql_minimal_chassis_no_lock, mysql_service_registry_no_lock) | |
END_COMPONENT_REQUIRES () | |
METADATA ("mysql.author", "Oracle Corporation") | |
METADATA ("mysql.license", "GPL") | |
METADATA ("validate_password_service", "1") | |
END_COMPONENT_METADATA () | |
#define array_elements | ( | A | ) | ((size_t)(sizeof(A) / sizeof(A[0]))) |
#define PSI_NOT_INSTRUMENTED 0 |
typedef std::set<string_type> set_type |
typedef std::string string_type |
enum password_policy_enum |
|
static |
Activate the new dictionary.
Assigns a local list to the global variable, taking the correct locks in the process. Also updates the status variables.
dict_words | new dictionary words set |
END_COMPONENT_METADATA | ( | ) |
END_COMPONENT_PROVIDES | ( | ) |
END_COMPONENT_REQUIRES | ( | ) |
|
static |
|
static |
std::atomic< bool > is_initialized | ( | false | ) |
|
static |
Check if the password is not the user name.
Helper function. Checks if the password supplied is valid to use by comparing it the effected and the login user names to it and to the reverse of it. logs an error to the error log if it can't pick up the names.
thd | MySQL THD object |
password | the password handle |
true | The password can be used |
false | the password is invalid |
|
static |
Validate a user name from the security context.
A helper function. Validates one user name (as specified by field_name) against the data in buffer/length by comparing the byte sequences in forward and reverse.
Logs an error to the error log if it can't pick up the user names.
ctx | the current security context |
buffer | the password data |
length | the length of buffer |
field_name | the id of the security context field to use |
true | name can be used |
false | name is invalid |
bool log_service_deinit | ( | ) |
logger services de-initialization method for Component used when unloading the Component.
false | success |
true | failure |
bool log_service_init | ( | ) |
logger services initialization method for Component used when loading the Component.
false | success |
true | failure |
METADATA | ( | "mysql.author" | , |
"Oracle Corporation" | |||
) |
METADATA | ( | "mysql.license" | , |
"GPL" | |||
) |
METADATA | ( | "validate_password_service" | , |
"1" | |||
) |
|
static |
Compare a sequence of bytes in "a" with the reverse sequence of bytes of "b".
a | the first sequence |
a_len | the length of a |
b | the second sequence |
b_len | the length of b |
true | sequences match |
false | sequences don't match |
PROVIDES_SERVICE | ( | validate_password | , |
validate_password | |||
) |
PROVIDES_SERVICE | ( | validate_password | , |
validate_password_changed_characters | |||
) |
|
static |
|
static |
Check and readjust effective value of validate_password_length.
Readjust validate_password_length according to the values of validate_password_number_count,validate_password_mixed_case_count and validate_password_special_char_count. This is required at the time plugin installation and as a part of setting new values for any of above mentioned variables.
int register_status_variables | ( | ) |
int register_system_variables | ( | ) |
REQUIRES_SERVICE | ( | component_sys_variable_register | ) |
REQUIRES_SERVICE | ( | component_sys_variable_unregister | ) |
REQUIRES_SERVICE | ( | log_builtins | ) |
REQUIRES_SERVICE | ( | log_builtins_string | ) |
REQUIRES_SERVICE | ( | mysql_security_context_options | ) |
REQUIRES_SERVICE | ( | mysql_string_case | ) |
REQUIRES_SERVICE | ( | mysql_string_character_access | ) |
REQUIRES_SERVICE | ( | mysql_string_converter | ) |
REQUIRES_SERVICE | ( | mysql_string_ctype | ) |
REQUIRES_SERVICE | ( | mysql_string_factory | ) |
REQUIRES_SERVICE | ( | mysql_string_iterator | ) |
REQUIRES_SERVICE | ( | mysql_string_value | ) |
REQUIRES_SERVICE | ( | mysql_thd_security_context | ) |
REQUIRES_SERVICE | ( | registry_registration | ) |
REQUIRES_SERVICE | ( | status_variable_registration | ) |
REQUIRES_SERVICE_IMPLEMENTATION_AS | ( | registry | , |
mysql_minimal_chassis_no_lock | , | ||
mysql_service_registry_no_lock | |||
) |
REQUIRES_SERVICE_IMPLEMENTATION_AS | ( | registry_registration | , |
mysql_minimal_chassis_no_lock | , | ||
mysql_service_registration_no_lock | |||
) |
REQUIRES_SERVICE_PLACEHOLDER | ( | component_sys_variable_register | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | component_sys_variable_unregister | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | log_builtins | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | log_builtins_string | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_security_context_options | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_case | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_character_access | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_converter | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_ctype | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_factory | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_iterator | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_string_value | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | mysql_thd_security_context | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | registry_registration | ) |
REQUIRES_SERVICE_PLACEHOLDER | ( | status_variable_registration | ) |
REQUIRES_SERVICE_PLACEHOLDER_AS | ( | registry | , |
mysql_service_registry_no_lock | |||
) |
REQUIRES_SERVICE_PLACEHOLDER_AS | ( | registry_registration | , |
mysql_service_registration_no_lock | |||
) |
int unregister_status_variables | ( | ) |
int unregister_system_variables | ( | ) |
|
static |
|
static |
De-initialization method for Component used when unloading the Component.
false | success |
true | failure |
|
static |
Initialization entry method for Component used when loading the Component.
false | success |
true | failure |
|
static |
|
static |
|
static |
const mysql_service_validate_password_t imp_validate_password_validate_password |
const mysql_service_validate_password_changed_characters_t imp_validate_password_validate_password_changed_characters |
PSI_rwlock_key key_validate_password_LOCK_dict_file |
mysql_rwlock_t LOCK_dict_file |
const mysql_service_log_builtins_t* log_bi |
accessor built-ins
accessor built-ins
const mysql_service_log_builtins_string_t* log_bs |
string built-ins
const int MAX_DICTIONARY_FILE_LENGTH = (1024 * 1024) |
const int MAX_PASSWORD_LENGTH = 100 |
const int MIN_DICTIONARY_WORD_LENGTH = 4 |
mysql_component_t mysql_component_validate_password |
|
static |
const int PASSWORD_SCORE = 25 |
|
static |
REQUIRES_MYSQL_RWLOCK_SERVICE |
REQUIRES_MYSQL_RWLOCK_SERVICE_PLACEHOLDER |
REQUIRES_PSI_MEMORY_SERVICE |
REQUIRES_PSI_MEMORY_SERVICE_PLACEHOLDER |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |