Compile adminusers.c as C++

This commit is contained in:
Johan Wikman
2017-03-22 15:50:45 +02:00
parent 1a8ff4b813
commit f82232eac6
2 changed files with 19 additions and 28 deletions

View File

@ -1,4 +1,6 @@
add_library(maxscale-common SHARED adminusers.c alloc.c authenticator.c atomic.c buffer.c config.c config_runtime.c dcb.c filter.c filter.cc externcmd.c paths.c hashtable.c hint.c housekeeper.c load_utils.c log_manager.cc maxscale_pcre2.c misc.c mlist.c modutil.c monitor.c queuemanager.c query_classifier.cc poll.c random_jkiss.c resultset.c router.cc secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c skygw_utils.cc statistics.c listener.c ssl.c mysql_utils.c mysql_binlog.c modulecmd.c)
add_library(maxscale-common SHARED
adminusers.cc
alloc.c authenticator.c atomic.c buffer.c config.c config_runtime.c dcb.c filter.c filter.cc externcmd.c paths.c hashtable.c hint.c housekeeper.c load_utils.c log_manager.cc maxscale_pcre2.c misc.c mlist.c modutil.c monitor.c queuemanager.c query_classifier.cc poll.c random_jkiss.c resultset.c router.cc secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c skygw_utils.cc statistics.c listener.c ssl.c mysql_utils.c mysql_binlog.c modulecmd.c)
if(WITH_JEMALLOC)
target_link_libraries(maxscale-common ${JEMALLOC_LIBRARIES})

View File

@ -25,19 +25,8 @@
/**
* @file adminusers.c - Administration user account management
*
* @verbatim
* Revision History
*
* Date Who Description
* 18/07/13 Mark Riddoch Initial implementation
* 23/07/13 Mark Riddoch Addition of error mechanism to add user
* 23/05/16 Massimiliano Pinto admin_add_user and admin_remove_user
* no longer accept password parameter
* 02/09/16 Johan Wikman Enabled Linux accounts and MaxScale users
*
* @endverbatim
*/
static void initialise();
static USERS *loadLinuxUsers();
@ -55,18 +44,18 @@ static USERS *linux_users = NULL;
static USERS *inet_users = NULL;
static int admin_init = 0;
static char *ADMIN_ERR_NOMEM = "Out of memory";
static char *ADMIN_ERR_FILEOPEN = "Unable to create password file";
static char *ADMIN_ERR_DUPLICATE = "Duplicate username specified";
static char *ADMIN_ERR_USERNOTFOUND = "User not found";
static char *ADMIN_ERR_AUTHENTICATION = "Authentication failed";
static char *ADMIN_ERR_FILEAPPEND = "Unable to append to password file";
static char *ADMIN_ERR_PWDFILEOPEN = "Failed to open password file";
static char *ADMIN_ERR_TMPFILEOPEN = "Failed to open temporary password file";
static char *ADMIN_ERR_PWDFILEACCESS = "Failed to access password file";
static char *ADMIN_ERR_DELLASTUSER = "Deleting the last user is forbidden";
static char *ADMIN_ERR_DELROOT = "Deleting the default admin user is forbidden";
static char *ADMIN_SUCCESS = NULL;
static const char *ADMIN_ERR_NOMEM = "Out of memory";
static const char *ADMIN_ERR_FILEOPEN = "Unable to create password file";
static const char *ADMIN_ERR_DUPLICATE = "Duplicate username specified";
static const char *ADMIN_ERR_USERNOTFOUND = "User not found";
static const char *ADMIN_ERR_AUTHENTICATION = "Authentication failed";
static const char *ADMIN_ERR_FILEAPPEND = "Unable to append to password file";
static const char *ADMIN_ERR_PWDFILEOPEN = "Failed to open password file";
static const char *ADMIN_ERR_TMPFILEOPEN = "Failed to open temporary password file";
static const char *ADMIN_ERR_PWDFILEACCESS = "Failed to access password file";
static const char *ADMIN_ERR_DELLASTUSER = "Deleting the last user is forbidden";
static const char *ADMIN_ERR_DELROOT = "Deleting the default admin user is forbidden";
static const char *ADMIN_SUCCESS = NULL;
static const int LINELEN = 80;
@ -329,10 +318,10 @@ void dcb_print_users(DCB *dcb, const char* heading, USERS *users)
if (iter)
{
char *sep = "";
const char *sep = "";
const char *user;
while ((user = hashtable_next(iter)) != NULL)
while ((user = (const char*)hashtable_next(iter)) != NULL)
{
dcb_printf(dcb, "%s%s", sep, user);
sep = ", ";
@ -387,7 +376,7 @@ loadUsers(const char *fname)
break;
}
char *password;
const char *password;
char *colon = strchr(uname, ':');
if (colon)
{