diff options
author | hasufell <hasufell@hasufell.de> | 2015-06-30 16:56:02 +0200 |
---|---|---|
committer | hasufell <hasufell@hasufell.de> | 2015-06-30 16:56:02 +0200 |
commit | 88b85faf930d9fc24ecc683644e9b686b4e9674a (patch) | |
tree | 2b12d6ec4e1c941579e1d10664f15c0d580d1848 /net-irc/znc/files | |
parent | Merge branch 'master' of git://github.com/lluixhi/libressl (diff) | |
download | libressl-88b85faf930d9fc24ecc683644e9b686b4e9674a.tar.gz libressl-88b85faf930d9fc24ecc683644e9b686b4e9674a.tar.bz2 libressl-88b85faf930d9fc24ecc683644e9b686b4e9674a.zip |
net-irc/znc: initial import to fix libressl compatibility
Diffstat (limited to 'net-irc/znc/files')
-rw-r--r-- | net-irc/znc/files/znc-1.0-systemwideconfig.patch | 147 | ||||
-rw-r--r-- | net-irc/znc/files/znc-1.4-libressl.patch | 19 | ||||
-rw-r--r-- | net-irc/znc/files/znc.confd | 7 | ||||
-rw-r--r-- | net-irc/znc/files/znc.initd | 39 |
4 files changed, 212 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 0000000..336163d --- /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.4-libressl.patch b/net-irc/znc/files/znc-1.4-libressl.patch new file mode 100644 index 0000000..8bbe9cf --- /dev/null +++ b/net-irc/znc/files/znc-1.4-libressl.patch @@ -0,0 +1,19 @@ +$OpenBSD: patch-src_Csocket_cpp,v 1.1 2014/07/12 14:42:37 pascal Exp $ +--- src/Csocket.cpp.orig Sat Jul 12 16:03:48 2014 ++++ src/Csocket.cpp Sat Jul 12 16:04:36 2014 +@@ -555,6 +555,7 @@ bool InitSSL( ECompType eCompressionType ) + } + #endif /* _WIN32 */ + ++#ifndef OPENSSL_NO_COMP + COMP_METHOD *cm = NULL; + + if( CT_ZLIB & eCompressionType ) +@@ -570,6 +571,7 @@ bool InitSSL( ECompType eCompressionType ) + if( cm ) + SSL_COMP_add_compression_method( CT_RLE, cm ); + } ++#endif + + // setting this up once in the begining + g_iCsockSSLIdx = SSL_get_ex_new_index( 0, ( void * )"CsockGlobalIndex", NULL, NULL, NULL ); diff --git a/net-irc/znc/files/znc.confd b/net-irc/znc/files/znc.confd new file mode 100644 index 0000000..9681f8d --- /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 0000000..8b7c8bc --- /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 +# $Header: /var/cvsroot/gentoo-x86/net-irc/znc/files/znc.initd,v 1.1 2012/11/21 18:11:31 wired Exp $ + +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 $? +} |