Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 395456 Details for
Bug 528774
net-irc/znc-9999: Failed Patch: znc-1.0-systemwideconfig.patch !
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
znc-1.2-555-gce3882e-system-wide-config.patch
znc-1.2-555-gce3882e-system-wide-config.patch (text/plain), 4.19 KB, created by
d00p
on 2015-02-03 15:53:36 UTC
(
hide
)
Description:
znc-1.2-555-gce3882e-system-wide-config.patch
Filename:
MIME Type:
Creator:
d00p
Created:
2015-02-03 15:53:36 UTC
Size:
4.19 KB
patch
obsolete
>diff --git a/include/znc/znc.h b/include/znc/znc.h >index cf2326e..feb47c8 100644 >--- a/include/znc/znc.h >+++ b/include/znc/znc.h >@@ -187,6 +187,8 @@ public: > > static void DumpConfig(const CConfig* Config); > >+ void SetSystemWideConfig(bool systemWideConfig); >+ > private: > CFile* InitPidFile(); > bool DoRehash(CString& sError); >@@ -232,6 +234,7 @@ protected: > TCacheMap<CString> m_sConnectThrottle; > bool m_bProtectWebSessions; > bool m_bHideVersion; >+ bool m_bSystemWideConfig; > }; > > #endif // !_ZNC_H >diff --git a/src/main.cpp b/src/main.cpp >index 1ab54df..552cd0d 100644 >--- a/src/main.cpp >+++ b/src/main.cpp >@@ -16,6 +16,9 @@ > > #include <znc/znc.h> > #include <signal.h> >+#include <sys/types.h> >+#include <pwd.h> >+#include <grp.h> > > #if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD) > #include <znc/Threads.h> >@@ -109,6 +112,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 } > }; > >@@ -192,6 +196,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; >@@ -201,7 +207,7 @@ int main(int argc, char** argv) { > #endif > CZNC::CreateInstance(); > >- 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]); >@@ -219,6 +225,10 @@ int main(int argc, char** argv) { > case 'c': > bMakeConf = true; > break; >+ case 'S': >+ bSystemWideConfig = true; >+ sSystemWideConfigUser = optarg; >+ break; > case 's': > bMakePass = true; > break; >@@ -253,8 +263,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) { >@@ -303,7 +341,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 7ebde5f..2a73d36 100644 >--- a/src/znc.cpp >+++ b/src/znc.cpp >@@ -56,6 +56,7 @@ CZNC::CZNC() { > m_pLockFile = NULL; > m_bProtectWebSessions = true; > m_bHideVersion = false; >+ m_bSystemWideConfig = false; > m_uDisabledSSLProtocols = Csock::EDP_SSL; > m_sSSLProtocols = ""; > } >@@ -861,7 +862,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); > } > > void CZNC::BackupConfigOnce(const CString& sSuffix) { >@@ -1973,3 +1974,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) { > bool CZNC::WaitForChildLock() { > return m_pLockFile && m_pLockFile->ExLock(); > } >+ >+void CZNC::SetSystemWideConfig(bool systemWideConfig) { >+ m_bSystemWideConfig = systemWideConfig; >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 528774
:
390180
| 395456