Limit access to non-shared mode

A read-only client should not be allowed to kick out other clients.
It will be forced into shared mode, or refused the connection, depending
on the neverShared parameter.
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index 20182a0..99a4850 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -42,6 +42,7 @@
 const SConnection::AccessRights SConnection::AccessPtrEvents      = 0x0004;
 const SConnection::AccessRights SConnection::AccessCutText        = 0x0008;
 const SConnection::AccessRights SConnection::AccessSetDesktopSize = 0x0010;
+const SConnection::AccessRights SConnection::AccessNonShared      = 0x0020;
 const SConnection::AccessRights SConnection::AccessDefault        = 0x03ff;
 const SConnection::AccessRights SConnection::AccessNoQuery        = 0x0400;
 const SConnection::AccessRights SConnection::AccessFull           = 0xffff;
diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h
index 0379b17..005a7a8 100644
--- a/common/rfb/SConnection.h
+++ b/common/rfb/SConnection.h
@@ -127,6 +127,7 @@
     static const AccessRights AccessPtrEvents;      // Send pointer events
     static const AccessRights AccessCutText;        // Send/receive clipboard events
     static const AccessRights AccessSetDesktopSize; // Change desktop size
+    static const AccessRights AccessNonShared;      // Exclusive access to the server
     static const AccessRights AccessDefault;        // The default rights, INCLUDING FUTURE ONES
     static const AccessRights AccessNoQuery;        // Connect without local user accepting
     static const AccessRights AccessFull;           // All of the available AND FUTURE rights
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 274c496..e30b4f4 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -445,9 +445,10 @@
 {
   lastEventTime = time(0);
   if (rfb::Server::alwaysShared || reverseConnection) shared = true;
+  if (!(accessRights & AccessNonShared)) shared = true;
   if (rfb::Server::neverShared) shared = false;
   if (!shared) {
-    if (rfb::Server::disconnectClients) {
+    if (rfb::Server::disconnectClients && (accessRights & AccessNonShared)) {
       // - Close all the other connected clients
       vlog.debug("non-shared connection - closing clients");
       server->closeClients("Non-shared connection requested", getSock());