2004-10-23 09:32:52 +02:00
|
|
|
/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2005-09-23 20:28:56 +02:00
|
|
|
#if defined(__GNUC__) && defined(USE_PRAGMA_IMPLEMENTATION)
|
2005-10-07 18:25:51 +02:00
|
|
|
#pragma implementation
|
2004-10-23 09:32:52 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "user_map.h"
|
2006-05-18 16:57:50 +02:00
|
|
|
#include "exit_codes.h"
|
2004-10-23 09:32:52 +02:00
|
|
|
#include "log.h"
|
2006-05-19 02:51:23 +02:00
|
|
|
#include "portability.h"
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
User::User(const LEX_STRING *user_name_arg, const char *password)
|
2004-10-23 09:32:52 +02:00
|
|
|
{
|
2006-05-18 16:57:50 +02:00
|
|
|
user_length= strmake(user, user_name_arg->str, USERNAME_LENGTH + 1) - user;
|
2004-10-23 09:32:52 +02:00
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
set_password(password);
|
|
|
|
}
|
2004-10-23 09:32:52 +02:00
|
|
|
|
|
|
|
int User::init(const char *line)
|
|
|
|
{
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
const char *name_begin, *name_end, *password;
|
2006-05-18 16:57:50 +02:00
|
|
|
int password_length;
|
2004-10-23 09:32:52 +02:00
|
|
|
|
|
|
|
if (line[0] == '\'' || line[0] == '"')
|
|
|
|
{
|
|
|
|
name_begin= line + 1;
|
|
|
|
name_end= strchr(name_begin, line[0]);
|
|
|
|
if (name_end == 0 || name_end[1] != ':')
|
2006-05-18 16:57:50 +02:00
|
|
|
{
|
|
|
|
log_info("Error: invalid format (unmatched quote) of user line (%s).",
|
2006-11-16 21:36:20 +01:00
|
|
|
(const char *) line);
|
2006-05-18 16:57:50 +02:00
|
|
|
return 1;
|
|
|
|
}
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
password= name_end + 2;
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name_begin= line;
|
|
|
|
name_end= strchr(name_begin, ':');
|
|
|
|
if (name_end == 0)
|
2006-05-18 16:57:50 +02:00
|
|
|
{
|
|
|
|
log_info("Error: invalid format (no delimiter) of user line (%s).",
|
2006-11-16 21:36:20 +01:00
|
|
|
(const char *) line);
|
2006-05-18 16:57:50 +02:00
|
|
|
return 1;
|
|
|
|
}
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
password= name_end + 1;
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
2006-05-18 16:57:50 +02:00
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
user_length= name_end - name_begin;
|
|
|
|
if (user_length > USERNAME_LENGTH)
|
2006-05-18 16:57:50 +02:00
|
|
|
{
|
|
|
|
log_info("Error: user name is too long (%d). Max length: %d. "
|
2006-11-16 21:36:20 +01:00
|
|
|
"User line: '%s'.",
|
|
|
|
(int) user_length,
|
|
|
|
(int) USERNAME_LENGTH,
|
|
|
|
(const char *) line);
|
2006-05-18 16:57:50 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
password_length= strlen(password);
|
|
|
|
if (password_length > SCRAMBLED_PASSWORD_CHAR_LENGTH)
|
|
|
|
{
|
2006-11-16 21:36:20 +01:00
|
|
|
log_info("Error: password is too long (%d). Max length: %d."
|
|
|
|
"User line: '%s'.",
|
2006-11-01 18:41:09 +01:00
|
|
|
(int) password_length,
|
|
|
|
(int) SCRAMBLED_PASSWORD_CHAR_LENGTH,
|
|
|
|
line);
|
2006-05-18 16:57:50 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2004-10-23 09:32:52 +02:00
|
|
|
|
|
|
|
memcpy(user, name_begin, user_length);
|
|
|
|
user[user_length]= 0;
|
2006-05-18 16:57:50 +02:00
|
|
|
|
|
|
|
memcpy(scrambled_password, password, password_length);
|
|
|
|
scrambled_password[password_length]= 0;
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
get_salt_from_password(salt, password);
|
2006-05-18 16:57:50 +02:00
|
|
|
|
|
|
|
log_info("loaded user '%s'.", user);
|
2004-10-23 09:32:52 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
C_MODE_START
|
|
|
|
|
|
|
|
static byte* get_user_key(const byte* u, uint* len,
|
|
|
|
my_bool __attribute__((unused)) t)
|
|
|
|
{
|
|
|
|
const User *user= (const User *) u;
|
|
|
|
*len= user->user_length;
|
|
|
|
return (byte *) user->user;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_user(void *u)
|
|
|
|
{
|
|
|
|
User *user= (User *) u;
|
|
|
|
delete user;
|
|
|
|
}
|
|
|
|
|
|
|
|
C_MODE_END
|
|
|
|
|
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
void User_map::Iterator::reset()
|
|
|
|
{
|
|
|
|
cur_idx= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User *User_map::Iterator::next()
|
|
|
|
{
|
|
|
|
if (cur_idx < user_map->hash.records)
|
|
|
|
return (User *) hash_element(&user_map->hash, cur_idx++);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-02 08:11:03 +01:00
|
|
|
int User_map::init()
|
2004-10-23 09:32:52 +02:00
|
|
|
{
|
IM port cleanup
server-tools/instance-manager/IMService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
simplify password file processing
2005-08-05 15:02:06 +02:00
|
|
|
enum { START_HASH_SIZE= 16 };
|
2004-11-02 08:11:03 +01:00
|
|
|
if (hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0,
|
|
|
|
get_user_key, delete_user, 0))
|
|
|
|
return 1;
|
2006-05-18 16:57:50 +02:00
|
|
|
|
|
|
|
initialized= TRUE;
|
|
|
|
|
2004-11-02 08:11:03 +01:00
|
|
|
return 0;
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
|
|
|
|
2004-11-02 08:11:03 +01:00
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
User_map::User_map()
|
|
|
|
:initialized(FALSE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
User_map::~User_map()
|
|
|
|
{
|
2006-05-18 16:57:50 +02:00
|
|
|
if (initialized)
|
|
|
|
hash_free(&hash);
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-05-18 16:57:50 +02:00
|
|
|
Load password database.
|
|
|
|
|
Port cleanups, trivial refactoring and code rearrangements from
Alik's patch for BUG#22306: STOP INSTANCE can not be applied for
instances in Crashed, Failed and Abandoned" to ease review process.
Evaluate global variable linuxthreads before starting threads to avoid
a race.
server-tools/instance-manager/buffer.cc:
Fix spelling.
server-tools/instance-manager/command.h:
Fix spelling.
server-tools/instance-manager/commands.cc:
Fix spelling.
server-tools/instance-manager/commands.h:
Fix spelling, tidy up.
server-tools/instance-manager/guardian.cc:
Cleanup logging, options.get_shutdown_delay() is a method, tidy up.
server-tools/instance-manager/instance.cc:
Rearrange methods to be the same as in Alik's patch, fix spelling errors,
clean up logging texts, port comments from Alik's patch,
implement some basic renames from his patch.
No real changes.
server-tools/instance-manager/instance.h:
Tidy up, renames.
server-tools/instance-manager/instance_map.cc:
Fix spellings, port some refactoring from Alik's patch.
server-tools/instance-manager/instance_map.h:
Cleanup.
server-tools/instance-manager/instance_options.cc:
Cleanup. Implement Instance_options::get_shutdown_delay() and
Instance_options::get_mysqld_port().
server-tools/instance-manager/instance_options.h:
Cleanup.
server-tools/instance-manager/listener.cc:
Cleanup.
server-tools/instance-manager/log.cc:
Fix spelling.
server-tools/instance-manager/manager.cc:
Cleanup.
server-tools/instance-manager/manager.h:
Add getters for Manager members.
server-tools/instance-manager/mysqlmanager.cc:
Evaluate linuxthreads before starting threads to avoid a race.
server-tools/instance-manager/parse_output.cc:
Fix spelling.
server-tools/instance-manager/priv.cc:
Cleanup.
server-tools/instance-manager/priv.h:
Cleanup.
server-tools/instance-manager/user_management_commands.cc:
Fix spelling.
server-tools/instance-manager/user_management_commands.h:
Fix spelling.
server-tools/instance-manager/user_map.cc:
Fix spelling.
2006-11-17 23:34:44 +01:00
|
|
|
SYNOPSIS
|
2006-05-18 16:57:50 +02:00
|
|
|
load()
|
|
|
|
password_file_name [IN] password file path
|
|
|
|
err_msg [OUT] error message
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Load all users from the password file. Must be called once right after
|
|
|
|
construction. In case of failure, puts error message to the log file and
|
|
|
|
returns specific error code.
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
0 on success
|
|
|
|
!0 on error
|
2004-10-23 09:32:52 +02:00
|
|
|
*/
|
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
int User_map::load(const char *password_file_name, const char **err_msg)
|
2004-10-23 09:32:52 +02:00
|
|
|
{
|
2006-05-18 16:57:50 +02:00
|
|
|
static const int ERR_MSG_BUF_SIZE = 255;
|
|
|
|
static char err_msg_buf[ERR_MSG_BUF_SIZE];
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
FILE *file;
|
|
|
|
char line[USERNAME_LENGTH + SCRAMBLED_PASSWORD_CHAR_LENGTH +
|
|
|
|
2 + /* for possible quotes */
|
|
|
|
1 + /* for ':' */
|
2005-08-29 21:29:35 +02:00
|
|
|
2 + /* for newline */
|
2004-10-23 09:32:52 +02:00
|
|
|
1]; /* for trailing zero */
|
|
|
|
User *user;
|
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
if (my_access(password_file_name, F_OK) != 0)
|
|
|
|
{
|
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"password file (%s) does not exist",
|
|
|
|
(const char *) password_file_name);
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERR_PASSWORD_FILE_DOES_NOT_EXIST;
|
|
|
|
}
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
if ((file= my_fopen(password_file_name, O_RDONLY | O_BINARY, MYF(0))) == 0)
|
|
|
|
{
|
2006-05-18 16:57:50 +02:00
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"can not open password file (%s): %s",
|
|
|
|
(const char *) password_file_name,
|
|
|
|
(const char *) strerror(errno));
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERR_IO_ERROR;
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
log_info("loading the password database...");
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
while (fgets(line, sizeof(line), file))
|
|
|
|
{
|
2006-05-18 16:57:50 +02:00
|
|
|
char *user_line= line;
|
|
|
|
|
|
|
|
/*
|
|
|
|
We need to skip EOL-symbols also from the beginning of the line, because
|
|
|
|
if the previous line was ended by \n\r sequence, we get \r in our line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (user_line[0] == '\r' || user_line[0] == '\n')
|
|
|
|
++user_line;
|
|
|
|
|
|
|
|
/* Skip EOL-symbols in the end of the line. */
|
|
|
|
|
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
if ((ptr= strchr(user_line, '\n')))
|
|
|
|
*ptr= 0;
|
|
|
|
|
|
|
|
if ((ptr= strchr(user_line, '\r')))
|
|
|
|
*ptr= 0;
|
|
|
|
}
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
/* skip comments and empty lines */
|
2006-05-18 16:57:50 +02:00
|
|
|
if (!user_line[0] || user_line[0] == '#')
|
2004-10-23 09:32:52 +02:00
|
|
|
continue;
|
2006-05-18 16:57:50 +02:00
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
if ((user= new User) == 0)
|
2006-05-18 16:57:50 +02:00
|
|
|
{
|
|
|
|
my_fclose(file, MYF(0));
|
|
|
|
|
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"out of memory while parsing password file (%s)",
|
|
|
|
(const char *) password_file_name);
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (user->init(user_line))
|
|
|
|
{
|
|
|
|
delete user;
|
|
|
|
my_fclose(file, MYF(0));
|
|
|
|
|
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"password file (%s) corrupted",
|
|
|
|
(const char *) password_file_name);
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERR_PASSWORD_FILE_CORRUPTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (my_hash_insert(&hash, (byte *) user))
|
|
|
|
{
|
|
|
|
delete user;
|
|
|
|
my_fclose(file, MYF(0));
|
|
|
|
|
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"out of memory while parsing password file (%s)",
|
|
|
|
(const char *) password_file_name);
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERR_OUT_OF_MEMORY;
|
|
|
|
}
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
2006-05-18 16:57:50 +02:00
|
|
|
|
|
|
|
log_info("the password database loaded successfully.");
|
|
|
|
|
2004-10-23 09:32:52 +02:00
|
|
|
my_fclose(file, MYF(0));
|
2006-05-18 16:57:50 +02:00
|
|
|
|
|
|
|
if (err_msg)
|
|
|
|
*err_msg= NULL;
|
|
|
|
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int User_map::save(const char *password_file_name, const char **err_msg)
|
|
|
|
{
|
|
|
|
static const int ERR_MSG_BUF_SIZE = 255;
|
|
|
|
static char err_msg_buf[ERR_MSG_BUF_SIZE];
|
|
|
|
|
|
|
|
FILE *file;
|
|
|
|
|
|
|
|
if ((file= my_fopen(password_file_name, O_WRONLY | O_TRUNC | O_BINARY,
|
|
|
|
MYF(0))) == 0)
|
|
|
|
{
|
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"can not open password file (%s) for writing: %s",
|
|
|
|
(const char *) password_file_name,
|
|
|
|
(const char *) strerror(errno));
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERR_IO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
User_map::Iterator it(this);
|
|
|
|
User *user;
|
|
|
|
|
|
|
|
while ((user= it.next()))
|
|
|
|
{
|
|
|
|
if (fprintf(file, "%s:%s\n", (const char *) user->user,
|
|
|
|
(const char *) user->scrambled_password) < 0)
|
|
|
|
{
|
|
|
|
if (err_msg)
|
|
|
|
{
|
|
|
|
snprintf(err_msg_buf, ERR_MSG_BUF_SIZE,
|
|
|
|
"can not write to password file (%s): %s",
|
|
|
|
(const char *) password_file_name,
|
|
|
|
(const char *) strerror(errno));
|
|
|
|
*err_msg= err_msg_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
my_fclose(file, MYF(0));
|
|
|
|
|
|
|
|
return ERR_IO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my_fclose(file, MYF(0));
|
|
|
|
|
|
|
|
return ERR_OK;
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check if user exists and password is correct
|
|
|
|
RETURN VALUE
|
|
|
|
0 - user found and password OK
|
|
|
|
1 - password mismatch
|
|
|
|
2 - user not found
|
|
|
|
*/
|
|
|
|
|
2006-05-18 16:57:50 +02:00
|
|
|
int User_map::authenticate(const LEX_STRING *user_name,
|
2004-10-23 09:32:52 +02:00
|
|
|
const char *scrambled_password,
|
|
|
|
const char *scramble) const
|
|
|
|
{
|
2006-05-18 16:57:50 +02:00
|
|
|
const User *user= find_user(user_name);
|
|
|
|
return user ? check_scramble(scrambled_password, scramble, user->salt) : 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User *User_map::find_user(const LEX_STRING *user_name)
|
|
|
|
{
|
|
|
|
return (User*) hash_search(&hash, (byte*) user_name->str, user_name->length);
|
|
|
|
}
|
|
|
|
|
|
|
|
const User *User_map::find_user(const LEX_STRING *user_name) const
|
|
|
|
{
|
|
|
|
return const_cast<User_map *> (this)->find_user(user_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool User_map::add_user(User *user)
|
|
|
|
{
|
|
|
|
return my_hash_insert(&hash, (byte*) user) == 0 ? FALSE : TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool User_map::remove_user(User *user)
|
|
|
|
{
|
|
|
|
return hash_delete(&hash, (byte*) user) == 0 ? FALSE : TRUE;
|
2004-10-23 09:32:52 +02:00
|
|
|
}
|