mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-12-02 03:47:41 +08:00
admin: SHOW VARIABLES print hashed admin-password
This commit is contained in:
parent
5b1bd43d4f
commit
f1144467ec
@ -836,17 +836,6 @@ void admin_select_connection_stat(network_mysqld_con* con, int backend_ndx, char
|
|||||||
g_free(numstr);
|
g_free(numstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bytes_to_hex_str(char* pin, int len, char* pout)
|
|
||||||
{
|
|
||||||
const char* hex = "0123456789ABCDEF";
|
|
||||||
int i = 0;
|
|
||||||
for(; i < len; ++i){
|
|
||||||
*pout++ = hex[(*pin>>4)&0xF];
|
|
||||||
*pout++ = hex[(*pin++)&0xF];
|
|
||||||
}
|
|
||||||
*pout = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum cetus_pwd_type password_type(char* table)
|
static enum cetus_pwd_type password_type(char* table)
|
||||||
{
|
{
|
||||||
if (strcmp(table, "user_pwd")==0) {
|
if (strcmp(table, "user_pwd")==0) {
|
||||||
|
@ -440,13 +440,18 @@ gchar*
|
|||||||
show_admin_password(gpointer param) {
|
show_admin_password(gpointer param) {
|
||||||
struct external_param *opt_param = (struct external_param *)param;
|
struct external_param *opt_param = (struct external_param *)param;
|
||||||
gint opt_type = opt_param->opt_type;
|
gint opt_type = opt_param->opt_type;
|
||||||
|
GString* hashed_pwd = g_string_new(0);
|
||||||
|
network_mysqld_proto_password_hash(hashed_pwd, L(config->admin_password));
|
||||||
|
|
||||||
|
char* pwdhex = g_malloc0(hashed_pwd->len * 2 + 10);
|
||||||
|
bytes_to_hex_str(hashed_pwd->str, hashed_pwd->len, pwdhex);
|
||||||
|
g_string_free(hashed_pwd, TRUE);
|
||||||
|
|
||||||
if(CAN_SHOW_OPTS_PROPERTY(opt_type)) {
|
if(CAN_SHOW_OPTS_PROPERTY(opt_type)) {
|
||||||
return g_strdup_printf("%s", config->admin_password != NULL ? config->admin_password: "NULL");
|
return pwdhex;
|
||||||
}
|
}
|
||||||
if(CAN_SAVE_OPTS_PROPERTY(opt_type)) {
|
if(CAN_SAVE_OPTS_PROPERTY(opt_type)) {
|
||||||
if(config->admin_password != NULL) {
|
return pwdhex;
|
||||||
return g_strdup_printf("%s", config->admin_password);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -132,3 +132,14 @@ guint64 get_timer_microseconds() {
|
|||||||
}
|
}
|
||||||
return last_value;
|
return last_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bytes_to_hex_str(char* pin, int len, char* pout)
|
||||||
|
{
|
||||||
|
const char* hex = "0123456789ABCDEF";
|
||||||
|
int i = 0;
|
||||||
|
for(; i < len; ++i){
|
||||||
|
*pout++ = hex[(*pin>>4)&0xF];
|
||||||
|
*pout++ = hex[(*pin++)&0xF];
|
||||||
|
}
|
||||||
|
*pout = 0;
|
||||||
|
}
|
||||||
|
@ -50,4 +50,6 @@ gboolean try_get_double_value(const gchar *option_value, gdouble *return_value);
|
|||||||
int make_iso8601_timestamp(char *buf, uint64_t utime);
|
int make_iso8601_timestamp(char *buf, uint64_t utime);
|
||||||
guint64 get_timer_microseconds();
|
guint64 get_timer_microseconds();
|
||||||
|
|
||||||
|
void bytes_to_hex_str(char* pin, int len, char* pout);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user