diff --git a/include/Request.h b/include/Request.h index b25d9702c4..3b1fb70140 100644 --- a/include/Request.h +++ b/include/Request.h @@ -57,6 +57,25 @@ public: INTERNAL = 0x2000, }; + /** + * Sets the format string to log xml-rpc method calls. The format string + * interprets the following sequences: + * %i -- request id + * %m -- method name + * %u -- user id + * %U -- user name + * %l -- param list + * %p -- user password + * %g -- group id + * %G -- group name + * %a -- auth token + * %% -- % + */ + static void set_call_log_format(const string& log_format) + { + format_str = log_format; + } + protected: /* ---------------------------------------------------------------------*/ @@ -73,6 +92,8 @@ protected: string uname; /**< name of the user */ string gname; /**< name of the user's group */ + string password; /**< password of the user */ + set group_ids; /**< set of user's group ids */ string session; /**< Session from ONE XML-RPC API */ @@ -92,6 +113,8 @@ protected: uname = ra.uname; gname = ra.gname; + password = ra.password; + session = ra.session; retval = ra.retval; @@ -103,6 +126,8 @@ protected: uid = _uid; gid = _gid; + password = ""; + uname = ""; gname = ""; @@ -123,6 +148,8 @@ protected: set hidden_params; + static string format_str; + /* -------------------- Constructors ---------------------------------- */ Request(const string& mn, diff --git a/include/RequestManager.h b/include/RequestManager.h index 42d8bc1353..ae26a3b7a9 100644 --- a/include/RequestManager.h +++ b/include/RequestManager.h @@ -49,20 +49,10 @@ public: int _keepalive_timeout, int _keepalive_max_conn, int _timeout, - const string _xml_log_file): - port(_port), - socket_fd(-1), - max_conn(_max_conn), - max_conn_backlog(_max_conn_backlog), - keepalive_timeout(_keepalive_timeout), - keepalive_max_conn(_keepalive_max_conn), - timeout(_timeout), - xml_log_file(_xml_log_file) - { - am.addListener(this); - }; + const string _xml_log_file, + const string call_log_format); - ~RequestManager(){}; + ~RequestManager(){}; /** * This functions starts the associated listener thread (XML server), and diff --git a/include/UserPool.h b/include/UserPool.h index 5f9cdde3ce..c9f2add3b7 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -145,6 +145,7 @@ public: * @return false if authn failed, true otherwise */ bool authenticate(const string& session, + string& password, int& uid, int& gid, string& uname, @@ -221,6 +222,7 @@ private: */ bool authenticate_internal(User * user, const string& token, + string& password, int& user_id, int& group_id, string& uname, @@ -233,6 +235,7 @@ private: */ bool authenticate_server(User * user, const string& token, + string& password, int& user_id, int& group_id, string& uname, @@ -246,6 +249,7 @@ private: */ bool authenticate_external(const string& username, const string& token, + string& password, int& user_id, int& group_id, string& uname, diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 1ffc9e002f..366649bfbd 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -134,6 +134,18 @@ FEDERATION = [ # # MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses. Only relevant for # slave zones. +# +# LOG_CALL_FORMAT: Format string to log XML-RPC calls. Interpreted strings: +# %i -- request id +# %m -- method name +# %u -- user id +# %U -- user name +# %l -- param list +# %p -- user password +# %g -- group id +# %G -- group name +# %a -- auth token +# %% -- % #******************************************************************************* #MAX_CONN = 15 @@ -143,6 +155,7 @@ FEDERATION = [ #TIMEOUT = 15 #RPC_LOG = NO #MESSAGE_SIZE = 1073741824 +#LOG_CALL_FORMAT = "Req:%i UID:%u %m invoked %l" #******************************************************************************* # Physical Networks configuration diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index d762342e08..6e24fcfc92 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -809,7 +809,7 @@ void Nebula::start(bool bootstrap_only) int keepalive_max_conn; int timeout; bool rpc_log; - + string log_call_format; string rpc_filename = ""; nebula_configuration->get("PORT", rm_port); @@ -819,6 +819,7 @@ void Nebula::start(bool bootstrap_only) nebula_configuration->get("KEEPALIVE_MAX_CONN", keepalive_max_conn); nebula_configuration->get("TIMEOUT", timeout); nebula_configuration->get("RPC_LOG", rpc_log); + nebula_configuration->get("LOG_CALL_FORMAT", log_call_format); if (rpc_log) { @@ -826,7 +827,8 @@ void Nebula::start(bool bootstrap_only) } rm = new RequestManager(rm_port, max_conn, max_conn_backlog, - keepalive_timeout, keepalive_max_conn, timeout, rpc_filename); + keepalive_timeout, keepalive_max_conn, timeout, rpc_filename, + log_call_format); } catch (bad_alloc&) { diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 7d966dd98c..d1f71ffe12 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -220,6 +220,7 @@ void OpenNebulaTemplate::set_conf_default() # TIMEOUT # RPC_LOG # MESSAGE_SIZE +# LOG_CALL_FORMAT #******************************************************************************* */ // MAX_CONN @@ -263,6 +264,12 @@ void OpenNebulaTemplate::set_conf_default() attribute = new SingleAttribute("MESSAGE_SIZE",value); conf_default.insert(make_pair(attribute->name(),attribute)); + + //LOG_CALL_FORMAT + value = "Req:%i UID:%u %m invoked %l"; + + attribute = new SingleAttribute("LOG_CALL_FORMAT",value); + conf_default.insert(make_pair(attribute->name(),attribute)); /* #******************************************************************************* # Physical Networks configuration diff --git a/src/rm/Request.cc b/src/rm/Request.cc index e993092607..13d8b81eb8 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -19,6 +19,8 @@ #include "PoolObjectAuth.h" +string Request::format_str; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -37,6 +39,7 @@ void Request::execute( UserPool* upool = nd.get_upool(); bool authenticated = upool->authenticate(att.session, + att.password, att.uid, att.gid, att.uname, @@ -67,28 +70,74 @@ void Request::log_method_invoked( { ostringstream oss; - oss << "Req:" << att.req_id << " UID:"; - - if ( att.uid != -1 ) + for (unsigned int j = 0 ;j < format_str.length() - 1; j++ ) { - oss << att.uid; - } - else - { - oss << "-"; - } - - oss << " " << method_name << " invoked"; - - for (unsigned int i=1; i #include #include @@ -50,6 +52,31 @@ #include #include + +RequestManager::RequestManager( + int _port, + int _max_conn, + int _max_conn_backlog, + int _keepalive_timeout, + int _keepalive_max_conn, + int _timeout, + const string _xml_log_file, + const string call_log_format): + port(_port), + socket_fd(-1), + max_conn(_max_conn), + max_conn_backlog(_max_conn_backlog), + keepalive_timeout(_keepalive_timeout), + keepalive_max_conn(_keepalive_max_conn), + timeout(_timeout), + xml_log_file(_xml_log_file) +{ + Request::set_call_log_format(call_log_format); + + am.addListener(this); +}; + + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 1693acf2b9..9837a321c5 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -415,6 +415,7 @@ int UserPool::update_quotas(User * user) bool UserPool::authenticate_internal(User * user, const string& token, + string& password, int& user_id, int& group_id, string& uname, @@ -426,7 +427,6 @@ bool UserPool::authenticate_internal(User * user, ostringstream oss; - string password; string auth_driver; string username; @@ -527,6 +527,8 @@ auth_failure: user_id = -1; group_id = -1; + password = ""; + group_ids.clear(); uname = ""; @@ -542,6 +544,7 @@ auth_failure: bool UserPool::authenticate_server(User * user, const string& token, + string& password, int& user_id, int& group_id, string& uname, @@ -587,6 +590,8 @@ bool UserPool::authenticate_server(User * user, goto auth_failure_user; } + password = user->get_password(); + user_id = user->oid; group_id = user->gid; @@ -663,6 +668,8 @@ auth_failure: user_id = -1; group_id = -1; + password = ""; + group_ids.clear(); uname = ""; @@ -678,6 +685,7 @@ auth_failure: bool UserPool::authenticate_external(const string& username, const string& token, + string& password, int& user_id, int& group_id, string& uname, @@ -855,6 +863,8 @@ bool UserPool::authenticate_external(const string& username, uname = mad_name; + password = mad_pass; + umask = User::get_default_umask(); return true; @@ -881,6 +891,8 @@ auth_failure: user_id = -1; group_id = -1; + password = ""; + group_ids.clear(); uname = ""; @@ -895,6 +907,7 @@ auth_failure: /* -------------------------------------------------------------------------- */ bool UserPool::authenticate(const string& session, + string& password, int& user_id, int& group_id, string& uname, @@ -924,19 +937,19 @@ bool UserPool::authenticate(const string& session, if ( fnmatch(UserPool::SERVER_AUTH, driver.c_str(), 0) == 0 ) { - ar = authenticate_server(user, token, user_id, group_id, uname, - gname, group_ids, umask); + ar = authenticate_server(user, token, password, user_id, group_id, + uname, gname, group_ids, umask); } else { - ar = authenticate_internal(user, token, user_id, group_id, uname, - gname, group_ids, umask); + ar = authenticate_internal(user, token, password, user_id, group_id, + uname, gname, group_ids, umask); } } else { - ar = authenticate_external(username, token, user_id, group_id, uname, - gname, group_ids, umask); + ar = authenticate_external(username, token, password, user_id, group_id, + uname, gname, group_ids, umask); } return ar;