Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions common/rfb/VNCSConnectionST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s, con
user[offset] = '\0';
}

bool read, write, owner;
bool read = false, write = false, owner = false;
if (!getPerms(read, write, owner)) {
accessRights &= ~(WRITER_PERMS | AccessView);
}
Expand Down Expand Up @@ -1242,9 +1242,12 @@ bool VNCSConnectionST::getPerms(bool &read, bool &write, bool &owner) const
{
bool found = false;
if (disablebasicauth) {
// We're running without basicauth
// No basicauth: grant full perms; owner is meaningless without an
// authenticated owner, so report it false (is_owner()/checkOwnerConn()
// would otherwise read it uninitialized).
read = true;
write = true;
owner = false;
return true;
}
if (user[0]) {
Expand Down Expand Up @@ -1869,7 +1872,7 @@ void VNCSConnectionST::udpDowngrade(const bool byServer)

void VNCSConnectionST::subscribeUnixRelay(const char *name)
{
bool read, write, owner;
bool read = false, write = false, owner = false;
if (!getPerms(read, write, owner) || !write) {
// Need write permissions to subscribe
writer()->writeSubscribeUnixRelay(false, "No permissions");
Expand Down
7 changes: 6 additions & 1 deletion common/rfb/VNCServerST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ std::vector<SessionInfo> VNCServerST::getSessionUsers() {
if (!client->authenticated()) {
continue;
}
users.push_back(SessionInfo(client->getUsername(),client->getConnectionTime()));
users.push_back(SessionInfo(client->getUsername(), client->getConnectionTime(), client->is_owner()));
}
return users;
}
Expand All @@ -830,6 +830,11 @@ void VNCServerST::updateSessionUsersList()
if (!sessionUsers.empty()) {
std::string sessionUsersJson = formatUsersToJson(sessionUsers);
apimessager->mainUpdateSessionsInfo(sessionUsersJson);
} else {
// Last disconnect: reset to the canonical empty shape so
// /api/get_sessions signals an empty session (matches the init
// literal in GetAPIMessager.cxx).
apimessager->mainUpdateSessionsInfo("{\"users\":[]}");
}
}

Expand Down
6 changes: 4 additions & 2 deletions common/rfb/util.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ namespace rfb {
{
std::string usersList = "[";
bool firstUser = true;
for (const auto&[userName, connectionTime] : users)
for (const auto&[userName, connectionTime, isOwner] : users)
{
std::string username =userName;
time_t connTime = connectionTime;
Expand All @@ -702,7 +702,9 @@ namespace rfb {
userEntry.append(username);
userEntry.append( "\", \"connected_since\":\"");
userEntry.append(timeStr);
userEntry.append("\"}");
userEntry.append( "\", \"is_owner\":");
userEntry.append( isOwner ? "true" : "false");
userEntry.append("}");

usersList.append(userEntry);
}
Expand Down
4 changes: 3 additions & 1 deletion common/rfb/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ namespace rfb {
struct SessionInfo {
std::string userName;
time_t connectionTime;
SessionInfo(const std::string& name, const time_t& time)
bool isOwner;
SessionInfo(const std::string& name, const time_t& time, const bool ownerFlag = false)
{
userName = name;
connectionTime = time;
isOwner = ownerFlag;
}

};
Expand Down