[Twisted-Python] Conch, getting the avatarId, session number, and terminal protocol instance of all connected users.

Jean-Paul Calderone exarkun at divmod.com
Sat Jul 4 13:16:48 EDT 2009


On Sat, 4 Jul 2009 02:11:36 -0700, asset <asset at impactdamage.com> wrote:
>Ive been at it for several days now trying to get at the username
>(avatarId), session id (SSHChannel session # I imagine), and terminal
>protocol instance (recvline.HistoricRecvLine) of my application's SSH
>terminal service's clients.  Specifically, I'm trying to expose these three
>things (for all connected users) to my terminal commands which are using
>the plugin system.
>
>I'm not considerably far off from this example for the setup,
>http://twistedmatrix.com/projects/conch/documentation/examples/demo_recvline
>.tac, minus the telnet support.
>
>For the life of me I can't seem to determine how best to approach this.
>Ive come as far as getting a list of the terminal recvline.HistoricRecvLine
>instances and then being able to manipulate the client terminals directly,
>but I need the usernames from the avatars and session id as well.
>
>I imagine this is a pretty common and simple thing, so I'm hoping that
>somebody can point me in the right direction.  Please help if you can.

The realm's requestAvatar is passed the avatarId:

http://twistedmatrix.com/trac/browser/trunk/twisted/conch/manhole_ssh.py#L82

See how this realm (which I assume is the one you're using, since it is the
one used by demo_recvline) passes the avatarId to its `userFactory´, but the
`TerminalUser´ which is the default `userFactory´ ignores it.

It seems like you want to provide an alternate `userFactory´ which saves the
avatarId passed to it.

For the session id, perhaps this information you can find on the connection
object.  See the API documentation:

http://twistedmatrix.com/documents/current/api/twisted.conch.ssh.connection.SSHConnection.html

Jean-Paul




More information about the Twisted-Python mailing list