added a way to disconnect a session from within a session

This commit is contained in:
Jay Sorg 2011-07-07 09:27:43 -07:00
parent c5b1b0fe45
commit 0e5e50925c
2 changed files with 37 additions and 0 deletions

View File

@ -99,6 +99,10 @@ xrdp_mm_delete(struct xrdp_mm* self)
self->sesman_trans_up = 0; self->sesman_trans_up = 0;
list_delete(self->login_names); list_delete(self->login_names);
list_delete(self->login_values); list_delete(self->login_values);
if (self->dis_wo > 0)
{
g_delete_wait_obj(self->dis_wo);
}
g_free(self); g_free(self);
} }
@ -147,6 +151,10 @@ xrdp_mm_send_login(struct xrdp_mm* self)
xrdp_wm_log_msg(self->wm, "Error finding username and password"); xrdp_wm_log_msg(self->wm, "Error finding username and password");
return 1; return 1;
} }
else
{
g_strncpy(self->username, username, 255);
}
s = trans_get_out_s(self->sesman_trans, 8192); s = trans_get_out_s(self->sesman_trans, 8192);
s_push_layer(s, channel_hdr, 8); s_push_layer(s, channel_hdr, 8);
@ -658,6 +666,8 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
int display = 0; int display = 0;
int rv = 0; int rv = 0;
int index = 0; int index = 0;
int uid;
int gid;
char text[256]; char text[256];
char ip[256]; char ip[256];
char port[256]; char port[256];
@ -724,6 +734,17 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
} }
} }
} }
g_snprintf(text, 255, "xrdp_disconnect_display_%d", self->display);
self->dis_wo = g_create_wait_obj(text);
if (self->dis_wo > 0)
{
g_snprintf(text, 255, "/tmp/xrdp_disconnect_display_%d",
self->display);
if (g_getuser_info(self->username, &uid, &gid, 0, 0, 0) == 0)
{
g_chown(text, uid, gid);
}
}
} }
else else
{ {
@ -1009,6 +1030,11 @@ xrdp_mm_get_wait_objs(struct xrdp_mm* self,
{ {
trans_get_wait_objs(self->chan_trans, read_objs, rcount, timeout); trans_get_wait_objs(self->chan_trans, read_objs, rcount, timeout);
} }
if (self->dis_wo > 0)
{
read_objs[*rcount] = self->dis_wo;
(*rcount)++;
}
if (self->mod != 0) if (self->mod != 0)
{ {
if (self->mod->mod_get_wait_objs != 0) if (self->mod->mod_get_wait_objs != 0)
@ -1046,6 +1072,15 @@ xrdp_mm_check_wait_objs(struct xrdp_mm* self)
self->delete_chan_trans = 1; self->delete_chan_trans = 1;
} }
} }
if (self->dis_wo > 0)
{
if (g_is_wait_obj_set(self->dis_wo))
{
g_writeln("xrdp_mm_check_wait_objs: disconnecting per user request");
g_reset_wait_obj(self->dis_wo);
return 1;
}
}
if (self->mod != 0) if (self->mod != 0)
{ {
if (self->mod->mod_check_wait_objs != 0) if (self->mod->mod_check_wait_objs != 0)

View File

@ -191,6 +191,8 @@ struct xrdp_mm
struct trans* chan_trans; /* connection to chansrv */ struct trans* chan_trans; /* connection to chansrv */
int chan_trans_up; /* true once connected to chansrv */ int chan_trans_up; /* true once connected to chansrv */
int delete_chan_trans; /* boolean set when done with channel connection */ int delete_chan_trans; /* boolean set when done with channel connection */
tbus dis_wo;
char username[256];
}; };
struct xrdp_key_info struct xrdp_key_info