Fix for bug 127 and 345 as part of it
Fix for bug 127 and 345 as part of it http://bugs.skysql.com/show_bug.cgi?id=127 http://bugs.skysql.com/show_bug.cgi?id=345
This commit is contained in:
@ -25,12 +25,24 @@
|
||||
* @verbatim
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* 25/06/13 Mark Riddoch Initial implementation
|
||||
* Date Who Description
|
||||
* 25/06/13 Mark Riddoch Initial implementation
|
||||
* 25/02/13 Massimiliano Pinto Added users table refresh rate default values
|
||||
*
|
||||
* @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
|
||||
|
||||
extern int load_mysql_users(SERVICE *service);
|
||||
extern int reload_mysql_users(SERVICE *service);
|
||||
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
|
||||
@ -27,12 +28,16 @@
|
||||
* @verbatim
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* 23/06/13 Mark Riddoch Initial implementation
|
||||
* Date Who Description
|
||||
* 23/06/13 Mark Riddoch Initial implementation
|
||||
* 26/02/14 Massimiliano Pinto Added checksum to users' table with SHA1
|
||||
* 27/02/14 Massimiliano Pinto Added USERS_HASHTABLE_DEFAULT_SIZE
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#define USERS_HASHTABLE_DEFAULT_SIZE 52
|
||||
|
||||
/**
|
||||
* The users table statistics structure
|
||||
*/
|
||||
@ -48,8 +53,10 @@ typedef struct {
|
||||
* for the authentication implementation within the gateway.
|
||||
*/
|
||||
typedef struct users {
|
||||
HASHTABLE *data; /**< The hashtable containing the actual data */
|
||||
USERS_STATS stats; /**< The statistics for the users table */
|
||||
HASHTABLE *data; /**< The hashtable containing the actual data */
|
||||
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