Record authenticated username for each connected client
Signed-off-by: Jim Ramsay <jramsay@redhat.com>pull/83/head
parent
86bd2ced85
commit
036b549fd8
|
@ -70,6 +70,7 @@ struct nvnc_client {
|
|||
int ref;
|
||||
struct stream* net_stream;
|
||||
char hostname[256];
|
||||
char username[256];
|
||||
struct nvnc* server;
|
||||
enum nvnc_client_state state;
|
||||
bool has_pixfmt;
|
||||
|
|
|
@ -132,6 +132,7 @@ void* nvnc_get_userdata(const void* self);
|
|||
struct nvnc* nvnc_client_get_server(const struct nvnc_client* client);
|
||||
bool nvnc_client_supports_cursor(const struct nvnc_client* client);
|
||||
const char* nvnc_client_get_hostname(const struct nvnc_client* client);
|
||||
const char* nvnc_client_get_auth_username(const struct nvnc_client* client);
|
||||
|
||||
void nvnc_set_name(struct nvnc* self, const char* name);
|
||||
|
||||
|
|
10
src/server.c
10
src/server.c
|
@ -331,6 +331,9 @@ static int on_vencrypt_plain_auth_message(struct nvnc_client* client)
|
|||
username[MIN(ulen, sizeof(username) - 1)] = '\0';
|
||||
password[MIN(plen, sizeof(password) - 1)] = '\0';
|
||||
|
||||
strncpy(client->username, username, sizeof(client->username));
|
||||
client->username[sizeof(client->username) - 1] = '\0';
|
||||
|
||||
if (server->auth_fn(username, password, server->auth_ud)) {
|
||||
nvnc_log(NVNC_LOG_INFO, "User \"%s\" authenticated", username);
|
||||
security_handshake_ok(client);
|
||||
|
@ -1631,6 +1634,13 @@ const char* nvnc_client_get_hostname(const struct nvnc_client* client) {
|
|||
return client->hostname;
|
||||
}
|
||||
|
||||
EXPORT
|
||||
const char* nvnc_client_get_auth_username(const struct nvnc_client* client) {
|
||||
if (client->username[0] == '\0')
|
||||
return NULL;
|
||||
return client->username;
|
||||
}
|
||||
|
||||
EXPORT
|
||||
bool nvnc_client_supports_cursor(const struct nvnc_client* client)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue