[SithNet-Patches] [CVS] Module gnuworld-sithnet: Change committed
Brought to you by:
darthsidious_
From: Tim I. <dar...@us...> - 2003-08-21 23:14:24
|
Committer : Tim Ireland <dar...@us...> CVSROOT : /cvsroot/sithnet-dev Module : gnuworld-sithnet Commit time: 2003-08-21 23:14:23 UTC Modified files: mod.cservice/cservice.cc mod.cservice/cservice.h mod.cservice/Makefile.am mod.cservice/cservice_config.h mod.cservice/levels.h Added files: mod.cservice/ADMINKILLCommand.cc mod.cservice/KILLCommand.cc Log message: new commands added. see README.SithNet and ChangeLog.sithnet for info. ---------------------- diff included ---------------------- Index: gnuworld-sithnet/mod.cservice/ADMINKILLCommand.cc diff -u /dev/null gnuworld-sithnet/mod.cservice/ADMINKILLCommand.cc:1.1 --- /dev/null Thu Aug 21 16:14:23 2003 +++ gnuworld-sithnet/mod.cservice/ADMINKILLCommand.cc Thu Aug 21 16:14:13 2003 @@ -0,0 +1,108 @@ +/* + * ADMINKILLCommand.cc + * + * 23/06/2003 - Tim Ireland <dar...@us...> + * Initial Version. + * Make purely to kill time, if it works cool :) + * If it doesnt it may never. + * Based from the mod.nickserv RECOVERCommand + * + * This is similar to my KILLCommand.cc, except you can #define wether or not + * you want to use it in your cservice_config.h file ( if you choose to + * enable, be aware that all *750+ admins can use it... ) + * $Id: ADMINKILLCommand.cc,v 1.1 2003/08/21 23:14:13 darthsidious_ Exp $ + */ + +#include <string> +#include <sstream> +#include <iostream> +#include <iomanip> + +#include "StringTokenizer.h" +#include "ELog.h" +#include "cservice.h" +#include "responses.h" +#include "networkData.h" +#include "cservice_config.h" +#include "Network.h" + +const char KILLCommand_cc_rcsId[] = "$Id: ADMINKILLCommand.cc,v 1.1 2003/08/21 23:14:13 darthsidious_ Exp $" ; + +namespace gnuworld +{ + +using namespace gnuworld; + +bool KILLCommand::Exec( iClient* theClient, const string& Message ) +{ +bot->incStat("COMMANDS.ADMINKILL"); + +#ifdef USE_ADMINKILL + +StringTokenizer st( Message ) ; +if( st.size() < 3 ) + { + Usage(theClient); + return true; + } + +/* + * Fetch the sqlUser record attached to this client. If there isn't one, + * they aren't logged in - tell them they should be. + */ + +sqlUser* theUser = bot->isAuthed(theClient, false); +if (!theUser) + { + return false; + } + +int admLevel = bot->getAdminAccessLevel(theUser); +// int oLevel = bot->GetOfficialAccessLevel(theUser); +if (admLevel < level::adminkill) // && (oLevel < level::official::scoder) + +/* keep this command 'quiet' i.e. dont let unauthorised user's + * know anyhting about it + * + bot->Notice(theClient, + bot->getResponse(theUser, + language::insuf_access, + string("Sorry, you have insufficient access to +perform that command."))); + */ + return false; + } + +/* + * First, check the user/ nickname exists - is this even the right way to +do this? + */ + + iClient* Target = Network->findNick( st[ 2 ] ) ; +if( NULL == Target ) + { + bot->Notice( theClient, "Unable to find nick: %s", + st[ 2 ].c_str() ) ; + return true ; + } + + if( Target->getMode(iClient::MODE_SERVICES)) + { + bot->Notice(theClient,"No. %s Appears to be a Network Service.",st[ 2 ].c_str()); + return false; + } +bot->Notice( theClient, "Killing %s because %s", + Target->getNickName().c_str(), + st.assemble( 3 ).c_str() ) ; + + bot->logAdminMessage("ADMINKILL %s ",theClient->getNickName.c_str()); + + +bot->Kill( iClient," %s ",reason.c_str()); + + +#endif // USE_KILLCMD + +} + +} // namespace gnuworld. Index: gnuworld-sithnet/mod.cservice/KILLCommand.cc diff -u /dev/null gnuworld-sithnet/mod.cservice/KILLCommand.cc:1.1 --- /dev/null Thu Aug 21 16:14:23 2003 +++ gnuworld-sithnet/mod.cservice/KILLCommand.cc Thu Aug 21 16:14:13 2003 @@ -0,0 +1,99 @@ +/* + * KILLCommand.cc + * + * 23/06/2003 - Tim Ireland <dar...@us...> + * Initial Version. + * Make purely to kill time, if it works cool :) + * If it doesnt it may never. + * Based from the mod.nickserv RECOVERCommand + * + * $Id: KILLCommand.cc,v 1.1 2003/08/21 23:14:13 darthsidious_ Exp $ + */ + +#include <string> +#include "StringTokenizer.h" +#include "ELog.h" +#include "cservice.h" +#include "responses.h" +#include "networkData.h" +#include "cservice_config.h" +#include "Network.h" + +const char KILLCommand_cc_rcsId[] = "$Id: KILLCommand.cc,v 1.1 2003/08/21 23:14:13 darthsidious_ Exp $" ; + +namespace gnuworld +{ + +using namespace gnuworld; +using std::string; + +bool KILLCommand::Exec( iClient* theClient, const string& Message ) +{ +bot->incStat("COMMANDS.KILL"); + +StringTokenizer st( Message ) ; +if( st.size() < 3 ) + { + Usage(theClient); + return true; + } + +/* + * Fetch the sqlUser record attached to this client. If there isn't one, + * they aren't logged in - tell them they should be. + */ + +sqlUser* theUser = bot->isAuthed(theClient, false); +if (!theUser) + { + return false; + } + +int aLevel = bot->getAdminAccessLevel(theUser); +/* int oLevel = bot->GetOfficialAccessLevel(theUser); */ +if (aLevel < level::kill) + +/* keep this command 'quiet' i.e. dont let unauthorised user's + * know anyhting about it + * + bot->Notice(theClient, + bot->getResponse(theUser, + language::insuf_access, + string("Sorry, you have insufficient access to +perform that command."))); + */ + return false; + } + +iClient* Target = Network->findNick( st[ 2 ] ) ; +if( NULL == Target ) + { + bot->Notice( theClient, "Unable to find nick: %s", + st[ 2 ].c_str() ) ; + return true ; + } + + if( Target->getMode(iClient::MODE_SERVICES)) + { + bot->Notice(theClient,"Cannot Kill %s as it appears to be a +Network Service.",st[ 2 ].c_str()); + return false; + } +} + +if(theClient == targetClient) { + bot->Notice(theClient, "Killing yourself is a bad idea."); + return true; +} + +bot->Kill(targetClient, " %s ",reason.c_str()); + +bot->Notice(theClient, "Succesfully Killed " + theClient->getNickName()); + +bot->logAdminMessage("KILL %s",theClient->getNickName.c_str()); + +return true; +} + + +} // namespace gnuworld Index: gnuworld-sithnet/mod.cservice/Makefile.am diff -u gnuworld-sithnet/mod.cservice/Makefile.am:1.2 gnuworld-sithnet/mod.cservice/Makefile.am:1.3 --- gnuworld-sithnet/mod.cservice/Makefile.am:1.2 Thu Aug 21 10:37:57 2003 +++ gnuworld-sithnet/mod.cservice/Makefile.am Thu Aug 21 16:14:13 2003 @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -# "$Id: Makefile.am,v 1.2 2003/08/21 17:37:57 darthsidious_ Exp $" +# "$Id: Makefile.am,v 1.3 2003/08/21 23:14:13 darthsidious_ Exp $" lib_LTLIBRARIES = libcservice.la libcservice_la_LDFLAGS = -module -export-dynamic -L@PGSQL_LIB@ \ @@ -67,7 +67,9 @@ UNSUSPENDCommand.cc \ VERIFYCommand.cc \ VOICECommand.cc \ - ADDUSERIDCommand.cc + ADDUSERIDCommand.cc \ + ADMINKILLCommand.cc \ + KILLCommand.cc EXTRA_DIST = constants.h \ cserviceCommands.h \ Index: gnuworld-sithnet/mod.cservice/cservice.cc diff -u gnuworld-sithnet/mod.cservice/cservice.cc:1.3 gnuworld-sithnet/mod.cservice/cservice.cc:1.4 --- gnuworld-sithnet/mod.cservice/cservice.cc:1.3 Thu Aug 21 10:37:57 2003 +++ gnuworld-sithnet/mod.cservice/cservice.cc Thu Aug 21 16:14:13 2003 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: cservice.cc,v 1.3 2003/08/21 17:37:57 darthsidious_ Exp $ + * $Id: cservice.cc,v 1.4 2003/08/21 23:14:13 darthsidious_ Exp $ */ #include <new> @@ -229,6 +229,8 @@ RegisterCommand(new STATSCommand(this, "STATS", "", 8)); RegisterCommand(new ADDCOMMENTCommand(this, "ADDCOMMENT", "<username> <comment>", 10)); RegisterCommand(new SHUTDOWNCommand(this, "SHUTDOWN", "[reason]", 10)); +RegisterCommand(new KILLCommand(this, "KILL", "<nick> <reason>", 3)); +RegisterCommand(new ADMINKILLCommand(this, "ADMINKILL", "<nick> <reason>", 3)); cserviceConfig = new (std::nothrow) EConfig( args ) ; assert( cserviceConfig != 0 ) ; @@ -699,8 +701,8 @@ const string Command = string_upper( st[ 0 ] ) ; /* - * Just quickly, abort if someone tries to LOGIN or NEWPASS - * unsecurely. + * Just quickly, abort if someone tries to LOGIN, NEWPASS + * or SUSPENDME unsecurely. */ if (!secure && ((Command == "LOGIN") || (Command == "NEWPASS") || (Command == "SUSPENDME")) ) Index: gnuworld-sithnet/mod.cservice/cservice.h diff -u gnuworld-sithnet/mod.cservice/cservice.h:1.2 gnuworld-sithnet/mod.cservice/cservice.h:1.3 --- gnuworld-sithnet/mod.cservice/cservice.h:1.2 Wed Aug 20 08:33:03 2003 +++ gnuworld-sithnet/mod.cservice/cservice.h Thu Aug 21 16:14:13 2003 @@ -17,11 +17,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: cservice.h,v 1.2 2003/08/20 15:33:03 darthsidious_ Exp $ + * $Id: cservice.h,v 1.3 2003/08/21 23:14:13 darthsidious_ Exp $ */ #ifndef __CSERVICE_H -#define __CSERVICE_H "$Id: cservice.h,v 1.2 2003/08/20 15:33:03 darthsidious_ Exp $" +#define __CSERVICE_H "$Id: cservice.h,v 1.3 2003/08/21 23:14:13 darthsidious_ Exp $" #include <string> #include <vector> @@ -139,6 +139,16 @@ virtual bool Notice( const iClient* Target, const string& ) ; virtual void OnWhois( iClient* sourceClient, iClient* targetClient ); + /** + * Kill will issue a KILL command to the network for + * the given iClient (network generic client). + */ + virtual bool Kill( iClient*, const string& ) ; + + /** + * OnKill() is called when the client has been KILL'd. + */ + virtual void OnKill() ; /* Sends a notice to a channel from the server. */ bool serverNotice( Channel*, const char*, ... ); Index: gnuworld-sithnet/mod.cservice/cservice_config.h diff -u gnuworld-sithnet/mod.cservice/cservice_config.h:1.2 gnuworld-sithnet/mod.cservice/cservice_config.h:1.3 --- gnuworld-sithnet/mod.cservice/cservice_config.h:1.2 Wed Aug 20 08:33:03 2003 +++ gnuworld-sithnet/mod.cservice/cservice_config.h Thu Aug 21 16:14:13 2003 @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: cservice_config.h,v 1.2 2003/08/20 15:33:03 darthsidious_ Exp $ + * $Id: cservice_config.h,v 1.3 2003/08/21 23:14:13 darthsidious_ Exp $ */ #ifndef __CSERVICE_CONFIG_H -#define __CSERVICE_CONFIG_H "$Id: cservice_config.h,v 1.2 2003/08/20 15:33:03 darthsidious_ Exp $" +#define __CSERVICE_CONFIG_H "$Id: cservice_config.h,v 1.3 2003/08/21 23:14:13 darthsidious_ Exp $" /** * Define this if you wish for all SQL queries to be sent @@ -79,5 +79,15 @@ */ #define USE_SETMAXLOGINS + +/** + * Do you want Senior Channel Service Administrators to be able to /kill + * user's throught the use of the ADMINKILL Command? #undef if you dont + * WARNING: this command can be a security risk. DO NOT ENABLE UNLESS + * YOU COMPLETELY TRUST ALL CSERVICE ADMINS WITH A GLOBAL ACCESS LEVEL + * OF 750 OR HIGHER. + */ + +#define USE_ADMINKILL #endif // __CSERVICE_CONFIG_H Index: gnuworld-sithnet/mod.cservice/levels.h diff -u gnuworld-sithnet/mod.cservice/levels.h:1.3 gnuworld-sithnet/mod.cservice/levels.h:1.4 --- gnuworld-sithnet/mod.cservice/levels.h:1.3 Thu Aug 21 10:37:57 2003 +++ gnuworld-sithnet/mod.cservice/levels.h Thu Aug 21 16:14:13 2003 @@ -21,11 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: levels.h,v 1.3 2003/08/21 17:37:57 darthsidious_ Exp $ + * $Id: levels.h,v 1.4 2003/08/21 23:14:13 darthsidious_ Exp $ */ #ifndef __LEVELS_H -#define __LEVELS_H "$Id: levels.h,v 1.3 2003/08/21 17:37:57 darthsidious_ Exp $" +#define __LEVELS_H "$Id: levels.h,v 1.4 2003/08/21 23:14:13 darthsidious_ Exp $" namespace gnuworld { @@ -90,6 +90,13 @@ // Debug Commands const int shutdown = 900; const int quote = 1000; + + // adminkill is a potential security risk if admins are untrustworthy + const int adminkill = 750; + // this one is not #defineable, make sure u trust urself if u have + // *1000 ;) + const int kill = 1000; + namespace set { const int alwaysop = 450; ----------------------- End of diff ----------------------- |