random/irc/znc_isadmin_patch.diff

175 lines
6.2 KiB
Diff

user@linux ~/build/znc-acid $ git diff
diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp
index 0b7796aa..edd14420 100644
--- a/modules/controlpanel.cpp
+++ b/modules/controlpanel.cpp
@@ -319,12 +319,37 @@ class CAdminMod : public CModule {
pUser->SetAltNick(sValue);
PutModule("AltNick = " + sValue);
} else if (sVar == "ident") {
+
+ // Don't need them changing this, used to identify them.
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
pUser->SetIdent(sValue);
+
PutModule("Ident = " + sValue);
} else if (sVar == "realname") {
+
+ // Some BNC's put their link in the realname.
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
pUser->SetRealName(sValue);
PutModule("RealName = " + sValue);
} else if (sVar == "bindhost") {
+
+ // That code below is annoying. Just do this first.
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) {
if (sValue.Equals(pUser->GetBindHost())) {
PutModule(t_s("This bind host is already set!"));
@@ -607,9 +632,24 @@ class CAdminMod : public CModule {
pNetwork->SetAltNick(sValue);
PutModule("AltNick = " + pNetwork->GetAltNick());
} else if (sVar.Equals("ident")) {
+
+ // Don't need them changing this, used to identify them.
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
pNetwork->SetIdent(sValue);
PutModule("Ident = " + pNetwork->GetIdent());
} else if (sVar.Equals("realname")) {
+
+ // Some BNC's put their link in the realname.
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
pNetwork->SetRealName(sValue);
PutModule("RealName = " + pNetwork->GetRealName());
} else if (sVar.Equals("bindhost")) {
@@ -1022,6 +1062,11 @@ class CAdminMod : public CModule {
CString sNetwork = sLine.Token(2);
CUser* pUser = GetUser();
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
if (sNetwork.empty()) {
sNetwork = sUser;
} else {
@@ -1067,6 +1112,12 @@ class CAdminMod : public CModule {
CString sNetwork = sLine.Token(2);
CUser* pUser = GetUser();
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
if (sNetwork.empty()) {
sNetwork = sUser;
} else {
@@ -1149,6 +1200,12 @@ class CAdminMod : public CModule {
CString sNetwork = sLine.Token(2);
CString sServer = sLine.Token(3, true);
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
if (sServer.empty()) {
PutModule(
t_s("Usage: AddServer <username> <network> <server> [[+]port] "
@@ -1180,6 +1237,12 @@ class CAdminMod : public CModule {
unsigned short uPort = sLine.Token(4).ToUShort();
CString sPass = sLine.Token(5);
+ if (!GetUser()->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
if (sServer.empty()) {
PutModule(
t_s("Usage: DelServer <username> <network> <server> [[+]port] "
diff --git a/src/ClientCommand.cpp b/src/ClientCommand.cpp
index 44bcc324..81704ed1 100644
--- a/src/ClientCommand.cpp
+++ b/src/ClientCommand.cpp
@@ -536,6 +536,14 @@ void CClient::UserCommand(CString& sLine) {
PutStatus(t_f("Total: {1}, Joined: {2}, Detached: {3}, Disabled: {4}")(
vChans.size(), uNumJoined, uNumDetached, uNumDisabled));
} else if (sCommand.Equals("ADDNETWORK")) {
+
+ // Just them anyway.
+ if (!m_pUser->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
if (!m_pUser->IsAdmin() && !m_pUser->HasSpaceForNewNetwork()) {
PutStatus(t_s(
"Network number limit reached. Ask an admin to increase the "
@@ -569,6 +577,12 @@ void CClient::UserCommand(CString& sLine) {
} else if (sCommand.Equals("DELNETWORK")) {
CString sNetwork = sLine.Token(1);
+ if (!m_pUser->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
+
if (sNetwork.empty()) {
PutStatus(t_s("Usage: DelNetwork <name>"));
return;
@@ -744,6 +758,11 @@ void CClient::UserCommand(CString& sLine) {
} else if (sCommand.Equals("ADDSERVER")) {
CString sServer = sLine.Token(1);
+ if (!m_pUser->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
if (!m_pNetwork) {
PutStatus(t_s(
"You must be connected with a network to use this command"));
@@ -763,6 +782,11 @@ void CClient::UserCommand(CString& sLine) {
"added or openssl is disabled?"));
}
} else if (sCommand.Equals("REMSERVER") || sCommand.Equals("DELSERVER")) {
+ if (!m_pUser->IsAdmin()) {
+ PutStatus(t_s(
+ "You cannot do that."));
+ return;
+ }
if (!m_pNetwork) {
PutStatus(t_s(
"You must be connected with a network to use this command"));