]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_oper.cpp
Fix trampling on memory in Z/G/K/ELine.
[user/henk/code/inspircd.git] / src / commands / cmd_oper.cpp
index bcb2991b71c78d115363ac775ff6432669f68bf9..4d4c54932185628b10e1709ce4dbacd5e5028fe0 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -35,7 +35,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
        return new CommandOper(Instance);
 }
 
-CmdResult CommandOper::Handle (const char** parameters, int pcnt, User *user)
+CmdResult CommandOper::Handle (const char** parameters, int, User *user)
 {
        char LoginName[MAXBUF];
        char Password[MAXBUF];
@@ -45,6 +45,7 @@ CmdResult CommandOper::Handle (const char** parameters, int pcnt, User *user)
        char ClassName[MAXBUF];
        char TheHost[MAXBUF];
        char TheIP[MAXBUF];
+       char HashType[MAXBUF];
        int j;
        bool found = false;
        bool type_invalid = false;
@@ -62,9 +63,10 @@ CmdResult CommandOper::Handle (const char** parameters, int pcnt, User *user)
                ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "password", i, Password, MAXBUF);
                ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "type", i, OperType, MAXBUF);
                ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "host", i, HostName, MAXBUF);
+               ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "hash", i, HashType, MAXBUF);
 
                match_login = !strcmp(LoginName,parameters[0]);
-               match_pass = !ServerInstance->OperPassCompare(Password,parameters[1], i);
+               match_pass = !ServerInstance->PassCompare(user, Password,parameters[1], HashType);
                match_hosts = OneOfMatches(TheHost,TheIP,HostName);
 
                if (match_login && match_pass && match_hosts)
@@ -89,7 +91,10 @@ CmdResult CommandOper::Handle (const char** parameters, int pcnt, User *user)
                                        if (*HostName)
                                                user->ChangeDisplayedHost(HostName);
                                        if (*ClassName)
-                                               user->CheckClass(ClassName);
+                                       {
+                                               user->SetClass(ClassName);
+                                               user->CheckClass();
+                                       }
                                        found = true;
                                        type_invalid = false;
                                        break;
@@ -105,7 +110,7 @@ CmdResult CommandOper::Handle (const char** parameters, int pcnt, User *user)
                ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",user->nick,user->ident,user->host,irc::Spacify(OperType),parameters[0]);
                user->WriteServ("381 %s :You are now %s %s",user->nick, strchr("aeiouAEIOU", *OperType) ? "an" : "a", irc::Spacify(OperType));
                if (!user->IsModeSet('o'))
-                       user->Oper(OperType);
+                       user->Oper(OperType, LoginName);
        }
        else
        {