Server info fields.

Some :rtype:s were left around as they were truly useful, given
difficulty of linking to constant integer values.
This commit is contained in:
Jeff Forcier 2014-02-26 14:29:36 -08:00
parent 3f34ea48db
commit dd9934f2b5
1 changed files with 109 additions and 160 deletions

View File

@ -70,13 +70,11 @@ class ServerInterface (object):
The default implementation always returns The default implementation always returns
``OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED``. ``OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED``.
:param kind: the kind of channel the client would like to open :param str kind:
(usually ``"session"``). the kind of channel the client would like to open (usually
:type kind: str ``"session"``).
:param chanid: ID of the channel :param int chanid: ID of the channel
:type chanid: int :return: an `int` success or failure code (listed above)
:return: a success or failure code (listed above)
:rtype: int
""" """
return OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED return OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
@ -92,10 +90,8 @@ class ServerInterface (object):
The default implementation always returns ``"password"``. The default implementation always returns ``"password"``.
:param username: the username requesting authentication. :param str username: the username requesting authentication.
:type username: str :return: a comma-separated `str` of authentication types
:return: a comma-separated list of authentication types
:rtype: str
""" """
return 'password' return 'password'
@ -110,10 +106,10 @@ class ServerInterface (object):
The default implementation always returns `.AUTH_FAILED`. The default implementation always returns `.AUTH_FAILED`.
:param username: the username of the client. :param str username: the username of the client.
:type username: str :return:
:return: `.AUTH_FAILED` if the authentication fails; `.AUTH_FAILED` if the authentication fails; `.AUTH_SUCCESSFUL` if
`.AUTH_SUCCESSFUL` if it succeeds. it succeeds.
:rtype: int :rtype: int
""" """
return AUTH_FAILED return AUTH_FAILED
@ -133,13 +129,11 @@ class ServerInterface (object):
The default implementation always returns `.AUTH_FAILED`. The default implementation always returns `.AUTH_FAILED`.
:param username: the username of the authenticating client. :param str username: the username of the authenticating client.
:type username: str :param str password: the password given by the client.
:param password: the password given by the client. :return:
:type password: str `.AUTH_FAILED` if the authentication fails; `.AUTH_SUCCESSFUL` if
:return: `.AUTH_FAILED` if the authentication fails; it succeeds; `.AUTH_PARTIALLY_SUCCESSFUL` if the password auth is
`.AUTH_SUCCESSFUL` if it succeeds;
`.AUTH_PARTIALLY_SUCCESSFUL` if the password auth is
successful, but authentication must continue. successful, but authentication must continue.
:rtype: int :rtype: int
""" """
@ -166,14 +160,13 @@ class ServerInterface (object):
The default implementation always returns `.AUTH_FAILED`. The default implementation always returns `.AUTH_FAILED`.
:param username: the username of the authenticating client :param str username: the username of the authenticating client
:type username: str :param .PKey key: the key object provided by the client
:param key: the key object provided by the client :return:
:type key: `.PKey` `.AUTH_FAILED` if the client can't authenticate with this key;
:return: `.AUTH_FAILED` if the client can't authenticate `.AUTH_SUCCESSFUL` if it can; `.AUTH_PARTIALLY_SUCCESSFUL` if it
with this key; `.AUTH_SUCCESSFUL` if it can; can authenticate with this key but must continue with
`.AUTH_PARTIALLY_SUCCESSFUL` if it can authenticate with authentication
this key but must continue with authentication
:rtype: int :rtype: int
""" """
return AUTH_FAILED return AUTH_FAILED
@ -192,13 +185,13 @@ class ServerInterface (object):
The default implementation always returns `.AUTH_FAILED`. The default implementation always returns `.AUTH_FAILED`.
:param username: the username of the authenticating client :param str username: the username of the authenticating client
:type username: str :param str submethods:
:param submethods: a comma-separated list of methods preferred by the a comma-separated list of methods preferred by the client (usually
client (usually empty) empty)
:type submethods: str :return:
:return: `.AUTH_FAILED` if this auth method isn't supported; otherwise `.AUTH_FAILED` if this auth method isn't supported; otherwise an
an object containing queries for the user object containing queries for the user
:rtype: int or `.InteractiveQuery` :rtype: int or `.InteractiveQuery`
""" """
return AUTH_FAILED return AUTH_FAILED
@ -224,13 +217,12 @@ class ServerInterface (object):
The default implementation always returns `.AUTH_FAILED`. The default implementation always returns `.AUTH_FAILED`.
:param responses: list of responses from the client :param list responses: list of `str` responses from the client
:type responses: list(str) :return:
:return: `.AUTH_FAILED` if the authentication fails; `.AUTH_FAILED` if the authentication fails; `.AUTH_SUCCESSFUL` if
`.AUTH_SUCCESSFUL` if it succeeds; it succeeds; `.AUTH_PARTIALLY_SUCCESSFUL` if the interactive auth
`.AUTH_PARTIALLY_SUCCESSFUL` if the interactive auth is is successful, but authentication must continue; otherwise an
successful, but authentication must continue; otherwise an object object containing queries for the user
containing queries for the user
:rtype: int or `.InteractiveQuery` :rtype: int or `.InteractiveQuery`
""" """
return AUTH_FAILED return AUTH_FAILED
@ -248,13 +240,11 @@ class ServerInterface (object):
port forwarding request. If the request is accepted, you should return port forwarding request. If the request is accepted, you should return
the port opened for listening. the port opened for listening.
:param address: the requested address :param str address: the requested address
:type address: str :param int port: the requested port
:param port: the requested port :return:
:type port: int the port number (`int`) that was opened for listening, or ``False``
:return: the port number that was opened for listening, or ``False`` to to reject
reject
:rtype: int
""" """
return False return False
@ -264,10 +254,8 @@ class ServerInterface (object):
If the given address and port is being forwarded across this ssh If the given address and port is being forwarded across this ssh
connection, the port should be closed. connection, the port should be closed.
:param address: the forwarded address :param str address: the forwarded address
:type address: str :param int port: the forwarded port
:param port: the forwarded port
:type port: int
""" """
pass pass
@ -293,13 +281,11 @@ class ServerInterface (object):
.. note:: Port forwarding requests are handled separately, in .. note:: Port forwarding requests are handled separately, in
`check_port_forward_request`. `check_port_forward_request`.
:param kind: the kind of global request being made. :param str kind: the kind of global request being made.
:type kind: str :param .Message msg: any extra arguments to the request.
:param msg: any extra arguments to the request. :return:
:type msg: `.Message` ``True`` or a `tuple` of data if the request was granted; ``False``
:return: ``True`` or a tuple of data if the request was granted; otherwise.
``False`` otherwise.
:rtype: bool
""" """
return False return False
@ -315,23 +301,17 @@ class ServerInterface (object):
The default implementation always returns ``False``. The default implementation always returns ``False``.
:param channel: the `.Channel` the pty request arrived on. :param .Channel channel: the `.Channel` the pty request arrived on.
:type channel: `.Channel` :param str term: type of terminal requested (for example, ``"vt100"``).
:param term: type of terminal requested (for example, ``"vt100"``). :param int width: width of screen in characters.
:type term: str :param int height: height of screen in characters.
:param width: width of screen in characters. :param int pixelwidth:
:type width: int width of screen in pixels, if known (may be ``0`` if unknown).
:param height: height of screen in characters. :param int pixelheight:
:type height: int height of screen in pixels, if known (may be ``0`` if unknown).
:param pixelwidth: width of screen in pixels, if known (may be ``0`` if :return:
unknown). ``True`` if the psuedo-terminal has been allocated; ``False``
:type pixelwidth: int
:param pixelheight: height of screen in pixels, if known (may be ``0``
if unknown).
:type pixelheight: int
:return: ``True`` if the psuedo-terminal has been allocated; ``False``
otherwise. otherwise.
:rtype: bool
""" """
return False return False
@ -344,11 +324,10 @@ class ServerInterface (object):
The default implementation always returns ``False``. The default implementation always returns ``False``.
:param channel: the `.Channel` the request arrived on. :param .Channel channel: the `.Channel` the request arrived on.
:type channel: `.Channel` :return:
:return: ``True`` if this channel is now hooked up to a shell; ``False`` ``True`` if this channel is now hooked up to a shell; ``False`` if
if a shell can't or won't be provided. a shell can't or won't be provided.
:rtype: bool
""" """
return False return False
@ -360,14 +339,12 @@ class ServerInterface (object):
The default implementation always returns ``False``. The default implementation always returns ``False``.
:param channel: the `.Channel` the request arrived on. :param .Channel channel: the `.Channel` the request arrived on.
:type channel: `.Channel` :param str command: the command to execute.
:param command: the command to execute. :return:
:type command: str ``True`` if this channel is now hooked up to the stdin, stdout, and
:return: ``True`` if this channel is now hooked up to the stdin, stderr of the executing command; ``False`` if the command will not
stdout, and stderr of the executing command; ``False`` if the be executed.
command will not be executed.
:rtype: bool
.. versionadded:: 1.1 .. versionadded:: 1.1
""" """
@ -389,13 +366,11 @@ class ServerInterface (object):
identify valid subsystems, you probably won't need to override this identify valid subsystems, you probably won't need to override this
method. method.
:param channel: the `.Channel` the pty request arrived on. :param .Channel channel: the `.Channel` the pty request arrived on.
:type channel: `.Channel` :param str name: name of the requested subsystem.
:param name: name of the requested subsystem. :return:
:type name: str ``True`` if this channel is now hooked up to the requested
:return: ``True`` if this channel is now hooked up to the requested
subsystem; ``False`` if that subsystem can't or won't be provided. subsystem; ``False`` if that subsystem can't or won't be provided.
:rtype: bool
""" """
handler_class, larg, kwarg = channel.get_transport()._get_subsystem_handler(name) handler_class, larg, kwarg = channel.get_transport()._get_subsystem_handler(name)
if handler_class is None: if handler_class is None:
@ -411,20 +386,14 @@ class ServerInterface (object):
The default implementation always returns ``False``. The default implementation always returns ``False``.
:param channel: the `.Channel` the pty request arrived on. :param .Channel channel: the `.Channel` the pty request arrived on.
:type channel: `.Channel` :param int width: width of screen in characters.
:param width: width of screen in characters. :param int height: height of screen in characters.
:type width: int :param int pixelwidth:
:param height: height of screen in characters. width of screen in pixels, if known (may be ``0`` if unknown).
:type height: int :param int pixelheight:
:param pixelwidth: width of screen in pixels, if known (may be ``0`` if height of screen in pixels, if known (may be ``0`` if unknown).
unknown).
:type pixelwidth: int
:param pixelheight: height of screen in pixels, if known (may be ``0``
if unknown).
:type pixelheight: int
:return: ``True`` if the terminal was resized; ``False`` if not. :return: ``True`` if the terminal was resized; ``False`` if not.
:rtype: bool
""" """
return False return False
@ -436,19 +405,14 @@ class ServerInterface (object):
The default implementation always returns ``False``. The default implementation always returns ``False``.
:param channel: the `.Channel` the X11 request arrived on :param .Channel channel: the `.Channel` the X11 request arrived on
:type channel: `.Channel` :param bool single_connection:
:param single_connection: ``True`` if only a single X11 channel should ``True`` if only a single X11 channel should be opened, else
be opened ``False``.
:type single_connection: bool :param str auth_protocol: the protocol used for X11 authentication
:param auth_protocol: the protocol used for X11 authentication :param str auth_cookie: the cookie used to authenticate to X11
:type auth_protocol: str :param int screen_number: the number of the X11 screen to connect to
:param auth_cookie: the cookie used to authenticate to X11
:type auth_cookie: str
:param screen_number: the number of the X11 screen to connect to
:type screen_number: int
:return: ``True`` if the X11 session was opened; ``False`` if not :return: ``True`` if the X11 session was opened; ``False`` if not
:rtype: bool
""" """
return False return False
@ -460,10 +424,8 @@ class ServerInterface (object):
The default implementation always returns ``False``. The default implementation always returns ``False``.
:param channel: the `.Channel` the request arrived on :param .Channel channel: the `.Channel` the request arrived on
:type channel: `.Channel`
:return: ``True`` if the AgentForward was loaded; ``False`` if not :return: ``True`` if the AgentForward was loaded; ``False`` if not
:rtype: bool
""" """
return False return False
@ -495,16 +457,14 @@ class ServerInterface (object):
The default implementation always returns The default implementation always returns
``OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED``. ``OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED``.
:param chanid: ID of the channel :param int chanid: ID of the channel
:type chanid: int :param tuple origin:
:param origin: 2-tuple containing the IP address and port of the 2-tuple containing the IP address and port of the originator
originator (client side) (client side)
:type origin: tuple :param tuple destination:
:param destination: 2-tuple containing the IP address and port of the 2-tuple containing the IP address and port of the destination
destination (server side) (server side)
:type destination: tuple :return: an `int` success or failure code (listed above)
:return: a success or failure code (listed above)
:rtype: int
""" """
return OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED return OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
@ -521,12 +481,10 @@ class InteractiveQuery (object):
user. A list of prompts may be included, or they may be added via user. A list of prompts may be included, or they may be added via
the `add_prompt` method. the `add_prompt` method.
:param name: name of this query :param str name: name of this query
:type name: str :param str instructions:
:param instructions: user instructions (usually short) about this query user instructions (usually short) about this query
:type instructions: str :param str prompts: one or more authentication prompts
:param prompts: one or more authentication prompts
:type prompts: str
""" """
self.name = name self.name = name
self.instructions = instructions self.instructions = instructions
@ -542,11 +500,10 @@ class InteractiveQuery (object):
Add a prompt to this query. The prompt should be a (reasonably short) Add a prompt to this query. The prompt should be a (reasonably short)
string. Multiple prompts can be added to the same query. string. Multiple prompts can be added to the same query.
:param prompt: the user prompt :param str prompt: the user prompt
:type prompt: str :param bool echo:
:param echo: ``True`` (default) if the user's response should be echoed; ``True`` (default) if the user's response should be echoed;
``False`` if not (for a password or similar) ``False`` if not (for a password or similar)
:type echo: bool
""" """
self.prompts.append((prompt, echo)) self.prompts.append((prompt, echo))
@ -573,13 +530,10 @@ class SubsystemHandler (threading.Thread):
``channel`` and ``name`` parameters through to the original ``__init__`` ``channel`` and ``name`` parameters through to the original ``__init__``
method here. method here.
:param channel: the channel associated with this subsystem request. :param .Channel channel: the channel associated with this subsystem request.
:type channel: `.Channel` :param str name: name of the requested subsystem.
:param name: name of the requested subsystem. :param .ServerInterface server:
:type name: str the server object for the session that started this subsystem
:param server: the server object for the session that started this
subsystem
:type server: `.ServerInterface`
""" """
threading.Thread.__init__(self, target=self._run) threading.Thread.__init__(self, target=self._run)
self.__channel = channel self.__channel = channel
@ -591,8 +545,6 @@ class SubsystemHandler (threading.Thread):
""" """
Return the `.ServerInterface` object associated with this channel and Return the `.ServerInterface` object associated with this channel and
subsystem. subsystem.
:rtype: `.ServerInterface`
""" """
return self.__server return self.__server
@ -628,12 +580,9 @@ class SubsystemHandler (threading.Thread):
Python interpreter may refuse to exit because this thread will Python interpreter may refuse to exit because this thread will
still be running. still be running.
:param name: name of the requested subsystem. :param str name: name of the requested subsystem.
:type name: str :param .Transport transport: the server-mode `.Transport`.
:param transport: the server-mode `.Transport`. :param .Channel channel: the channel associated with this subsystem request.
:type transport: `.Transport`
:param channel: the channel associated with this subsystem request.
:type channel: `.Channel`
""" """
pass pass