Index: Changes
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/Changes,v
retrieving revision 1.1.1.1.2.1.2.1.2.2234.2.394
diff -u -r1.1.1.1.2.1.2.1.2.2234.2.394 Changes
--- Changes	9 Nov 2005 14:29:31 -0000	1.1.1.1.2.1.2.1.2.2234.2.394
+++ Changes	10 Nov 2005 23:32:01 -0000
@@ -917,3 +917,6 @@
 - Couple of source code cleanups (svsnick, a *line msg, kill, and some useless l_commands
   code), suggested by Nazzy and Requi3m.
 - Fixed extbans no longer working properly in CVS, fix provided by Nazzy (#0002681).
+- Made it so you no longer can change your nick to a banned one in a channel, suggested
+  by vonitsanet (#0002388), partial patch provided by Nazzy.
+  This option can be turned off by setting set::check-target-nick-bans to 'no'.
Index: doc/unreal32docs.html
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/doc/Attic/unreal32docs.html,v
retrieving revision 1.1.2.144.2.80
diff -u -r1.1.2.144.2.80 unreal32docs.html
--- doc/unreal32docs.html	28 Sep 2005 21:34:39 -0000	1.1.2.144.2.80
+++ doc/unreal32docs.html	10 Nov 2005 23:32:04 -0000
@@ -28,7 +28,7 @@
 <div align="center"><b><font size="7">UnrealIRCd</font></b><br>
   <font size="4"><a href="http://www.unrealircd.com">http://www.unrealircd.com</a></font><br>
   <font size="4">Version: 3.2.3</font><br>
-  <b>Last doc update:</b> 2005-03-13</div>
+  <b>Last doc update:</b> 2005-10-11</div>
 <br>
   <b>Head Coders:</b> Stskeeps / codemastr / Syzop / Luke<br>
   <b>Contributors:</b> McSkaf / Zogg / NiQuiL / assyrian / chasm / DrBin / llthangel / Griever / nighthawk<br>
@@ -2371,6 +2371,9 @@
  <p><font class="set">set::spamfilter::except &lt;target(s)&gt;</font><br>
   These targets are exempt from spam filtering (no action will be taken),
   can be single target or comma seperated list.. Ex: except "#help,#spamreport"</p>
+ <p><font class="set">set::check-target-nick-bans &lt;yes|no&gt;</font><br>
+  Whenever the user changes his/her nick, check if the NEW nick would be
+  banned. If so, do not allow the nickchange. Default is yes.</p>
 <p></p> </div>
 <p><b><font size="+2">5 &#8211; Additional Files<a name="addtlfiles"></a>
   </font></b></p><div class="desc">
Index: include/dynconf.h
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/include/dynconf.h,v
retrieving revision 1.1.1.1.6.1.2.52.2.9
diff -u -r1.1.1.1.6.1.2.52.2.9 dynconf.h
--- include/dynconf.h	1 Dec 2004 20:55:36 -0000	1.1.1.1.6.1.2.52.2.9
+++ include/dynconf.h	10 Nov 2005 23:32:04 -0000
@@ -81,6 +81,7 @@
 	unsigned use_ban_version:1;
 	unsigned mkpasswd_for_everyone:1;
 	unsigned allow_part_if_shunned:1;
+	unsigned check_target_nick_bans:1;
 	unsigned use_egd;
 	long host_timeout;
 	int  host_retries;
@@ -246,6 +247,7 @@
 #define SPAMFILTER_VIRUSCHAN	iConf.spamfilter_virus_help_channel
 #define SPAMFILTER_VIRUSCHANDENY	iConf.spamfilter_vchan_deny
 #define SPAMFILTER_EXCEPT		iConf.spamexcept_line
+#define CHECK_TARGET_NICK_BANS	iConf.check_target_nick_bans
 
 /* Used for duplicate checking */
 struct SetCheck {
@@ -277,6 +279,7 @@
 	unsigned has_snomask_on_oper:1;
 	unsigned has_auto_join:1;
 	unsigned has_oper_auto_join:1;
+	unsigned has_check_target_nick_bans:1;
 	unsigned has_oper_only_stats:1;
 	unsigned has_maxchannelsperuser:1;
 	unsigned has_maxdccallow:1;
Index: include/h.h
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/include/h.h,v
retrieving revision 1.1.1.1.6.1.2.173.2.33
diff -u -r1.1.1.1.6.1.2.173.2.33 h.h
--- include/h.h	15 Oct 2005 23:26:57 -0000	1.1.1.1.6.1.2.173.2.33
+++ include/h.h	10 Nov 2005 23:32:04 -0000
@@ -188,6 +188,7 @@
 extern int has_voice(aClient *, aChannel *);
 extern int is_chanowner(aClient *, aChannel *);
 extern Ban *is_banned(aClient *, aChannel *, int);
+extern Ban *is_banned_with_nick(aClient *, aChannel *, int, char *);
 extern int parse_help(aClient *, char *, char *);
 
 extern void ircd_log(int, char *, ...) __attribute__((format(printf,2,3)));
Index: src/channel.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/channel.c,v
retrieving revision 1.1.1.1.6.1.2.319.2.27
diff -u -r1.1.1.1.6.1.2.319.2.27 channel.c
--- src/channel.c	26 Feb 2005 22:47:09 -0000	1.1.1.1.6.1.2.319.2.27
+++ src/channel.c	10 Nov 2005 23:32:05 -0000
@@ -435,15 +435,26 @@
  */
 char *ban_realhost = NULL, *ban_virthost = NULL, *ban_ip = NULL;
 
-/** is_banned - checks for bans.
- * PARAMETERS:
- * sptr:	the client to check (can be remote client)
- * chptr:	the channel to check
- * type:	one of BANCHK_*
- * RETURNS:
- * a pointer to the ban structure if banned, else NULL.
+/** is_banned - Check if a user is banned on a channel.
+ * @param sptr   Client to check (can be remote client)
+ * @param chptr  Channel to check
+ * @param type   Type of ban to check for (BANCHK_*)
+ * @returns      A pointer to the ban struct if banned, otherwise NULL.
+ * @comments     Simple wrapper for is_banned_with_nick()
  */
-Ban *is_banned(aClient *sptr, aChannel *chptr, int type)
+inline Ban *is_banned(aClient *sptr, aChannel *chptr, int type)
+{
+	return is_banned_with_nick(sptr, chptr, type, sptr->name);
+}
+
+/** is_banned_with_nick - Check if a user is banned on a channel.
+ * @param sptr   Client to check (can be remote client)
+ * @param chptr  Channel to check
+ * @param type   Type of ban to check for (BANCHK_*)
+ * @param nick   Nick of the user
+ * @returns      A pointer to the ban struct if banned, otherwise NULL.
+ */
+Ban *is_banned_with_nick(aClient *sptr, aChannel *chptr, int type, char *nick)
 {
 	Ban *tmp, *tmp2;
 	char *s;
@@ -461,7 +472,7 @@
 
 	if (MyConnect(sptr)) {
 		mine = 1;
-		s = make_nick_user_host(sptr->name, sptr->user->username, GetIP(sptr));
+		s = make_nick_user_host(nick, sptr->user->username, GetIP(sptr));
 		strlcpy(nuip, s, sizeof nuip);
 		ban_ip = nuip;
 	}
@@ -472,13 +483,13 @@
 			dovirt = 1;
 		}
 
-	s = make_nick_user_host(sptr->name, sptr->user->username,
+	s = make_nick_user_host(nick, sptr->user->username,
 	    sptr->user->realhost);
 	strlcpy(realhost, s, sizeof realhost);
 
 	if (dovirt)
 	{
-		s = make_nick_user_host(sptr->name, sptr->user->username,
+		s = make_nick_user_host(nick, sptr->user->username,
 		    sptr->user->virthost);
 		strlcpy(virthost, s, sizeof virthost);
 		ban_virthost = virthost;
Index: src/s_conf.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/s_conf.c,v
retrieving revision 1.1.1.1.6.1.2.355.2.60
diff -u -r1.1.1.1.6.1.2.355.2.60 s_conf.c
--- src/s_conf.c	25 Oct 2005 15:28:00 -0000	1.1.1.1.6.1.2.355.2.60
+++ src/s_conf.c	10 Nov 2005 23:32:07 -0000
@@ -1512,6 +1512,7 @@
 	i->spamfilter_virus_help_channel = strdup("#help");
 	i->maxdccallow = 10;
 	i->channel_command_prefix = strdup("`!.");
+	i->check_target_nick_bans = 1;
 }
 
 /* 1: needed for set::options::allow-part-if-shunned,
@@ -6409,6 +6410,9 @@
 		else if (!strcmp(cep->ce_varname, "oper-auto-join")) {
 			ircstrdup(tempiConf.oper_auto_join_chans, cep->ce_vardata);
 		}
+		else if (!strcmp(cep->ce_varname, "check-target-nick-bans")) {
+			tempiConf.check_target_nick_bans = config_checkval(cep->ce_vardata, CFG_YESNO);
+		}
 		else if (!strcmp(cep->ce_varname, "allow-userhost-change")) {
 			if (!stricmp(cep->ce_vardata, "always"))
 				tempiConf.userhost_allowed = UHALLOW_ALWAYS;
@@ -6919,6 +6923,10 @@
 			CheckNull(cep);
 			CheckDuplicate(cep, oper_auto_join, "oper-auto-join");
 		}
+		else if (!strcmp(cep->ce_varname, "check-target-nick-bans")) {
+			CheckNull(cep);
+			CheckDuplicate(cep, check_target_nick_bans, "check-target-nick-bans");
+		}
 		else if (!strcmp(cep->ce_varname, "channel-command-prefix")) {
 			CheckNull(cep);
 			CheckDuplicate(cep, channel_command_prefix, "channel-command-prefix");
Index: src/modules/m_nick.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/modules/Attic/m_nick.c,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 m_nick.c
--- src/modules/m_nick.c	25 Sep 2005 21:49:19 -0000	1.1.2.9
+++ src/modules/m_nick.c	10 Nov 2005 23:32:07 -0000
@@ -616,6 +616,14 @@
 					    mp->chptr->chname);
 					return 0;
 				}
+				if (CHECK_TARGET_NICK_BANS && !is_skochanop(sptr, mp->chptr) && is_banned_with_nick(sptr, mp->chptr, BANCHK_NICK, nick))
+				{
+					sendto_one(sptr,
+					    ":%s 437 %s %s :Cannot change to a nickname banned on channel",
+					    me.name, parv[0],
+					    mp->chptr->chname);
+					return 0;
+				}
 				if (!IsOper(sptr) && !IsULine(sptr)
 				    && mp->chptr->mode.mode & MODE_NONICKCHANGE
 				    && !is_chanownprotop(sptr, mp->chptr))
Index: src/modules/m_stats.c
===================================================================
RCS file: /home/cmunk/ircsystems/cvsroot/unreal/src/modules/Attic/m_stats.c,v
retrieving revision 1.1.2.8.2.14
diff -u -r1.1.2.8.2.14 m_stats.c
--- src/modules/m_stats.c	10 Oct 2005 14:32:12 -0000	1.1.2.8.2.14
+++ src/modules/m_stats.c	10 Nov 2005 23:32:08 -0000
@@ -1392,6 +1392,8 @@
 	if (SPAMFILTER_EXCEPT)
 		sendto_one(sptr, ":%s %i %s :spamfilter::except: %s", me.name, RPL_TEXT,
 			sptr->name, SPAMFILTER_EXCEPT);
+	sendto_one(sptr, ":%s %i %s :check-target-nick-bans: %s", me.name, RPL_TEXT,
+		sptr->name, CHECK_TARGET_NICK_BANS ? "yes" : "no");
 	sendto_one(sptr, ":%s %i %s :hosts::global: %s", me.name, RPL_TEXT,
 	    sptr->name, oper_host);
 	sendto_one(sptr, ":%s %i %s :hosts::admin: %s", me.name, RPL_TEXT,
