Hi,
On the guacd level, I am detecting once a connection is closed or logged
off when we are towards the end of the thread.
Basically, I have a custom daemon that creates a new thread for every
connection that has a single client and a single user for my use case,
then that thread comes to end once it is done with
guac_user_handle_connection and then I conclude that the connection is
closing. // please refer below code

But I want to perform extra activity here, once I know connection is
closed, I want to go and delete the redirected drive that the session had
used
that I passed in my connection args, but I am not able to do so using
(guac_rdp_settings*)(user->data) as guac_rdp_settings is visible only for
rdp connections, not anyone outside.

How can I get the values of those connection params so that I can perform
some actions later on after logging out?
I guess these are sensitive params, that's why they are rightly hidden by
this approach but I want those values to pass to other exe.

This is my simple daemon code,

// Thread function to handle each connection
unsigned __stdcall handle_connection(void* arg) {

    guac_socket* socket = guac_socket_open_wsa(connection);
    guac_parser* parser = guac_parser_alloc();

    printf("Thread %lu: Accepted connection. Waiting for select...\n",
GetCurrentThreadId());

    /* Wait for select */
    if (guac_parser_expect(parser, socket, 15000000, "select")) {
        printf("Thread %lu: \"select\" not read: %s %d\n",
GetCurrentThreadId(),
                guac_error_message, WSAGetLastError());
        guac_parser_free(parser);
        guac_socket_free(socket);
        return 1;
    }

    guac_client* client = guac_client_alloc();
    client->log_handler = my_logging_handler;

    if(guac_client_load_plugin(client, "rdp")) {
        printf("Thread %lu: protocol loading failed\n",
GetCurrentThreadId());
        guac_parser_free(parser);
        guac_socket_free(socket);
        guac_client_free(client);
        return 1;
    }

    guac_socket_require_keep_alive(client->socket);

    /* Validate select length */
    if (parser->argc != 1) {
        printf("Thread %lu: \"select\" had wrong number of arguments.\n",
GetCurrentThreadId());
        guac_parser_free(parser);
        guac_socket_free(socket);
        guac_client_free(client);
        return 1;
    }

    guac_user* user = guac_user_alloc();
    user->owner = 1;
    user->client = client;
    user->socket = socket;

    guac_user_handle_connection(user, 150000000);

    // can I read those values here?

    /* User done */
    printf("Thread %lu: User has left connection.\n", GetCurrentThreadId());
    guac_user_free(user);
    guac_parser_free(parser);
    guac_socket_free(socket);

    /* Signal client to shut down */
    guac_client_stop(client);

    /* Client done */
    guac_client_free(client);
    printf("Thread %lu: Done!\n", GetCurrentThreadId());

    return 0;
}

- Palaash

Reply via email to