connectors.tunnel_dispatcher
Provides a stdin/stdout based protocol to safely dispatch commands and return their results over any connection that forwards both stdin/stdout, as well as some other needed remote system related utilities.
class tunnel_dispatcher.RemoteOSError
tunnel_dispatcher.RemoteOSError
An exception type for remote OSErrors.
class tunnel_dispatcher.Connection
tunnel_dispatcher.Connection
Represents a connection to this dispatcher via an input and output buffer.
def Connection.flush()
Connection.flush()
Flushes the output buffer.
def Connection.read()
Connection.read()
Reads exactly the given amount of bytes.
def Connection.write()
Connection.write()
Writes exactly the given amount of bytes from data.
def Connection.write_packet()
Connection.write_packet()
Writes the given packet.
class tunnel_dispatcher.PacketOk
tunnel_dispatcher.PacketOk
This packet is used by some requests as a generic successful status indicator.
class tunnel_dispatcher.PacketAck
tunnel_dispatcher.PacketAck
This packet is used to acknowledge a previous PacketCheckAlive packet.
class tunnel_dispatcher.PacketCheckAlive
tunnel_dispatcher.PacketCheckAlive
This packet is used to check whether a connection is alive. The receiver must answer with PacketAck immediately.
def PacketCheckAlive.handle()
PacketCheckAlive.handle()
Responds with PacketAck.
class tunnel_dispatcher.PacketExit
tunnel_dispatcher.PacketExit
This packet is used to signal the server to close the connection and end the dispatcher.
def PacketExit.handle()
PacketExit.handle()
Signals the connection to close.
class tunnel_dispatcher.PacketOSError
tunnel_dispatcher.PacketOSError
This packet is sent when an OSError occurs.
class tunnel_dispatcher.PacketInvalidField
tunnel_dispatcher.PacketInvalidField
This packet is used when an invalid value was given in a previous packet.
class tunnel_dispatcher.PacketProcessCompleted
tunnel_dispatcher.PacketProcessCompleted
This packet is used to return the results of a process.
class tunnel_dispatcher.PacketProcessError
tunnel_dispatcher.PacketProcessError
This packet is used to indicate an error when running a process or when running the preexec_fn.
class tunnel_dispatcher.PacketProcessRun
tunnel_dispatcher.PacketProcessRun
This packet is used to run a process.
def PacketProcessRun.handle()
PacketProcessRun.handle()
Runs the requested command.
class tunnel_dispatcher.PacketStatResult
tunnel_dispatcher.PacketStatResult
This packet is used to return the results of a stat packet.
class tunnel_dispatcher.PacketStat
tunnel_dispatcher.PacketStat
This packet is used to retrieve information about a file or directory.
def PacketStat.handle()
PacketStat.handle()
Stats the requested path.
class tunnel_dispatcher.PacketResolveResult
tunnel_dispatcher.PacketResolveResult
This packet is used to return the results of a resolve packet.
class tunnel_dispatcher.PacketResolveUser
tunnel_dispatcher.PacketResolveUser
This packet is used to canonicalize a user name / uid and to ensure it exists. If None is given, it queries the current user.
def PacketResolveUser.handle()
PacketResolveUser.handle()
Resolves the requested user.
class tunnel_dispatcher.PacketResolveGroup
tunnel_dispatcher.PacketResolveGroup
This packet is used to canonicalize a group name / gid and to ensure it exists. If None is given, it queries the current group.
def PacketResolveGroup.handle()
PacketResolveGroup.handle()
Resolves the requested group.
class tunnel_dispatcher.PacketUpload
tunnel_dispatcher.PacketUpload
This packet is used to upload the given content to the remote and save it as a file. Overwrites existing files. Responds with PacketOk if saving was successful, or PacketInvalidField if any field contained an invalid value.
def PacketUpload.handle()
PacketUpload.handle()
Saves the content under the given path.
class tunnel_dispatcher.PacketDownloadResult
tunnel_dispatcher.PacketDownloadResult
This packet is used to return the content of a file.
class tunnel_dispatcher.PacketDownload
tunnel_dispatcher.PacketDownload
This packet is used to download the contents of a given file. Responds with PacketDownloadResult if reading was successful, or PacketInvalidField if any field contained an invalid value.
def PacketDownload.handle()
PacketDownload.handle()
Reads the file.
class tunnel_dispatcher.PacketUserEntry
tunnel_dispatcher.PacketUserEntry
This packet is used to return information about a user.
Attributes
attr name
name
The name of the user
attr uid
uid
The numerical user id
attr group
group
The name of the primary group
attr gid
gid
The numerical primary group id
attr groups
groups
All names of the supplementary groups this user belongs to
attr password_hash
password_hash
The password hash from shadow
attr gecos
gecos
The comment (GECOS) field of the user
attr home
home
The home directory of the user
attr shell
shell
The default shell of the user
class tunnel_dispatcher.PacketQueryUser
tunnel_dispatcher.PacketQueryUser
This packet is used to get information about a group via pwd.getpw*.
Attributes
attr user
user
User name or decimal uid
attr query_password_hash
query_password_hash
Whether the current password hash from shadow should also be returned
def PacketQueryUser.handle()
PacketQueryUser.handle()
Queries the requested user.
class tunnel_dispatcher.PacketGroupEntry
tunnel_dispatcher.PacketGroupEntry
This packet is used to return information about a group.
Attributes
attr name
name
The name of the group
attr gid
gid
The numerical group id
attr members
members
All the group member's user names
class tunnel_dispatcher.PacketQueryGroup
tunnel_dispatcher.PacketQueryGroup
This packet is used to get information about a group via grp.getgr*.
Attributes
attr group
group
Group name or decimal gid
def PacketQueryGroup.handle()
PacketQueryGroup.handle()
Queries the requested group.
class tunnel_dispatcher.PacketEnvironVar
tunnel_dispatcher.PacketEnvironVar
This packet is used to return an environment variable.
Attributes
attr value
value
The value of the environment variable, if it was set.
class tunnel_dispatcher.PacketGetenv
tunnel_dispatcher.PacketGetenv
This packet is used to get an environment variable.
Attributes
attr key
key
The environment variable to retrieve
def PacketGetenv.handle()
PacketGetenv.handle()
Gets the requested environment variable.
Functions
def tunnel_dispatcher.Packet()
tunnel_dispatcher.Packet()
Decorator for packet types. Registers the packet and generates read and write methods.
def tunnel_dispatcher.receive_packet()
tunnel_dispatcher.receive_packet()
Receives the next packet from the given connection.
Parameters
conn: The connection
request: The corresponding request packet, if any.
Returns
Any: The received packet
Raises
RemoteOSError: An OSError occurred on the remote host.
IOError: When an issue on the connection occurs.
ValueError: When an PacketInvalidField is received as the response and a corresponding request packet was given.
Last updated