summaryrefslogtreecommitdiff
path: root/src/modules/m_ident.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-13 22:50:34 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-13 22:50:34 +0000
commit9ca3a5fdad9c865b990540f30315e69fed03546a (patch)
tree946f07ae61f05d4eb7e870f7bcbacd9d227be930 /src/modules/m_ident.cpp
parenta6d1638ff6e976eea7332ab89b925b4a0428d3b1 (diff)
More fixes to the ident stuff to make sure that one socket doesnt go before the other, without the one thats left knowing its gone!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8166 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_ident.cpp')
-rw-r--r--src/modules/m_ident.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index eb1959c86..9272c5054 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -57,7 +57,7 @@ class IdentRequestSocket : public InspSocket
if ((getsockname(user->GetFd(), (sockaddr*) &laddr, &laddrsz) != 0) || (getpeername(user->GetFd(), (sockaddr*) &raddr, &raddrsz) != 0))
{
// Error
- user->Shrink("ident_socket");
+ TidyUser();
return false;
}
@@ -91,7 +91,7 @@ class IdentRequestSocket : public InspSocket
if (*user->ident == '~' && user->GetExt("ident_socket"))
user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead", user->ident);
- user->Shrink("ident_socket");
+ TidyUser();
Instance->next_call = Instance->Time();
}
@@ -107,7 +107,7 @@ class IdentRequestSocket : public InspSocket
if (*user->ident == '~' && user->GetExt("ident_socket"))
user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead", user->ident);
- user->Shrink("ident_socket");
+ TidyUser();
Instance->next_call = Instance->Time();
}
@@ -121,7 +121,10 @@ class IdentRequestSocket : public InspSocket
char *ibuf = this->Read();
if (!ibuf)
+ {
+ TidyUser();
return false;
+ }
// We don't really need to buffer for incomplete replies here, since IDENT replies are
// extremely short - there is *no* sane reason it'd be in more than one packet
@@ -166,9 +169,20 @@ class IdentRequestSocket : public InspSocket
break;
}
- user->Shrink("ident_socket");
+ TidyUser();
return false;
}
+
+ void TidyUser()
+ {
+ user->Shrink("ident_socket");
+ int* delfd;
+ if (user->GetExt("ident_socket_fd", delfd))
+ {
+ delete delfd;
+ user->Shrink("ident_socket_fd");
+ }
+ }
};
class ModuleIdent : public Module
@@ -239,7 +253,10 @@ class ModuleIdent : public Module
IdentRequestSocket *isock = new IdentRequestSocket(ServerInstance, user, RequestTimeout, ip);
if (isock->GetFd() > -1)
+ {
+ user->Extend("ident_socket_fd", new int(isock->GetFd()));
user->Extend("ident_socket", isock);
+ }
else
if (ServerInstance->SocketCull.find(isock) == ServerInstance->SocketCull.end())
ServerInstance->SocketCull[isock] = isock;
@@ -258,7 +275,11 @@ class ModuleIdent : public Module
IdentRequestSocket *isock;
userrec *user = (userrec*)item;
if (user->GetExt("ident_socket", isock))
- isock->Close();
+ {
+ int *fd;
+ if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock))
+ isock->Close();
+ }
}
}
@@ -266,8 +287,13 @@ class ModuleIdent : public Module
{
IdentRequestSocket *isock;
if (user->GetExt("ident_socket", isock))
- isock->Close();
+ {
+ int *fd;
+ if (user->GetExt("ident_socket_fd", fd) && (ServerInstance->SE->GetRef(*fd) == isock))
+ isock->Close();
+ }
}
};
MODULE_INIT(ModuleIdent);
+