Revision d49bd2fb vncauthproxy/client.py

b/vncauthproxy/client.py
65 65
                      metavar="PASSWORD",
66 66
                      help=("Use password PASSWD to authenticate incoming "
67 67
                            "VNC connections"))
68
    parser.add_option("--auth-user", dest="auth_user",
69
                      default=None,
70
                      metavar="AUTH_USER",
71
                      help=("User to authenticate as, for the control "
72
                            "connection"))
73
    parser.add_option("--auth-password", dest="auth_password",
74
                      default=None,
75
                      metavar="AUTH_PASSWORD",
76
                      help=("User password for the control connection "
77
                            "authentication"))
78
    parser.add_option("--no-ssl", dest="no_ssl",
79
                      action='store_false', default=False,
80
                      help=("Disable SSL/TLS for control connecions "
81
                            "(default: %s)" % False))
68 82

  
69 83
    (opts, args) = parser.parse_args(args)
70 84

  
......
75 89
        parser.error("The -d/--dest argument is mandatory.")
76 90
    if not opts.dport:
77 91
        parser.error("The -p/--dport argument is mandatory.")
92
    if not opts.auth_user:
93
        parser.error("The --auth-user argument is mandatory.")
94
    if not opts.auth_password:
95
        parser.error("The --auth-password argument is mandatory.")
78 96

  
79 97
    return (opts, args)
80 98

  
81 99

  
82 100
def request_forwarding(sport, daddr, dport, password,
101
                       auth_user, auth_password,
83 102
                       server_address=DEFAULT_SERVER_ADDRESS,
84
                       server_port=DEFAULT_SERVER_PORT, ssl_sock=True):
103
                       server_port=DEFAULT_SERVER_PORT, no_ssl=False):
85 104
    """Connect to vncauthproxy and request a VNC forwarding."""
86 105
    if not password:
87 106
        raise ValueError("You must specify a non-empty password")
......
91 110
        "destination_address": daddr,
92 111
        "destination_port": int(dport),
93 112
        "password": password,
113
        "auth_user": auth_user,
114
        "auth_password": auth_password,
94 115
    }
95 116

  
96 117
    retries = 5
......
107 128
                server = None
108 129
                continue
109 130

  
110
            if ssl_sock:
131
            if not no_ssl:
111 132
                server = ssl.wrap_socket(
112 133
                      server, cert_reqs=ssl.CERT_NONE,
113 134
                      ssl_version=ssl.PROTOCOL_TLSv1)
......
119 140
            except socket.error:
120 141
                server.close()
121 142
                server = None
143
                retries -= 1
122 144
                continue
123 145

  
124 146
            retries = 0
......
141 163
    (opts, args) = parse_arguments(sys.argv[1:])
142 164

  
143 165
    res = request_forwarding(sport=opts.sport, daddr=opts.daddr,
144
                             dport=opts.dport, password=opts.password)
145

  
146
    sys.stderr.write("Forwaring %s -> %s:%s: %s\n" % (res['source_port'],
166
                             dport=opts.dport, password=opts.password,
167
                             auth_user=opts.auth_user,
168
                             auth_password=opts.auth_password,
169
                             no_ssl=opts.no_ssl)
170

  
171
    reason = None
172
    if 'reason' in res:
173
        reason = 'Reason: %s\n' % res['reason']
174
    sys.stderr.write("Forwaring %s -> %s:%s: %s\n%s" % (res['source_port'],
147 175
                                                      opts.daddr, opts.dport,
148
                                                      res['status']))
176
                                                      res['status'], reason))
149 177

  
150 178
    if res['status'] == "OK":
151 179
        sys.exit(0)

Also available in: Unified diff