]> jfr.im git - irc/quakenet/snircd.git/blobdiff - ircd/s_conf.c
add sbounce from asuka into snircd tree
[irc/quakenet/snircd.git] / ircd / s_conf.c
index 5fb596bd3995ecaf464cfd00e0c07f42c22ced6d..244c073b9d1b7bdedd81a756e0144fc3347a42a3 100644 (file)
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief ircd configuration file driver
- * @version $Id: s_conf.c,v 1.81.2.1 2005/10/06 00:37:31 entrope Exp $
+ * @version $Id: s_conf.c,v 1.81.2.3 2006/02/16 03:49:54 entrope Exp $
  */
 #include "config.h"
 
@@ -34,7 +34,6 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
-#include "ircd_auth.h"
 #include "ircd_chattr.h"
 #include "ircd_log.h"
 #include "ircd_reply.h"
@@ -49,6 +48,7 @@
 #include "opercmds.h"
 #include "parse.h"
 #include "res.h"
+#include "s_auth.h"
 #include "s_bsd.h"
 #include "s_debug.h"
 #include "s_misc.h"
@@ -74,6 +74,8 @@ int              GlobalConfCount;
 struct s_map     *GlobalServiceMapList;
 /** Global list of channel quarantines. */
 struct qline     *GlobalQuarantineList;
+/** Global list of spoofhosts. */
+struct sline    *GlobalSList = 0;
 
 /** Current line number in scanner input. */
 int lineno;
@@ -482,7 +484,8 @@ struct ConfItem *conf_debug_iline(const char *client)
             (aconf->username ? aconf->username : "(null)"),
             (aconf->host ? aconf->host : "(null)"),
             (aconf->name ? aconf->name : "(null)"),
-            ConfClass(aconf), aconf->maximum,  aconf->passwd);
+            ConfClass(aconf), aconf->maximum,
+            (aconf->passwd ? aconf->passwd : "(null)"));
     break;
   }
 
@@ -942,20 +945,21 @@ int rehash(struct Client *cptr, int sig)
   clearNickJupes();
 
   clear_quarantines();
+  clear_slines();
 
   if (sig != 2)
     restart_resolver();
 
   class_mark_delete();
   mark_listeners_closing();
-  iauth_mark_closing();
+  auth_mark_closing();
   close_mappings();
 
   read_configuration_file();
 
   log_reopen(); /* reopen log files */
 
-  iauth_close_unused();
+  auth_close_unused();
   close_listeners();
   class_delete_marked();         /* unless it fails */
 
@@ -1192,3 +1196,81 @@ int conf_check_server(struct Client *cptr)
   return 0;
 }
 
+void clear_slines(void)
+{
+  struct sline *sline;
+  while ((sline = GlobalSList)) {
+    GlobalSList = sline->next;
+    MyFree(sline->spoofhost);
+    if (!EmptyString(sline->passwd))
+      MyFree(sline->passwd);
+    if (!EmptyString(sline->realhost))
+      MyFree(sline->realhost);
+    if (!EmptyString(sline->username))
+      MyFree(sline->username);
+    MyFree(sline);
+  }
+}
+
+/*
+ * conf_check_slines()
+ *
+ * Check S lines for the specified client, passed in cptr struct.
+ * If the client's IP is S-lined, process the substitution here.
+ *
+ * Precondition
+ *  cptr != NULL
+ *
+ * Returns
+ *  0 = No S-line found
+ *  1 = S-line found and substitution done.
+ *
+ * -mbuna 9/2001
+ * -froo 1/2003
+ *
+ */
+
+int
+conf_check_slines(struct Client *cptr)
+{
+  struct sline *sconf;
+  char *hostonly;
+
+  for (sconf = GlobalSList; sconf; sconf = sconf->next) {
+    if (sconf->flags == SLINE_FLAGS_IP) {
+      if (!ipmask_check(&(cli_ip(cptr)), &(sconf->address), sconf->bits))
+        continue;
+    } else if (sconf->flags == SLINE_FLAGS_HOSTNAME) {
+        if ((match(sconf->realhost, cli_sockhost(cptr)) != 0) &&
+           (match(sconf->realhost, cli_sock_ip(cptr)) != 0))   /* wildcarded IP address */
+          continue;
+    } else {
+        continue;
+    }
+
+    if (match(sconf->username, cli_user(cptr)->username) == 0) {
+     /* Ignore user part if u@h. */
+     if ((hostonly = strchr(sconf->spoofhost, '@')))
+        hostonly++;
+      else
+        hostonly = sconf->spoofhost;
+
+      if(!*hostonly)
+        continue;
+
+      ircd_strncpy(cli_user(cptr)->host, hostonly, HOSTLEN);
+      log_write(LS_USER, L_INFO, LOG_NOSNOTICE, "S-Line (%s@%s) by (%#R)",
+          cli_user(cptr)->username, hostonly, cptr);
+      return 1;
+    }
+  }
+  return 0;
+}
+
+void free_spoofhost(struct sline *spoof) {
+       MyFree(spoof->spoofhost);
+       MyFree(spoof->passwd);
+       MyFree(spoof->realhost);
+       MyFree(spoof->username);
+       MyFree(spoof);
+}