mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
znc: copy from old packages and add PKG_LICENSE
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
From 5f655f9a25a377c01cb15517859eb514628a43d4 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
|
||||
Date: Wed, 6 Apr 2011 04:10:23 +0200
|
||||
Subject: [PATCH] Move the root check to after config parsing
|
||||
|
||||
---
|
||||
src/main.cpp | 27 ++++++++++++++-------------
|
||||
1 files changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/src/main.cpp
|
||||
+++ b/src/main.cpp
|
||||
@@ -243,19 +243,6 @@ int main(int argc, char** argv) {
|
||||
CUtils::PrintStatus(true, "");
|
||||
}
|
||||
|
||||
- if (isRoot()) {
|
||||
- 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) {
|
||||
- delete pZNC;
|
||||
- return 1;
|
||||
- }
|
||||
- CUtils::PrintError("You have been warned.");
|
||||
- CUtils::PrintError("Hit CTRL+C now if you don't want to run ZNC as root.");
|
||||
- CUtils::PrintError("ZNC will start in 30 seconds.");
|
||||
- sleep(30);
|
||||
- }
|
||||
-
|
||||
if (bMakeConf) {
|
||||
if (!pZNC->WriteNewConfig(sConfig)) {
|
||||
delete pZNC;
|
||||
@@ -276,6 +263,20 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
+ if (isRoot()) {
|
||||
+ 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) {
|
||||
+ delete pZNC;
|
||||
+ return 1;
|
||||
+ }
|
||||
+ CUtils::PrintError("You have been warned.");
|
||||
+ CUtils::PrintError("Hit CTRL+C now if you don't want to run ZNC as root.");
|
||||
+ CUtils::PrintError("ZNC will start in 30 seconds.");
|
||||
+ sleep(30);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
if (bForeground) {
|
||||
int iPid = getpid();
|
||||
CUtils::PrintMessage("Staying open for debugging [pid: " + CString(iPid) + "]");
|
||||
@@ -0,0 +1,28 @@
|
||||
From fa14938321eda39f16bee6068296e6abc9df7b85 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
|
||||
Date: Wed, 6 Apr 2011 04:11:48 +0200
|
||||
Subject: [PATCH] Add a uClibc++ build workaround
|
||||
|
||||
---
|
||||
modules/webadmin.cpp | 4 +++-
|
||||
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||
|
||||
--- a/modules/webadmin.cpp
|
||||
+++ b/modules/webadmin.cpp
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <znc/IRCNetwork.h>
|
||||
#include <znc/IRCSock.h>
|
||||
|
||||
+using std::string;
|
||||
using std::stringstream;
|
||||
using std::make_pair;
|
||||
using std::set;
|
||||
@@ -75,7 +76,7 @@ class CWebAdminMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CWebAdminMod) {
|
||||
VPair vParams;
|
||||
- vParams.push_back(make_pair("user", ""));
|
||||
+ vParams.push_back(make_pair((string)"user", (string)""));
|
||||
AddSubPage(new CWebSubPage("settings", "Global Settings", CWebSubPage::F_ADMIN));
|
||||
AddSubPage(new CWebSubPage("edituser", "Your Settings", vParams));
|
||||
AddSubPage(new CWebSubPage("traffic", "Traffic Info", CWebSubPage::F_ADMIN));
|
||||
@@ -0,0 +1,38 @@
|
||||
From 94aff4c3389111fc85054eb06b40bea26a216d0c Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
|
||||
Date: Sat, 16 Apr 2011 05:51:04 +0200
|
||||
Subject: [PATCH] Don't rebuild everything when the Makefile's timestamp changed
|
||||
|
||||
---
|
||||
Makefile.in | 2 +-
|
||||
modules/Makefile.in | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -104,7 +104,7 @@ clean:
|
||||
distclean: clean
|
||||
rm -rf $(DISTCLEAN)
|
||||
|
||||
-src/%.o: src/%.cpp Makefile
|
||||
+src/%.o: src/%.cpp
|
||||
@mkdir -p .depend src
|
||||
$(E) Building core object $*...
|
||||
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< -MD -MF .depend/$*.dep -MT $@
|
||||
--- a/modules/Makefile.in
|
||||
+++ b/modules/Makefile.in
|
||||
@@ -117,12 +117,12 @@ install_datadir:
|
||||
clean:
|
||||
rm -rf $(CLEAN)
|
||||
|
||||
-%.o: %.cpp Makefile
|
||||
+%.o: %.cpp
|
||||
@mkdir -p .depend
|
||||
$(E) Building module $(notdir $(basename $@))...
|
||||
$(Q)$(CXX) $(MODFLAGS) -c -o $@ $< $($(notdir $(basename $@))CXXFLAGS) -MD -MF .depend/$(notdir $@).dep
|
||||
|
||||
-%.so: %.o Makefile
|
||||
+%.so: %.o
|
||||
$(E) "Linking module" $(notdir $(basename $@))...
|
||||
$(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))LDFLAGS) $(LIBS)
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
--- /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.")
|
||||
Reference in New Issue
Block a user