summaryrefslogtreecommitdiff
path: root/src/inspircd_io.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-15 20:21:08 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-15 20:21:08 +0000
commite5f9f1f62113b8e1f5bd774b89138d8afc239eba (patch)
tree2e492c6b17479abc087bececbce3746cdc4cc11d /src/inspircd_io.cpp
parent25ce714b64d987416bc7a605cfa0f621f39b450c (diff)
Added checks to forbid declaring certain config tags twice (ones which should only exist once like <server> and <admin>)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2804 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd_io.cpp')
-rw-r--r--src/inspircd_io.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 2b380becf..67baa11ad 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -91,6 +91,33 @@ bool ServerConfig::DelIOHook(int port)
return false;
}
+bool ServerConfig::CheckOnce(char* tag,bool bail)
+{
+ if (ConfValueEnum(tag,&Config->config_f) > 1)
+ {
+ if (bail)
+ {
+ printf("There were errors in your configuration:\nYou have more than one <%s> tag, this is not permitted.\n",tag);
+ Exit(0);
+ }
+ else
+ {
+ if (user)
+ {
+ WriteServ(user->fd,"There were errors in your configuration:");
+ WriteServ(user->fd,"You have more than one <%s> tag, this is not permitted.\n",tag);
+ }
+ else
+ {
+ WriteOpers("There were errors in the configuration file:");
+ WriteOpers("You have more than one <%s> tag, this is not permitted.\n",tag);
+ }
+ }
+ return false;
+ }
+ return true;
+}
+
void ServerConfig::Read(bool bail, userrec* user)
{
char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF],MCON[MAXBUF];
@@ -133,6 +160,14 @@ void ServerConfig::Read(bool bail, userrec* user)
}
}
+ /* Check we dont have more than one of singular tags
+ */
+ if (!CheckOnce("server") || !CheckOnce("admin") || !CheckOnce("files") || !CheckOnce("power") || !CheckOnce("options")
+ || !CheckOnce("dns") || !CheckOnce("options") || !CheckOnce("disabled") || !CheckOnce("pid"))
+ {
+ return;
+ }
+
ConfValue("server","name",0,Config->ServerName,&Config->config_f);
ConfValue("server","description",0,Config->ServerDesc,&Config->config_f);
ConfValue("server","network",0,Config->Network,&Config->config_f);