diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-05-24 15:51:25 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-05-24 15:51:25 -0500 |
commit | 9de6851c1974125821e10b8ea13c183d4d5dbf79 (patch) | |
tree | 28872d79a2b40dd5484c676fbf8d1f396a811900 | |
parent | f460ac5207077c708c41d3b65d0a2111660cabcf (diff) | |
download | xrdp-proprietary-9de6851c1974125821e10b8ea13c183d4d5dbf79.tar.gz xrdp-proprietary-9de6851c1974125821e10b8ea13c183d4d5dbf79.zip |
Add ability to recover somewhat from a dead master node
-rw-r--r-- | raptorsmiface/libraptorsmiface.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/raptorsmiface/libraptorsmiface.c b/raptorsmiface/libraptorsmiface.c index ead1fd06..7ea3de09 100644 --- a/raptorsmiface/libraptorsmiface.c +++ b/raptorsmiface/libraptorsmiface.c @@ -103,6 +103,35 @@ char raptor_sm_deallocate_session(char* username) { return 1; } + pid_t serverpid = raptor_sm_get_pid_for_username(username); + if (serverpid >= 0) { + // Verify existence of PID on remote server + dprint("Verifying process %d on %s...\n\r", serverpid, row[1]); + char* ip = raptor_sm_get_ip_for_hostname(row[1], 0); + char* command_string; + asprintf(&command_string, "ssh root@%s \'ps -p %d | grep %d\'", ip, serverpid, serverpid); + FILE *fp; + char output[1024]; + // Open the command for reading + fp = popen(command_string, "r"); + if (fp == NULL) { + mysql_close(conn); + return -1; + } + // Read the output a line at a time + fgets(output, sizeof(output)-1, fp); + // Close output + pclose(fp); + free(command_string); + free(ip); + dprint("...result was %s\n\r", output); + if (strcmp(output, "") != 0) { + mysql_free_result(res); + mysql_close(conn); + return 0; + } + } + // Remove the user from the system char* safe_username = get_mysql_escaped_string(conn, username); asprintf(&query, "DELETE FROM sessions WHERE username='%s'", safe_username); |