summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-05-24 15:51:25 -0500
committerTimothy Pearson <tpearson@raptorengineering.com>2019-03-04 08:04:29 -0600
commitcf13a16ce2d39dcc300edded6a5b5d8023744de7 (patch)
tree82ef2c4e0752731594664c579e12c4dfee6b0dd1
parent7b7a6adb718e91c6f721b1e057405ab0eafd8b60 (diff)
downloadxrdp-proprietary-cf13a16ce2d39dcc300edded6a5b5d8023744de7.tar.gz
xrdp-proprietary-cf13a16ce2d39dcc300edded6a5b5d8023744de7.zip
Add ability to recover somewhat from a dead master node
-rw-r--r--raptorsmiface/libraptorsmiface.c29
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);