[Xrdp-devel] Adding Session Deletion Functionality

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Xrdp-devel] Adding Session Deletion Functionality

Murtaza Munaim
Hey guys. So I was looking at the code for xrdp. I know I need to have
the connection between sesman and xrdp be maintained for the entire
session, and then have sesman kill the session when xrdp sees a user
disconnect. I could go looking through all the code, but I was just
wondering if someone knew where in the code xrdp connects/disconnects
from sesman. Thanks

-Murtaza


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

jsorg71
> Hey guys. So I was looking at the code for xrdp. I know I need to have the
> connection between sesman and xrdp be maintained for the entire session, and
> then have sesman kill the session when xrdp sees a user disconnect. I could
> go looking through all the code, but I was just wondering if someone knew
> where in the code xrdp connects/disconnects from sesman. Thanks

Hi Murtaza,

The connection goes up in
file xrdp/xrdp_mm.c
function xrdp_mm_connect

It uses an object called struct trans to talk to sesman.
trans_connect is the call to do the connect.

The connection goes down in xrdp_mm_process_login_response
self->delete_sesman_trans = 1; will cause the disconnect later.

Then on the sesman side, I have to look more.

Jay

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Murtaza Munaim
On 6/23/2010 9:42 AM, Jay Sorg wrote:

>> Hey guys. So I was looking at the code for xrdp. I know I need to have the
>> connection between sesman and xrdp be maintained for the entire session, and
>> then have sesman kill the session when xrdp sees a user disconnect. I could
>> go looking through all the code, but I was just wondering if someone knew
>> where in the code xrdp connects/disconnects from sesman. Thanks
>
> Hi Murtaza,
>
> The connection goes up in
> file xrdp/xrdp_mm.c
> function xrdp_mm_connect
>
> It uses an object called struct trans to talk to sesman.
> trans_connect is the call to do the connect.
>
> The connection goes down in xrdp_mm_process_login_response
> self->delete_sesman_trans = 1; will cause the disconnect later.
>
> Then on the sesman side, I have to look more.
>
> Jay
Hey Jay. Ive been looking at the code, and I can't find the struct trans
anywhere, nor trans_connect call in the xrdp_mm.c file. Is this updated
code that you are referring to? The version I have is xrdp-0.4.1.

-Murtaza


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

jsorg71
> Hey Jay. Ive been looking at the code, and I can't find the struct trans
> anywhere, nor trans_connect call in the xrdp_mm.c file. Is this updated code
> that you are referring to? The version I have is xrdp-0.4.1.

Get the CVS version.
I think we should do this first in CVS, then merge into branches if needed.

Jay

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Murtaza Munaim
On 6/26/2010 9:01 AM, Jay Sorg wrote:
>> Hey Jay. Ive been looking at the code, and I can't find the struct trans
>> anywhere, nor trans_connect call in the xrdp_mm.c file. Is this updated code
>> that you are referring to? The version I have is xrdp-0.4.1.
>
> Get the CVS version.
> I think we should do this first in CVS, then merge into branches if needed.
>
> Jay

Hey Jay. So I was thinking on how to implement this, and I had an idea
that might make implementing it a bit easier. Instead of having the
connection between the two remain the entire time, just add a parameter
that is sent to the sesman stream which states what type of information
will be sent. If it is say, 0, then it is a regular xrdp login
connection. However, if it is say, 1, it is a disconnect call to sesman.
This way, when a disconnects happens on the xrdp server, the xrdp server
will create a new connection with sesman, relay that information, and
close the connection again.

What do you think of this?

-Murtaza


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Murtaza Munaim
In reply to this post by jsorg71
On 6/23/2010 9:42 AM, Jay Sorg wrote:

>> Hey guys. So I was looking at the code for xrdp. I know I need to have the
>> connection between sesman and xrdp be maintained for the entire session, and
>> then have sesman kill the session when xrdp sees a user disconnect. I could
>> go looking through all the code, but I was just wondering if someone knew
>> where in the code xrdp connects/disconnects from sesman. Thanks
>
> Hi Murtaza,
>
> The connection goes up in
> file xrdp/xrdp_mm.c
> function xrdp_mm_connect
>
> It uses an object called struct trans to talk to sesman.
> trans_connect is the call to do the connect.
>
> The connection goes down in xrdp_mm_process_login_response
> self->delete_sesman_trans = 1; will cause the disconnect later.
>
> Then on the sesman side, I have to look more.
>
> Jay
Hey Jay. Let me know what you remember/find from the sesman side. Also,
the enviornment I was running xrdp before was using xrdp-0.4.0~dfsg as
the main xrdp server. I downloaded the cvs version of xrdp, and did the
standard make && make install and it worked fine, the compiling and
installing at least. Then when I rdesktop'ed like I usually would have.
As it was connecting, it would get to "connecting to 127.0.0.1 5910".
Then I would get an error - problem connecting. Is there a debug or
verbose mode to xrdp or something of the like? What could be different
between the two version to break it?

-Murtaza


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Murtaza Munaim
On 6/29/2010 12:00 AM, Murtaza Munaim wrote:

> On 6/28/2010 8:19 PM, Robert Seward wrote:
>> On Mon, Jun 28, 2010 at 5:46 PM, Murtaza Munaim<[hidden email]> wrote:
>>> On 6/23/2010 9:42 AM, Jay Sorg wrote:
>>>>>
>>>>> Hey guys. So I was looking at the code for xrdp. I know I need to have
>>>>> the
>>>>> connection between sesman and xrdp be maintained for the entire
>>>>> session,
>>>>> and
>>>>> then have sesman kill the session when xrdp sees a user disconnect. I
>>>>> could
>>>>> go looking through all the code, but I was just wondering if
>>>>> someone knew
>>>>> where in the code xrdp connects/disconnects from sesman. Thanks
>>>>
>>>> Hi Murtaza,
>>>>
>>>> The connection goes up in
>>>> file xrdp/xrdp_mm.c
>>>> function xrdp_mm_connect
>>>>
>>>> It uses an object called struct trans to talk to sesman.
>>>> trans_connect is the call to do the connect.
>>>>
>>>> The connection goes down in xrdp_mm_process_login_response
>>>> self->delete_sesman_trans = 1; will cause the disconnect later.
>>>>
>>>> Then on the sesman side, I have to look more.
>>>>
>>>> Jay
>>>
>>> Hey Jay. Let me know what you remember/find from the sesman side.
>>> Also, the
>>> enviornment I was running xrdp before was using xrdp-0.4.0~dfsg as
>>> the main
>>> xrdp server. I downloaded the cvs version of xrdp, and did the
>>> standard make
>>> && make install and it worked fine, the compiling and installing at
>>> least.
>>> Then when I rdesktop'ed like I usually would have. As it was
>>> connecting, it
>>> would get to "connecting to 127.0.0.1 5910". Then I would get an error -
>>> problem connecting. Is there a debug or verbose mode to xrdp or
>>> something of
>>> the like? What could be different between the two version to break it?
>>>
>>> -Murtaza
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> This SF.net email is sponsored by Sprint
>>> What will you do first with EVO, the first 4G phone?
>>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>>> _______________________________________________
>>> xrdp-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/xrdp-devel
>>
>> Hey Murtaza,
>>
>> I don't know if you are interested, but I did pretty much want you are
>> trying to do. However, the changes were done to xrdp 0.4.1, and there
>> are a number of other changes that I made that you may or may not
>> want.
>>
>> I haven't had time to try to submit all the patches against the latest
>> CVS, but you can take what I have if you want.
>>
>> Robert
> Robert,
>
> Could you briefly summarize the changes you made?
>
> And send me a tarball of your patches? That would be awesome. Thanks
>
> -Murtaza
>
Hey Guys.

Robert: If you have time, could you send me the patches you have written
so I can see what you did? Thanks a bunch

Jay: I had a question about how sesman works. So I see that sesman has
two version of scp(Sesman Control Protocol). I was wondering why that
is. Also, as mentioned in the old idea about communication from xrdp to
sesman, I have a thought on that. I see that sesman keeps a list of
disconnected sessions from a particular user. To add this functionality
of session deletion, would it be cleaner to instead, if the option is
enabled, kill any sessions with sesman the moment that a disconnected
session is added to sesman. That way, everytime a disconnected session
is added, the session is killed automatically. Would this work? And to
kill the particular session, would I use the session_kill function in
session.c? Could this also be extended to a timeout feature being added
so that when a disconnected session is added to the list, if it has a
particular time, then I kill that as well.

Thanks a lot guys.

-Murtaza


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Robert Seward-2
On Wed, Jun 30, 2010 at 1:20 PM, Murtaza Munaim <[hidden email]> wrote:

> On 6/29/2010 12:00 AM, Murtaza Munaim wrote:
>>
>> On 6/28/2010 8:19 PM, Robert Seward wrote:
>>>
>>> On Mon, Jun 28, 2010 at 5:46 PM, Murtaza Munaim<[hidden email]> wrote:
>>>>
>>>> On 6/23/2010 9:42 AM, Jay Sorg wrote:
>>>>>>
>>>>>> Hey guys. So I was looking at the code for xrdp. I know I need to have
>>>>>> the
>>>>>> connection between sesman and xrdp be maintained for the entire
>>>>>> session,
>>>>>> and
>>>>>> then have sesman kill the session when xrdp sees a user disconnect. I
>>>>>> could
>>>>>> go looking through all the code, but I was just wondering if
>>>>>> someone knew
>>>>>> where in the code xrdp connects/disconnects from sesman. Thanks
>>>>>
>>>>> Hi Murtaza,
>>>>>
>>>>> The connection goes up in
>>>>> file xrdp/xrdp_mm.c
>>>>> function xrdp_mm_connect
>>>>>
>>>>> It uses an object called struct trans to talk to sesman.
>>>>> trans_connect is the call to do the connect.
>>>>>
>>>>> The connection goes down in xrdp_mm_process_login_response
>>>>> self->delete_sesman_trans = 1; will cause the disconnect later.
>>>>>
>>>>> Then on the sesman side, I have to look more.
>>>>>
>>>>> Jay
>>>>
>>>> Hey Jay. Let me know what you remember/find from the sesman side.
>>>> Also, the
>>>> enviornment I was running xrdp before was using xrdp-0.4.0~dfsg as
>>>> the main
>>>> xrdp server. I downloaded the cvs version of xrdp, and did the
>>>> standard make
>>>> && make install and it worked fine, the compiling and installing at
>>>> least.
>>>> Then when I rdesktop'ed like I usually would have. As it was
>>>> connecting, it
>>>> would get to "connecting to 127.0.0.1 5910". Then I would get an error -
>>>> problem connecting. Is there a debug or verbose mode to xrdp or
>>>> something of
>>>> the like? What could be different between the two version to break it?
>>>>
>>>> -Murtaza
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>>
>>>> This SF.net email is sponsored by Sprint
>>>> What will you do first with EVO, the first 4G phone?
>>>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>>>> _______________________________________________
>>>> xrdp-devel mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/xrdp-devel
>>>
>>> Hey Murtaza,
>>>
>>> I don't know if you are interested, but I did pretty much want you are
>>> trying to do. However, the changes were done to xrdp 0.4.1, and there
>>> are a number of other changes that I made that you may or may not
>>> want.
>>>
>>> I haven't had time to try to submit all the patches against the latest
>>> CVS, but you can take what I have if you want.
>>>
>>> Robert
>>
>> Robert,
>>
>> Could you briefly summarize the changes you made?
>>
>> And send me a tarball of your patches? That would be awesome. Thanks
>>
>> -Murtaza
>>
>
> Hey Guys.
>
> Robert: If you have time, could you send me the patches you have written so
> I can see what you did? Thanks a bunch
Attached is the tar file.

Here are the changes (as best as I can tell - I have been hacking on
this for a while, so my memory is a bit dim on some of it):

- Optionally disconnect a session after a specified idle time (idle
time means no input from the client).  Controlled by the
'max_idle_time' global option in xrdp.ini.
- Make the port over which xrdp and sesman communicate configurable.
- Limit the number of sessions that a user can have active at one
time.  Controlled by the 'MaxSessionsPerUser' option in sesman.ini
under 'Sessions'.
- Add an option to allow/disallow sharing of a session by multiple
logins from the same user.  Controlled by the 'AllowSharing' option in
sesman.ini under 'Sessions'.
- Add a minimum X server color depth.  Certain programs (notably
Firefox) don't work with a 8 bpp.  However, I wanted to use 8 bpp on
the RDP side for bandwidth efficiency.  VNC will do the translation
from one color depth to another.  This option is controlled by the
'MinServerDepth' option in sesman.ini under 'Xvnc'.
- Added options to control the ports used for VNC.  These are
controlled by the options 'MinDisplay' and 'MaxDisplay' in sesman.ini
under 'Globals'.
- Allow the RDP client to use 8 bit unicode.
- Do conversions of text and rectangles to bitmaps.  One of these is
controlled by the client capability, but the other is hardcoded.  I
was having a problem with a particularly crippled client, and the only
way to make it work was to basically only send bitmaps.  This only
effects the startup screen.  However, the code I wrote doesn't handle
large text - it makes the bitmap too large, which causes nothing to be
sent to the client.
- Because the above, I changed the checks on bitmap size to be a
little more tolerant (but still OK in RDP).
- I had problems with the child VNC/X-server processes not being
killed reliably, so I changed things a bit to make that work better.
The original xrdp had a separate program that just babysat those child
processes.  I made it to where that program isn't necessary.
- Fixed a problem where xrdp would go into an infinite loop on certain
malformed input.
- If the client screen width or height is zero, shove in a width and
height that is acceptable.
- Print the IP address of bad logins in the sesman log file.
- Redid locking in sesman a little.  It looked to me like there were
some conditions that wouldn't work, so I fixed it.
- I vaguely recall I had problems with sesman not waiting properly for
the X server to start, so I changed how it waits a bit.
- I took out the login window - I only allow auto login.  This should
probably be configurable.

I hope this helps.

Robert

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

xrdp-0.4.1-hacked.tar.gz (333K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Murtaza Munaim
On 6/30/2010 10:12 PM, Robert Seward wrote:

> On Wed, Jun 30, 2010 at 1:20 PM, Murtaza Munaim<[hidden email]>  wrote:
>> On 6/29/2010 12:00 AM, Murtaza Munaim wrote:
>>>
>>> On 6/28/2010 8:19 PM, Robert Seward wrote:
>>>>
>>>> On Mon, Jun 28, 2010 at 5:46 PM, Murtaza Munaim<[hidden email]>  wrote:
>>>>>
>>>>> On 6/23/2010 9:42 AM, Jay Sorg wrote:
>>>>>>>
>>>>>>> Hey guys. So I was looking at the code for xrdp. I know I need to have
>>>>>>> the
>>>>>>> connection between sesman and xrdp be maintained for the entire
>>>>>>> session,
>>>>>>> and
>>>>>>> then have sesman kill the session when xrdp sees a user disconnect. I
>>>>>>> could
>>>>>>> go looking through all the code, but I was just wondering if
>>>>>>> someone knew
>>>>>>> where in the code xrdp connects/disconnects from sesman. Thanks
>>>>>>
>>>>>> Hi Murtaza,
>>>>>>
>>>>>> The connection goes up in
>>>>>> file xrdp/xrdp_mm.c
>>>>>> function xrdp_mm_connect
>>>>>>
>>>>>> It uses an object called struct trans to talk to sesman.
>>>>>> trans_connect is the call to do the connect.
>>>>>>
>>>>>> The connection goes down in xrdp_mm_process_login_response
>>>>>> self->delete_sesman_trans = 1; will cause the disconnect later.
>>>>>>
>>>>>> Then on the sesman side, I have to look more.
>>>>>>
>>>>>> Jay
>>>>>
>>>>> Hey Jay. Let me know what you remember/find from the sesman side.
>>>>> Also, the
>>>>> enviornment I was running xrdp before was using xrdp-0.4.0~dfsg as
>>>>> the main
>>>>> xrdp server. I downloaded the cvs version of xrdp, and did the
>>>>> standard make
>>>>> &&  make install and it worked fine, the compiling and installing at
>>>>> least.
>>>>> Then when I rdesktop'ed like I usually would have. As it was
>>>>> connecting, it
>>>>> would get to "connecting to 127.0.0.1 5910". Then I would get an error -
>>>>> problem connecting. Is there a debug or verbose mode to xrdp or
>>>>> something of
>>>>> the like? What could be different between the two version to break it?
>>>>>
>>>>> -Murtaza
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>>
>>>>> This SF.net email is sponsored by Sprint
>>>>> What will you do first with EVO, the first 4G phone?
>>>>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>>>>> _______________________________________________
>>>>> xrdp-devel mailing list
>>>>> [hidden email]
>>>>> https://lists.sourceforge.net/lists/listinfo/xrdp-devel
>>>>
>>>> Hey Murtaza,
>>>>
>>>> I don't know if you are interested, but I did pretty much want you are
>>>> trying to do. However, the changes were done to xrdp 0.4.1, and there
>>>> are a number of other changes that I made that you may or may not
>>>> want.
>>>>
>>>> I haven't had time to try to submit all the patches against the latest
>>>> CVS, but you can take what I have if you want.
>>>>
>>>> Robert
>>>
>>> Robert,
>>>
>>> Could you briefly summarize the changes you made?
>>>
>>> And send me a tarball of your patches? That would be awesome. Thanks
>>>
>>> -Murtaza
>>>
>>
>> Hey Guys.
>>
>> Robert: If you have time, could you send me the patches you have written so
>> I can see what you did? Thanks a bunch
>
> Attached is the tar file.
>
> Here are the changes (as best as I can tell - I have been hacking on
> this for a while, so my memory is a bit dim on some of it):
>
> - Optionally disconnect a session after a specified idle time (idle
> time means no input from the client).  Controlled by the
> 'max_idle_time' global option in xrdp.ini.
> - Make the port over which xrdp and sesman communicate configurable.
> - Limit the number of sessions that a user can have active at one
> time.  Controlled by the 'MaxSessionsPerUser' option in sesman.ini
> under 'Sessions'.
> - Add an option to allow/disallow sharing of a session by multiple
> logins from the same user.  Controlled by the 'AllowSharing' option in
> sesman.ini under 'Sessions'.
> - Add a minimum X server color depth.  Certain programs (notably
> Firefox) don't work with a 8 bpp.  However, I wanted to use 8 bpp on
> the RDP side for bandwidth efficiency.  VNC will do the translation
> from one color depth to another.  This option is controlled by the
> 'MinServerDepth' option in sesman.ini under 'Xvnc'.
> - Added options to control the ports used for VNC.  These are
> controlled by the options 'MinDisplay' and 'MaxDisplay' in sesman.ini
> under 'Globals'.
> - Allow the RDP client to use 8 bit unicode.
> - Do conversions of text and rectangles to bitmaps.  One of these is
> controlled by the client capability, but the other is hardcoded.  I
> was having a problem with a particularly crippled client, and the only
> way to make it work was to basically only send bitmaps.  This only
> effects the startup screen.  However, the code I wrote doesn't handle
> large text - it makes the bitmap too large, which causes nothing to be
> sent to the client.
> - Because the above, I changed the checks on bitmap size to be a
> little more tolerant (but still OK in RDP).
> - I had problems with the child VNC/X-server processes not being
> killed reliably, so I changed things a bit to make that work better.
> The original xrdp had a separate program that just babysat those child
> processes.  I made it to where that program isn't necessary.
> - Fixed a problem where xrdp would go into an infinite loop on certain
> malformed input.
> - If the client screen width or height is zero, shove in a width and
> height that is acceptable.
> - Print the IP address of bad logins in the sesman log file.
> - Redid locking in sesman a little.  It looked to me like there were
> some conditions that wouldn't work, so I fixed it.
> - I vaguely recall I had problems with sesman not waiting properly for
> the X server to start, so I changed how it waits a bit.
> - I took out the login window - I only allow auto login.  This should
> probably be configurable.
>
> I hope this helps.
>
> Robert
Yeah this will really help. I could probably look at the code and figure
it out, but I wanted to know how you added the disconnect functionality
in the first place, like what did you do? I know xrdp can tell when the
session is disconnected, using the function libxrdp_disconnect, and
sesman has the capability to kill a session using
sig_sesman_session_end, but how did you relay this information to one
another? Could you maybe point out in the code what you did?

Thanks alot.

-Murtaza


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Xrdp-devel] Adding Session Deletion Functionality

Robert Seward-2
On Wed, Jun 30, 2010 at 11:50 PM, Murtaza Munaim <[hidden email]> wrote:

> On 6/30/2010 10:12 PM, Robert Seward wrote:
>>
>> On Wed, Jun 30, 2010 at 1:20 PM, Murtaza Munaim<[hidden email]>  wrote:
>>>
>>> On 6/29/2010 12:00 AM, Murtaza Munaim wrote:
>>>>
>>>> On 6/28/2010 8:19 PM, Robert Seward wrote:
>>>>>
>>>>> On Mon, Jun 28, 2010 at 5:46 PM, Murtaza Munaim<[hidden email]>
>>>>>  wrote:
>>>>>>
>>>>>> On 6/23/2010 9:42 AM, Jay Sorg wrote:
>>>>>>>>
>>>>>>>> Hey guys. So I was looking at the code for xrdp. I know I need to
>>>>>>>> have
>>>>>>>> the
>>>>>>>> connection between sesman and xrdp be maintained for the entire
>>>>>>>> session,
>>>>>>>> and
>>>>>>>> then have sesman kill the session when xrdp sees a user disconnect.
>>>>>>>> I
>>>>>>>> could
>>>>>>>> go looking through all the code, but I was just wondering if
>>>>>>>> someone knew
>>>>>>>> where in the code xrdp connects/disconnects from sesman. Thanks
>>>>>>>
>>>>>>> Hi Murtaza,
>>>>>>>
>>>>>>> The connection goes up in
>>>>>>> file xrdp/xrdp_mm.c
>>>>>>> function xrdp_mm_connect
>>>>>>>
>>>>>>> It uses an object called struct trans to talk to sesman.
>>>>>>> trans_connect is the call to do the connect.
>>>>>>>
>>>>>>> The connection goes down in xrdp_mm_process_login_response
>>>>>>> self->delete_sesman_trans = 1; will cause the disconnect later.
>>>>>>>
>>>>>>> Then on the sesman side, I have to look more.
>>>>>>>
>>>>>>> Jay
>>>>>>
>>>>>> Hey Jay. Let me know what you remember/find from the sesman side.
>>>>>> Also, the
>>>>>> enviornment I was running xrdp before was using xrdp-0.4.0~dfsg as
>>>>>> the main
>>>>>> xrdp server. I downloaded the cvs version of xrdp, and did the
>>>>>> standard make
>>>>>> &&  make install and it worked fine, the compiling and installing at
>>>>>> least.
>>>>>> Then when I rdesktop'ed like I usually would have. As it was
>>>>>> connecting, it
>>>>>> would get to "connecting to 127.0.0.1 5910". Then I would get an error
>>>>>> -
>>>>>> problem connecting. Is there a debug or verbose mode to xrdp or
>>>>>> something of
>>>>>> the like? What could be different between the two version to break it?
>>>>>>
>>>>>> -Murtaza
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>>
>>>>>> This SF.net email is sponsored by Sprint
>>>>>> What will you do first with EVO, the first 4G phone?
>>>>>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>>>>>> _______________________________________________
>>>>>> xrdp-devel mailing list
>>>>>> [hidden email]
>>>>>> https://lists.sourceforge.net/lists/listinfo/xrdp-devel
>>>>>
>>>>> Hey Murtaza,
>>>>>
>>>>> I don't know if you are interested, but I did pretty much want you are
>>>>> trying to do. However, the changes were done to xrdp 0.4.1, and there
>>>>> are a number of other changes that I made that you may or may not
>>>>> want.
>>>>>
>>>>> I haven't had time to try to submit all the patches against the latest
>>>>> CVS, but you can take what I have if you want.
>>>>>
>>>>> Robert
>>>>
>>>> Robert,
>>>>
>>>> Could you briefly summarize the changes you made?
>>>>
>>>> And send me a tarball of your patches? That would be awesome. Thanks
>>>>
>>>> -Murtaza
>>>>
>>>
>>> Hey Guys.
>>>
>>> Robert: If you have time, could you send me the patches you have written
>>> so
>>> I can see what you did? Thanks a bunch
>>
>> Attached is the tar file.
>>
>> Here are the changes (as best as I can tell - I have been hacking on
>> this for a while, so my memory is a bit dim on some of it):
>>
>> - Optionally disconnect a session after a specified idle time (idle
>> time means no input from the client).  Controlled by the
>> 'max_idle_time' global option in xrdp.ini.
>> - Make the port over which xrdp and sesman communicate configurable.
>> - Limit the number of sessions that a user can have active at one
>> time.  Controlled by the 'MaxSessionsPerUser' option in sesman.ini
>> under 'Sessions'.
>> - Add an option to allow/disallow sharing of a session by multiple
>> logins from the same user.  Controlled by the 'AllowSharing' option in
>> sesman.ini under 'Sessions'.
>> - Add a minimum X server color depth.  Certain programs (notably
>> Firefox) don't work with a 8 bpp.  However, I wanted to use 8 bpp on
>> the RDP side for bandwidth efficiency.  VNC will do the translation
>> from one color depth to another.  This option is controlled by the
>> 'MinServerDepth' option in sesman.ini under 'Xvnc'.
>> - Added options to control the ports used for VNC.  These are
>> controlled by the options 'MinDisplay' and 'MaxDisplay' in sesman.ini
>> under 'Globals'.
>> - Allow the RDP client to use 8 bit unicode.
>> - Do conversions of text and rectangles to bitmaps.  One of these is
>> controlled by the client capability, but the other is hardcoded.  I
>> was having a problem with a particularly crippled client, and the only
>> way to make it work was to basically only send bitmaps.  This only
>> effects the startup screen.  However, the code I wrote doesn't handle
>> large text - it makes the bitmap too large, which causes nothing to be
>> sent to the client.
>> - Because the above, I changed the checks on bitmap size to be a
>> little more tolerant (but still OK in RDP).
>> - I had problems with the child VNC/X-server processes not being
>> killed reliably, so I changed things a bit to make that work better.
>> The original xrdp had a separate program that just babysat those child
>> processes.  I made it to where that program isn't necessary.
>> - Fixed a problem where xrdp would go into an infinite loop on certain
>> malformed input.
>> - If the client screen width or height is zero, shove in a width and
>> height that is acceptable.
>> - Print the IP address of bad logins in the sesman log file.
>> - Redid locking in sesman a little.  It looked to me like there were
>> some conditions that wouldn't work, so I fixed it.
>> - I vaguely recall I had problems with sesman not waiting properly for
>> the X server to start, so I changed how it waits a bit.
>> - I took out the login window - I only allow auto login.  This should
>> probably be configurable.
>>
>> I hope this helps.
>>
>> Robert
>
> Yeah this will really help. I could probably look at the code and figure it
> out, but I wanted to know how you added the disconnect functionality in the
> first place, like what did you do? I know xrdp can tell when the session is
> disconnected, using the function libxrdp_disconnect, and sesman has the
> capability to kill a session using sig_sesman_session_end, but how did you
> relay this information to one another? Could you maybe point out in the code
> what you did?

Sorry for the late response - the 4th of July weekend in the States.

As you may know, a VNC/X server session is started by xrdp sending a
message to sesman.  Once the session has started, sesman sends a
message back to xrdp.

I enhanced this messaging a bit.  In the original, there was a code
that was being sent that was always zero.  If you look in
xrdp_mm_send_msg() (was xrdp_mm_send_login() in the original code),
you will see that the code can now be one of three values.  These
three values are the different commands that can be sent - start,
disconnect, and terminate.

If you look at xrdp_process_main_loop() in xrdp_process.c, you will
see where the code sends the disconnect command to sesman.  It calls
xrdp_mm_connect() with a SCP_CMD_TYPE_DISCONNECT command.  The code
around there is a bit tricky, as we only want to send a disconnect if
sesman actually got something running.  Also, if we told sesman to
start a session, and it hasn't responded yet, and the client drops the
connection, we need to wait for the response from sesman before
possibly sending the disconnect.

On the sesman side, look at scp_v0_process() in scp_v0.c to see how the
code processes the different commands.  Note that I enhanced the messaging
a bit to send the display that needs to be disconnected.  Once a display
has zero connections and the configuration says to kill disconnected
displays, then the code will kill the child processes associated with that
display.

Robert

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
xrdp-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xrdp-devel