packages: znc: update to 1.0

Update ZNC to newest version 1.0

 * Update config format to reflect new config format and allow
   multiple networks per user.
 * Update init script to create a 1.0 compatible config.
 * Add new modules introduced in 1.0, remove dropped ones.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>

git-svn-id: svn://svn.openwrt.org/openwrt/packages@34659 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jogo 2012-12-13 14:07:57 +00:00
parent d37b83b518
commit 9e9d3900d4
6 changed files with 267 additions and 96 deletions

View File

@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=znc
PKG_VERSION:=0.206
PKG_RELEASE:=2
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://znc.in/releases \
http://znc.in/releases/archive
PKG_MD5SUM:=b7d3f21da81abaeb553066b0e10beb53
PKG_MD5SUM:=23807ca830c27392cccb6774f542df6e
PKG_BUILD_PARALLEL:=1
@ -30,7 +30,7 @@ endef
define Package/znc
$(Package/znc/default)
DEPENDS:=+libopenssl $(CXX_DEPENDS)
DEPENDS:=+libopenssl +libpthread $(CXX_DEPENDS)
MENU:=1
endef
@ -53,12 +53,12 @@ define Package/znc/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/znc.conf $(1)/etc/config/znc
$(INSTALL_DIR) $(1)/usr/lib/znc/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/extra/droproot.so $(1)/usr/lib/znc/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/droproot.so $(1)/usr/lib/znc/
endef
ZNC_MODULES :=
ZNC_MODULE_TARGETS := extra/droproot.so
ZNC_MODULE_TARGETS := droproot.so
define module
define Package/znc-mod-$(strip $(1))
@ -73,16 +73,16 @@ define module
define Package/znc-mod-$(strip $(1))/install
$(INSTALL_DIR) $$(1)/usr/lib/znc/
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/modules/$(strip $(3))$(subst -,_,$(strip $(1))).so $$(1)/usr/lib/znc/
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/modules/$(subst -,_,$(strip $(1))).so $$(1)/usr/lib/znc/
# include webadmin page templates if existing
if [ -d $$(PKG_BUILD_DIR)/modules/$(strip $(3))data/$(subst -,_,$(strip $(1))) ]; then \
if [ -d $$(PKG_BUILD_DIR)/modules/data/$(subst -,_,$(strip $(1))) ]; then \
$(INSTALL_DIR) $$(1)/usr/share/znc/modules ;\
$(CP) -r $$(PKG_BUILD_DIR)/modules/$(strip $(3))data/$(subst -,_,$(strip $(1))) $$(1)/usr/share/znc/modules ;\
$(CP) -r $$(PKG_BUILD_DIR)/modules/data/$(subst -,_,$(strip $(1))) $$(1)/usr/share/znc/modules ;\
fi
endef
ZNC_MODULES += znc-mod-$(strip $(1))
$(if $(CONFIG_PACKAGE_znc-mod-$(strip $(1))),ZNC_MODULE_TARGETS += $(strip $(3))$(subst -,_,$(strip $(1))).so)
$(if $(CONFIG_PACKAGE_znc-mod-$(strip $(1))),ZNC_MODULE_TARGETS += $(subst -,_,$(strip $(1))).so)
endef
define webadmin
@ -129,21 +129,28 @@ endef
, := ,
$(eval $(call module,admin,Allows you to add/remove/edit users and settings on \
the fly via IRC messages.))
$(eval $(call module,adminlog,Log user connects and disconnects and failed \
logins to file or syslog.))
$(eval $(call module,autoattach,Reattaches you to channels on activity.))
$(eval $(call module,autocycle,Cycles a channel when you are the only one in \
there and you don't have op.))
$(eval $(call module,autoop,Auto op the good guys.))
$(eval $(call module,autoreply,Gives a automatic reply if someone messages you \
if you are away.))
$(eval $(call module,autovoice,Autovoices everyone who joins some channel.))
$(eval $(call module,awaynick,Change your nick while you are away.))
$(eval $(call module,awaystore,Stores messages while away$(,) also auto away.))
$(eval $(call module,block-motd,This module blocks the server's Message of the \
Day.))
$(eval $(call module,blockuser,Blocks certain users from using ZNC saying \
their account was disabled.))
@ -161,16 +168,29 @@ $(eval $(call module,certauth,This module allows users to log in to ZNC via \
$(eval $(call module,chansaver,Keeping config up to date when user joins and \
parts.))
$(eval $(call module,clearbufferonmsg,This module keeps the buffer until the \
next message from the client.))
$(eval $(call module,clientnotify,Notify about new incoming connections to \
your user.))
$(eval $(call module,controlpanel,Allows you to add/remove/edit users and \
settings on the fly via IRC messages.))
$(eval $(call module,crypt,Encryption for channel/private messages.))
$(eval $(call module,ctcpflood,This module tries to block ctcp floods.))
$(eval $(call module,dcc,Allows you to transfer files to and from ZNC.))
$(eval $(call module,disconkick,This module will kick your client from all \
channels where you are$(,) in case if ZNC disconnects from server.))
$(eval $(call module,fail2ban,Block IPs for some time after a failed login.))
$(eval $(call module,flooddetach,This module detaches you from channels which \
are flooded.))
$(eval $(call module,identfile,Places the ident of a user to a file when they \
are trying to connect.))
@ -180,11 +200,19 @@ $(eval $(call module,kickrejoin,Implements auto-rejoin-on-kick.))
$(eval $(call module,lastseen,Logs when a user last logged in to ZNC.))
$(eval $(call module,listsockets,This module displays a list of all open \
sockets in ZNC.))
$(eval $(call module,log,Log conversations to file.))
$(eval $(call module,nickserv,Auths you with NickServ.))
$(eval $(call module,notes,This modules stores and displays short notes using \
a key/note pairs and shows them to you on connect.))
$(eval $(call module,notify-connect,Sends a notice to all admins when a user \
logs in or out.))
$(eval $(call module,partyline,Allows ZNC users to join internal channels and \
query other ZNC users on the same ZNC.))
@ -197,64 +225,28 @@ $(eval $(call module,raw,View all of the raw traffic.))
$(eval $(call module,route-replies,Routes back answers to the right client \
when connected with multiple clients.))
$(eval $(call module,sasl,The SASL module allows you to authenticate to an \
IRC network via SASL.))
$(eval $(call module,savebuff,Saves your channel buffers into an encrypted \
file so they can survive restarts and reboots.))
$(eval $(call module,schat,SSL (encrypted) DCC chats.))
$(eval $(call module,send-raw,Allows you to send raw traffic to IRC from \
other users.))
$(eval $(call module,simple-away,This module will automatically set you away \
on IRC while you are disconnected from the bouncer.))
$(eval $(call module,shell,Have your unix shell in a query window right inside \
of your IRC client.))
$(eval $(call module,stickychan,Keeps you sticked to specific channels.))
$(eval $(call module,watch,Monitor activity for specific text patterns from \
specific users and have the text sent to a special query window.))
$(eval $(call module,antiidle,Hides your idle time.,extra/))
$(eval $(call module,autocycle,Cycles a channel when you are the only one in \
there and you don't have op.,extra/))
$(eval $(call module,autovoice,Autovoices everyone who joins some channel., \
extra/))
$(eval $(call module,away,Stores messages while away$(,) also auto away.,extra/))
$(eval $(call module,block-motd,This module blocks the server's Message of the \
Day.,extra/))
$(eval $(call module,clearbufferonmsg,This module keeps the buffer until the \
next message from the client.,extra/))
$(eval $(call module,ctcpflood,This module tries to block ctcp floods.,extra/))
$(eval $(call module,dcc,Allows you to transfer files to and from ZNC.,extra/))
$(eval $(call module,email,Watches a local mailbox for new mails.,extra/))
$(eval $(call module,fakeonline,This module fakes the online status of \
ZNC-*users.,extra/))
$(eval $(call module,flooddetach,This module detaches you from channels which \
are flooded.,extra/))
$(eval $(call module,listsockets,This module displays a list of all open \
sockets in ZNC.,extra/))
$(eval $(call module,log,Log conversations to file.,extra/))
$(eval $(call module,motdfile,Reads a MOTD from a file and displays it to \
users when they login.,extra/))
$(eval $(call module,notify-connect,Sends a notice to all admins when a user \
logs in or out.,extra/))
$(eval $(call module,send-raw,Allows you to send raw traffic to IRC from \
other users.,extra/))
$(eval $(call module,shell,Have your unix shell in a query window right inside \
of your IRC client.,extra/))
$(eval $(call webadmin))
$(eval $(call webskin,dark-clouds))
@ -274,7 +266,6 @@ CONFIGURE_VARS += \
CONFIGURE_ARGS += \
--disable-c-ares \
--enable-extra \
--disable-perl
define Build/Configure

View File

@ -20,9 +20,25 @@ add_param() {
add_chan() {
chan=${1% *}
pass=${1#* }
echo " <Chan $chan>" >> $ZNC_CONFIG
[ "$chan" != "$pass" ] && echo " Key = $pass" >> $ZNC_CONFIG
echo " </Chan>" >> $ZNC_CONFIG
echo " <Chan $chan>" >> $ZNC_CONFIG
[ "$chan" != "$pass" ] && echo " Key = $pass" >> $ZNC_CONFIG
echo " </Chan>" >> $ZNC_CONFIG
}
add_network() {
local current_user="$1"
local network="$2"
local user
local name
config_get user "$network" user
[ "$user" = "$current_user" ] || return 0
config_get name "$network" name
echo " <Network $name>" >> $ZNC_CONFIG
config_list_foreach "$network" server "add_param \" Server\""
config_list_foreach "$network" channel "add_chan"
}
znc_global() {
@ -51,6 +67,8 @@ znc_global() {
mkdir -p $ZNC_CONFIG_PATH/configs/
[ ! -f "$ZNC_CONFIG" ] || rm "$ZNC_CONFIG"
add_param "Version" "1.0"
config_get anoniplimit "$znc" anoniplimit
config_get maxbuffersize "$znc" maxbuffersize
config_get connectdelay "$znc" connectdelay
@ -84,6 +102,7 @@ add_user() {
local quitmsg
local chanmodes
local vhost
local server
config_get password "$user" password
config_get nick "$user" nick
@ -94,31 +113,41 @@ add_user() {
config_get quitmsg "$user" quitmsg
config_get chanmodes "$user" chanmodes
config_get vhost "$user" vhost
config_get server "$user" server
echo "<User $user>" >> $ZNC_CONFIG
case "$password" in
"md5#"* | "sha256#"* | "plain#"*)
echo " Pass = $password" >> $ZNC_CONFIG
add_param " Pass" "$password"
;;
*)
echo " Pass = plain#$password" >> $ZNC_CONFIG
add_param " Pass" "plain#$password"
;;
esac
echo " Nick = $nick" >> $ZNC_CONFIG
echo " AltNick = ${altnick:-$nick"_"}" >> $ZNC_CONFIG
echo " Ident = ${ident:-$nick}" >> $ZNC_CONFIG
echo " RealName = ${realname:-$nick}" >> $ZNC_CONFIG
[ -z "$vhost" ] || echo " VHost = $vhost" >> $ZNC_CONFIG
echo " Buffer = ${buffer:-50}" >> $ZNC_CONFIG
echo " KeepBuffer = false" >> $ZNC_CONFIG
echo " ChanModes = ${chanmodes:-"+stn"}" >> $ZNC_CONFIG
[ -z "$quitmsg" ] || echo " QuitMsg = $quitmsg" >> $ZNC_CONFIG
add_param " Nick" "$nick"
add_param " AltNick" "${altnick:-$nick"_"}"
add_param " Ident" "${ident:-$nick}"
add_param " RealName" "${realname:-$nick}"
[ -z "$vhost" ] || add_param " VHost" "$vhost"
add_param " Buffer" "${buffer:-50}"
add_param " KeepBuffer" "false"
add_param " ChanModes" "${chanmodes:-"+stn"}"
[ -z "$quitmsg" ] || add_param " QuitMsg" "$quitmsg"
config_list_foreach "$user" server "add_param \" Server\""
config_list_foreach "$user" module "add_param \" LoadModule\""
config_list_foreach "$user" channel "add_chan"
# add legacy network
if [ "$server" ]; then
echo " <Network Default>" >> $ZNC_CONFIG
config_list_foreach "$user" server "add_param \" Server\""
config_list_foreach "$user" channel "add_chan"
echo " </Network>" >> $ZNC_CONFIG
fi
config_foreach "add_network \"$user\"" network
echo "</User>" >> $ZNC_CONFIG
}

View File

@ -4,11 +4,11 @@ Date: Wed, 6 Apr 2011 04:10:23 +0200
Subject: [PATCH] Move the root check to after config parsing
---
main.cpp | 27 ++++++++++++++-------------
src/main.cpp | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
--- a/main.cpp
+++ b/main.cpp
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -211,19 +211,6 @@ int main(int argc, char** argv) {
}
#endif

View File

@ -9,20 +9,18 @@ Subject: [PATCH] Add a uClibc++ build workaround
--- a/modules/webadmin.cpp
+++ b/modules/webadmin.cpp
@@ -15,11 +15,13 @@
#include "WebModules.h"
#include "ZNCString.h"
#include "Listener.h"
@@ -15,9 +15,11 @@
#include <znc/Listener.h>
#include <znc/IRCNetwork.h>
#include <znc/IRCSock.h>
+#include <string>
#include <sstream>
#include <utility>
+using std::string;
using std::stringstream;
using std::make_pair;
+using std::string;
/* Stuff to be able to write this:
// i will be name of local variable, see below
using std::set;
@@ -55,7 +57,7 @@ class CWebAdminMod : public CGlobalModul
public:
GLOBALMODCONSTRUCTOR(CWebAdminMod) {

View File

@ -14,19 +14,25 @@ Subject: [PATCH] Don't rebuild everything when the Makefile's timestamp changed
distclean: clean
rm -rf $(DISTCLEAN)
-%.o: %.cpp Makefile
+%.o: %.cpp
@mkdir -p .depend
$(E) Building $@...
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -MMD -MF .depend/$@.dep
-src/%.o: src/%.cpp Makefile
+src/%.o: src/%.cpp
@mkdir -p .depend src
$(E) Building core object $*...
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -MD -MF .depend/$*.dep -MT $@
--- a/modules/Makefile.in
+++ b/modules/Makefile.in
@@ -114,7 +114,7 @@ install_datadir:
@@ -114,12 +114,12 @@ install_datadir:
clean:
rm -rf $(CLEAN)
-%.so: %.cpp Makefile
+%.so: %.cpp
-%.o: %.cpp Makefile
+%.o: %.cpp
@mkdir -p .depend
@mkdir -p extra
$(E) Building $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))...
$(E) Building module $(notdir $(basename $@))...
$(Q)$(CXX) $(MODFLAGS) -c -o $@ $< $($(notdir $(basename $@))CXXFLAGS) -MD -MF .depend/$(notdir $@).dep
-%.so: %.o Makefile
+%.so: %.o
$(E) Linking module $(notdir $(basename $@))...
$(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))LDFLAGS) $(LIBS)

View File

@ -0,0 +1,147 @@
--- /dev/null
+++ b/modules/droproot.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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 <znc/znc.h>
+#include <znc/User.h>
+#include <pwd.h>
+#include <grp.h>
+
+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 <uid> <gid>";
+ return false;
+ }
+
+ m_user = GetUser(sUser, sMessage);
+
+ if (m_user == 0) {
+ sMessage
+ = "Error: Cannot run as root, check your config file | Useage: LoadModule = Droproot <uid> <gid>";
+ return false;
+ }
+
+ m_group = GetGroup(sGroup, sMessage);
+
+ if (m_group == 0) {
+ sMessage
+ = "Error: Cannot run as root, check your config file | Useage: LoadModule = Droproot <uid> <gid>";
+ 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.")