From c31aea58ed12b5c7726e04a2521124b72165dfef Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Mon, 26 Dec 2011 16:06:00 +0000 Subject: [PATCH] Diagnostics --- .../manage/SrpManagement.cpp | 27 ---------------- src/common/security.cpp | 32 +++++++++++++++++++ src/common/security.h | 2 ++ src/jrd/UserManagement.cpp | 7 ++-- src/jrd/UserManagement.h | 2 +- src/remote/server/server.cpp | 9 +++--- src/utilities/gsec/gsec.cpp | 3 +- 7 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp index 2415453f68..94a7a08fb3 100644 --- a/src/auth/SecureRemotePassword/manage/SrpManagement.cpp +++ b/src/auth/SecureRemotePassword/manage/SrpManagement.cpp @@ -456,8 +456,6 @@ public: disp += " WHERE PLG$USER_NAME = ?"; } - printf("disp=%s\n", disp.c_str()); - Login login(di); Name first(di), middle(di), last(di); Field admin(di); @@ -527,31 +525,6 @@ public: { ex.stuffException(status); return -1; - - /* To be moved to plugin invoking code. !!!! - switch(user->operation()) - { - case ADD_OPER: - return GsecMsg19; - - case MOD_OPER: - return GsecMsg20; - - case DEL_OPER: - return GsecMsg23; - - case OLD_DIS_OPER: - case DIS_OPER: - return GsecMsg28; - - case MAP_DROP_OPER: - case MAP_SET_OPER: - return GsecMsg97; - - default: - return GsecMsg17; - } - */ } return 0; diff --git a/src/common/security.cpp b/src/common/security.cpp index fe42d6bf89..06f83f271a 100644 --- a/src/common/security.cpp +++ b/src/common/security.cpp @@ -26,6 +26,7 @@ #include "firebird.h" #include "../common/security.h" #include "../common/StatusArg.h" +#include "../utilities/gsec/gsec.h" // gsec error codes using namespace Firebird; @@ -72,4 +73,35 @@ void FB_CARG UserData::clear() // never clear this permanent block! authenticationBlock.clear(); } +// This function sets typical gsec return code based on requested operation if it was not set by plugin +int setGsecCode(int code, IUser* user) +{ + if (code >= 0) + { + return code; + } + + switch(user->operation()) + { + case ADD_OPER: + return GsecMsg19; + + case MOD_OPER: + return GsecMsg20; + + case DEL_OPER: + return GsecMsg23; + + case OLD_DIS_OPER: + case DIS_OPER: + return GsecMsg28; + + case MAP_DROP_OPER: + case MAP_SET_OPER: + return GsecMsg97; + } + + return GsecMsg17; +} + } // namespace Auth diff --git a/src/common/security.h b/src/common/security.h index 01746473e7..ef2406110a 100644 --- a/src/common/security.h +++ b/src/common/security.h @@ -221,6 +221,8 @@ public: Get(Config* firebirdConf); }; +int setGsecCode(int code, IUser* iUser); + } // namespace Auth #endif // UTILITIES_SECUR_PROTO_H diff --git a/src/jrd/UserManagement.cpp b/src/jrd/UserManagement.cpp index 8fc060029b..846ca6bcc4 100644 --- a/src/jrd/UserManagement.cpp +++ b/src/jrd/UserManagement.cpp @@ -179,12 +179,13 @@ USHORT UserManagement::put(Auth::UserData* userData) return ret; } -void UserManagement::checkSecurityResult(int errcode, Firebird::IStatus* status, const char* userName) +void UserManagement::checkSecurityResult(int errcode, Firebird::IStatus* status, const char* userName, Auth::IUser* user) { if (!errcode) { return; } + errcode = Auth::setGsecCode(errcode, user); Arg::StatusVector tmp; tmp << Arg::Gds(ENCODE_ISC_MSG(errcode, GSEC_MSG_FAC)); @@ -212,7 +213,7 @@ void UserManagement::execute(USHORT id) LocalStatus status; int errcode = manager->execute(&status, commands[id], NULL); - checkSecurityResult(errcode, &status, commands[id]->userName()->get()); + checkSecurityResult(errcode, &status, commands[id]->userName()->get(), commands[id]); delete commands[id]; commands[id] = NULL; @@ -310,7 +311,7 @@ RecordBuffer* UserManagement::getList(thread_db* tdbb, jrd_rel* relation) Auth::StackUserData u; u.op = DIS_OPER; int errcode = manager->execute(&status, &u, &display); - checkSecurityResult(errcode, &status, "Unknown"); + checkSecurityResult(errcode, &status, "Unknown", &u); } catch (const Exception&) { diff --git a/src/jrd/UserManagement.h b/src/jrd/UserManagement.h index d383e9122a..0b8ef32bf2 100644 --- a/src/jrd/UserManagement.h +++ b/src/jrd/UserManagement.h @@ -89,7 +89,7 @@ private: Display display; Auth::IManagement* manager; - static void checkSecurityResult(int errcode, Firebird::IStatus* status, const char* userName); + static void checkSecurityResult(int errcode, Firebird::IStatus* status, const char* userName, Auth::IUser* user); }; } // namespace diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index 62111adb5d..b6a25204c6 100644 --- a/src/remote/server/server.cpp +++ b/src/remote/server/server.cpp @@ -3775,16 +3775,16 @@ static bool process_packet(rem_port* port, PACKET* sendL, PACKET* receive, rem_p if (!accept_connection(port, &receive->p_cnct, sendL)) { const string& s = port->port_user_name; - if (s.hasData()) - { +/* if (s.hasData()) + { looks like logging rejects is not good idea any more? gds__log("SERVER/process_packet: connection rejected for %s", s.c_str()); - } + } */ if (port->port_server->srvr_flags & SRVR_multi_client) { port->port_state = rem_port::BROKEN; } else { - gds__log("SERVER/process_packet: connect reject, server exiting"); + // gds__log("SERVER/process_packet: connect reject, server exiting"); port->disconnect(sendL, receive); return false; } @@ -5430,7 +5430,6 @@ static THREAD_ENTRY_DECLARE loopThread(THREAD_ENTRY_PARAM) if (new_request->req_receive.p_operation == op_partial) { - // gds__log("Partial"); free_request(new_request); port->setRecvState(recvState); } diff --git a/src/utilities/gsec/gsec.cpp b/src/utilities/gsec/gsec.cpp index 832be1913c..dde80934c9 100644 --- a/src/utilities/gsec/gsec.cpp +++ b/src/utilities/gsec/gsec.cpp @@ -156,7 +156,7 @@ int gsec(Firebird::UtilSvc* uSvc) //if (!uSvc->isService() && argv.getCount() == 1) // GSEC_error(GsecMsg101); // use gsec -? to get help - SSHORT ret = parse_cmd_line(argv, tdsec); + int ret = parse_cmd_line(argv, tdsec); if (!uSvc->isService() && ret == -2) // user asked for help GSEC_exit(); @@ -426,6 +426,7 @@ int gsec(Firebird::UtilSvc* uSvc) if (ret) { + ret = setGsecCode(ret, user_data); fb_utils::copyStatus(status, FB_NELEM(status), st.get(), fb_utils::statusLength(st.get())); GSEC_print(ret, user_data->userName()->get());