Log account rather than ident upon exit.
[ircu2.10.12-pk.git] / ircd / s_misc.c
index 4021bccd55ad16ab08a2021e8d03bcb7c823efd6..111e9c7dc56508c11028a717367c1fd604c31dc9 100644 (file)
@@ -33,7 +33,6 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
-#include "ircd_auth.h"
 #include "ircd_features.h"
 #include "ircd_log.h"
 #include "ircd_reply.h"
@@ -47,6 +46,7 @@
 #include "parse.h"
 #include "querycmds.h"
 #include "res.h"
+#include "s_auth.h"
 #include "s_bsd.h"
 #include "s_conf.h"
 #include "s_debug.h"
@@ -164,32 +164,12 @@ const char* get_client_name(const struct Client* sptr, int showip)
 {
   static char nbuf[HOSTLEN * 2 + USERLEN + 5];
 
-  if (MyConnect(sptr)) {
-    if (showip)
-      ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr),
-                    IsIdented(sptr) ? cli_username(sptr) : "unknown",
-                    cli_sock_ip(sptr));
-    else
-        return cli_name(sptr);
-    return nbuf;
-  }
-  return cli_name(sptr);
-}
-
-/** Set cli_sockhost(cptr) from \a host.
- * If \a host contains an '@', copy starting after that byte.
- * Otherwise copy all of \a host.
- * @param cptr Client to operate on.
- * @param host hostname or user\@hostname string.
- */
-void get_sockhost(struct Client *cptr, char *host)
-{
-  char *s;
-  if ((s = strchr(host, '@')))
-    s++;
-  else
-    s = host;
-  ircd_strncpy(cli_sockhost(cptr), s, HOSTLEN);
+  if (!MyConnect(sptr) || !showip)
+    return cli_name(sptr);
+  ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr),
+                IsIdented(sptr) ? cli_username(sptr) : "",
+                cli_sock_ip(sptr));
+  return nbuf;
 }
 
 /**
@@ -243,15 +223,18 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
     if (MyUser(bcptr))
       set_snomask(bcptr, ~0, SNO_DEL);
 
-    if (IsInvisible(bcptr))
+    if (IsInvisible(bcptr)) {
+      assert(UserStats.inv_clients > 0);
       --UserStats.inv_clients;
-    if (IsOper(bcptr))
+    }
+    if (IsOper(bcptr)) {
+      assert(UserStats.opers > 0);
       --UserStats.opers;
+    }
     if (MyConnect(bcptr))
       Count_clientdisconnects(bcptr, UserStats);
-    else {
+    else
       Count_remoteclientquits(UserStats, bcptr);
-    }
   }
   else if (IsServer(bcptr))
   {
@@ -287,8 +270,6 @@ static void exit_one_client(struct Client* bcptr, const char* comment)
     assert(!IsServer(bcptr));
     /* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
     RemoveYXXClient(cli_user(bcptr)->server, cli_yxx(bcptr));
-    if (IsIAuthed(bcptr) || cli_iauth(bcptr))
-        iauth_exit_client(bcptr);
   }
 
   /* Remove bcptr from the client list */
@@ -400,12 +381,15 @@ int exit_client(struct Client *cptr,
 
     on_for = CurrentTime - cli_firsttime(victim);
 
+    if (IsUser(victim) || IsUserPort(victim))
+      auth_send_exit(victim);
+
     if (IsUser(victim))
       log_write(LS_USER, L_TRACE, 0, "%Tu %i %s@%s %s %s %s%s %s :%s",
                cli_firsttime(victim), on_for,
                cli_user(victim)->username, cli_sockhost(victim),
                 ircd_ntoa(&cli_ip(victim)),
-                IsAccount(victim) ? cli_username(victim) : "0",
+                cli_account(victim),
                 NumNick(victim), /* two %s's */
                 cli_name(victim), cli_info(victim));
 
@@ -422,8 +406,9 @@ int exit_client(struct Client *cptr,
                          cli_name(killer), comment);
          else
            sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)",
-                         cli_name(victim), IsServer(killer) ? cli_name(&me) :
-                         cli_name(killer), comment);
+                         cli_name(victim),
+                          cli_name(IsServer(killer) ? &his : killer),
+                         comment);
        }
       }
       if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) &&