MXS-1354: Prevent removal of last admin account

Removing the last admin account is now forbidden. This should prevent most
cases where users could lock themselves out of the administrative
interface.

This change does allow a non-root network user to be the last admin
account. In practice this does not prevent the root user from gaining
access to maxadmin. Access can be gained by removing the users file and
restarting MaxScale or by editing the users file by hand.
This commit is contained in:
Markus Mäkelä
2017-08-17 09:59:30 +03:00
parent 828649ba99
commit 6cc3986db5
5 changed files with 34 additions and 27 deletions

View File

@ -85,6 +85,7 @@ bool admin_verify_inet_user(const char *uname, const char *password);
bool admin_user_is_inet_admin(const char* username);
bool admin_user_is_unix_admin(const char* username);
bool admin_have_admin();
bool admin_is_last_admin(const char* user);
/**
* @brief Convert all admin users to JSON

View File

@ -109,13 +109,13 @@ bool users_find(USERS* users, const char* user);
bool users_is_admin(USERS* users, const char* user);
/**
* Check if at least one admin account exists
* Check how many admin account exists
*
* @param users Users to check
*
* @return True if at least one admin account exists
* @return Number of admin accounts
*/
bool users_have_admin(USERS* users);
int users_admin_count(USERS* users);
/**
* Dump users as JSON