mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / server-tools / instance-manager / user_map.h
blobe395dad39d1a7d88cd6504c132eab36ccf4460ca
1 /* Copyright (C) 2004-2006 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_USER_MAP_H
17 #define INCLUDES_MYSQL_INSTANCE_MANAGER_USER_MAP_H
19 #include <my_global.h>
20 #include <my_sys.h>
21 #include <mysql_com.h>
22 #include <m_string.h>
23 #include <hash.h>
25 #if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
26 #pragma interface
27 #endif
29 struct User
31 User()
34 User(const LEX_STRING *user_name_arg, const char *password);
36 int init(const char *line);
38 inline void set_password(const char *password)
40 make_scrambled_password(scrambled_password, password);
43 char user[USERNAME_LENGTH + 1];
44 char scrambled_password[SCRAMBLED_PASSWORD_CHAR_LENGTH + 1];
45 uint8 user_length;
46 uint8 salt[SCRAMBLE_LENGTH];
50 User_map -- all users and passwords
53 class User_map
55 public:
56 /* User_map iterator */
58 class Iterator
60 public:
61 Iterator(User_map *user_map_arg) :
62 user_map(user_map_arg), cur_idx(0)
63 { }
65 public:
66 void reset();
68 User *next();
70 private:
71 User_map *user_map;
72 uint cur_idx;
75 public:
76 User_map();
77 ~User_map();
79 int init();
80 int load(const char *password_file_name, const char **err_msg);
81 int save(const char *password_file_name, const char **err_msg);
82 int authenticate(const LEX_STRING *user_name,
83 const char *scrambled_password,
84 const char *scramble) const;
86 const User *find_user(const LEX_STRING *user_name) const;
87 User *find_user(const LEX_STRING *user_name);
89 bool add_user(User *user);
90 bool remove_user(User *user);
92 private:
93 User_map(const User_map &);
94 User_map &operator =(const User_map &);
96 private:
97 HASH hash;
98 bool initialized;
100 friend class Iterator;
103 #endif // INCLUDES_MYSQL_INSTANCE_MANAGER_USER_MAP_H