diff options
author | Timothy Pearson <tpearson@raptorengineering.com> | 2019-03-02 19:39:52 -0600 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-03-02 19:49:22 -0600 |
commit | 315b8914c853078d8bb04a7d16e47d19128ca318 (patch) | |
tree | 5e64fe8ea46443663d287360c5b6b45aea095fb1 /xup | |
parent | 58e06a0aa7db8e0762b31304ead0c3e0df5a7be4 (diff) | |
download | xrdp-proprietary-315b8914c853078d8bb04a7d16e47d19128ca318.tar.gz xrdp-proprietary-315b8914c853078d8bb04a7d16e47d19128ca318.zip |
Second batch of initial commits:
* Add server/group pamming
* Partially fix immediate exit after login
Still will not compile due to libraptorsmiface being too new
Diffstat (limited to 'xup')
-rw-r--r-- | xup/xup.c | 104 |
1 files changed, 104 insertions, 0 deletions
@@ -32,6 +32,98 @@ #define LLOGLN(_level, _args) \ do { if (_level < LOG_LEVEL) { g_writeln _args ; } } while (0) +#include <arpa/inet.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> +#include <netdb.h> + +/******************************************************************************/ +/** ++ * ++ * @brief checks if there's a server running on a host and port ++ * @param display the display to check + * @return 0 if the port is closed, 1 if it is open + * + */ +static int +check_port_status(const char* host, const char* port) +{ + char text[256]; + int x_running; + int sck; + + struct sockaddr_in servaddr; + int soc = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + + g_memset( &servaddr, 0, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons(atoi(port)); + + struct hostent* hostaddr; + hostaddr = gethostbyname(host); + g_memcpy(&servaddr.sin_addr, hostaddr->h_addr, hostaddr->h_length); + + int res = connect(soc, (struct sockaddr*)&servaddr, sizeof(servaddr)); + + close(soc); + + if (res == -1) + { + // Port is closed, no server there! + return 0; + } + else { + // Port is open + return 1; + } +} + +/******************************************************************************/ +/** + * + * @brief checks if there's a server running on a remote display + * @param display the display to check + * @return 0 if there isn't a display running, nonzero otherwise + * + */ +static int +x_server_running_check_remote_port(const char* host, const char* port) +{ + int x_running; + int sck; + + x_running = 0; + x_running += check_port_status(host, port); + + return x_running; +} + +/******************************************************************************/ +static int +wait_for_remote_xserver(const char* host, const char* port) +{ + int i; + + /* give X a bit to start */ + /* wait up to 15 secs for x server to start */ + i = 0; + while (!x_server_running_check_remote_port(host, port)) + { + i++; + if (i > 60) + { + break; + } + g_sleep(250); + } + return 0; +} + + static int lib_mod_process_message(struct mod *mod, struct stream *s); @@ -164,6 +256,18 @@ lib_mod_connect(struct mod *mod) return 1; } + char text[256]; + g_snprintf(text, 255, "allocating resources on %s, please wait...\n\r", mod->ip); + mod->server_msg(mod, text, 0); + + // Prevent an immediate RDP exit + wait_for_remote_xserver(mod->ip, mod->port); + + // FIXME CRITICAL + // Prevent an immediate RDP exit + // Why is this still needed even after waiting for the X11rdp server to start!?!? + g_sleep(5000); + if (g_strcmp(mod->ip, "") == 0) { mod->server_msg(mod, "error - no ip set", 0); |