diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-09-14 17:28:32 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2010-09-14 17:28:32 +0200 |
commit | 0505ac9e5c110de659cc03e106066eb3868282c7 (patch) | |
tree | 01761c60b263e2c03739272a1d28999bd3d76ea8 | |
parent | 4fbbd7a2109d82f67f409e423e281fc71544f9a4 (diff) |
passwd support
-rw-r--r-- | gtk/README | 1 | ||||
-rw-r--r-- | gtk/spice-channel.c | 2 | ||||
-rw-r--r-- | gtk/spice-session.c | 16 | ||||
-rw-r--r-- | gtk/spice-session.h | 2 | ||||
-rw-r--r-- | gtk/spicy.c | 19 |
5 files changed, 36 insertions, 4 deletions
@@ -11,7 +11,6 @@ current state Starts becoming usable. Lots of features are missing: - - No password authentication. - No TLS support. - No server mouse mode support. - No sound support. diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c index ecb8cf4..190fb56 100644 --- a/gtk/spice-channel.c +++ b/gtk/spice-channel.c @@ -285,7 +285,7 @@ static void spice_channel_send_auth(SpiceChannel *channel) int nRSASize; BIO *bioKey; RSA *rsa; - uint8_t *password = ""; + const uint8_t *password = spice_session_get_password(c->session); uint8_t *encrypted; int rc; diff --git a/gtk/spice-session.c b/gtk/spice-session.c index 08cf2fc..2ef2897 100644 --- a/gtk/spice-session.c +++ b/gtk/spice-session.c @@ -6,6 +6,7 @@ struct spice_session { char *host; char *port; + char *password; struct addrinfo ai; int connection_id; @@ -101,6 +102,21 @@ void spice_session_set_port(SpiceSession *session, const char *port) s->port = strdup(port); } +void spice_session_set_password(SpiceSession *session, const char *password) +{ + spice_session *s = SPICE_SESSION_GET_PRIVATE(session); + + free(s->password); + s->password = strdup(password); +} + +const char *spice_session_get_password(SpiceSession *session) +{ + spice_session *s = SPICE_SESSION_GET_PRIVATE(session); + + return s->password ? s->password : ""; +} + gboolean spice_session_connect(SpiceSession *session) { SpiceChannel *cmain; diff --git a/gtk/spice-session.h b/gtk/spice-session.h index 686a0e2..1777624 100644 --- a/gtk/spice-session.h +++ b/gtk/spice-session.h @@ -36,6 +36,8 @@ GType spice_session_get_type(void) G_GNUC_CONST; SpiceSession *spice_session_new(void); void spice_session_set_host(SpiceSession *session, const char *host); void spice_session_set_port(SpiceSession *session, const char *port); +void spice_session_set_password(SpiceSession *session, const char *password); +const char *spice_session_get_password(SpiceSession *session); gboolean spice_session_connect(SpiceSession *session); void spice_session_disconnect(SpiceSession *session); int spice_session_get_channels(SpiceSession *session, SpiceChannel **channels, int max); diff --git a/gtk/spicy.c b/gtk/spicy.c index 4ec9b52..efb5f77 100644 --- a/gtk/spicy.c +++ b/gtk/spicy.c @@ -15,6 +15,7 @@ struct spice_window { /* config */ static char *host = "localhost"; static char *port = "5920"; +static char *password; static bool fullscreen = false; /* state */ @@ -262,14 +263,22 @@ static spice_window *create_spice_window(SpiceSession *s, int id) static void main_channel_event(SpiceChannel *channel, enum SpiceChannelEvent event, gpointer *data) { - fprintf(stderr, "main channel event: %d\n", event); switch (event) { case SPICE_CHANNEL_OPENED: /* nothing */ break; + case SPICE_CHANNEL_CLOSED: + fprintf(stderr, "main channel: closed\n"); + gtk_main_quit(); + break; + case SPICE_CHANNEL_ERROR_AUTH: + fprintf(stderr, "main channel: auth failure (wrong password?)\n"); + gtk_main_quit(); + break; default: /* TODO: more sophisticated error handling */ + fprintf(stderr, "unknown main channel event: %d\n", event); gtk_main_quit(); break; } @@ -320,7 +329,7 @@ int main(int argc, char *argv[]) /* parse opts */ gtk_init(&argc, &argv); for (;;) { - if (-1 == (c = getopt(argc, argv, "h:p:f"))) + if (-1 == (c = getopt(argc, argv, "h:p:w:f"))) break; switch (c) { case 'h': @@ -329,6 +338,9 @@ int main(int argc, char *argv[]) case 'p': port = optarg; break; + case 'w': + password = optarg; + break; case 'f': fullscreen = true; break; @@ -350,6 +362,9 @@ int main(int argc, char *argv[]) spice_session_set_host(session, host); spice_session_set_port(session, port); + if (password) + spice_session_set_password(session, password); + if (!spice_session_connect(session)) { fprintf(stderr, "spice_session_connect failed\n"); exit(1); |