]> jfr.im git - solanum.git/blobdiff - modules/m_signon.c
make more snotes L_NETWIDE
[solanum.git] / modules / m_signon.c
index c933ae66d2e6b51228ffbcd615f52c4bf5f82143..3ad9183477f30d18b302461809e9c8a554998256 100644 (file)
@@ -32,8 +32,7 @@
 #include "send.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
-#include "config.h"
+#include "defaults.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_conf.h"
 #include "match.h"
 #include "s_user.h"
 
-static int me_svslogin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
-static int ms_signon(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 static const char signon_desc[] = "Provides account login/logout support for services";
 
+static void me_svslogin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void ms_signon(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+
 static void send_signon(struct Client *, struct Client *, const char *, const char *, const char *, unsigned int, const char *);
 
 struct Message svslogin_msgtab = {
@@ -74,7 +74,7 @@ DECLARE_MODULE_AV2(signon, NULL, NULL, signon_clist, NULL, NULL, NULL, NULL, sig
 #define USER_VALID     2
 #define HOST_VALID     4
 
-static int
+static bool
 clean_username(const char *username)
 {
        int len = 0;
@@ -84,16 +84,16 @@ clean_username(const char *username)
                len++;
 
                if(!IsUserChar(*username))
-                       return 0;
+                       return false;
        }
 
        if(len > USERLEN)
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
-static int
+static bool
 clean_host(const char *host)
 {
        int len = 0;
@@ -103,16 +103,16 @@ clean_host(const char *host)
                len++;
 
                if(!IsHostChar(*host))
-                       return 0;
+                       return false;
        }
 
        if(len > HOSTLEN)
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
-static int
+static void
 me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
@@ -125,14 +125,14 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
        {
                sendto_realops_snomask(SNO_GENERAL, L_ALL,
                        "Non-service server %s attempting to execute services-only command SVSLOGIN", source_p->name);
-               return 0;
+               return;
        }
 
        if((target_p = find_client(parv[1])) == NULL)
-               return 0;
+               return;
 
        if(!MyClient(target_p) && !IsUnknown(target_p))
-               return 0;
+               return;
 
        if(clean_nick(parv[2], 0))
        {
@@ -174,7 +174,7 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
 
        /* Login (mostly) follows nick rules. */
        if(*login && !clean_nick(login, 0))
-               return 0;
+               return;
 
        if((exist_p = find_person(nick)) && target_p != exist_p)
        {
@@ -194,7 +194,9 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
                snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
                        me.name);
                exit_client(NULL, exist_p, &me, buf);
-       }else if((exist_p = find_client(nick)) && IsUnknown(exist_p) && exist_p != target_p) {
+       }
+       else if((exist_p = find_client(nick)) && IsUnknown(exist_p) && exist_p != target_p)
+       {
                exit_client(NULL, exist_p, &me, "Overridden");
        }
 
@@ -219,30 +221,28 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
                struct User *user_p = make_user(target_p);
 
                if(valid & NICK_VALID)
-                       strcpy(target_p->preClient->spoofnick, nick);
+                       rb_strlcpy(target_p->preClient->spoofnick, nick, sizeof(target_p->preClient->spoofnick));
 
                if(valid & USER_VALID)
-                       strcpy(target_p->preClient->spoofuser, user);
+                       rb_strlcpy(target_p->preClient->spoofuser, user, sizeof(target_p->preClient->spoofuser));
 
                if(valid & HOST_VALID)
-                       strcpy(target_p->preClient->spoofhost, host);
+                       rb_strlcpy(target_p->preClient->spoofhost, host, sizeof(target_p->preClient->spoofhost));
 
                rb_strlcpy(user_p->suser, login, NICKLEN + 1);
        }
        else
        {
-               char note[NICKLEN + 10];
+               char note[NAMELEN + 10];
 
                send_signon(NULL, target_p, nick, user, host, rb_current_time(), login);
 
-               snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
+               snprintf(note, sizeof(note), "Nick: %s", target_p->name);
                rb_note(target_p->localClient->F, note);
        }
-
-       return 0;
 }
 
-static int
+static void
 ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
        int parc, const char *parv[])
 {
@@ -253,7 +253,7 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
        if(!clean_nick(parv[1], 0))
        {
                ServerStats.is_kill++;
-               sendto_realops_snomask(SNO_DEBUG, L_ALL,
+               sendto_realops_snomask(SNO_DEBUG, L_NETWIDE,
                                "Bad Nick from SIGNON: %s From: %s(via %s)",
                                parv[1], source_p->servptr->name, client_p->name);
                /* if source_p has an id, kill_client_serv_butone() will
@@ -265,13 +265,13 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                                me.name);
                source_p->flags |= FLAGS_KILLED;
                exit_client(NULL, source_p, &me, "Bad nickname from SIGNON");
-               return 0;
+               return;
        }
 
        if(!clean_username(parv[2]) || !clean_host(parv[3]))
        {
                ServerStats.is_kill++;
-               sendto_realops_snomask(SNO_DEBUG, L_ALL,
+               sendto_realops_snomask(SNO_DEBUG, L_NETWIDE,
                                "Bad user@host from SIGNON: %s@%s From: %s(via %s)",
                                parv[2], parv[3], source_p->servptr->name, client_p->name);
                /* if source_p has an id, kill_client_serv_butone() will
@@ -283,7 +283,7 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                                me.name);
                source_p->flags |= FLAGS_KILLED;
                exit_client(NULL, source_p, &me, "Bad user@host from SIGNON");
-               return 0;
+               return;
        }
 
        newts = atol(parv[4]);
@@ -295,7 +295,7 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                if (clean_nick(parv[5], 0))
                        rb_strlcpy(login, parv[5], NICKLEN + 1);
                else
-                       return 0;
+                       return;
        }
        else
                login[0] = '\0';
@@ -311,7 +311,7 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                {
                        if(!newts || !target_p->tsinfo || (newts == target_p->tsinfo) || !source_p->user)
                        {
-                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                                     "Nick change collision from SIGNON from %s to %s(%s <- %s)(both killed)",
                                                     source_p->name, target_p->name, target_p->from->name,
                                                     client_p->name);
@@ -330,7 +330,7 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                                exit_client(NULL, target_p, &me, "Nick collision(new)");
                                source_p->flags |= FLAGS_KILLED;
                                exit_client(client_p, source_p, &me, "Nick collision(old)");
-                               return 0;
+                               return;
                        }
                        else
                        {
@@ -341,12 +341,12 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                                   (!sameuser && newts > target_p->tsinfo))
                                {
                                        if(sameuser)
-                                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                                                     "Nick change collision from SIGNON from %s to %s(%s <- %s)(older killed)",
                                                                     source_p->name, target_p->name,
                                                                     target_p->from->name, client_p->name);
                                        else
-                                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                                                     "Nick change collision from SIGNON from %s to %s(%s <- %s)(newer killed)",
                                                                     source_p->name, target_p->name,
                                                                     target_p->from->name, client_p->name);
@@ -366,17 +366,17 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                                                exit_client(client_p, source_p, &me, "Nick collision(old)");
                                        else
                                                exit_client(client_p, source_p, &me, "Nick collision(new)");
-                                       return 0;
+                                       return;
                                }
                                else
                                {
                                        if(sameuser)
-                                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                                                     "Nick collision from SIGNON on %s(%s <- %s)(older killed)",
                                                                     target_p->name, target_p->from->name,
                                                                     client_p->name);
                                        else
-                                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
                                                                     "Nick collision from SIGNON on %s(%s <- %s)(newer killed)",
                                                                     target_p->name, target_p->from->name,
                                                                     client_p->name);
@@ -399,7 +399,6 @@ ms_signon(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
        }
 
        send_signon(client_p, source_p, parv[1], parv[2], parv[3], newts, login);
-       return 0;
 }
 
 static void
@@ -411,7 +410,7 @@ send_signon(struct Client *client_p, struct Client *target_p,
                        use_id(target_p), nick, user, host,
                        (long) target_p->tsinfo, *login ? login : "0");
 
-       strcpy(target_p->user->suser, login);
+       rb_strlcpy(target_p->user->suser, login, sizeof(target_p->user->suser));
 
        change_nick_user_host(target_p, nick, user, host, newts, "Signing %s (%s)", *login ?  "in" : "out", nick);
 }