~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to sql/sql_acl.h

  • Committer: bk at mysql
  • Date: 2000-07-31 19:29:14 UTC
  • Revision ID: sp1r-bk@work.mysql.com-20000731192914-08846
Import changeset

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
 
6
   (at your option) any later version.
 
7
   
 
8
   This program is distributed in the hope that it will be useful,
 
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
   GNU General Public License for more details.
 
12
   
 
13
   You should have received a copy of the GNU General Public License
 
14
   along with this program; if not, write to the Free Software
 
15
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
16
 
 
17
 
 
18
#define SELECT_ACL      1
 
19
#define INSERT_ACL      2
 
20
#define UPDATE_ACL      4
 
21
#define DELETE_ACL      8
 
22
#define CREATE_ACL      16
 
23
#define DROP_ACL        32
 
24
#define RELOAD_ACL      64
 
25
#define SHUTDOWN_ACL    128
 
26
#define PROCESS_ACL     256
 
27
#define FILE_ACL        512
 
28
#define GRANT_ACL       1024
 
29
#define REFERENCES_ACL  2048
 
30
#define INDEX_ACL       4096
 
31
#define ALTER_ACL       8192
 
32
#define EXTRA_ACL       16384
 
33
#define DB_ACLS         (UPDATE_ACL | SELECT_ACL | INSERT_ACL | \
 
34
                         DELETE_ACL | CREATE_ACL | DROP_ACL | GRANT_ACL | \
 
35
                         REFERENCES_ACL | INDEX_ACL | ALTER_ACL)
 
36
#define TABLE_ACLS      (SELECT_ACL | INSERT_ACL | UPDATE_ACL | \
 
37
                         DELETE_ACL | CREATE_ACL | DROP_ACL | GRANT_ACL | \
 
38
                         REFERENCES_ACL | INDEX_ACL | ALTER_ACL)
 
39
#define COL_ACLS        (SELECT_ACL | INSERT_ACL | UPDATE_ACL | REFERENCES_ACL)
 
40
#define GLOBAL_ACLS     (SELECT_ACL | INSERT_ACL | UPDATE_ACL | DELETE_ACL |\
 
41
                         CREATE_ACL | DROP_ACL |  RELOAD_ACL | SHUTDOWN_ACL |\
 
42
                         PROCESS_ACL | FILE_ACL | GRANT_ACL | REFERENCES_ACL |\
 
43
                         INDEX_ACL | ALTER_ACL)
 
44
#define NO_ACCESS       32768
 
45
 
 
46
/* defines to change the above bits to how things are stored in tables */
 
47
 
 
48
#define fix_rights_for_db(A) (((A) & 63) | (((A) & ~63) << 4))
 
49
#define get_rights_for_db(A) (((A) & 63) | (((A) & ~63) >> 4))
 
50
#define fix_rights_for_table(A) (((A) & 63) | (((A) & ~63) << 4))
 
51
#define get_rights_for_table(A) (((A) & 63) | (((A) & ~63) >> 4))
 
52
#define fix_rights_for_column(A) (((A) & COL_ACLS) | ((A & ~COL_ACLS) << 7))
 
53
#define get_rights_for_column(A) (((A) & COL_ACLS) | ((A & ~COL_ACLS) >> 7))
 
54
 
 
55
/* prototypes */
 
56
 
 
57
int  acl_init(bool dont_read_acl_tables);
 
58
void acl_reload(void);
 
59
void acl_free(bool end=0);
 
60
uint acl_get(const char *host, const char *ip, const char *bin_ip,
 
61
             const char *user, const char *db);
 
62
uint acl_getroot(const char *host, const char *ip, const char *user,
 
63
                 const char *password,const char *scramble,char **priv_user,
 
64
                 bool old_ver);
 
65
bool acl_check_host(const char *host, const char *ip);
 
66
bool change_password(THD *thd, const char *host, const char *user,
 
67
                     char *password);
 
68
int mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list,
 
69
                uint rights, bool revoke);
 
70
int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
 
71
                      List <LEX_COLUMN> &column_list, uint rights,
 
72
                      bool revoke);
 
73
int  grant_init(void);
 
74
void grant_free(void);
 
75
void grant_reload(void);
 
76
bool check_grant(THD *thd, uint want_access, TABLE_LIST *tables,
 
77
                 uint show_command=0);
 
78
bool check_grant_column (THD *thd,TABLE *table, const char *name,uint length,
 
79
                         uint show_command=0);
 
80
bool check_grant_all_columns(THD *thd, uint want_access, TABLE *table);
 
81
bool check_grant_db(THD *thd,const char *db);
 
82
uint get_table_grant(THD *thd, TABLE_LIST *table);
 
83
uint get_column_grant(THD *thd, TABLE_LIST *table, Field *field);
 
84
int mysql_show_grants(THD *thd, LEX_USER *user);