Dynamically apply permissions

This commit is contained in:
Lauri Kasanen
2020-10-13 13:38:18 +03:00
parent 263d05a296
commit 0c83a86bc8
4 changed files with 79 additions and 1 deletions

View File

@@ -59,7 +59,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
losslessTimer(this), kbdLogTimer(this), server(server_), updates(false),
updateRenderedCursor(false), removeRenderedCursor(false),
continuousUpdates(false), encodeManager(this, &server_->encCache),
pointerEventTime(0),
needsPermCheck(false), pointerEventTime(0),
clientHasCursor(false),
accessRights(AccessDefault), startTime(time(0))
{
@@ -1126,6 +1126,22 @@ void VNCSConnectionST::writeFramebufferUpdate()
if (isCongested())
return;
// Check for permission changes?
if (needsPermCheck) {
needsPermCheck = false;
bool write, owner, ret;
ret = getPerms(write, owner);
if (!ret) {
close("User was deleted");
return;
} else if (!write) {
accessRights = (accessRights & ~(AccessPtrEvents | AccessKeyEvents));
} else {
accessRights |= AccessPtrEvents | AccessKeyEvents;
}
}
// Updates often consists of many small writes, and in continuous
// mode, we will also have small fence messages around the update. We
// need to aggregate these in order to not clog up TCP's congestion