*/
/** @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"
#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"
#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"
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;
(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;
}
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 */
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);
+}