From a4426b68247a97568594fc95bd838e3e1f8a77a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 1 Mar 2012 18:48:25 +0100 Subject: [PATCH] Feature #1112: Store oneadmin's ID and name in UserPool --- include/UserPool.h | 10 ++++++++++ src/um/UserPool.cc | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/UserPool.h b/include/UserPool.h index 3926c71613..afe2e54e36 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -176,6 +176,16 @@ public: */ static const char * SERVER_NAME; + /** + * Name of the oneadmin user + */ + static string oneadmin_name; + + /** + * Identifier for the oneadmin user + */ + static const int ONEADMIN_ID; + private: //-------------------------------------------------------------------------- // Configuration Attributes for Users diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 49598ed499..d06e6d90d6 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -40,11 +40,15 @@ const char * UserPool::DEFAULT_AUTH = "default"; const char * UserPool::SERVER_NAME = "serveradmin"; +const int UserPool::ONEADMIN_ID = 0; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ time_t UserPool::_session_expiration_time; +string UserPool::oneadmin_name; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -74,8 +78,13 @@ UserPool::UserPool(SqlDB * db, _session_expiration_time = __session_expiration_time; - if (get(0,false) != 0) + User * oneadmin_user = get(0, true); + + if (oneadmin_user != 0) { + oneadmin_name = oneadmin_user->get_name(); + oneadmin_user->unlock(); + return; } @@ -122,6 +131,8 @@ UserPool::UserPool(SqlDB * db, goto error_token; } + oneadmin_name = one_name; + if ( one_name == SERVER_NAME ) { goto error_one_name;