[Spice-commits] 4 commits - server/inputs_channel.c server/main_channel.c server/main_channel.h server/reds.c

Hans de Goede jwrdegoede at kemper.freedesktop.org
Fri Mar 15 01:44:20 PDT 2013


 server/inputs_channel.c |    6 ++++++
 server/main_channel.c   |   38 ++++++++++++++++++--------------------
 server/main_channel.h   |    3 ++-
 server/reds.c           |    6 ------
 4 files changed, 26 insertions(+), 27 deletions(-)

New commits:
commit 25f84a2d6e0a007a08f3907ce98d535d785b12d5
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Mar 14 17:20:00 2013 +0100

    inputs-channel: Don't send insecure keyb notify to in migrate client
    
    This fixes spice-gtk printing message like these on migration:
    (remote-viewer:18402): GSpice-CRITICAL **: spice_channel_iterate_read: assertion `c->state != SPICE_CHANNEL_STATE_MIGRATING' failed
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index c9c79be..c968bb2 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -522,7 +522,7 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
     spice_assert(g_inputs_channel);
     spice_assert(channel == &g_inputs_channel->base);
 
-    if (!stream->ssl) {
+    if (!stream->ssl && !red_client_during_migrate_at_target(client)) {
         main_channel_client_push_notify(red_client_get_main(client),
                                         "keyboard channel is insecure");
     }
commit 8d44aa032892ea6643925fa7485d9af32853e127
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Mar 14 17:15:55 2013 +0100

    inputs-channel: Handle printing of insecure keyboard notify
    
    This is clearly something which should be handled in the inputs_channel code,
    rather then having a special case for it in the generic channel handling
    code in reds.c. Moving it here also fixes the TODO we had on only sending
    this message to new clients.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index 1a64e2d..c9c79be 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -37,6 +37,7 @@
 #include "red_common.h"
 #include "reds.h"
 #include "red_channel.h"
+#include "main_channel.h"
 #include "inputs_channel.h"
 #include "migration_protocol.h"
 
@@ -521,6 +522,11 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
     spice_assert(g_inputs_channel);
     spice_assert(channel == &g_inputs_channel->base);
 
+    if (!stream->ssl) {
+        main_channel_client_push_notify(red_client_get_main(client),
+                                        "keyboard channel is insecure");
+    }
+
     spice_printerr("inputs channel client create");
     icc = (InputsChannelClient*)red_channel_client_create(sizeof(InputsChannelClient),
                                                           channel,
diff --git a/server/reds.c b/server/reds.c
index bbff68e..822289b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1747,11 +1747,6 @@ static void reds_channel_do_link(RedChannel *channel, RedClient *client,
     spice_assert(link_msg);
     spice_assert(stream);
 
-    if (link_msg->channel_type == SPICE_CHANNEL_INPUTS && !stream->ssl) {
-        const char *mess = "keyboard channel is insecure";
-        main_channel_push_notify(reds->main_channel, mess);
-    }
-
     caps = (uint32_t *)((uint8_t *)link_msg + link_msg->caps_offset);
     channel->client_cbs.connect(channel, client, stream,
                                 red_client_during_migrate_at_target(client),
commit 0711a4a464ca90f5ac34ba1363a8c4916d415103
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Mar 14 17:11:31 2013 +0100

    main-channel: Add a main_channel_client_push_notify function
    
    Sometimes we want to send a notify to a single client, rather then to
    all of them.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/server/main_channel.c b/server/main_channel.c
index 55c3291..618f5bf 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -575,13 +575,18 @@ void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16])
     red_channel_client_pipe_add_push(&mcc->base, item);
 }
 
-// TODO - some notifications are new client only (like "keyboard is insecure" on startup)
 void main_channel_push_notify(MainChannel *main_chan, const char *msg)
 {
     red_channel_pipes_new_add_push(&main_chan->base,
         main_notify_item_new, (void *)msg);
 }
 
+void main_channel_client_push_notify(MainChannelClient *mcc, const char *msg)
+{
+    PipeItem *item = main_notify_item_new(&mcc->base, (void *)msg, 1);
+    red_channel_client_pipe_add_push(&mcc->base, item);
+}
+
 static uint64_t get_time_stamp(void)
 {
     struct timespec time_space;
diff --git a/server/main_channel.h b/server/main_channel.h
index 5f77b74..56663b7 100644
--- a/server/main_channel.h
+++ b/server/main_channel.h
@@ -61,6 +61,7 @@ void main_channel_push_init(MainChannelClient *mcc, int display_channels_hint,
     int current_mouse_mode, int is_client_mouse_allowed, int multi_media_time,
     int ram_hint);
 void main_channel_push_notify(MainChannel *main_chan, const char *msg);
+void main_channel_client_push_notify(MainChannelClient *mcc, const char *msg);
 void main_channel_push_multi_media_time(MainChannel *main_chan, int time);
 int main_channel_getsockname(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen);
 int main_channel_getpeername(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen);
commit 3a2f42555dbae4357aa9fc2e83c9b31a837ac98d
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Mar 14 17:06:22 2013 +0100

    main-channel: Make main_channel_push_notify deal with dynamic memory
    
    Currently main_channel_push_notify only gets passed a static string, but
    chances are in the future it may get passed dynamically allocated strings,
    prepare it for this.
    
    While at it also make clear that its argument is a string, and simplify
    things a bit by making use of this knowledge (pushing the strlen call down).
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/server/main_channel.c b/server/main_channel.c
index 0fd5ab6..55c3291 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -131,8 +131,7 @@ typedef struct UuidPipeItem {
 
 typedef struct NotifyPipeItem {
     PipeItem base;
-    uint8_t *mess;
-    int mess_len;
+    char *msg;
 } NotifyPipeItem;
 
 typedef struct MultiMediaTimePipeItem {
@@ -305,20 +304,14 @@ static PipeItem *main_uuid_item_new(MainChannelClient *mcc, const uint8_t uuid[1
     return &item->base;
 }
 
-typedef struct NotifyPipeInfo {
-    uint8_t *mess;
-    int mess_len;
-} NotifyPipeInfo;
-
 static PipeItem *main_notify_item_new(RedChannelClient *rcc, void *data, int num)
 {
     NotifyPipeItem *item = spice_malloc(sizeof(NotifyPipeItem));
-    NotifyPipeInfo *info = data;
+    const char *msg = data;
 
     red_channel_pipe_item_init(rcc->channel, &item->base,
                                PIPE_ITEM_TYPE_MAIN_NOTIFY);
-    item->mess = info->mess;
-    item->mess_len = info->mess_len;
+    item->msg = spice_strdup(msg);
     return &item->base;
 }
 
@@ -583,15 +576,10 @@ void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16])
 }
 
 // TODO - some notifications are new client only (like "keyboard is insecure" on startup)
-void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len)
+void main_channel_push_notify(MainChannel *main_chan, const char *msg)
 {
-    NotifyPipeInfo info = {
-        .mess = mess,
-        .mess_len = mess_len,
-    };
-
     red_channel_pipes_new_add_push(&main_chan->base,
-        main_notify_item_new, &info);
+        main_notify_item_new, (void *)msg);
 }
 
 static uint64_t get_time_stamp(void)
@@ -611,9 +599,9 @@ static void main_channel_marshall_notify(RedChannelClient *rcc,
     notify.severity = SPICE_NOTIFY_SEVERITY_WARN;
     notify.visibilty = SPICE_NOTIFY_VISIBILITY_HIGH;
     notify.what = SPICE_WARN_GENERAL;
-    notify.message_len = item->mess_len;
+    notify.message_len = strlen(item->msg);
     spice_marshall_msg_notify(m, &notify);
-    spice_marshaller_add(m, item->mess, item->mess_len + 1);
+    spice_marshaller_add(m, (uint8_t *)item->msg, notify.message_len + 1);
 }
 
 static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
@@ -816,6 +804,11 @@ static void main_channel_release_pipe_item(RedChannelClient *rcc,
                 data->free_data(data->data, data->opaque);
                 break;
         }
+        case PIPE_ITEM_TYPE_MAIN_NOTIFY: {
+                NotifyPipeItem *data = (NotifyPipeItem *)base;
+                free(data->msg);
+                break;
+        }
         default:
             break;
     }
diff --git a/server/main_channel.h b/server/main_channel.h
index 285a009..5f77b74 100644
--- a/server/main_channel.h
+++ b/server/main_channel.h
@@ -60,7 +60,7 @@ void main_channel_client_start_net_test(MainChannelClient *mcc);
 void main_channel_push_init(MainChannelClient *mcc, int display_channels_hint,
     int current_mouse_mode, int is_client_mouse_allowed, int multi_media_time,
     int ram_hint);
-void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len);
+void main_channel_push_notify(MainChannel *main_chan, const char *msg);
 void main_channel_push_multi_media_time(MainChannel *main_chan, int time);
 int main_channel_getsockname(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen);
 int main_channel_getpeername(MainChannel *main_chan, struct sockaddr *sa, socklen_t *salen);
diff --git a/server/reds.c b/server/reds.c
index 5c46909..bbff68e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1749,8 +1749,7 @@ static void reds_channel_do_link(RedChannel *channel, RedClient *client,
 
     if (link_msg->channel_type == SPICE_CHANNEL_INPUTS && !stream->ssl) {
         const char *mess = "keyboard channel is insecure";
-        const int mess_len = strlen(mess);
-        main_channel_push_notify(reds->main_channel, (uint8_t*)mess, mess_len);
+        main_channel_push_notify(reds->main_channel, mess);
     }
 
     caps = (uint32_t *)((uint8_t *)link_msg + link_msg->caps_offset);


More information about the Spice-commits mailing list