Files updated for user@host mysql auth
Files updated for user@host mysql auth
This commit is contained in:
@ -17,7 +17,9 @@
|
||||
*
|
||||
* Copyright SkySQL Ab 2013
|
||||
*/
|
||||
|
||||
#include <service.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -28,11 +30,22 @@
|
||||
*
|
||||
* Date Who Description
|
||||
* 25/06/13 Mark Riddoch Initial implementation
|
||||
* 07/02/14 Massimiliano Pinto Added MySQL user and host data structure
|
||||
* 25/02/13 Massimiliano Pinto Added users table refresh rate default values
|
||||
* 28/02/14 Massimiliano Pinto Added MySQL user and host data structure
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
/* Refresh rate limits for load users from database */
|
||||
#define USERS_REFRESH_TIME 30 /* Allowed time interval (in seconds) after last update*/
|
||||
#define USERS_REFRESH_MAX_PER_TIME 4 /* Max number of load calls within the time interval */
|
||||
|
||||
/* Max length of fields in the mysql.user table */
|
||||
#define MYSQL_USER_MAXLEN 128
|
||||
#define MYSQL_PASSWORD_LEN 41
|
||||
#define MYSQL_HOST_MAXLEN 60
|
||||
#define MYSQL_DATABASE_MAXLEN 128
|
||||
|
||||
/**
|
||||
* MySQL user and host data structure
|
||||
*/
|
||||
@ -46,4 +59,5 @@ extern int reload_mysql_users(SERVICE *service);
|
||||
extern int mysql_users_add(USERS *users, MYSQL_USER_HOST *key, char *auth);
|
||||
extern USERS *mysql_users_alloc();
|
||||
extern char *mysql_users_fetch(USERS *users, MYSQL_USER_HOST *key);
|
||||
extern int replace_mysql_users(SERVICE *service);
|
||||
#endif
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
* prototypes
|
||||
* 23/06/13 Mark Riddoch Added service user and users
|
||||
* 06/02/14 Massimiliano Pinto Added service flag for root user access
|
||||
* 25/02/14 Massimiliano Pinto Added service refresh limit feature
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -79,6 +80,15 @@ typedef struct {
|
||||
char *authdata; /**< The authentication data requied */
|
||||
} SERVICE_USER;
|
||||
|
||||
/**
|
||||
* The service refresh rate hols the counter and last load timet for this service to
|
||||
* load users data from the backend database
|
||||
*/
|
||||
typedef struct {
|
||||
int nloads;
|
||||
time_t last;
|
||||
} SERVICE_REFRESH_RATE;
|
||||
|
||||
/**
|
||||
* Defines a service within the gateway.
|
||||
*
|
||||
@ -87,24 +97,28 @@ typedef struct {
|
||||
* to the service.
|
||||
*/
|
||||
typedef struct service {
|
||||
char *name; /**< The service name */
|
||||
int state; /**< The service state */
|
||||
SERV_PROTOCOL *ports; /**< Linked list of ports and protocols
|
||||
* that this service will listen on.
|
||||
*/
|
||||
char *routerModule; /**< Name of router module to use */
|
||||
char **routerOptions;/**< Router specific option strings */
|
||||
char *name; /**< The service name */
|
||||
int state; /**< The service state */
|
||||
SERV_PROTOCOL *ports; /**< Linked list of ports and protocols
|
||||
* that this service will listen on.
|
||||
*/
|
||||
char *routerModule; /**< Name of router module to use */
|
||||
char **routerOptions; /**< Router specific option strings */
|
||||
struct router_object
|
||||
*router; /**< The router we are using */
|
||||
*router; /**< The router we are using */
|
||||
void *router_instance;
|
||||
/**< The router instance for this service */
|
||||
struct server *databases; /**< The set of servers in the backend */
|
||||
SERVICE_USER credentials; /**< The cedentials of the service user */
|
||||
SPINLOCK spin; /**< The service spinlock */
|
||||
SERVICE_STATS stats; /**< The service statistics */
|
||||
struct users *users; /**< The user data for this service */
|
||||
int enable_root; /**< Allow root user access */
|
||||
struct service *next; /**< The next service in the linked list */
|
||||
/**< The router instance for this service */
|
||||
struct server *databases; /**< The set of servers in the backend */
|
||||
SERVICE_USER credentials; /**< The cedentials of the service user */
|
||||
SPINLOCK spin; /**< The service spinlock */
|
||||
SERVICE_STATS stats; /**< The service statistics */
|
||||
struct users *users; /**< The user data for this service */
|
||||
int enable_root; /**< Allow root user access */
|
||||
SPINLOCK
|
||||
users_table_spin; /**< The spinlock for users data refresh */
|
||||
SERVICE_REFRESH_RATE
|
||||
rate_limit; /**< The refresh rate limit for users table */
|
||||
struct service *next; /**< The next service in the linked list */
|
||||
} SERVICE;
|
||||
|
||||
#define SERVICE_STATE_ALLOC 1 /**< The service has been allocated */
|
||||
@ -128,6 +142,7 @@ extern int serviceSetUser(SERVICE *, char *, char *);
|
||||
extern int serviceGetUser(SERVICE *, char **, char **);
|
||||
extern int serviceEnableRootUser(SERVICE *, int );
|
||||
extern void service_update(SERVICE *, char *, char *, char *);
|
||||
extern int service_refresh_users(SERVICE *);
|
||||
extern void printService(SERVICE *);
|
||||
extern void printAllServices();
|
||||
extern void dprintAllServices(DCB *);
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
*/
|
||||
#include <hashtable.h>
|
||||
#include <dcb.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
/**
|
||||
* @file users.h The functions to manipulate the table of users maintained
|
||||
@ -29,13 +30,14 @@
|
||||
*
|
||||
* Date Who Description
|
||||
* 23/06/13 Mark Riddoch Initial implementation
|
||||
* 14/02/14 Massimiliano Pinto Added usersCustomUserFormat, optional username format routine
|
||||
* 21/02/14 Massimiliano Pinto Added USERS_HASHTABLE_SIZE
|
||||
* 26/02/14 Massimiliano Pinto Added checksum to users' table with SHA1
|
||||
* 27/02/14 Massimiliano Pinto Added USERS_HASHTABLE_DEFAULT_SIZE
|
||||
* 28/02/14 Massimiliano Pinto Added usersCustomUserFormat, optional username format routine
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#define USERS_HASHTABLE_SIZE 52
|
||||
#define USERS_HASHTABLE_DEFAULT_SIZE 52
|
||||
|
||||
/**
|
||||
* The users table statistics structure
|
||||
@ -55,6 +57,8 @@ typedef struct users {
|
||||
HASHTABLE *data; /**< The hashtable containing the actual data */
|
||||
char *(*usersCustomUserFormat)(void *); /**< Optional username format routine */
|
||||
USERS_STATS stats; /**< The statistics for the users table */
|
||||
unsigned char
|
||||
cksum[SHA_DIGEST_LENGTH]; /**< The users' table ckecksum */
|
||||
} USERS;
|
||||
|
||||
extern USERS *users_alloc(); /**< Allocate a users table */
|
||||
|
||||
Reference in New Issue
Block a user