diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2016-05-15 18:45:57 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2016-06-24 01:03:12 +0300 |
commit | b1285fc5e330d72e7904220184ee9db8c64b9564 (patch) | |
tree | 2a2070fa2a8d4a0d4c6e99f6bcdbb4ee6ab3a6e0 /src/murmur/Messages.cpp | |
parent | cfb535aa15e23df6b5407d0762a4b1576b29e2e8 (diff) |
Ensure all ACL write operations hold qrwlVoiceThread.
Diffstat (limited to 'src/murmur/Messages.cpp')
-rw-r--r-- | src/murmur/Messages.cpp | 107 |
1 files changed, 58 insertions, 49 deletions
diff --git a/src/murmur/Messages.cpp b/src/murmur/Messages.cpp index 52a9bd9c0..2d502401e 100644 --- a/src/murmur/Messages.cpp +++ b/src/murmur/Messages.cpp @@ -1306,68 +1306,77 @@ void Server::msgACL(ServerUser *uSource, MumbleProto::ACL &msg) { Group *g; ChanACL *a; - QHash<QString, QSet<int> > hOldTemp; - - foreach(g, c->qhGroups) { - hOldTemp.insert(g->qsName, g->qsTemporary); - delete g; - } - - foreach(a, c->qlACL) - delete a; - - c->qhGroups.clear(); - c->qlACL.clear(); + { + QWriteLocker wl(&qrwlVoiceThread); - c->bInheritACL = msg.inherit_acls(); + QHash<QString, QSet<int> > hOldTemp; - for (int i=0;i<msg.groups_size(); ++i) { - const MumbleProto::ACL_ChanGroup &group = msg.groups(i); - g = new Group(c, u8(group.name())); - g->bInherit = group.inherit(); - g->bInheritable = group.inheritable(); - for (int j=0;j<group.add_size();++j) - if (!getUserName(group.add(j)).isEmpty()) - g->qsAdd << group.add(j); - for (int j=0;j<group.remove_size();++j) - if (!getUserName(group.remove(j)).isEmpty()) - g->qsRemove << group.remove(j); - g->qsTemporary = hOldTemp.value(g->qsName); - } + foreach(g, c->qhGroups) { + hOldTemp.insert(g->qsName, g->qsTemporary); + delete g; + } - for (int i=0;i<msg.acls_size(); ++i) { - const MumbleProto::ACL_ChanACL &mpacl = msg.acls(i); - if (mpacl.has_user_id() && getUserName(mpacl.user_id()).isEmpty()) - continue; + foreach(a, c->qlACL) + delete a; + + c->qhGroups.clear(); + c->qlACL.clear(); + + c->bInheritACL = msg.inherit_acls(); + + for (int i = 0; i < msg.groups_size(); ++i) { + const MumbleProto::ACL_ChanGroup &group = msg.groups(i); + g = new Group(c, u8(group.name())); + g->bInherit = group.inherit(); + g->bInheritable = group.inheritable(); + for (int j = 0; j < group.add_size(); ++j) + if (!getUserName(group.add(j)).isEmpty()) + g->qsAdd << group.add(j); + for (int j = 0; j < group.remove_size(); ++j) + if (!getUserName(group.remove(j)).isEmpty()) + g->qsRemove << group.remove(j); + g->qsTemporary = hOldTemp.value(g->qsName); + } - a = new ChanACL(c); - a->bApplyHere=mpacl.apply_here(); - a->bApplySubs=mpacl.apply_subs(); - if (mpacl.has_user_id()) - a->iUserId=mpacl.user_id(); - else - a->qsGroup=u8(mpacl.group()); - a->pDeny=static_cast<ChanACL::Permissions>(mpacl.deny()) & ChanACL::All; - a->pAllow=static_cast<ChanACL::Permissions>(mpacl.grant()) & ChanACL::All; + for (int i = 0; i < msg.acls_size(); ++i) { + const MumbleProto::ACL_ChanACL &mpacl = msg.acls(i); + if (mpacl.has_user_id() && getUserName(mpacl.user_id()).isEmpty()) + continue; + + a = new ChanACL(c); + a->bApplyHere = mpacl.apply_here(); + a->bApplySubs = mpacl.apply_subs(); + if (mpacl.has_user_id()) + a->iUserId = mpacl.user_id(); + else + a->qsGroup = u8(mpacl.group()); + a->pDeny = static_cast<ChanACL::Permissions>(mpacl.deny()) & ChanACL::All; + a->pAllow = static_cast<ChanACL::Permissions>(mpacl.grant()) & ChanACL::All; + } } clearACLCache(); if (! hasPermission(uSource, c, ChanACL::Write) && ((uSource->iId >= 0) || !uSource->qsHash.isEmpty())) { - a = new ChanACL(c); - a->bApplyHere=true; - a->bApplySubs=false; - if (uSource->iId >= 0) - a->iUserId=uSource->iId; - else - a->qsGroup=QLatin1Char('$') + uSource->qsHash; - a->iUserId=uSource->iId; - a->pDeny=ChanACL::None; - a->pAllow=ChanACL::Write | ChanACL::Traverse; + { + QWriteLocker wl(&qrwlVoiceThread); + + a = new ChanACL(c); + a->bApplyHere = true; + a->bApplySubs = false; + if (uSource->iId >= 0) + a->iUserId = uSource->iId; + else + a->qsGroup = QLatin1Char('$') + uSource->qsHash; + a->iUserId = uSource->iId; + a->pDeny = ChanACL::None; + a->pAllow = ChanACL::Write | ChanACL::Traverse; + } clearACLCache(); } + updateChannel(c); log(uSource, QString("Updated ACL in channel %1").arg(*c)); } |