1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
6
(at your option) any later version.
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.
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 */
25
#define SHUTDOWN_ACL 128
26
#define PROCESS_ACL 256
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
46
/* defines to change the above bits to how things are stored in tables */
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))
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,
65
bool acl_check_host(const char *host, const char *ip);
66
bool change_password(THD *thd, const char *host, const char *user,
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,
74
void grant_free(void);
75
void grant_reload(void);
76
bool check_grant(THD *thd, uint want_access, TABLE_LIST *tables,
78
bool check_grant_column (THD *thd,TABLE *table, const char *name,uint length,
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);