summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /net-irc/znc/files
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'net-irc/znc/files')
-rw-r--r--net-irc/znc/files/znc-1.0-systemwideconfig.patch147
-rw-r--r--net-irc/znc/files/znc-1.2-webadmin-correctly-handle-channel-names.patch73
-rw-r--r--net-irc/znc/files/znc.confd7
-rw-r--r--net-irc/znc/files/znc.initd39
4 files changed, 266 insertions, 0 deletions
diff --git a/net-irc/znc/files/znc-1.0-systemwideconfig.patch b/net-irc/znc/files/znc-1.0-systemwideconfig.patch
new file mode 100644
index 000000000000..336163dd6a0c
--- /dev/null
+++ b/net-irc/znc/files/znc-1.0-systemwideconfig.patch
@@ -0,0 +1,147 @@
+diff --git a/include/znc/znc.h b/include/znc/znc.h
+index 03be646..f493c83 100644
+--- a/include/znc/znc.h
++++ b/include/znc/znc.h
+@@ -169,6 +169,8 @@ public:
+
+ static void DumpConfig(const CConfig* Config);
+
++ void SetSystemWideConfig(bool systemWideConfig);
++
+ private:
+ CFile* InitPidFile();
+ bool DoRehash(CString& sError);
+@@ -209,6 +211,7 @@ protected:
+ unsigned int m_uiConnectPaused;
+ TCacheMap<CString> m_sConnectThrottle;
+ bool m_bProtectWebSessions;
++ bool m_bSystemWideConfig;
+ };
+
+ #endif // !_ZNC_H
+diff --git a/src/main.cpp b/src/main.cpp
+index a1f3904..4950911 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -10,6 +10,9 @@
+ #include <znc/FileUtils.h>
+ #include <sys/wait.h>
+ #include <signal.h>
++#include <sys/types.h>
++#include <pwd.h>
++#include <grp.h>
+
+ using std::cout;
+ using std::endl;
+@@ -46,6 +49,7 @@ static const struct option g_LongOpts[] = {
+ { "makepass", no_argument, 0, 's' },
+ { "makepem", no_argument, 0, 'p' },
+ { "datadir", required_argument, 0, 'd' },
++ { "system-wide-config-as", required_argument, 0, 'S' },
+ { 0, 0, 0, 0 }
+ };
+
+@@ -127,6 +131,8 @@ int main(int argc, char** argv) {
+ bool bMakeConf = false;
+ bool bMakePass = false;
+ bool bAllowRoot = false;
++ bool bSystemWideConfig = false;
++ CString sSystemWideConfigUser = "znc";
+ bool bForeground = false;
+ #ifdef ALWAYS_RUN_IN_FOREGROUND
+ bForeground = true;
+@@ -135,7 +141,7 @@ int main(int argc, char** argv) {
+ bool bMakePem = false;
+ #endif
+
+- while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) {
++ while ((iArg = getopt_long(argc, argv, "hvnrcspd:DfS:", g_LongOpts, &iOptIndex)) != -1) {
+ switch (iArg) {
+ case 'h':
+ GenerateHelp(argv[0]);
+@@ -153,6 +159,10 @@ int main(int argc, char** argv) {
+ case 'c':
+ bMakeConf = true;
+ break;
++ case 'S':
++ bSystemWideConfig = true;
++ sSystemWideConfigUser = optarg;
++ break;
+ case 's':
+ bMakePass = true;
+ break;
+@@ -187,8 +197,36 @@ int main(int argc, char** argv) {
+ return 1;
+ }
+
++ if (bSystemWideConfig && getuid() == 0) {
++ struct passwd *pwd;
++
++ pwd = getpwnam(sSystemWideConfigUser.c_str());
++ if (pwd == NULL) {
++ CUtils::PrintError("Daemon user not found.");
++ return 1;
++ }
++
++ if ((long) pwd->pw_uid == 0) {
++ CUtils::PrintError("Please define a daemon user other than root.");
++ return 1;
++ }
++ if (setgroups(0, NULL) != 0) {
++ CUtils::PrintError("setgroups: Unable to clear supplementary group IDs");
++ return 1;
++ }
++ if (setgid((long) pwd->pw_gid) != 0) {
++ CUtils::PrintError("setgid: Unable to drop group privileges");
++ return 1;
++ }
++ if (setuid((long) pwd->pw_uid) != 0) {
++ CUtils::PrintError("setuid: Unable to drop user privileges");
++ return 1;
++ }
++ }
++
+ CZNC* pZNC = &CZNC::Get();
+ pZNC->InitDirs(((argc) ? argv[0] : ""), sDataDir);
++ pZNC->SetSystemWideConfig(bSystemWideConfig);
+
+ #ifdef HAVE_LIBSSL
+ if (bMakePem) {
+@@ -229,7 +267,7 @@ int main(int argc, char** argv) {
+ CUtils::PrintStatus(true, "");
+ }
+
+- if (isRoot()) {
++ if (isRoot() && !bSystemWideConfig) {
+ CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid");
+ CUtils::PrintError("reasons for this and it can, in theory, cause great damage!");
+ if (!bAllowRoot) {
+diff --git a/src/znc.cpp b/src/znc.cpp
+index 9469790..297b021 100644
+--- a/src/znc.cpp
++++ b/src/znc.cpp
+@@ -47,6 +47,7 @@ CZNC::CZNC() {
+ m_sConnectThrottle.SetTTL(30000);
+ m_pLockFile = NULL;
+ m_bProtectWebSessions = true;
++ m_bSystemWideConfig = false;
+ }
+
+ CZNC::~CZNC() {
+@@ -952,7 +953,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
+ CUtils::PrintMessage("");
+
+ File.UnLock();
+- return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true);
++ return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true);
+ }
+
+ size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) {
+@@ -1971,3 +1972,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) {
+ bool CZNC::WaitForChildLock() {
+ return m_pLockFile && m_pLockFile->ExLock();
+ }
++
++void CZNC::SetSystemWideConfig(bool systemWideConfig) {
++ m_bSystemWideConfig = systemWideConfig;
++}
diff --git a/net-irc/znc/files/znc-1.2-webadmin-correctly-handle-channel-names.patch b/net-irc/znc/files/znc-1.2-webadmin-correctly-handle-channel-names.patch
new file mode 100644
index 000000000000..93705f77ecb3
--- /dev/null
+++ b/net-irc/znc/files/znc-1.2-webadmin-correctly-handle-channel-names.patch
@@ -0,0 +1,73 @@
+https://bugs.gentoo.org/show_bug.cgi?id=507794
+
+From 5e6e3be32acfeadeaf1fb3bb17bada08aec6432f Mon Sep 17 00:00:00 2001
+From: Uli Schlachter <psychon@znc.in>
+Date: Sun, 13 Apr 2014 20:36:55 +0200
+Subject: [PATCH] webadmin/add channel: Correctly handle channel names
+
+The CChan constructor makes sure that the channel name begins with a valid
+channel prefix. Thus, this could change the name of the resulting channel.
+
+When you edited an irc network which already had a channel "#foo", were
+connected to IRC (so ZNC knows which prefixes are valid) and added a channel
+"foo", this would lead to a problem:
+
+Webadmin checks and sees that there is no channel "foo" yet. Webadmin creates a
+new CChan instance for "foo". The CChan constructor notices that "f" is not a
+valid channel prefix and instead calls itself "#foo". Then,
+CIRCNetwork::AddChan() would see that this channel already exists, delete the
+given channel and return false.
+
+However, webadmin didn't check this result and would continue changing settings
+on an already destroyed CChan instance.
+
+Fix this by checking if the channel exists after CChan had its chance to mess
+with the channel name. Also handle failures from CIRCNetwork::AddChan().
+
+Fixes #528.
+
+Signed-off-by: Uli Schlachter <psychon@znc.in>
+---
+ modules/webadmin.cpp | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp
+index 40a28d3..90ddfd2 100644
+--- a/modules/webadmin.cpp
++++ b/modules/webadmin.cpp
+@@ -668,13 +668,19 @@ class CWebAdminMod : public CModule {
+ return true;
+ }
+
+- if (pNetwork->FindChan(sChanName.Token(0))) {
+- WebSock.PrintErrorPage("Channel [" + sChanName.Token(0) + "] already exists");
++ // This could change the channel name and e.g. add a "#" prefix
++ pChan = new CChan(sChanName, pNetwork, true);
++
++ if (pNetwork->FindChan(pChan->GetName())) {
++ WebSock.PrintErrorPage("Channel [" + pChan->GetName() + "] already exists");
++ delete pChan;
+ return true;
+ }
+
+- pChan = new CChan(sChanName, pNetwork, true);
+- pNetwork->AddChan(pChan);
++ if (!pNetwork->AddChan(pChan)) {
++ WebSock.PrintErrorPage("Could not add channel [" + pChan->GetName() + "]");
++ return true;
++ }
+ }
+
+ pChan->SetBufferCount(WebSock.GetParam("buffercount").ToUInt(), spSession->IsAdmin());
+@@ -700,7 +706,7 @@ class CWebAdminMod : public CModule {
+
+ CTemplate TmplMod;
+ TmplMod["User"] = pUser->GetUserName();
+- TmplMod["ChanName"] = sChanName;
++ TmplMod["ChanName"] = pChan->GetName();
+ TmplMod["WebadminAction"] = "change";
+ FOR_EACH_MODULE(it, pNetwork) {
+ (*it)->OnEmbeddedWebRequest(WebSock, "webadmin/channel", TmplMod);
+--
+1.9.1
+
diff --git a/net-irc/znc/files/znc.confd b/net-irc/znc/files/znc.confd
new file mode 100644
index 000000000000..9681f8d792fb
--- /dev/null
+++ b/net-irc/znc/files/znc.confd
@@ -0,0 +1,7 @@
+# /etc/conf.d/znc
+
+# Location of the znc configuration folder
+ZNC_CONF="/var/lib/znc"
+
+# User to run znc as
+ZNC_USER="znc"
diff --git a/net-irc/znc/files/znc.initd b/net-irc/znc/files/znc.initd
new file mode 100644
index 000000000000..f0825a1e9024
--- /dev/null
+++ b/net-irc/znc/files/znc.initd
@@ -0,0 +1,39 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+extra_commands="config"
+extra_started_commands="reload save"
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting ZNC"
+ start-stop-daemon --start --user ${ZNC_USER} --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ZNC"
+ start-stop-daemon --signal SIGINT --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ZNC Configuration File from Disk"
+ start-stop-daemon --signal SIGHUP --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
+
+save() {
+ ebegin "Saving ZNC Configuration File to Disk"
+ start-stop-daemon --signal SIGUSR1 --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}