diff --git a/configure.ac b/configure.ac index 5e34869b..f49ad863 100644 --- a/configure.ac +++ b/configure.ac @@ -92,10 +92,6 @@ esac AC_ARG_WITH( [openssl], AS_HELP_STRING([--with-openssl=DIR], [openssl installation prefix]), [OPENSSL=$withval],) -AC_ARG_ENABLE( [extra], - AS_HELP_STRING([--enable-extra], [enable some extra modules]), - [EXTRA="$enableval"], - [EXTRA="no"]) AC_ARG_ENABLE( [debug], AS_HELP_STRING([--enable-debug], [enable debugging]), [DEBUG="$enableval"], @@ -456,31 +452,28 @@ then LIBS="$my_saved_LIBS" fi -if test x"$EXTRA" = "xyes" +AC_CHECK_FUNC( iconv, CHARSET=1 ) +AC_CHECK_LIB( iconv, iconv_open, LIBICONV=-liconv ; CHARSET=1 ) +if test "x$CHARSET" = "x1" then - AC_CHECK_FUNC( iconv, CHARSET=1 ) - AC_CHECK_LIB( iconv, iconv_open, LIBICONV=-liconv ; CHARSET=1 ) - if test "x$CHARSET" = "x1" - then - AC_MSG_CHECKING([whether iconv expects a const second argument]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ - #include - ]], [[ - const char input[] = "X"; const char *inptr = input; size_t inbytes = 1; - char buf[1]; char *outptr = buf; size_t outbytes = 1; - iconv_t ic = iconv_open("ISO8859-1", "UTF8"); - iconv(ic, (char**)&inptr, &inbytes, &outptr, &outbytes); - ]])], [ - AC_MSG_RESULT([no]) - appendMod -DICONV_CONST= - ], [ - AC_MSG_RESULT([yes]) - appendMod -DICONV_CONST=const - ]) - else - AC_MSG_WARN([libiconv was not found, disabling the charset module]) - fi + AC_MSG_CHECKING([whether iconv expects a const second argument]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + #include + ]], [[ + const char input[] = "X"; const char *inptr = input; size_t inbytes = 1; + char buf[1]; char *outptr = buf; size_t outbytes = 1; + iconv_t ic = iconv_open("ISO8859-1", "UTF8"); + iconv(ic, (char**)&inptr, &inbytes, &outptr, &outbytes); + ]])], [ + AC_MSG_RESULT([no]) + appendMod -DICONV_CONST= + ], [ + AC_MSG_RESULT([yes]) + appendMod -DICONV_CONST=const + ]) +else + AC_MSG_WARN([libiconv was not found, disabling the charset module]) fi AC_CACHE_CHECK([for GNU make], [ac_cv_path_GNUMAKE], [ @@ -504,7 +497,6 @@ AC_SUBST([LIBZNC]) AC_SUBST([LIBZNCDIR]) AC_SUBST([MODLINK]) AC_SUBST([NOSSL]) -AC_SUBST([EXTRA]) AC_SUBST([TCL_FLAGS]) AC_SUBST([SASL]) AC_SUBST([CHARSET]) @@ -542,7 +534,6 @@ if test x"$SASL" = "x" ; then else echo "sasl: yes" fi -echo "extra: $EXTRA" if test x"$TCL_FLAGS" = "x" ; then echo "tcl: no" else diff --git a/modules/Makefile.in b/modules/Makefile.in index 906f57d6..97c8b6bb 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -59,10 +59,6 @@ endif CLEAN := FILES := $(notdir $(wildcard $(srcdir)/*.cpp)) -# If extra is enabled -ifeq "@EXTRA@" "yes" -FILES += $(addprefix extra/, $(notdir $(wildcard $(srcdir)/extra/*.cpp))) -endif include $(srcdir)/modperl/Makefile.inc include $(srcdir)/modpython/Makefile.inc @@ -79,18 +75,18 @@ FILES := $(foreach file, $(FILES), \ endif ifeq "@SASL@" "" -FILES := $(shell echo $(FILES) | sed -e "s:extra/saslauth::") +FILES := $(shell echo $(FILES) | sed -e "s:saslauth::") endif saslauthLDFLAGS := -lsasl2 ifeq "@CHARSET@" "" -FILES := $(shell echo $(FILES) | sed -e "s:extra/charset::") +FILES := $(shell echo $(FILES) | sed -e "s:charset::") endif charsetLDFLAGS := @LIBICONV@ TARGETS := $(addsuffix .so, $(FILES)) -CLEAN += *.so extra/*.so *.o extra/*.o +CLEAN += *.so *.o .PHONY: all clean install install_datadir uninstall .SECONDARY: @@ -106,9 +102,6 @@ install_datadir: test -d $(DESTDIR)$(DATADIR)/modules || $(INSTALL) -d $(DESTDIR)$(DATADIR)/modules rm -rf $(DESTDIR)$(MODDIR)/*.so cp -R $(srcdir)/data/* $(DESTDIR)$(DATADIR)/modules - if test "@EXTRA@" = "yes" ; then \ - cp -R $(srcdir)/extra/data/* $(DESTDIR)$(DATADIR)/modules ; \ - fi find $(DESTDIR)$(DATADIR)/modules -type d -exec chmod 0755 '{}' \; find $(DESTDIR)$(DATADIR)/modules -type f -exec chmod 0644 '{}' \; @@ -116,12 +109,12 @@ clean: rm -rf $(CLEAN) %.o: %.cpp Makefile - @mkdir -p .depend extra - $(E) Building $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))... + @mkdir -p .depend + $(E) Building module $(notdir $(basename $@))... $(Q)$(CXX) $(MODFLAGS) -c -o $@ $< $($(notdir $(basename $@))CXXFLAGS) -MD -MF .depend/$(notdir $@).dep %.so: %.o Makefile - $(E) Linking $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))... + $(E) Linking module $(notdir $(basename $@))... $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))LDFLAGS) uninstall: diff --git a/modules/extra/antiidle.cpp b/modules/antiidle.cpp similarity index 100% rename from modules/extra/antiidle.cpp rename to modules/antiidle.cpp diff --git a/modules/extra/autoaway.cpp b/modules/autoaway.cpp similarity index 100% rename from modules/extra/autoaway.cpp rename to modules/autoaway.cpp diff --git a/modules/extra/autocycle.cpp b/modules/autocycle.cpp similarity index 100% rename from modules/extra/autocycle.cpp rename to modules/autocycle.cpp diff --git a/modules/extra/autovoice.cpp b/modules/autovoice.cpp similarity index 100% rename from modules/extra/autovoice.cpp rename to modules/autovoice.cpp diff --git a/modules/extra/block_motd.cpp b/modules/block_motd.cpp similarity index 100% rename from modules/extra/block_motd.cpp rename to modules/block_motd.cpp diff --git a/modules/extra/charset.cpp b/modules/charset.cpp similarity index 100% rename from modules/extra/charset.cpp rename to modules/charset.cpp diff --git a/modules/extra/clearbufferonmsg.cpp b/modules/clearbufferonmsg.cpp similarity index 100% rename from modules/extra/clearbufferonmsg.cpp rename to modules/clearbufferonmsg.cpp diff --git a/modules/extra/ctcpflood.cpp b/modules/ctcpflood.cpp similarity index 100% rename from modules/extra/ctcpflood.cpp rename to modules/ctcpflood.cpp diff --git a/modules/extra/data/listsockets/tmpl/index.tmpl b/modules/data/listsockets/tmpl/index.tmpl similarity index 100% rename from modules/extra/data/listsockets/tmpl/index.tmpl rename to modules/data/listsockets/tmpl/index.tmpl diff --git a/modules/extra/data/send_raw/tmpl/index.tmpl b/modules/data/send_raw/tmpl/index.tmpl similarity index 100% rename from modules/extra/data/send_raw/tmpl/index.tmpl rename to modules/data/send_raw/tmpl/index.tmpl diff --git a/modules/extra/dcc.cpp b/modules/dcc.cpp similarity index 100% rename from modules/extra/dcc.cpp rename to modules/dcc.cpp diff --git a/modules/extra/droproot.cpp b/modules/extra/droproot.cpp deleted file mode 100644 index dce5c2a7..00000000 --- a/modules/extra/droproot.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * droproot.cpp - * - * Copyright (c) 2009 Vadtec (vadtec@vadtec.net) - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - * - * Copyright (C) 2004-2012 See the AUTHORS file for details. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include -#include -#include - -class CDroproot : public CModule { - -public: - MODCONSTRUCTOR(CDroproot) { - } - - virtual ~CDroproot() { - } - - uid_t GetUser(const CString& sUser, CString& sMessage) { - uid_t ret = sUser.ToUInt(); - - if (ret != 0) - return ret; - - struct passwd *pUser = getpwnam(sUser.c_str()); - - if (!pUser) { - sMessage = "User [" + sUser + "] not found!"; - return 0; - } - - return pUser->pw_uid; - } - - gid_t GetGroup(const CString& sGroup, CString& sMessage) { - gid_t ret = sGroup.ToUInt(); - - if (ret != 0) - return ret; - - struct group *pGroup = getgrnam(sGroup.c_str()); - - if (!pGroup) { - sMessage = "Group [" + sGroup + "] not found!"; - return 0; - } - - return pGroup->gr_gid; - } - - virtual bool OnLoad(const CString& sArgs, CString& sMessage) { - CString sUser = sArgs.Token(0); - CString sGroup = sArgs.Token(1, true); - - if (sUser.empty() || sGroup.empty()) { - sMessage = "Usage: LoadModule = Droproot "; - return false; - } - - m_user = GetUser(sUser, sMessage); - - if (m_user == 0) { - sMessage - = "Error: Cannot run as root, check your config file | Useage: LoadModule = Droproot "; - return false; - } - - m_group = GetGroup(sGroup, sMessage); - - if (m_group == 0) { - sMessage - = "Error: Cannot run as root, check your config file | Useage: LoadModule = Droproot "; - return false; - } - - return true; - } - - virtual bool OnBoot() { - int u, eu, g, eg, sg; - - if ((geteuid() == 0) || (getuid() == 0) || (getegid() == 0) || (getgid() - == 0)) { - - CUtils::PrintAction("Dropping root permissions"); - - // Clear all the supplementary groups - sg = setgroups(0, NULL); - - if (sg < 0) { - CUtils::PrintStatus(false, - "Could not remove supplementary groups! [" - + CString(strerror(errno)) + "]"); - - return false; - } - - // Set the group (if we are root, this sets all three group IDs) - g = setgid(m_group); - eg = setegid(m_group); - - if ((g < 0) || (eg < 0)) { - CUtils::PrintStatus(false, "Could not switch group id! [" - + CString(strerror(errno)) + "]"); - - return false; - } - - // and set the user (if we are root, this sets all three user IDs) - u = setuid(m_user); - eu = seteuid(m_user); - - if ((u < 0) || (eu < 0)) { - CUtils::PrintStatus(false, "Could not switch user id! [" - + CString(strerror(errno)) + "]"); - - return false; - } - - CUtils::PrintStatus(true); - - return true; - } - - return true; - } - -protected: - uid_t m_user; - gid_t m_group; -}; - -GLOBALMODULEDEFS(CDroproot, "Allows ZNC to drop root privileges and run as an un-privileged user.") diff --git a/modules/extra/email.cpp b/modules/extra/email.cpp deleted file mode 100644 index 7cc8a034..00000000 --- a/modules/extra/email.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (C) 2004-2012 See the AUTHORS file for details. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - * - * Email Monitor / Retrieval - * Author: imaginos - */ - -#include -#include -#include -#include -#include - -using std::stringstream; - -struct EmailST -{ - CString sFrom; - CString sSubject; - CString sUidl; - u_int iSize; -}; - -class CEmailJob : public CTimer -{ -public: - CEmailJob(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) - : CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {} - - virtual ~CEmailJob() {} - -protected: - virtual void RunJob(); -}; - -class CEmail : public CModule -{ -public: - MODCONSTRUCTOR(CEmail) - { - m_iLastCheck = 0; - m_bInitialized = false; - } - - virtual ~CEmail() {} - - virtual bool OnLoad(const CString & sArgs, CString& sMessage) { -#ifndef MOD_EMAIL_ALLOW_EVERYONE - if (!m_pUser->IsAdmin()) { - sMessage = "You must be admin to use the email module"; - return false; - } -#endif - m_sMailPath = sArgs; - - StartParser(); - if (m_pUser->IsUserAttached()) - StartTimer(); - - return true; - } - - virtual void OnClientLogin() - { - stringstream s; - s << "You have " << m_ssUidls.size() << " emails."; - PutModule(s.str()); - StartTimer(); - } - virtual void OnClientDisconnect() - { - RemTimer("EMAIL::" + m_pUser->GetUserName()); - } - - void StartTimer() - { - if (!FindTimer("EMAIL::" + m_pUser->GetUserName())) - { - CEmailJob *p = new CEmailJob(this, 60, 0, "EmailMonitor", "Monitors email activity"); - AddTimer(p); - } - } - - virtual void OnModCommand(const CString& sCommand); - void StartParser(); - - void ParseEmails(const vector & vEmails) - { - if (!m_bInitialized) - { - m_bInitialized = true; - for (u_int a = 0; a < vEmails.size(); a++) - m_ssUidls.insert(vEmails[a].sUidl); - - stringstream s; - s << "You have " << vEmails.size() << " emails."; - PutModule(s.str()); - } else - { - set ssUidls; - - CTable Table; - Table.AddColumn("From"); - Table.AddColumn("Size"); - Table.AddColumn("Subject"); - - for (u_int a = 0; a < vEmails.size(); a++) - { - if (m_ssUidls.find(vEmails[a].sUidl) == m_ssUidls.end()) - { - //PutModule("------------------- New Email -------------------"); - Table.AddRow(); - Table.SetCell("From", vEmails[a].sFrom.Ellipsize(32)); - Table.SetCell("Size", CString(vEmails[a].iSize)); - Table.SetCell("Subject", vEmails[a].sSubject.Ellipsize(64)); - } - ssUidls.insert(vEmails[a].sUidl); - } - - m_ssUidls = ssUidls; // keep the list in synch - - if (Table.size()) { - PutModule(Table); - - stringstream s; - s << "You have " << vEmails.size() << " emails."; - PutModule(s.str()); - } - } - } - -private: - CString m_sMailPath; - time_t m_iLastCheck; - set m_ssUidls; - bool m_bInitialized; -}; - -class CEmailFolder : public CSocket -{ -public: - CEmailFolder(CEmail *pModule, const CString & sMailbox) : CSocket(pModule) - { - m_pModule = pModule; - m_sMailbox = sMailbox; - EnableReadLine(); - } - - virtual ~CEmailFolder() - { - if (!m_sMailBuffer.empty()) - ProcessMail(); // get the last one - - if (!m_vEmails.empty()) - m_pModule->ParseEmails(m_vEmails); - } - - virtual void ReadLine(const CS_STRING & sLine) - { - if (sLine.Left(5) == "From ") - { - if (!m_sMailBuffer.empty()) - { - ProcessMail(); - m_sMailBuffer.clear(); - } - } - m_sMailBuffer += sLine; - } - - void ProcessMail() - { - EmailST tmp; - tmp.sUidl = (char *)CMD5(m_sMailBuffer.Left(255)); - VCString vsLines; - VCString::iterator it; - - m_sMailBuffer.Split("\n", vsLines); - - for (it = vsLines.begin(); it != vsLines.end(); it++) { - CString sLine(*it); - sLine.Trim(); - if (sLine.empty()) - break; // out of the headers - - if (sLine.Equals("From: ", false, 6)) - tmp.sFrom = sLine.substr(6, CString::npos); - else if (sLine.Equals("Subject: ", false, 9)) - tmp.sSubject = sLine.substr(9, CString::npos); - - if ((!tmp.sFrom.empty()) && (!tmp.sSubject.empty())) - break; - } - tmp.iSize = m_sMailBuffer.length(); - m_vEmails.push_back(tmp); - } -private: - CEmail *m_pModule; - CString m_sMailbox; - CString m_sMailBuffer; - vector m_vEmails; -}; - -void CEmail::OnModCommand(const CString& sCommand) -{ - CString sCom = sCommand.Token(0); - - if (sCom == "timers") - { - ListTimers(); - } else - PutModule("Error, no such command [" + sCom + "]"); -} - -void CEmail::StartParser() -{ - CString sParserName = "EMAIL::" + m_pUser->GetUserName(); - - if (m_pManager->FindSockByName(sParserName)) - return; // one at a time sucker - - CFile cFile(m_sMailPath); - if ((!cFile.Exists()) || (cFile.GetSize() == 0)) - { - m_bInitialized = true; - return; // der - } - - if (cFile.GetMTime() <= m_iLastCheck) - return; // only check if modified - - int iFD = open(m_sMailPath.c_str(), O_RDONLY); - if (iFD >= 0) - { - m_iLastCheck = time(NULL); - CEmailFolder *p = new CEmailFolder(this, m_sMailPath); - p->SetRSock(iFD); - p->SetWSock(iFD); - m_pManager->AddSock(p, "EMAIL::" + m_pUser->GetUserName()); - } -} - -void CEmailJob::RunJob() -{ - CEmail *p = (CEmail *)m_pModule; - p->StartParser(); -} -USERMODULEDEFS(CEmail, "Monitors Email activity on local disk /var/mail/user") - diff --git a/modules/extra/fakeonline.cpp b/modules/fakeonline.cpp similarity index 100% rename from modules/extra/fakeonline.cpp rename to modules/fakeonline.cpp diff --git a/modules/extra/flooddetach.cpp b/modules/flooddetach.cpp similarity index 100% rename from modules/extra/flooddetach.cpp rename to modules/flooddetach.cpp diff --git a/modules/extra/imapauth.cpp b/modules/imapauth.cpp similarity index 100% rename from modules/extra/imapauth.cpp rename to modules/imapauth.cpp diff --git a/modules/extra/listsockets.cpp b/modules/listsockets.cpp similarity index 100% rename from modules/extra/listsockets.cpp rename to modules/listsockets.cpp diff --git a/modules/extra/motdfile.cpp b/modules/motdfile.cpp similarity index 100% rename from modules/extra/motdfile.cpp rename to modules/motdfile.cpp diff --git a/modules/extra/notify_connect.cpp b/modules/notify_connect.cpp similarity index 100% rename from modules/extra/notify_connect.cpp rename to modules/notify_connect.cpp diff --git a/modules/extra/saslauth.cpp b/modules/saslauth.cpp similarity index 100% rename from modules/extra/saslauth.cpp rename to modules/saslauth.cpp diff --git a/modules/extra/send_raw.cpp b/modules/send_raw.cpp similarity index 100% rename from modules/extra/send_raw.cpp rename to modules/send_raw.cpp diff --git a/modules/extra/shell.cpp b/modules/shell.cpp similarity index 100% rename from modules/extra/shell.cpp rename to modules/shell.cpp diff --git a/src/Modules.cpp b/src/Modules.cpp index dd100338..acae8385 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -1092,10 +1092,6 @@ CModules::ModDirList CModules::GetModDirs() { // ./modules sDir = CZNC::Get().GetCurPath() + "/modules/"; ret.push(std::make_pair(sDir, sDir + "data/")); - - // ./modules/extra - sDir = CZNC::Get().GetCurPath() + "/modules/extra/"; - ret.push(std::make_pair(sDir, sDir + "data/")); #endif // ~/.znc/modules