git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5640
e03df62e-2008-0410-955e-
edbf42e46eb7
void Implements(char* List)
{
void Implements(char* List)
{
- List[I_OnRequest] = List[I_OnRehash] = List[I_OnPostCommand] = 1;
+ List[I_OnRequest] = List[I_OnRehash] = List[I_OnPreCommand] = 1;
- virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line)
+ virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
- if ((result == CMD_FAILURE) && (command == "OPER"))
+ if ((validated) && (command == "OPER"))
{
if (LookupOper(user, parameters[0], parameters[1]))
{
{
if (LookupOper(user, parameters[0], parameters[1]))
{
}
bool LookupOper(userrec* user, const std::string &username, const std::string &password)
}
bool LookupOper(userrec* user, const std::string &username, const std::string &password)
Module* target;
target = Srv->FindFeature("SQL");
Module* target;
target = Srv->FindFeature("SQL");
if (target)
{
SQLrequest req = SQLreq(this, target, databaseid, "SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password=md5('?')", username, password);
if (target)
{
SQLrequest req = SQLreq(this, target, databaseid, "SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password=md5('?')", username, password);
ServerInstance->Log(DEBUG, "Sent query, got given ID %lu", req.id);
AssociateUser(this, SQLutils, req.id, user).Send();
ServerInstance->Log(DEBUG, "Sent query, got given ID %lu", req.id);
AssociateUser(this, SQLutils, req.id, user).Send();
+
+ user->Extend("oper_user", strdup(username.c_str()));
+ user->Extend("oper_pass", strdup(password.c_str()));
userrec* user = GetAssocUser(this, SQLutils, res->id).S().user;
UnAssociate(this, SQLutils, res->id).S();
userrec* user = GetAssocUser(this, SQLutils, res->id).S().user;
UnAssociate(this, SQLutils, res->id).S();
+
+ char* tried_user = NULL;
+ char* tried_pass = NULL;
+
+ user->GetExt("oper_user", tried_user);
+ user->GetExt("oper_pass", tried_pass);
* we should have already checked the o:lines so now we need an
* "insufficient awesomeness" (invalid credentials) error
*/
* we should have already checked the o:lines so now we need an
* "insufficient awesomeness" (invalid credentials) error
*/
-
- LoginFail(user, row["username"].d, row["password"].d);
+ if (tried_user && tried_pass)
+ {
+ LoginFail(user, tried_user, tried_pass);
+ free(tried_user);
+ free(tried_pass);
+ user->Shrink("oper_user");
+ user->Shrink("oper_pass");
+ }
*/
ServerInstance->Log(DEBUG, "Query failed: %s", res->error.Str());
*/
ServerInstance->Log(DEBUG, "Query failed: %s", res->error.Str());
- LoginFail(user, row["username"].d, row["password"].d);
+ if (tried_user && tried_pass)
+ {
+ LoginFail(user, tried_user, tried_pass);
+ free(tried_user);
+ free(tried_pass);
+ user->Shrink("oper_user");
+ user->Shrink("oper_pass");
+ }
+
}
ServerInstance->Log(DEBUG, "Got unsupported API version string: %s", request->GetId());
}
ServerInstance->Log(DEBUG, "Got unsupported API version string: %s", request->GetId());
- void LoginFail(userrec* user, const std::string &user, const std::string &pass)
+ void LoginFail(userrec* user, const std::string &username, const std::string &pass)
- command_t* oper_command = ServerInstance->Parser->GetCommand("OPER");
+ command_t* oper_command = ServerInstance->Parser->GetHandler("OPER");
- const char* params = { user.c_str(), pass.c_str() };
+ const char* params[] = { username.c_str(), pass.c_str() };
oper_command->Handle(params, 2, user);
}
else
oper_command->Handle(params, 2, user);
}
else