From e5f9f1f62113b8e1f5bd774b89138d8afc239eba Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 15 Jan 2006 20:21:08 +0000 Subject: Added checks to forbid declaring certain config tags twice (ones which should only exist once like and ) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2804 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd_io.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') 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); -- cgit v1.2.3