]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/parse.c
mkpasswd: Default to MD5-based crypt instead of SHA-based.
[irc/rqf/shadowircd.git] / src / parse.c
index 38e0d30dca0730dfafd7a1cd4a30835ea1f35410..18adef8b9cb7bb536eaa9e9745a8a987e5a26fe5 100644 (file)
@@ -22,7 +22,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: parse.c 3177 2007-02-01 00:19:14Z jilles $
  */
 
 #include "stdinc.h"
 #include "channel.h"
 #include "common.h"
 #include "hash.h"
-#include "irc_string.h"
-#include "sprintf_irc.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
-#include "s_log.h"
+#include "logger.h"
 #include "s_stats.h"
 #include "send.h"
 #include "msg.h"
 #include "s_conf.h"
-#include "memory.h"
 #include "s_serv.h"
 #include "packet.h"
 
@@ -52,7 +49,7 @@ struct Dictionary *alias_dict = NULL;
  */
 static char *sender;
 
-/* parv[0] == source, and parv[LAST] == NULL */
+/* parv[0] is not used, and parv[LAST] == NULL */
 static char *para[MAXPARA + 2];
 
 static void cancel_clients(struct Client *, struct Client *, char *);
@@ -106,7 +103,7 @@ string_to_array(char *string, char **parv)
                if(*buf == '\0')
                        return x;
        }
-       /* we can go upto parv[MAXPARA], as parv[0] is taken by source */
+       /* we can go upto parv[MAXPARA], as parv[0] is skipped */
        while (x < MAXPARA);
 
        if(*p == ':')
@@ -133,7 +130,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
        struct Message *mptr;
 
        s_assert(MyConnect(client_p));
-       s_assert(client_p->localClient->fd >= 0);
+       s_assert(client_p->localClient->F != NULL);
        if(IsAnyDead(client_p))
                return;
 
@@ -163,7 +160,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
                        /* didnt find any matching client, issue a kill */
                        if(from == NULL)
                        {
-                               ServerStats->is_unpf++;
+                               ServerStats.is_unpf++;
                                remove_unknown(client_p, sender, pbuffer);
                                return;
                        }
@@ -173,7 +170,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
                        /* fake direction, hmm. */
                        if(from->from != client_p)
                        {
-                               ServerStats->is_wrdi++;
+                               ServerStats.is_wrdi++;
                                cancel_clients(client_p, from, pbuffer);
                                return;
                        }
@@ -184,7 +181,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
 
        if(*ch == '\0')
        {
-               ServerStats->is_empt++;
+               ServerStats.is_empt++;
                return;
        }
 
@@ -205,7 +202,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
        {
                mptr = NULL;
                numeric = ch;
-               ServerStats->is_num++;
+               ServerStats.is_num++;
                s = ch + 3;     /* I know this is ' ' from above if */
                *s++ = '\0';    /* blow away the ' ', and point s to next part */
        }
@@ -249,7 +246,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
                                                   me.name, from->name, ch);
                                }
                        }
-                       ServerStats->is_unco++;
+                       ServerStats.is_unco++;
                        return;
                }
 
@@ -366,7 +363,7 @@ handle_command(struct Message *mptr, struct Client *client_p,
                ilog(L_SERVER,
                     "Insufficient parameters (%d < %d) for command '%s' from %s.",
                     i, ehandler.min_para, mptr->cmd, client_p->name);
-               snprintf(squitreason, sizeof squitreason,
+               rb_snprintf(squitreason, sizeof squitreason,
                                "Insufficient parameters (%d < %d) for command '%s'",
                                i, ehandler.min_para, mptr->cmd);
                exit_client(client_p, client_p, client_p, squitreason);
@@ -510,7 +507,7 @@ cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
                sendto_realops_snomask(SNO_DEBUG, L_ALL,
                                     "Message for %s[%s] from %s",
                                     source_p->name, source_p->from->name,
-                                    get_server_name(client_p, SHOW_IP));
+                                    client_p->name);
        }
        else
        {
@@ -520,7 +517,7 @@ cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
                                     source_p->username,
                                     source_p->host,
                                     source_p->from->name,
-                                    get_server_name(client_p, SHOW_IP));
+                                    client_p->name);
        }
 }
 
@@ -534,8 +531,10 @@ static void
 remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
 {
        int slen = strlen(lsender);
+       char sid[4];
+       struct Client *server;
 
-       /* meepfoo      is a nickname (KILL)
+       /* meepfoo      is a nickname (ignore)
         * #XXXXXXXX    is a UID (KILL)
         * #XX          is a SID (SQUIT)
         * meep.foo     is a server (SQUIT)
@@ -545,16 +544,28 @@ remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
        {
                sendto_realops_snomask(SNO_DEBUG, L_ALL,
                                     "Unknown prefix (%s) from %s, Squitting %s",
-                                    lbuffer, get_server_name(client_p, SHOW_IP), lsender);
+                                    lbuffer, client_p->name, lsender);
 
                sendto_one(client_p,
                           ":%s SQUIT %s :(Unknown prefix (%s) from %s)",
                           get_id(&me, client_p), lsender, 
                           lbuffer, client_p->name);
        }
+       else if(!IsDigit(lsender[0]))
+               ;
+       else if(slen != 9)
+               sendto_realops_snomask(SNO_DEBUG, L_ALL,
+                                    "Invalid prefix (%s) from %s",
+                                    lbuffer, client_p->name);
        else
-               sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)", 
-                          get_id(&me, client_p), lsender, me.name);
+       {
+               memcpy(sid, lsender, 3);
+               sid[3] = '\0';
+               server = find_server(NULL, sid);
+               if (server != NULL && server->from == client_p)
+                       sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)", 
+                                       get_id(&me, client_p), lsender, me.name);
+       }
 }
 
 
@@ -562,7 +573,6 @@ remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
 /*
  *
  *      parc    number of arguments ('sender' counted as one!)
- *      parv[0] pointer to 'sender' (may point to empty string) (not used)
  *      parv[1]..parv[parc-1]
  *              pointers to additional parameters, this is a NULL
  *              terminated list (parv[parc] == NULL).
@@ -600,10 +610,10 @@ do_numeric(char numeric[], struct Client *client_p, struct Client *source_p, int
                int tl;         /* current length of presently being built string in t */
                for (i = 2; i < (parc - 1); i++)
                {
-                       tl = ircsprintf(t, " %s", parv[i]);
+                       tl = rb_sprintf(t, " %s", parv[i]);
                        t += tl;
                }
-               ircsprintf(t, " :%s", parv[parc - 1]);
+               rb_sprintf(t, " :%s", parv[parc - 1]);
        }
 
        if((target_p = find_client(parv[1])) != NULL)
@@ -658,9 +668,9 @@ do_numeric(char numeric[], struct Client *client_p, struct Client *source_p, int
                return;
        }
        else if((chptr = find_channel(parv[1])) != NULL)
-               sendto_channel_local(ALL_MEMBERS, chptr,
-                                    ":%s %s %s %s",
-                                    source_p->name, numeric, chptr->chname, buffer);
+               sendto_channel_flags(client_p, ALL_MEMBERS, source_p, chptr,
+                                    "%s %s%s",
+                                    numeric, chptr->chname, buffer);
 }
 
 static void do_alias(struct alias_entry *aptr, struct Client *source_p, char *text)