hook into ACL system for CM shenanigans

This commit is contained in:
in1tiate 2021-03-02 20:45:01 -06:00
parent 6a6029b6da
commit 0b024abe5c
3 changed files with 21 additions and 38 deletions

View File

@ -63,6 +63,7 @@ class AOClient : public QObject {
{"BAN", 1ULL << 1}, {"BAN", 1ULL << 1},
{"BGLOCK", 1ULL << 2}, {"BGLOCK", 1ULL << 2},
{"MODIFY_USERS", 1ULL << 3}, {"MODIFY_USERS", 1ULL << 3},
{"CM", 1ULL << 4},
{"SUPER", ~0ULL} {"SUPER", ~0ULL}
}; };
@ -231,12 +232,12 @@ class AOClient : public QObject {
{"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}}, {"doc", {ACLFlags.value("NONE"), 0, &AOClient::cmdDoc}},
{"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}}, {"cleardoc", {ACLFlags.value("NONE"), 0, &AOClient::cmdClearDoc}},
{"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}}, {"cm", {ACLFlags.value("NONE"), 0, &AOClient::cmdCM}},
{"uncm", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnCM}}, {"uncm", {ACLFlags.value("CM"), 0, &AOClient::cmdUnCM}},
{"invite", {ACLFlags.value("NONE"), 1, &AOClient::cmdInvite}}, {"invite", {ACLFlags.value("CM"), 1, &AOClient::cmdInvite}},
{"uninvite", {ACLFlags.value("NONE"), 1, &AOClient::cmdUnInvite}}, {"uninvite", {ACLFlags.value("CM"), 1, &AOClient::cmdUnInvite}},
{"lock", {ACLFlags.value("NONE"), 0, &AOClient::cmdLock}}, {"lock", {ACLFlags.value("CM"), 0, &AOClient::cmdLock}},
{"spectatable", {ACLFlags.value("NONE"), 0, &AOClient::cmdSpectatable}}, {"spectatable", {ACLFlags.value("CM"), 0, &AOClient::cmdSpectatable}},
{"unlock", {ACLFlags.value("NONE"), 0, &AOClient::cmdUnLock}}, {"unlock", {ACLFlags.value("CM"), 0, &AOClient::cmdUnLock}},
}; };

View File

@ -264,10 +264,16 @@ void AOClient::sendServerBroadcast(QString message)
bool AOClient::checkAuth(unsigned long long acl_mask) bool AOClient::checkAuth(unsigned long long acl_mask)
{ {
if (acl_mask != ACLFlags.value("NONE")) { if (acl_mask != ACLFlags.value("NONE")) {
if (!authenticated) { if (!authenticated && acl_mask != ACLFlags.value("CM")) {
return false; return false;
} }
if (acl_mask == ACLFlags.value("CM")) {
AreaData* area = server->areas[current_area];
if (area->owners.contains(id))
return true;
}
QSettings settings("config/config.ini", QSettings::IniFormat); QSettings settings("config/config.ini", QSettings::IniFormat);
settings.beginGroup("Options"); settings.beginGroup("Options");
QString auth_type = settings.value("auth", "simple").toString(); QString auth_type = settings.value("auth", "simple").toString();

View File

@ -448,12 +448,8 @@ void AOClient::cmdUnCM(int argc, QStringList argv)
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
int removed = area->owners.removeAll(id); int removed = area->owners.removeAll(id);
area->invited.removeAll(id); area->invited.removeAll(id);
if (removed == 0)
sendServerMessage("You are not a CM in this area.");
else {
sendServerMessage("You are no longer CM in this area."); sendServerMessage("You are no longer CM in this area.");
arup(ARUPType::CM, true); arup(ARUPType::CM, true);
}
if (area->owners.isEmpty()) if (area->owners.isEmpty())
area->invited.clear(); area->invited.clear();
} }
@ -462,11 +458,7 @@ void AOClient::cmdInvite(int argc, QStringList argv)
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
bool ok; bool ok;
int invited_id = argv[0].toInt(&ok); int invited_id = argv[0].toInt(&ok);
if (!area->owners.contains(id)) { if (!ok) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (!ok) {
sendServerMessage("That does not look like a valid ID."); sendServerMessage("That does not look like a valid ID.");
return; return;
} }
@ -482,11 +474,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
bool ok; bool ok;
int uninvited_id = argv[0].toInt(&ok); int uninvited_id = argv[0].toInt(&ok);
if (!area->owners.contains(id)) { if (!ok) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (!ok) {
sendServerMessage("That does not look like a valid ID."); sendServerMessage("That does not look like a valid ID.");
return; return;
} }
@ -504,11 +492,7 @@ void AOClient::cmdUnInvite(int argc, QStringList argv)
void AOClient::cmdLock(int argc, QStringList argv) void AOClient::cmdLock(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (!area->owners.contains(id)) { if (area->locked == AreaData::LockStatus::LOCKED) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (area->locked == AreaData::LockStatus::LOCKED) {
sendServerMessage("This area is already locked."); sendServerMessage("This area is already locked.");
return; return;
} }
@ -524,11 +508,7 @@ void AOClient::cmdLock(int argc, QStringList argv)
void AOClient::cmdSpectatable(int argc, QStringList argv) void AOClient::cmdSpectatable(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (!area->owners.contains(id)) { if (area->locked == AreaData::LockStatus::SPECTATABLE) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (area->locked == AreaData::LockStatus::SPECTATABLE) {
sendServerMessage("This area is already in spectate mode."); sendServerMessage("This area is already in spectate mode.");
return; return;
} }
@ -544,11 +524,7 @@ void AOClient::cmdSpectatable(int argc, QStringList argv)
void AOClient::cmdUnLock(int argc, QStringList argv) void AOClient::cmdUnLock(int argc, QStringList argv)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (!area->owners.contains(id)) { if (area->locked == AreaData::LockStatus::FREE) {
sendServerMessage("You are not a CM in this area.");
return;
}
else if (area->locked == AreaData::LockStatus::FREE) {
sendServerMessage("This area is not locked."); sendServerMessage("This area is not locked.");
return; return;
} }