~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to server-tools/instance-manager/user_map.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2004-2006 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_USER_MAP_H
 
17
#define INCLUDES_MYSQL_INSTANCE_MANAGER_USER_MAP_H
 
18
 
 
19
#include <my_global.h>
 
20
#include <my_sys.h>
 
21
#include <mysql_com.h>
 
22
#include <m_string.h>
 
23
#include <hash.h>
 
24
 
 
25
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
 
26
#pragma interface
 
27
#endif
 
28
 
 
29
struct User
 
30
{
 
31
  User()
 
32
  {}
 
33
 
 
34
  User(const LEX_STRING *user_name_arg, const char *password);
 
35
 
 
36
  int init(const char *line);
 
37
 
 
38
  inline void set_password(const char *password)
 
39
  {
 
40
    make_scrambled_password(scrambled_password, password);
 
41
  }
 
42
 
 
43
  char user[USERNAME_LENGTH + 1];
 
44
  char scrambled_password[SCRAMBLED_PASSWORD_CHAR_LENGTH + 1];
 
45
  uint8 user_length;
 
46
  uint8 salt[SCRAMBLE_LENGTH];
 
47
};
 
48
 
 
49
/*
 
50
  User_map -- all users and passwords
 
51
*/
 
52
 
 
53
class User_map
 
54
{
 
55
public:
 
56
  /* User_map iterator */
 
57
 
 
58
  class Iterator
 
59
  {
 
60
  public:
 
61
    Iterator(User_map *user_map_arg) :
 
62
      user_map(user_map_arg), cur_idx(0)
 
63
    { }
 
64
 
 
65
  public:
 
66
    void reset();
 
67
 
 
68
    User *next();
 
69
 
 
70
  private:
 
71
    User_map *user_map;
 
72
    uint cur_idx;
 
73
  };
 
74
 
 
75
public:
 
76
  User_map();
 
77
  ~User_map();
 
78
 
 
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;
 
85
 
 
86
  const User *find_user(const LEX_STRING *user_name) const;
 
87
  User *find_user(const LEX_STRING *user_name);
 
88
 
 
89
  bool add_user(User *user);
 
90
  bool remove_user(User *user);
 
91
 
 
92
private:
 
93
  User_map(const User_map &);
 
94
  User_map &operator =(const User_map &);
 
95
 
 
96
private:
 
97
  HASH hash;
 
98
  bool initialized;
 
99
 
 
100
  friend class Iterator;
 
101
};
 
102
 
 
103
#endif // INCLUDES_MYSQL_INSTANCE_MANAGER_USER_MAP_H