8eec9395 | 2019-03-17 00:37:11 | Timothy Pearson |
FIXUP |
||
M raptorsmiface/libraptorsmiface.c M sesman/chansrv/sound.c |
||
raptorsmiface/libraptorsmiface.cdiff --git a/raptorsmiface/libraptorsmiface.c b/raptorsmiface/libraptorsmiface.c index bd75168..cec1508 100644 --- a/raptorsmiface/libraptorsmiface.c +++ b/raptorsmiface/libraptorsmiface.c @@ -557,23 +557,11 @@ } char* origstr = command_string; -#ifndef RAPTOR_SM_DISABLE_PULSEAUDIO - if (display >= 0) { - asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && export PULSE_SERVER=tcp:%s:%d && pulseaudio -D --load=\\\"module-native-protocol-tcp listen=0.0.0.0 auth-ip-acl=%s port=%d\\\"\' &> /dev/null\" &", ipaddr, username, display, ipaddr, (RAPTOR_SM_BASE_PULSEAUDIO_PORT+display), RAPTOR_SM_MANAGEMENT_SERVER_IP_NETRANGE, (RAPTOR_SM_BASE_PULSEAUDIO_PORT+display)); - dprint("Running command %s...\n\r", command_string); - system(command_string); - } -#endif - if (strcmp(dbfield, RAPTOR_SM_SERVER_PID_FIELD) == 0) { asprintf(&command_string, "ssh root@%s \'%s & echo $! &\'", ipaddr, origstr); } else { -#if RAPTOR_SM_DISABLE_PULSEAUDIO asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && %s\' &> /dev/null & echo \\$!\"", ipaddr, username, display, origstr); -#else - asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && export PULSE_SERVER=tcp:%s:%d && %s\' &> /dev/null & echo \\$!\"", ipaddr, username, display, ipaddr, (RAPTOR_SM_BASE_PULSEAUDIO_PORT+display), origstr); -#endif } dprint("Running command %s...\n\r", command_string); free(origstr); @@ -853,11 +841,7 @@ void raptor_sm_run_remote_desktop(char* username, int display, char* executable) { char* ipaddr = raptor_sm_get_ip_for_username(username, true); char* command_string; -#if RAPTOR_SM_DISABLE_PULSEAUDIO asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && %s && exit\' &> /dev/null\"", ipaddr, username, display, executable); -#else - asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && export PULSE_SERVER=tcp:%s:%d && %s && exit\' &> /dev/null\"", ipaddr, username, display, ipaddr, (RAPTOR_SM_BASE_PULSEAUDIO_PORT+display), executable); -#endif system(command_string); free(command_string); } sesman/chansrv/sound.cdiff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c index 5499d4b..c2c9b3b 100644 --- a/sesman/chansrv/sound.c +++ b/sesman/chansrv/sound.c @@ -1401,21 +1401,7 @@ for upto one minute */ for (i = 0; i < 60; i++) { - // RAJA FIXME - // How can I make this work with the distributed server system!?!? - // pa_simple_new can take a server as its first argument, but each server can have multiple sessions active at any given time... - // This will involve reserving a range of ports (e.g. port 2000 and up), and setting PULSE_SERVER=tcp:<backend hostname>:<2000 + X11 display number> - // The pulseaudio server would then need to be manually started before TDE starts with something like these commands: - // pulseaudio -D --load="module-native-protocol-tcp listen=0.0.0.0 port=<2000 + X11 display number>" - // Then the first argument to pa_simple_new needs to use the same syntax; i.e. "tcp:node001.cluster90.local:2010" - char errcode; - char* remote_backend_hostname = raptor_sm_get_hostname_for_display(g_display_num); - char* ip = raptor_sm_get_ip_for_hostname(remote_backend_hostname, &errcode); - g_free(remote_backend_hostname); - g_snprintf(paserver_string, 255, "tcp:%s:%d", ip, (RAPTOR_SM_BASE_PULSEAUDIO_PORT + g_display_num)); - g_free(ip); - LOG(0, ("read_raw_audio_data: connecting to pulseaudio server with connection string %s\n", paserver_string)); - simple = pa_simple_new(paserver_string, "xrdp", PA_STREAM_RECORD, NULL, + simple = pa_simple_new(NULL, "xrdp", PA_STREAM_RECORD, NULL, "record", &samp_spec, NULL, NULL, &error); if (simple) |
||
f78715c6 | 2019-03-17 00:37:35 | Timothy Pearson |
Add statistics reporting |
||
M raptorsmiface/libraptorsmiface.c M raptorsmiface/libraptorsmiface.h M xrdp/xrdp_types.h |
||
raptorsmiface/libraptorsmiface.cdiff --git a/raptorsmiface/libraptorsmiface.c b/raptorsmiface/libraptorsmiface.c index cec1508..6900a63 100644 --- a/raptorsmiface/libraptorsmiface.c +++ b/raptorsmiface/libraptorsmiface.c @@ -23,6 +23,12 @@ #include "libraptorsmiface.h" +#define STATISTICS_SERVER_START_EVENT 0 +#define STATISTICS_SERVER_STOP_EVENT 1 +#define STATISTICS_NEW_CONNECTION_EVENT 2 +#define STATISTICS_CONNECTION_STATUS_EVENT 3 +#define STATISTICS_DISCONNECTION_EVENT 4 + //char *server = "localhost"; char *server = "freyja.starlink.edu"; char *user = "remotelab"; @@ -104,6 +110,7 @@ return 1; } + int display = raptor_sm_get_display_for_username(username); char* hostname = raptor_sm_get_hostname_for_username(username, false); pid_t serverpid = raptor_sm_get_pid_for_username(username, RAPTOR_SM_SERVER_PID_FIELD); if (serverpid >= 0) { @@ -138,12 +145,28 @@ free(safe_username); if (mysql_query_internal(conn, query)) { // Server error + free(hostname); free(query); mysql_close(conn); return 2; } else { free(query); + + // Insert connection information into the statistics database + char* safe_servername = get_mysql_escaped_string(conn, hostname); + char* safe_username = get_mysql_escaped_string(conn, username); + long long timestamp = time(NULL); + asprintf(&query, "INSERT INTO statistics (timestamp, eventtypeid, servername, display, typeid, username) VALUES ('%lld', '%d', '%s', '%d', '%d', '%s')", timestamp, STATISTICS_DISCONNECTION_EVENT, safe_servername, display, -1, safe_username); + free(safe_servername); + free(safe_username); + free(hostname); + if (mysql_query_internal(conn, query)) { + // Server error + dprint("Unable to insert data into statistics database! [%s]\n\r", mysql_error(conn)); + } + free(query); + mysql_close(conn); return 0; } @@ -265,6 +288,20 @@ } else { free(query); + + // Insert connection information into the statistics database + char* safe_servername = get_mysql_escaped_string(conn, bestserver); + char* safe_username = get_mysql_escaped_string(conn, username); + long long timestamp = time(NULL); + asprintf(&query, "INSERT INTO statistics (timestamp, eventtypeid, servername, display, typeid, username) VALUES ('%lld', '%d', '%s', '%d', '%d', '%s')", timestamp, STATISTICS_NEW_CONNECTION_EVENT, safe_servername, -1, SM_STATUS_ALLOCATED, safe_username); + free(safe_servername); + free(safe_username); + if (mysql_query_internal(conn, query)) { + // Server error + dprint("Unable to insert data into statistics database! [%s]\n\r", mysql_error(conn)); + } + free(query); + mysql_close(conn); return strdup(bestserver); } @@ -653,6 +690,22 @@ } else { free(query); + + // Insert connection information into the statistics database + char* current_server = raptor_sm_get_hostname_for_display(display); + char* safe_servername = get_mysql_escaped_string(conn, current_server); + char* safe_username = get_mysql_escaped_string(conn, username); + long long timestamp = time(NULL); + asprintf(&query, "INSERT INTO statistics (timestamp, eventtypeid, servername, display, typeid, username) VALUES ('%lld', '%d', '%s', '%d', '%d', '%s')", timestamp, STATISTICS_CONNECTION_STATUS_EVENT, safe_servername, display, SM_STATUS_RUNNING, safe_username); + free(safe_servername); + free(safe_username); + free(current_server); + if (mysql_query_internal(conn, query)) { + // Server error + dprint("Unable to insert data into statistics database! [%s]\n\r", mysql_error(conn)); + } + free(query); + mysql_close(conn); return 0; } @@ -724,6 +777,48 @@ mysql_free_result(res); mysql_close(conn); return -4; + } +} + +char* raptor_sm_get_username_for_display_and_hostname(int display, char* hostname) { + MYSQL_RES *res; + MYSQL_ROW row; + char* query; + + MYSQL *conn = connect_if_needed(); + if (!conn) { + return -1; + } + + char* safe_hostname = get_mysql_escaped_string(conn, hostname); + asprintf(&query, "SELECT username FROM sessions WHERE display='%d' AND servername='%s'", display, safe_hostname); + free(safe_hostname); + if (mysql_query_internal(conn, query)) { + // Server error + free(query); + mysql_close(conn); + return strdup(""); + } + else { + free(query); + res = mysql_store_result(conn); + while ((row = mysql_fetch_row(res)) != NULL) { + if (row[0]) { + char* ret = strdup(row[0]); + mysql_free_result(res); + mysql_close(conn); + return ret; + } + else { + mysql_free_result(res); + mysql_close(conn); + return strdup(""); + } + } + // Nothing in the DB + mysql_free_result(res); + mysql_close(conn); + return strdup(""); } } @@ -833,6 +928,24 @@ } else { free(query); + + // Insert connection information into the statistics database + char* hostname = raptor_sm_get_hostname_for_display(display); + char* username = raptor_sm_get_username_for_display_and_hostname(display, hostname); + char* safe_servername = get_mysql_escaped_string(conn, hostname); + char* safe_username = get_mysql_escaped_string(conn, username); + long long timestamp = time(NULL); + asprintf(&query, "INSERT INTO statistics (timestamp, eventtypeid, servername, display, typeid, username) VALUES ('%lld', '%d', '%s', '%d', '%d', '%s')", timestamp, STATISTICS_CONNECTION_STATUS_EVENT, safe_servername, display, state, safe_username); + free(safe_servername); + free(safe_username); + free(hostname); + free(username); + if (mysql_query_internal(conn, query)) { + // Server error + dprint("Unable to insert data into statistics database! [%s]\n\r", mysql_error(conn)); + } + free(query); + mysql_close(conn); return 0; } raptorsmiface/libraptorsmiface.hdiff --git a/raptorsmiface/libraptorsmiface.h b/raptorsmiface/libraptorsmiface.h index d0a12a2..b27110b 100644 --- a/raptorsmiface/libraptorsmiface.h +++ b/raptorsmiface/libraptorsmiface.h @@ -36,6 +36,7 @@ char* raptor_sm_wm_started(char* username, pid_t pid, char* dbfield); int raptor_sm_get_display_for_username(char* username); void raptor_sm_wait_for_pid_exit(char* username, pid_t pid); +char* raptor_sm_get_username_for_display_and_hostname(int display, char* hostname); void raptor_sm_session_terminated(char* username); void raptor_sm_wm_terminated(char* username);** Diff limit reached (max: 250 lines) ** |
||
5a87ceec | 2019-03-17 00:37:36 | Timothy Pearson |
Add additional statistics reporting |
||
M raptorsmiface/libraptorsmiface.c M raptorsmiface/libraptorsmiface.h M xrdp/xrdp.c |
||
** Diff limit reached (max: 250 lines) **
|
||
8ad89383 | 2019-03-17 00:37:36 | Timothy Pearson |
Add MySQL database skeleton file |
||
A database/mysql/remotelab_sm_database.sql |
||
** Diff limit reached (max: 250 lines) **
|
||
8817f19a | 2019-03-17 00:37:36 | Timothy Pearson |
Add database configuration options to main config file |
||
M raptorsmiface/libraptorsmiface.c M raptorsmiface/libraptorsmiface.h |
||
** Diff limit reached (max: 250 lines) **
|
||
ddbb6256 | 2019-03-17 00:38:20 | Timothy Pearson |
Fix non-root-user display server startup failure Transfer and clean up Kerberos ticket on login and logout Remove spurious debugging messages |
||
M instfiles/pam.d/xrdp-sesman M raptorsmiface/libraptorsmiface.c M sesman/env.c M xrdp/xrdp_login_wnd.c |
||
** Diff limit reached (max: 250 lines) **
|
||
8c49e119 | 2019-03-17 00:38:21 | Timothy Pearson |
Fix sporadic xrdp-sesman crash on session initiation Fix a number of memory leaks Fix access to freed memory Fix invalid function return values |
||
M raptorsmiface/libraptorsmiface.c M raptorsmiface/libraptorsmiface.h |
||
** Diff limit reached (max: 250 lines) **
|
||
d5783ccf | 2019-03-17 00:38:21 | Timothy Pearson |
Download installation files from correct locations Keep track of arbiter(s) in use per connection |
||
M raptorsmiface/libraptorsmiface.c M raptorsmiface/libraptorsmiface.h |
||
** Diff limit reached (max: 250 lines) **
|
||
c601678a | 2019-03-17 00:38:21 | Timothy Pearson |
Second part of prior commit |
||
M database/mysql/remotelab_sm_database.sql |
||
** Diff limit reached (max: 250 lines) **
|
||
ae59f8d0 | 2019-03-17 00:38:21 | Timothy Pearson |
Update for OpenSSL 1.1 |
||
M common/ssl_calls.c |
||
** Diff limit reached (max: 250 lines) **
|
||
600e0e5d | 2019-03-17 00:38:21 | Timothy Pearson |
Update sources to build on ppc64el |
||
A xorg/X11R7.6/libdrm-2.4.26.patch M xorg/X11R7.6/buildx.sh |
||
** Diff limit reached (max: 250 lines) **
|
||
e0e22542 | 2019-03-17 00:38:21 | Timothy Pearson |
Fix endianness checks on ppc64 |
||
M common/arch.h |
||
** Diff limit reached (max: 250 lines) **
|
||
426af3f5 | 2019-03-17 00:38:21 | Timothy Pearson |
Don't try connecting to remote node if preliminary node allocation has failed for any reason |
||
M sesman/session.c |
||
** Diff limit reached (max: 250 lines) **
|
||
c435c3e1 | 2019-03-17 00:38:21 | Timothy Pearson |
Add debug warning when maximum session limit is hit for a specified user group |
||
M raptorsmiface/libraptorsmiface.c |
||
** Diff limit reached (max: 250 lines) **
|
||
a5ac8875 | 2019-03-17 00:38:21 | Timothy Pearson |
Fix a few situations where process output was corrupted with existing uncleard buffer data This fixes session termination not being marked in the database |
||
M raptorsmiface/libraptorsmiface.c |
||
** Diff limit reached (max: 250 lines) **
|
||
77ce975b | 2019-03-17 00:38:21 | Timothy Pearson |
Fix a couple of additional ppc64 endianness / alignment issues |
||
A xorg/X11R7.6/xorg-server-1.9.3.patch M common/arch.h M xorg/X11R7.6/rdp/rdp.h |
||
** Diff limit reached (max: 250 lines) **
|
||
d609087e | 2019-03-17 00:38:21 | Timothy Pearson |
Work around GTK pixmaps (e.g. GIMP icons, etc) showing up as black squares |
||
M xorg/X11R7.6/rdp/rdpmain.c |
||
** Diff limit reached (max: 250 lines) **
|
||
05bf005b | 2019-03-17 00:38:21 | Timothy Pearson |
Update management network range |
||
M raptorsmiface/libraptorsmiface.h |
||
** Diff limit reached (max: 250 lines) **
|
||
84617302 | 2019-03-17 00:38:21 | Timothy Pearson |
Always show log during connection |
||
M xrdp/xrdp_wm.c |
||
** Diff limit reached (max: 250 lines) **
|
||
1fb6afc5 | 2019-03-17 00:38:21 | Timothy Pearson |
Disable SHM access between XUP and Xorg as they are not running on the same machine |
||
M sesman/session.c M xorg/X11R7.6/rdp/rdpup.c |
||
** Diff limit reached (max: 250 lines) **
|
||
5f6a7062 | 2019-03-17 00:38:21 | Timothy Pearson |
Fix crash when SHM not available Enhance debug logging of SHM related functions |
||
M common/os_calls.c M xup/xup.c |
||
** Diff limit reached (max: 250 lines) **
|