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
define Package/znc
$(Package/znc/default)
- DEPENDS:=+libopenssl $(CXX_DEPENDS)
+ DEPENDS:=+libopenssl +libpthread $(CXX_DEPENDS)
MENU:=1
endef
$(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))
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
, := ,
-$(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.))
$(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.))
$(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.))
$(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))
CONFIGURE_ARGS += \
--disable-c-ares \
- --enable-extra \
--disable-perl
define Build/Configure
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() {
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
local quitmsg
local chanmodes
local vhost
+ local server
config_get password "$user" password
config_get nick "$user" nick
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
-
- config_list_foreach "$user" server "add_param \" Server\""
+ 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" 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
}
--- /dev/null
+--- /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.")