summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd_pass.cpp4
-rw-r--r--src/helperfuncs.cpp21
-rw-r--r--src/users.cpp14
3 files changed, 13 insertions, 26 deletions
diff --git a/src/cmd_pass.cpp b/src/cmd_pass.cpp
index 5b640fb76..0e40fea81 100644
--- a/src/cmd_pass.cpp
+++ b/src/cmd_pass.cpp
@@ -70,11 +70,11 @@ void cmd_pass::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
return;
}
+ ConnectClass* a = GetClass(user);
strlcpy(user->password,parameters[0],MAXBUF);
- if (!strcasecmp(parameters[0],Passwd(user)))
+ if (!strcmp(parameters[0],a->pass.c_str()))
{
user->haspassed = true;
}
}
-
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index c2a323a7c..2ff939dc6 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -1153,33 +1153,18 @@ int usercount(chanrec *c)
// looks up a users password for their connection class (<ALLOW>/<DENY> tags)
-char* Passwd(userrec *user)
+ConnectClass* GetClass(userrec *user)
{
for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
{
- if ((i->type == CC_ALLOW) && match(user->host,i->host.c_str()))
+ if (match(user->host,i->host.c_str()))
{
- return (char*)i->pass.c_str();
+ return (ConnectClass*)i->second;
}
}
return "";
}
-bool IsDenied(userrec *user)
-{
- for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
- {
- if ((i->type == CC_DENY) && match(user->host,i->host.c_str()))
- {
- return true;
- }
- }
- return false;
-}
-
-
-
-
/* sends out an error notice to all connected clients (not to be used
* lightly!) */
diff --git a/src/users.cpp b/src/users.cpp
index f4075dec4..fd7efb7aa 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -642,16 +642,18 @@ void FullConnectUser(userrec* user, CullList* Goners)
user->idle_lastmsg = TIME;
log(DEBUG,"ConnectUser: %s",user->nick);
- if ((*(Passwd(user))) && (!user->haspassed))
+ ConnectClass* a = GetClass(user);
+
+ if (a->type == CC_DENY)
+ {
+ Goners->AddItem(user,"Unauthorised connection");
+ return;
+ }
+ if ((*(a->pass.c_str())) && (!user->haspassed))
{
Goners->AddItem(user,"Invalid password");
return;
}
- if (IsDenied(user))
- {
- Goners->AddItem(user,"Unauthorised connection");
- return;
- }
char match_against[MAXBUF];
snprintf(match_against,MAXBUF,"%s@%s",user->ident,user->host);