summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-06-23 16:56:38 +0000
committeradam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-06-23 16:56:38 +0000
commitdc8f7923f4c9cd685a338072bcc2bb351bf575d9 (patch)
treecb55529a96b40d43b2646640a06cc248efa76efb
parent59c1a509b4264648a6ef61e96b85f06f735d6dd6 (diff)
Adds check for using commands on non-registered channels before the
commands are called git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2336 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/modules.h3
-rw-r--r--include/services.h2
-rw-r--r--src/commands.c5
-rw-r--r--src/core/bs_act.c8
-rw-r--r--src/core/bs_assign.c6
-rw-r--r--src/core/bs_badwords.c6
-rw-r--r--src/core/bs_kick.c4
-rw-r--r--src/core/bs_say.c6
-rw-r--r--src/core/bs_set.c6
-rw-r--r--src/core/bs_unassign.c4
-rw-r--r--src/core/cs_access.c8
-rw-r--r--src/core/cs_akick.c4
-rw-r--r--src/core/cs_ban.c15
-rw-r--r--src/core/cs_clear.c9
-rw-r--r--src/core/cs_drop.c6
-rw-r--r--src/core/cs_getkey.c6
-rw-r--r--src/core/cs_getpass.c7
-rw-r--r--src/core/cs_identify.c6
-rw-r--r--src/core/cs_info.c6
-rw-r--r--src/core/cs_invite.c10
-rw-r--r--src/core/cs_kick.c9
-rw-r--r--src/core/cs_logout.c4
-rw-r--r--src/core/cs_modes.c9
-rw-r--r--src/core/cs_register.c2
-rw-r--r--src/core/cs_sendpass.c6
-rw-r--r--src/core/cs_set.c4
-rw-r--r--src/core/cs_suspend.c17
-rw-r--r--src/core/cs_topic.c7
-rw-r--r--src/core/cs_xop.c6
-rw-r--r--src/core/ms_del.c8
-rw-r--r--src/core/ms_info.c7
-rw-r--r--src/core/ms_list.c9
-rw-r--r--src/core/ms_read.c9
-rw-r--r--src/modules/cs_appendtopic.c9
-rw-r--r--src/modules/cs_enforce.c9
-rw-r--r--src/modules/cs_tban.c8
-rw-r--r--src/modules/os_info.c38
-rw-r--r--src/protocol.cpp7
-rw-r--r--src/protocol/unreal32.c2
39 files changed, 107 insertions, 190 deletions
diff --git a/include/modules.h b/include/modules.h
index 8c45bdeaa..db1c2f0a3 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -219,7 +219,8 @@ enum CommandFlags
{
CFLAG_ALLOW_UNREGISTERED = 1,
CFLAG_ALLOW_FORBIDDEN = 2,
- CFLAG_ALLOW_SUSPENDED = 4
+ CFLAG_ALLOW_SUSPENDED = 4,
+ CFLAG_ALLOW_UNREGISTEREDCHANNEL = 8
};
/** Every services command is a class, inheriting from Command.
diff --git a/include/services.h b/include/services.h
index 5dcb83183..55b437da3 100644
--- a/include/services.h
+++ b/include/services.h
@@ -1340,7 +1340,7 @@ class CoreExport IRCDProto
virtual void SendServer(Server *) = 0;
virtual void ProcessUsermodes(User *, int, const char **) = 0;
virtual int IsNickValid(const char *) { return 1; }
- virtual int IsChannelValid(const char *) { return 1; }
+ virtual int IsChannelValid(const char *);
virtual int IsFloodModeParamValid(const char *) { return 0; }
virtual void SendNumeric(const char *source, int numeric, const char *dest, const char *fmt, ...);
diff --git a/src/commands.c b/src/commands.c
index 344805f9a..7fe9f829b 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -144,6 +144,11 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
return;
}
}
+ else if (!c->HasFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL))
+ {
+ notice_lang(service, u, CHAN_X_NOT_REGISTERED, params[0].c_str());
+ return;
+ }
}
// If the command requires a permission, and they aren't registered or don't have the required perm, DENIED
diff --git a/src/core/bs_act.c b/src/core/bs_act.c
index a73868497..780f08e78 100644
--- a/src/core/bs_act.c
+++ b/src/core/bs_act.c
@@ -25,13 +25,7 @@ class CommandBSAct : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
- ChannelInfo *ci;
-
- if (!(ci = cs_findchan(params[0].c_str())))
- {
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, params[0].c_str());
- return MOD_CONT;
- }
+ ChannelInfo *ci = cs_findchan(params[0].c_str());
if (!check_access(u, ci, CA_SAY))
{
diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c
index a19f1a8dd..aa8d30b9f 100644
--- a/src/core/bs_assign.c
+++ b/src/core/bs_assign.c
@@ -41,11 +41,7 @@ class CommandBSAssign : public Command
return MOD_CONT;
}
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if ((ci->botflags & BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration")))
{
diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c
index 627d84569..190f5b510 100644
--- a/src/core/bs_badwords.c
+++ b/src/core/bs_badwords.c
@@ -248,11 +248,7 @@ class CommandBSBadwords : public Command
return MOD_CONT;
}
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if (!check_access(u, ci, CA_BADWORDS) && (!need_args || !u->nc->HasPriv("botserv/administration")))
{
diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c
index a39cb6b6d..7b6b153bf 100644
--- a/src/core/bs_kick.c
+++ b/src/core/bs_kick.c
@@ -31,7 +31,7 @@ class CommandBSKick : public Command
const char *value = params[2].c_str();
const char *ttb = params.size() > 3 ? params[3].c_str() : NULL;
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
if (readonly)
notice_lang(s_BotServ, u, BOT_KICK_DISABLED);
@@ -39,8 +39,6 @@ class CommandBSKick : public Command
syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
else if (stricmp(value, "ON") && stricmp(value, "OFF"))
syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
else if (!check_access(u, ci, CA_SET) && !u->nc->HasPriv("botserv/administration"))
notice_lang(s_BotServ, u, ACCESS_DENIED);
else if (!ci->bi)
diff --git a/src/core/bs_say.c b/src/core/bs_say.c
index 5a262e4b7..5f9c766bf 100644
--- a/src/core/bs_say.c
+++ b/src/core/bs_say.c
@@ -29,11 +29,7 @@ class CommandBSSay : public Command
const char *chan = params[0].c_str();
const char *text = params[1].c_str();
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if (!check_access(u, ci, CA_SAY))
{
diff --git a/src/core/bs_set.c b/src/core/bs_set.c
index d99bec581..17df27541 100644
--- a/src/core/bs_set.c
+++ b/src/core/bs_set.c
@@ -35,6 +35,8 @@ class CommandBSSet : public Command
return MOD_CONT;
}
+ ci = cs_findchan(chan);
+
if (u->nc->HasCommand("botserv/set/private") && !stricmp(option, "PRIVATE"))
{
BotInfo *bi;
@@ -60,9 +62,7 @@ class CommandBSSet : public Command
syntax_error(s_BotServ, u, "SET PRIVATE", BOT_SET_PRIVATE_SYNTAX);
}
return MOD_CONT;
- } else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (!u->nc->HasPriv("botserv/administration") && !check_access(u, ci, CA_SET))
+ } else if (!u->nc->HasPriv("botserv/administration") && !check_access(u, ci, CA_SET))
notice_lang(s_BotServ, u, ACCESS_DENIED);
else {
if (!stricmp(option, "DONTKICKOPS")) {
diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c
index 64d6fa269..52b28a078 100644
--- a/src/core/bs_unassign.c
+++ b/src/core/bs_unassign.c
@@ -27,12 +27,10 @@ class CommandBSUnassign : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
const char *chan = params[0].c_str();
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
if (readonly)
notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
else if (!u->nc->HasPriv("botserv/administration") && !check_access(u, ci, CA_ASSIGN))
notice_lang(s_BotServ, u, ACCESS_DENIED);
else if (!ci->bi)
diff --git a/src/core/cs_access.c b/src/core/cs_access.c
index 7a4ad8a78..8798d7c20 100644
--- a/src/core/cs_access.c
+++ b/src/core/cs_access.c
@@ -95,7 +95,7 @@ class CommandCSAccess : public Command
const char *nick = params.size() > 2 ? params[2].c_str() : NULL;
const char *s = params.size() > 3 ? params[3].c_str() : NULL;
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
NickAlias *na = NULL;
NickCore *nc;
ChanAccess *access;
@@ -109,8 +109,6 @@ class CommandCSAccess : public Command
* Else (ADD), we require a level (which implies a nick). */
if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : (!stricmp(cmd, "DEL")) ? (!nick || s) : !s))
this->OnSyntaxError(u);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
/* We still allow LIST in xOP mode, but not others */
else if ((ci->flags & CI_XOP) && !is_list)
{
@@ -367,7 +365,7 @@ class CommandCSLevels : public Command
const char *s = params.size() > 3 ? params[3].c_str() : NULL;
char *error;
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
int level;
int i;
@@ -378,8 +376,6 @@ class CommandCSLevels : public Command
|| ((stricmp(cmd, "SET") == 0) ? !s
: ((strnicmp(cmd, "DIS", 3) == 0)) ? (!what || s) : !!what)) {
this->OnSyntaxError(u);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
} else if (ci->flags & CI_XOP) {
notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP);
} else if (!is_founder(u, ci) && !u->nc->HasPriv("chanserv/access/change")) {
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index 64e864dc1..4afad1279 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -186,7 +186,7 @@ class CommandCSAKick : public Command
reason = params[3].c_str();
}
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
AutoKick *akick;
int i;
Channel *c;
@@ -201,8 +201,6 @@ class CommandCSAKick : public Command
|| !stricmp(cmd, "DEL")))) {
syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
} else if (!check_access(u, ci, CA_AKICK) && !u->nc->HasPriv("chanserv/access/change"))
{
notice_lang(s_ChanServ, u, ACCESS_DENIED);
diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c
index 8f9e9c2e2..277834571 100644
--- a/src/core/cs_ban.c
+++ b/src/core/cs_ban.c
@@ -36,7 +36,7 @@ class CommandCSBan : public Command
}
- Channel *c;
+ Channel *c = findchan(chan);
ChannelInfo *ci;
User *u2;
@@ -47,10 +47,11 @@ class CommandCSBan : public Command
is_same = (stricmp(target, u->nick) == 0);
- if (!(c = findchan(chan))) {
+ if (c)
+ ci = c->ci;
+
+ if (!c) {
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
} else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) {
notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, target);
} else if (!is_same ? !check_access(u, ci, CA_BAN) :
@@ -133,11 +134,7 @@ class CommandCSUnban : public Command
return MOD_CONT;
}
- if (!(ci = c->ci))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = c->ci;
if (!check_access(u, ci, CA_UNBAN))
{
diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c
index 5ffc33035..e7e54867f 100644
--- a/src/core/cs_clear.c
+++ b/src/core/cs_clear.c
@@ -27,13 +27,14 @@ class CommandCSClear : public Command
{
const char *chan = params[0].c_str();
const char *what = params[1].c_str();
- Channel *c;
+ Channel *c = findchan(chan);
ChannelInfo *ci;
- if (!(c = findchan(chan))) {
+ if (c)
+ ci = c->ci;
+
+ if (!c) {
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
} else if (!u || !check_access(u, ci, CA_CLEAR)) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else if (stricmp(what, "bans") == 0) {
diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c
index 8e6328607..b2e58f4c8 100644
--- a/src/core/cs_drop.c
+++ b/src/core/cs_drop.c
@@ -35,11 +35,7 @@ class CommandCSDrop : public Command
return MOD_CONT;
}
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if ((ci->flags & CI_FORBIDDEN) && !u->nc->HasCommand("chanserv/drop"))
{
diff --git a/src/core/cs_getkey.c b/src/core/cs_getkey.c
index cc7e4792f..9b45e7846 100644
--- a/src/core/cs_getkey.c
+++ b/src/core/cs_getkey.c
@@ -34,11 +34,7 @@ class CommandCSGetKey : public Command
return MOD_CONT;
}
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if (!check_access(u, ci, CA_GETKEY))
{
diff --git a/src/core/cs_getpass.c b/src/core/cs_getpass.c
index 74f7e87d6..a4f2fa9c9 100644
--- a/src/core/cs_getpass.c
+++ b/src/core/cs_getpass.c
@@ -29,11 +29,8 @@ class CommandCSGetPass : public Command
char tmp_pass[PASSMAX];
ChannelInfo *ci;
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
+
if (!enc_decrypt(ci->founderpass, tmp_pass, PASSMAX - 1))
{
notice_lang(s_ChanServ, u, CHAN_GETPASS_UNAVAILABLE);
diff --git a/src/core/cs_identify.c b/src/core/cs_identify.c
index aa8f3ac32..14de4134a 100644
--- a/src/core/cs_identify.c
+++ b/src/core/cs_identify.c
@@ -30,11 +30,7 @@ class CommandCSIdentify : public Command
ChannelInfo *ci;
struct u_chaninfolist *uc;
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if (is_founder(u, ci))
{
diff --git a/src/core/cs_info.c b/src/core/cs_info.c
index f4f2b5b17..8778d002e 100644
--- a/src/core/cs_info.c
+++ b/src/core/cs_info.c
@@ -48,11 +48,7 @@ class CommandCSInfo : public Command
int show_all = 0;
time_t expt;
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
+ ci = cs_findchan(chan);
if (ci->flags & CI_FORBIDDEN)
{
diff --git a/src/core/cs_invite.c b/src/core/cs_invite.c
index 09ea33f64..1c6ac1f93 100644
--- a/src/core/cs_invite.c
+++ b/src/core/cs_invite.c
@@ -33,12 +33,10 @@ class CommandCSInvite : public Command
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
return MOD_CONT;
}
- else if (!(ci = c->ci))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
- else if (!u || !check_access(u, ci, CA_INVITE))
+
+ ci = c->ci;
+
+ if (!u || !check_access(u, ci, CA_INVITE))
{
notice_lang(s_ChanServ, u, ACCESS_DENIED);
return MOD_CONT;
diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c
index be30f792f..f7049593d 100644
--- a/src/core/cs_kick.c
+++ b/src/core/cs_kick.c
@@ -35,7 +35,7 @@ class CommandCSKick : public Command
reason = params[2].c_str();
}
- Channel *c;
+ Channel *c = findchan(chan);
ChannelInfo *ci;
User *u2;
@@ -47,10 +47,11 @@ class CommandCSKick : public Command
is_same = (target == u->nick) ? 1 : (stricmp(target, u->nick) == 0);
- if (!(c = findchan(chan))) {
+ if (c)
+ ci = c->ci;
+
+ if (!c) {
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
} else if (is_same ? !(u2 = u) : !(u2 = finduser(target))) {
notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, target);
} else if (!is_on_chan(c, u2)) {
diff --git a/src/core/cs_logout.c b/src/core/cs_logout.c
index 90ba2928b..948d32bcb 100644
--- a/src/core/cs_logout.c
+++ b/src/core/cs_logout.c
@@ -54,14 +54,12 @@ class CommandCSLogout : public Command
{
const char *chan = params[0].c_str();
const char *nick = params.size() > 1 ? params[1].c_str() : NULL;
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
User *u2 = NULL;
int is_admin = u->nc->HasCommand("chanserv/logout");
if (!is_admin && !nick)
this->OnSyntaxError(u);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
else if (nick && !(u2 = finduser(nick)))
notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
else if (u2 != u && !is_real_founder(u, ci) && !is_admin)
diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c
index 3b081e3b1..239b31305 100644
--- a/src/core/cs_modes.c
+++ b/src/core/cs_modes.c
@@ -20,7 +20,7 @@
static CommandReturn do_util(User *u, CSModeUtil *util, const char *chan, const char *nick)
{
const char *av[2];
- Channel *c;
+ Channel *c = findchan(chan);
ChannelInfo *ci;
User *u2;
@@ -32,10 +32,11 @@ static CommandReturn do_util(User *u, CSModeUtil *util, const char *chan, const
is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);
- if (!(c = findchan(chan))) {
+ if (c)
+ ci = c->ci;
+
+ if (!c) {
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
} else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) {
notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
} else if (!is_on_chan(c, u2)) {
diff --git a/src/core/cs_register.c b/src/core/cs_register.c
index 7e38a52da..089f6a785 100644
--- a/src/core/cs_register.c
+++ b/src/core/cs_register.c
@@ -20,7 +20,7 @@ class CommandCSRegister : public Command
public:
CommandCSRegister() : Command("REGISTER", 3, 3)
{
-
+ this->SetFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL);
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
diff --git a/src/core/cs_sendpass.c b/src/core/cs_sendpass.c
index 2b87e0b77..d9821b34d 100644
--- a/src/core/cs_sendpass.c
+++ b/src/core/cs_sendpass.c
@@ -25,13 +25,11 @@ class CommandCSSendPass : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
const char *chan = params[0].c_str();
- ChannelInfo *ci;
- NickCore *founder;
+ ChannelInfo *ci = cs_findchan(chan);
+ NickCore *founder = ci->founder;;
if (RestrictMail && !u->nc->HasCommand("chanserv/sendpass"))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- else if (!(ci = cs_findchan(chan)) || !(founder = ci->founder))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
else
{
char buf[BUFSIZE];
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
index a2586e380..1f6bdd765 100644
--- a/src/core/cs_set.c
+++ b/src/core/cs_set.c
@@ -558,7 +558,7 @@ class CommandCSSet : public Command
const char *chan = params[0].c_str();
const char *cmd = params[1].c_str();
const char *param = params.size() > 2 ? params[2].c_str() : NULL;
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
bool is_servadmin = u->nc->HasPriv("chanserv/set");
if (readonly) {
@@ -572,8 +572,6 @@ class CommandCSSet : public Command
stricmp(cmd, "ENTRYMSG") != 0) &&
stricmp(cmd, "MLOCK") != 0)) {
syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
} else if (!is_servadmin && !check_access(u, ci, CA_SET)) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else if (stricmp(cmd, "FOUNDER") == 0) {
diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c
index 7a63a0fe6..2f6662d8b 100644
--- a/src/core/cs_suspend.c
+++ b/src/core/cs_suspend.c
@@ -24,9 +24,9 @@ class CommandCSSuspend : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
- ChannelInfo *ci;
const char *chan = params[0].c_str();
const char *reason = params.size() > 1 ? params[1].c_str() : NULL;
+ ChannelInfo *ci = cs_findchan(chan);
Channel *c;
@@ -43,13 +43,6 @@ class CommandCSSuspend : public Command
return MOD_CONT;
}
- /* Only SUSPEND existing channels, otherwise use FORBID (bug #54) */
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
-
/* You should not SUSPEND a FORBIDEN channel */
if (ci->flags & CI_FORBIDDEN)
{
@@ -125,8 +118,8 @@ class CommandCSUnSuspend : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
- ChannelInfo *ci;
const char *chan = params[0].c_str();
+ ChannelInfo *ci = cs_findchan(chan);
if (chan[0] != '#')
{
@@ -137,12 +130,6 @@ class CommandCSUnSuspend : public Command
notice_lang(s_ChanServ, u, READ_ONLY_MODE);
/* Only UNSUSPEND already suspended channels */
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
-
if (!(ci->flags & CI_SUSPENDED))
{
notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan);
diff --git a/src/core/cs_topic.c b/src/core/cs_topic.c
index 86cef26eb..4c981cb47 100644
--- a/src/core/cs_topic.c
+++ b/src/core/cs_topic.c
@@ -30,10 +30,11 @@ class CommandCSTopic : public Command
Channel *c;
ChannelInfo *ci;
- if (!(c = findchan(chan)))
+ if ((c = findchan(chan)))
+ ci = c->ci;
+
+ if (!c)
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- else if (!(ci = c->ci))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
else if (!check_access(u, ci, CA_TOPIC) && !u->nc->HasCommand("chanserv/topic"))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else
diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c
index 2a73ce3f6..60772b0f3 100644
--- a/src/core/cs_xop.c
+++ b/src/core/cs_xop.c
@@ -360,11 +360,9 @@ class XOPBase : public Command
const char *chan = params[0].c_str();
const char *cmd = params[1].c_str();
- ChannelInfo *ci;
+ ChannelInfo *ci = cs_findchan(chan);
- if (!(ci = cs_findchan(chan)))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (!(ci->flags & CI_XOP))
+ if (!(ci->flags & CI_XOP))
notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ);
else if (!stricmp(cmd, "ADD"))
return this->DoAdd(u, params, ci, level, messages);
diff --git a/src/core/ms_del.c b/src/core/ms_del.c
index e73404f46..f5f0a231d 100644
--- a/src/core/ms_del.c
+++ b/src/core/ms_del.c
@@ -37,12 +37,8 @@ class CommandMSDel : public Command
{
chan = numstr;
numstr = params.size() > 1 ? params[1].c_str() : NULL;
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
- else if (readonly)
+ ci = cs_findchan(chan);
+ if (readonly)
{
notice_lang(s_MemoServ, u, READ_ONLY_MODE);
return MOD_CONT;
diff --git a/src/core/ms_info.c b/src/core/ms_info.c
index ba78954e7..890bb74b9 100644
--- a/src/core/ms_info.c
+++ b/src/core/ms_info.c
@@ -49,12 +49,7 @@ class CommandMSInfo : public Command
else if (name && *name == '#')
{
ci = cs_findchan(name);
- if (!ci)
- {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, name);
- return MOD_CONT;
- }
- else if (!check_access(u, ci, CA_MEMO))
+ if (!check_access(u, ci, CA_MEMO))
{
notice_lang(s_MemoServ, u, ACCESS_DENIED);
return MOD_CONT;
diff --git a/src/core/ms_list.c b/src/core/ms_list.c
index 5c2aab3d2..7dccbe06e 100644
--- a/src/core/ms_list.c
+++ b/src/core/ms_list.c
@@ -37,12 +37,9 @@ class CommandMSList : public Command
{
chan = param;
param = params.size() > 1 ? params[1].c_str() : NULL;
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
- else if (!check_access(u, ci, CA_MEMO))
+ ci = cs_findchan(chan);
+
+ if (!check_access(u, ci, CA_MEMO))
{
notice_lang(s_MemoServ, u, ACCESS_DENIED);
return MOD_CONT;
diff --git a/src/core/ms_read.c b/src/core/ms_read.c
index e47a674e6..6a1e5af6e 100644
--- a/src/core/ms_read.c
+++ b/src/core/ms_read.c
@@ -37,12 +37,9 @@ class CommandMSRead : public Command
{
chan = numstr;
numstr = params.size() > 1 ? params[1].c_str() : NULL;
- if (!(ci = cs_findchan(chan)))
- {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
- else if (!check_access(u, ci, CA_MEMO))
+ ci = cs_findchan(chan);
+
+ if (!check_access(u, ci, CA_MEMO))
{
notice_lang(s_MemoServ, u, ACCESS_DENIED);
return MOD_CONT;
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c
index a314e9d8c..c102e35b1 100644
--- a/src/modules/cs_appendtopic.c
+++ b/src/modules/cs_appendtopic.c
@@ -62,13 +62,14 @@ class CommandCSAppendTopic : public Command
const char *chan = params[0].c_str();
const char *newtopic = params[1].c_str();
char topic[1024];
- Channel *c;
+ Channel *c = findchan(chan);
ChannelInfo *ci;
- if (!(c = findchan(chan)))
+ if (c)
+ ci = c->ci;
+
+ if (!c)
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- else if (!(ci = c->ci))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
else if (ci->flags & CI_FORBIDDEN)
notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
else if (!check_access(u, ci, CA_TOPIC))
diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c
index 440366709..22987965e 100644
--- a/src/modules/cs_enforce.c
+++ b/src/modules/cs_enforce.c
@@ -182,13 +182,14 @@ class CommandCSEnforce : public Command
{
const char *chan = params[0].c_str();
const char *what = params.size() > 1 ? params[1].c_str() : NULL;
- Channel *c;
+ Channel *c = findchan(chan);
ChannelInfo *ci;
- if (!(c = findchan(chan)))
+ if (c)
+ ci = c->ci;
+
+ if (!c)
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- else if (!(ci = c->ci))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
else if (ci->flags & CI_FORBIDDEN)
notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
else if (!check_access(u, ci, CA_AKICK))
diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c
index 7dde83f09..43c4395ee 100644
--- a/src/modules/cs_tban.c
+++ b/src/modules/cs_tban.c
@@ -203,13 +203,9 @@ int delBan(int argc, char **argv)
int canBanUser(Channel * c, User * u, User * u2)
{
- ChannelInfo *ci;
+ ChannelInfo *ci = c->ci;
int ok = 0;
- if (!(ci = c->ci))
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
- else if (ci->flags & CI_FORBIDDEN)
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, c->name);
- else if (!check_access(u, ci, CA_BAN))
+ if (!check_access(u, ci, CA_BAN))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else if (ircd->except && is_excepted(ci, u2))
notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
diff --git a/src/modules/os_info.c b/src/modules/os_info.c
index 20dc839e3..efaecead9 100644
--- a/src/modules/os_info.c
+++ b/src/modules/os_info.c
@@ -146,7 +146,7 @@ class CommandCSOInfo : public Command
const char *chan = params[1].c_str();
const char *info = params.size() > 2 ? params[2].c_str() : NULL;
char *c;
- ChannelInfo *ci = NULL;
+ ChannelInfo *ci = cs_findchan(chan);
if (!info)
{
@@ -154,19 +154,14 @@ class CommandCSOInfo : public Command
return MOD_CONT;
}
- if ((ci = cs_findchan(chan)))
+ if (ci->GetExt("os_info", c))
{
- if (ci->GetExt("os_info", c))
- {
- delete [] c;
- ci->Shrink("os_info");
- }
- /* Add the module data to the channel */
- ci->Extend("os_info", sstrdup(info));
- me->NoticeLang(s_ChanServ, u, OCINFO_ADD_SUCCESS, chan);
+ delete [] c;
+ ci->Shrink("os_info");
}
- else
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ /* Add the module data to the channel */
+ ci->Extend("os_info", sstrdup(info));
+ me->NoticeLang(s_ChanServ, u, OCINFO_ADD_SUCCESS, chan);
return MOD_CONT;
}
@@ -174,21 +169,16 @@ class CommandCSOInfo : public Command
CommandReturn DoDel(User *u, std::vector<std::string> &params)
{
const char *chan = params[1].c_str();
- ChannelInfo *ci = NULL;
+ ChannelInfo *ci = cs_findchan(chan);
- if ((ci = cs_findchan(chan)))
+ /* Del the module data from the channel */
+ char *c;
+ if (ci->GetExt("os_info", c))
{
- /* Del the module data from the channel */
- char *c;
- if (ci->GetExt("os_info", c))
- {
- delete [] c;
- ci->Shrink("os_info");
- }
- me->NoticeLang(s_ChanServ, u, OCINFO_DEL_SUCCESS, chan);
+ delete [] c;
+ ci->Shrink("os_info");
}
- else
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ me->NoticeLang(s_ChanServ, u, OCINFO_DEL_SUCCESS, chan);
return MOD_CONT;
}
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 2ad41c675..3b75b29f3 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -228,3 +228,10 @@ void IRCDProto::SendNumeric(const char *source, int numeric, const char *dest, c
SendNumericInternal(source, numeric, dest, buf);
}
+int IRCDProto::IsChannelValid(const char *chan)
+{
+ if (*chan != '#')
+ return 0;
+
+ return 1;
+}
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index 24f406dd6..773717495 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -899,7 +899,7 @@ class UnrealIRCdProto : public IRCDProto
int IsChannelValid(const char *chan)
{
- if (strchr(chan, ':')) return 0;
+ if (strchr(chan, ':') || *chan != '#') return 0;
return 1;
}