aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-10-05 16:59:22 +0200
committerPierre Ossman <ossman@cendio.se>2018-10-09 17:22:17 +0200
commite6aab2465493d6088c5218d888d9b77d069e514c (patch)
treef2f6ebc586125dd7e2dc8c47925fcbcc146eef37 /common
parent4a4453fc69cf56f9991a13a62023969dcf5b8a4f (diff)
downloadtigervnc-e6aab2465493d6088c5218d888d9b77d069e514c.tar.gz
tigervnc-e6aab2465493d6088c5218d888d9b77d069e514c.zip
Force common flow of connection queries
Force queryConnection() to always call back to approveConnection() rather than return special values. This makes the flow easier to follow as it will be the same in all cases.
Diffstat (limited to 'common')
-rw-r--r--common/rfb/VNCSConnectionST.cxx11
-rw-r--r--common/rfb/VNCSConnectionST.h9
-rw-r--r--common/rfb/VNCServerST.h25
3 files changed, 12 insertions, 33 deletions
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index f1591f4c..cfefcca1 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -457,16 +457,7 @@ void VNCSConnectionST::queryConnection(const char* userName)
}
// - Get the server to display an Accept/Reject dialog, if required
- // If a dialog is displayed, the result will be PENDING, and the
- // server will call approveConnection at a later time
- CharArray reason;
- VNCServerST::queryResult qr = server->queryConnection(sock, userName,
- &reason.buf);
- if (qr == VNCServerST::PENDING)
- return;
-
- // - If server returns ACCEPT/REJECT then pass result to SConnection
- approveConnection(qr == VNCServerST::ACCEPT, reason.buf);
+ server->queryConnection(sock, userName);
}
void VNCSConnectionST::clientInit(bool shared)
diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h
index dfc8bcb5..faa04793 100644
--- a/common/rfb/VNCSConnectionST.h
+++ b/common/rfb/VNCSConnectionST.h
@@ -78,6 +78,7 @@ namespace rfb {
void serverCutTextOrClose(const char *str, int len);
void setDesktopNameOrClose(const char *name);
void setLEDStateOrClose(unsigned int state);
+ void approveConnectionOrClose(bool accept, const char* reason);
// checkIdleTimeout() returns the number of milliseconds left until the
// idle timeout expires. If it has expired, the connection is closed and
@@ -110,14 +111,6 @@ namespace rfb {
const char* getPeerEndpoint() const {return peerEndpoint.buf;}
- // approveConnectionOrClose() is called some time after
- // VNCServerST::queryConnection() has returned with PENDING to accept or
- // reject the connection. The accept argument should be true for
- // acceptance, or false for rejection, in which case a string reason may
- // also be given.
-
- void approveConnectionOrClose(bool accept, const char* reason);
-
char* getStartTime();
void setStatus(int status);
diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h
index b7845ddd..30a9c9ff 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -133,19 +133,13 @@ namespace rfb {
//
// queryConnection() is called when a connection has been
// successfully authenticated. The sock and userName arguments identify
- // the socket and the name of the authenticated user, if any. It should
- // return ACCEPT if the connection should be accepted, REJECT if it should
- // be rejected, or PENDING if a decision cannot yet be reached. If REJECT
- // is returned, *reason can be set to a string describing the reason - this
- // will be delete[]ed when it is finished with. If PENDING is returned,
+ // the socket and the name of the authenticated user, if any.
// approveConnection() must be called some time later to accept or reject
// the connection.
- enum queryResult { ACCEPT, REJECT, PENDING };
struct QueryConnectionHandler {
virtual ~QueryConnectionHandler() {}
- virtual queryResult queryConnection(network::Socket* sock,
- const char* userName,
- char** reason) = 0;
+ virtual void queryConnection(network::Socket* sock,
+ const char* userName) = 0;
};
void setQueryConnectionHandler(QueryConnectionHandler* qch) {
queryConnectionHandler = qch;
@@ -154,12 +148,13 @@ namespace rfb {
// queryConnection is called as described above, and either passes the
// request on to the registered handler, or accepts the connection if
// no handler has been specified.
- virtual queryResult queryConnection(network::Socket* sock,
- const char* userName,
- char** reason) {
- return queryConnectionHandler
- ? queryConnectionHandler->queryConnection(sock, userName, reason)
- : ACCEPT;
+ virtual void queryConnection(network::Socket* sock,
+ const char* userName) {
+ if (queryConnectionHandler) {
+ queryConnectionHandler->queryConnection(sock, userName);
+ return;
+ }
+ approveConnection(sock, true, NULL);
}
// approveConnection() is called by the active QueryConnectionHandler,