File: commands.py

package info (click to toggle)
sshproxy 0.6.0~beta2-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 956 kB
  • ctags: 1,296
  • sloc: python: 8,932; sh: 268; sql: 40; makefile: 38; xml: 21
file content (62 lines) | stat: -rw-r--r-- 1,832 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# -*- coding: ISO-8859-15 -*-
#
# Copyright (C) 2005-2007 David Guerizec <david@guerizec.net>
#
# Last modified: 2006 Sep 20, 17:21:55 by david
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

from sshproxy import get_class
from sshproxy.dispatcher import Dispatcher
from sshproxy.server import Server

base = get_class('Dispatcher')

class ConsoleExtra_Dispatcher(base):
    acl_open = "acl(cmd_open)"
    def cmd_open(self, *args):
        """
        open user@site

        Open a shell session on user@site.
        """
        self.check_args(1, args, strict=True)

        server = Server()

        server.args = list(args)
        server.do_shell_session()


    acl_run = "acl(cmd_run)"
    def cmd_run(self, *args):
        """
        run user@site cmd args...

        Run a command remotely on user@site.

        WARNING: You could experience locks-up using this command with some
                 SSH servers. I still don't know why but I'm investigating.
        """
        self.check_args(2, args)

        server = Server()

        server.args = list(args)
        server.do_remote_execution()

ConsoleExtra_Dispatcher.register()