100-move_rootcheck_after_config.patch (1696B)
1 From adf42357c9043c38d9a9b47544a1b46445bdae19 Mon Sep 17 00:00:00 2001 2 From: Jonas Gorski <jonas.gorski+openwrt@gmail.com> 3 Date: Wed, 6 Apr 2011 04:10:23 +0200 4 Subject: [PATCH] Move the root check to after config parsing 5 6 --- 7 src/main.cpp | 27 ++++++++++++++------------- 8 1 file changed, 14 insertions(+), 13 deletions(-) 9 10 --- a/src/main.cpp 11 +++ b/src/main.cpp 12 @@ -312,19 +312,6 @@ int main(int argc, char** argv) { 13 CUtils::PrintStatus(true, ""); 14 } 15 16 - if (isRoot()) { 17 - CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid"); 18 - CUtils::PrintError("reasons for this and it can, in theory, cause great damage!"); 19 - if (!bAllowRoot) { 20 - CZNC::DestroyInstance(); 21 - return 1; 22 - } 23 - CUtils::PrintError("You have been warned."); 24 - CUtils::PrintError("Hit CTRL+C now if you don't want to run ZNC as root."); 25 - CUtils::PrintError("ZNC will start in 30 seconds."); 26 - sleep(30); 27 - } 28 - 29 if (bMakeConf) { 30 if (!pZNC->WriteNewConfig(sConfig)) { 31 CZNC::DestroyInstance(); 32 @@ -346,6 +333,20 @@ int main(int argc, char** argv) { 33 return 1; 34 } 35 36 + if (isRoot()) { 37 + CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid"); 38 + CUtils::PrintError("reasons for this and it can, in theory, cause great damage!"); 39 + if (!bAllowRoot) { 40 + CZNC::DestroyInstance(); 41 + return 1; 42 + } 43 + CUtils::PrintError("You have been warned."); 44 + CUtils::PrintError("Hit CTRL+C now if you don't want to run ZNC as root."); 45 + CUtils::PrintError("ZNC will start in 30 seconds."); 46 + sleep(30); 47 + } 48 + 49 + 50 if (bForeground) { 51 int iPid = getpid(); 52 CUtils::PrintMessage("Staying open for debugging [pid: " + CString(iPid) + "]");