]> jfr.im git - solanum.git/blobdiff - modules/core/m_server.c
Remove shared blocks
[solanum.git] / modules / core / m_server.c
index 992ede46e075366b90c4194fb0fc41e2ff6ee8d9..850a67d8d0d90eccc3d8650341f62df594d21ea8 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "stdinc.h"
 #include "client.h"            /* client struct */
-#include "common.h"
 #include "hash.h"              /* add_to_client_hash */
 #include "match.h"
 #include "ircd.h"              /* me */
@@ -78,6 +77,7 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
        int hop;
        unsigned int required_mask;
        const char *missing;
+       int ret;
 
        name = parv[1];
        hop = atoi(parv[2]);
@@ -113,8 +113,12 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
 
        /* Now we just have to call check_server and everything should be
         * check for us... -A1kmm. */
-       switch (check_server(name, client_p))
+       ret = check_server(name, client_p);
+       switch (ret)
        {
+       case 0:
+               /* success */
+               break;
        case -1:
                if(ConfigFileEntry.warn_no_nline)
                {
@@ -184,6 +188,46 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
 
                exit_client(client_p, client_p, client_p, "Access denied, requires SSL/TLS but is plaintext");
                return;
+       case -6:
+               if (client_p->certfp)
+               {
+                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                            "Connection from servername %s has invalid certificate fingerprint %s",
+                            name, client_p->certfp);
+                       ilog(L_SERVER, "Access denied, invalid certificate fingerprint %s from %s",
+                            client_p->certfp, log_client_name(client_p, SHOW_IP));
+                       exit_client(client_p, client_p, client_p, "Invalid fingerprint.");
+               }
+               else
+               {
+                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                           "Connection from servername %s failed certificate validation",
+                           name);
+                       ilog(L_SERVER, "Access denied; certificate validation failed for certificate from %s",
+                           log_client_name(client_p, SHOW_IP));
+                       exit_client(client_p, client_p, client_p, "Invalid certificate.");
+               }
+
+               return;
+       case -7:
+               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                    "Connection from servername %s rejected, no more connections allowed in class",
+                    name);
+               ilog(L_SERVER, "Access denied, no more connections allowed in class for %s",
+                    log_client_name(client_p, SHOW_IP));
+
+               exit_client(client_p, client_p, client_p, "Access denied, no more connections allowed in class");
+               return;
+       default:
+               sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                    "Connection from servername %s rejected, unknown error %d",
+                    name, ret);
+               ilog(L_SERVER, "Access denied, unknown error %d for server %s%s", ret,
+                    EmptyString(client_p->name) ? name : "",
+                    log_client_name(client_p, SHOW_IP));
+
+               exit_client(client_p, client_p, client_p, "Unknown error.");
+               return;
        }
 
        /* require TS6 for direct links */
@@ -252,22 +296,25 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                return;
        }
 
-       if(has_id(client_p) && (target_p = find_id(client_p->id)) != NULL)
-       {
-               sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
-                                    "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
-                                    client_p->id,
-                                    EmptyString(client_p->name) ? name : "",
-                                    client_p->name, target_p->name);
-               ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
-                               client_p->id,
-                               EmptyString(client_p->name) ? name : "",
-                               log_client_name(client_p, SHOW_IP),
-                               target_p->name);
-
-               sendto_one(client_p, "ERROR :SID already exists.");
-               exit_client(client_p, client_p, client_p, "SID Exists");
-               return;
+       if (client_p->preClient && !EmptyString(client_p->preClient->id)) {
+               if ((target_p = find_id(client_p->preClient->id)) != NULL) {
+                       sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
+                                       "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
+                                       client_p->preClient->id,
+                                       EmptyString(client_p->name) ? name : "",
+                                       client_p->name, target_p->name);
+                       ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
+                                       client_p->preClient->id,
+                                       EmptyString(client_p->name) ? name : "",
+                                       log_client_name(client_p, SHOW_IP),
+                                       target_p->name);
+
+                       sendto_one(client_p, "ERROR :SID already exists.");
+                       exit_client(client_p, client_p, client_p, "SID Exists");
+                       return;
+               } else {
+                       rb_strlcpy(client_p->id, client_p->preClient->id, sizeof(client_p->id));
+               }
        }
 
        /*
@@ -613,7 +660,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
 
        rb_strlcpy(target_p->name, parv[1], sizeof(target_p->name));
        target_p->hopcount = atoi(parv[2]);
-       strcpy(target_p->id, parv[3]);
+       rb_strlcpy(target_p->id, parv[3], sizeof(target_p->id));
        set_server_gecos(target_p, parv[4]);
 
        target_p->servptr = source_p;