|
|
|
@ -23,7 +23,8 @@
|
|
|
|
|
|
|
|
|
|
#include "libraptorsmiface.h"
|
|
|
|
|
|
|
|
|
|
char *server = "localhost";
|
|
|
|
|
//char *server = "localhost";
|
|
|
|
|
char *server = "freyja.starlink.edu";
|
|
|
|
|
char *user = "remotelab";
|
|
|
|
|
char *password = "rlpass123"; /* set me first */
|
|
|
|
|
char *database = "remotelab_sm";
|
|
|
|
@ -349,6 +350,39 @@ char* raptor_sm_get_hostname_for_username(char* username, bool create) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* raptor_sm_get_hostname_for_display(int display) {
|
|
|
|
|
MYSQL_RES *res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
char* query;
|
|
|
|
|
|
|
|
|
|
MYSQL *conn = connect_if_needed();
|
|
|
|
|
if (!conn) {
|
|
|
|
|
return strdup("SQLERR100");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asprintf(&query, "SELECT servername FROM sessions WHERE display='%d'", display);
|
|
|
|
|
if (mysql_query_internal(conn, query)) {
|
|
|
|
|
// Server error
|
|
|
|
|
free(query);
|
|
|
|
|
mysql_close(conn);
|
|
|
|
|
return strdup("SQLERR101");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
free(query);
|
|
|
|
|
res = mysql_store_result(conn);
|
|
|
|
|
while ((row = mysql_fetch_row(res)) != NULL) {
|
|
|
|
|
char* ret = strdup(row[0]);
|
|
|
|
|
mysql_free_result(res);
|
|
|
|
|
mysql_close(conn);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
// Nothing in the DB
|
|
|
|
|
mysql_free_result(res);
|
|
|
|
|
mysql_close(conn);
|
|
|
|
|
return strdup("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* raptor_sm_get_ip_for_username(char* username, bool create) {
|
|
|
|
|
char* hostname = raptor_sm_get_hostname_for_username(username, create);
|
|
|
|
|
char err;
|
|
|
|
@ -529,7 +563,7 @@ pid_t raptor_sm_run_remote_server(char* username, char *const argv[], char* dbfi
|
|
|
|
|
else {
|
|
|
|
|
asprintf(&command_string, "ssh root@%s \"su %s -c \'export DISPLAY=:%d && %s\' &> /dev/null & echo \\$!\"", ipaddr, username, display, origstr);
|
|
|
|
|
}
|
|
|
|
|
dprint("Running command %s...\n\r", command_string);
|
|
|
|
|
dprint("Running command %s...\n\r", command_string);
|
|
|
|
|
free(origstr);
|
|
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|