|
|
|
@ -184,6 +184,26 @@ char* get_group_for_user(char* username) {
|
|
|
|
|
return strdup(primarygroup->gr_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int raptor_sm_get_uid_for_user(char* username) {
|
|
|
|
|
struct passwd *pwd = calloc(1, sizeof(struct passwd));
|
|
|
|
|
if (pwd == NULL) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
size_t buffer_len = sysconf(_SC_GETPW_R_SIZE_MAX) * sizeof(char);
|
|
|
|
|
char *buffer = malloc(buffer_len);
|
|
|
|
|
if (buffer == NULL) {
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
getpwnam_r(username, pwd, buffer, buffer_len, &pwd);
|
|
|
|
|
if (pwd == NULL) {
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
uid_t uid = pwd->pw_uid;
|
|
|
|
|
free(buffer);
|
|
|
|
|
free(pwd);
|
|
|
|
|
return uid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char raptor_sm_deallocate_session(char* username) {
|
|
|
|
|
MYSQL_RES *res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
@ -227,6 +247,16 @@ char raptor_sm_deallocate_session(char* username) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef RAPTOR_SM_DISABLE_KERBEROS
|
|
|
|
|
char* command_string;
|
|
|
|
|
char* ip = raptor_sm_get_ip_for_hostname(hostname, 0);
|
|
|
|
|
asprintf(&command_string, "ssh root@%s \'rm -f /tmp/krb5cc_%d\'", ip, raptor_sm_get_uid_for_user(username));
|
|
|
|
|
dprint("Running command %s...\n\r", command_string);
|
|
|
|
|
system(command_string);
|
|
|
|
|
free(command_string);
|
|
|
|
|
free(ip);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
@ -682,11 +712,26 @@ pid_t raptor_sm_run_remote_server(char* username, char *const argv[], char* dbfi
|
|
|
|
|
}
|
|
|
|
|
char* origstr = command_string;
|
|
|
|
|
|
|
|
|
|
#ifndef RAPTOR_SM_DISABLE_KERBEROS
|
|
|
|
|
if (display >= 0) {
|
|
|
|
|
uid_t uid = raptor_sm_get_uid_for_user(username);
|
|
|
|
|
asprintf(&command_string, "rsync -a /tmp/krb5cc_%d root@%s:/tmp/krb5cc_%d", uid, ipaddr, uid);
|
|
|
|
|
dprint("Running command %s...\n\r", command_string);
|
|
|
|
|
system(command_string);
|
|
|
|
|
free(command_string);
|
|
|
|
|
asprintf(&command_string, "rm -f /tmp/krb5cc_%d", uid);
|
|
|
|
|
dprint("Running command %s...\n\r", command_string);
|
|
|
|
|
system(command_string);
|
|
|
|
|
free(command_string);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#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);
|
|
|
|
|
free(command_string);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|