Commit Graph

2932 Commits

Author SHA1 Message Date
Eduardo Lima (Etrunko)
a4d40532da Rename stream-device.[ch] to red-stream-device.[ch]
In order to avoid confusion with file named stream-device.h, from
spice-protocol.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-03-13 10:53:05 +00:00
Christophe Fergeau
f4dd0f1aa7 test-listen: Add Unix socket test
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:41:00 +01:00
Christophe Fergeau
0308530d5e test-listen: Add TLS test
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:58 +01:00
Christophe Fergeau
d1d43223af test-listen: Add event loop helpers
These factor a bit of common code, and more importantly, help with
freeing all event loop related data at the end of each test.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:55 +01:00
Christophe Fergeau
a58d44cec3 test-listen: Add test case for port/address configuration
This test case will be testing the external spice-server API to
configure the address/port it's listening on. For now it sets up a
listening server, spawns a thread which is going to connect to that
port, and check it gets the REDQ magic upon connection. It will be
extended to test for Unix sockets, TLS sockets, ...

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:53 +01:00
Christophe Fergeau
1a230cdac0 tests: basic-event-loop: Silence debug message
There is currently a debug printf which is always shown when a mainloop
event is triggered. This is unlikely to be useful unless one is
debugging the event loop code.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:50 +01:00
Christophe Fergeau
4ec9f3e02f reds: Close sockets when failing to watch them
Currently if we fail to set up the watch waiting for accept() to be
called on the socket, we still keep the network socket(s) open even if we
are not going to be able to use it. This commit makes sure it's closed a
set to -1 when such a failure occurs rather than having a half
initialized spice-server instance.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-13 11:40:44 +01:00
Frediano Ziglio
9dd9ee2468 red-record-qxl: fix clang warning
Fix clang warning:

red-record-qxl.c:893:13: error: variable 'fd_in' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (ret)

This is technically impossible but is not on a hot path.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-12 13:00:31 +00:00
Frediano Ziglio
04aff69a99 dcc: Remove unused channel parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2018-03-11 14:02:53 +00:00
Frediano Ziglio
40ef0cb625 stream-device: Create channels before first non-main channel connection
Due to ticket expiration, it is possible that the streaming channels for
the client are created after the ticket expires. Currently, streaming
channels are created dynamically when the guest starts streaming to the
server, which can happen at any time (for instance if you decide to start
the graphic server manually).
If the ticket has expired before the streaming channel is created,
authentication will fail and the client will not be able to connect.
To avoid this, create the channels when the first main channel connection
is made. This ensures that client will connect to all streaming channels.
This could be considered a temporary solution. There may be other
situations where it would be useful to connect new channels after the
ticket has expired, but enabling this behavior would require protocol
changes and a careful analysis of security implications.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-08 11:14:34 +00:00
Frediano Ziglio
6bd9a486a9 stream-device: Separate declaration in a separate header
Move public declaration (stream_device_connect) from char-device.h
to a new stream-device.h.
Add type declaration for StreamDevice.
This allows to use the type outside the implementation file and makes it
easier to extend the interface without changing char-device.h header.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-08 10:58:46 +00:00
Eduardo Lima (Etrunko)
dafc941c76 build: Rename spice-server-enums.tmpl.[ch] to spice-server-enums.[ch].tmpl
This is a preparation for meson build, which has built-in support for
generating enums, but requires the template files to be renamed. It uses
the basename of template files to generate the output, and in this case
it would be the same file for both '.c' and '.h'. Ideally meson would
let us specify the name of the output files, but this is not the case.

Without renaming, the following error happens:

Meson encountered an error in file server/meson.build, line 30, column 0:
Tried to create target "spice-server-enums.tmpl", but a target of that
name already exists.

Reference: http://mesonbuild.com/Gnome-module.html#gnomemkenums

Note that by the time of this commit, the documentation is not accurate
and does not mention the fact that output files will get the base name
of the template files if they are specified, I submitted a pull request
to meson fixing this detail in docs:

   https://github.com/mesonbuild/meson/pull/3191

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-07 10:04:04 -03:00
Frediano Ziglio
e45e087617 test-stream-device: Check we don't read past data message
Test case for the issue fixed by previous commit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 12:56:43 +00:00
Frediano Ziglio
ac57ee547a stream-device: Do not read past data message
If data message is followed by another message, it's theoretically
possible that device loses the sync with the guest.
The actual Qemu and streaming agent implementation avoids it, but better to
make sure this can't happen in the server code too.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 12:56:43 +00:00
Frediano Ziglio
a88533a21b stream-device: Workaround Qemu bug closing device
Previous patch causes a bug in Qemu if the patch
46764fe09ca2e0f15c0981a672c166ed8cf57e72 ("virtio-serial: fix segfault
on disconnect") is not included in that version of Qemu (patch present in
version 2.10.0).
This crash happens when device is closed during a write operation.
For SPICE character device, spice_server_char_device_wakeup is called
to write data which handles both read and write pending operations.
As we want to close the device but we can't do it inside the handler
without causing a crash, this commit schedules a timer that will close the
guest device outside this callback.
The proper solution would be to patch Qemu but making sure of this is not
so easy, hence this workaround in spice-server.
Code is marked with some comments to remember to remove this
hack in a safe future.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 12:56:43 +00:00
Frediano Ziglio
52a36fabde stream-device: Disable guest device on errors
Once the device is an error state, we don't want the guest to keep
reading/writing to it, especially as this could put the device in an
inconsistent state. This commit disables the device when an error occurs to
prevent further unintended use of the device by the guest.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 12:56:41 +00:00
Frediano Ziglio
19d2e2e8b5 stream-device: Implement properly device reset on open/close
Due to the way Qemu handle the device, when an error occurs we must consume
all pending data inside the callback which reads data from the device.
If we don't flush this data, the next time spice-server tries to read from
the device (after the guest closes/reopens it), we'll be getting stale
data. This can happen because we cannot prevent the guest from writing to
the device even after it got in an error state.
This needs to be done within this callback, as QEMU returns 0 if you call
SpiceCharDeviceInterface::read() outside of it. QEMU invokes this callback
through a call to spice_server_char_device_wakeup.
On the test now we must test that we receive an error from the device.
Previously we checked that last part of the data was not read. Now
potentially all data are read, so we need another way to check the device
detected the error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-03-06 11:21:39 +00:00
Frediano Ziglio
5327d0f559 test-stream-device: Test batched multiple messages
Test all batched (send together) messages are handled correctly
and device is not stuck.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-02-27 10:41:19 +00:00
Frediano Ziglio
c5ad710056 test-stream-device: Better Qemu emulation for data reading
Qemu does not trigger a new data read if we don't read all data in
the buffer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-02-27 10:40:20 +00:00
Frediano Ziglio
65efca3f32 stream-device: Implement mouse movement
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-02-16 22:29:10 +00:00
Frediano Ziglio
d71364537a stream-device: handle cursor from device
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-02-16 22:29:01 +00:00
Frediano Ziglio
ebdda84dc1 stream-device: Avoid device to get stuck if multiple messages are batched
If messages are sent together by the agent the device is reading
only part of the data. This cause Qemu to not poll for new data and
stream_device_read_msg_from_dev won't be called again.
This can cause a stall. To avoid this continue handling data
after a full message was processed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-02-16 22:18:36 +00:00
Frediano Ziglio
fac12737d5 reds: Disable TLS 1.0
TLS 1.0 is considered now insecure.
TLS 1.1 was introduced in 2006.
Our SPICE clients uses OpenSSL to use TLS and the support for TLS 1.1
in OpenSSL was introduced in 2006 too so even in systems like
Windows XP which are not officially supporting TLS 1.0 will work
with SPICE and TLS 1.1.
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1521053.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-02-12 15:03:35 +00:00
Frediano Ziglio
41aa4a978f utils: Avoid possible unaligned access
Code in rgb32_data_has_alpha possibly generate this warning using
clang:

utils.c:35:16: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
        line = (uint32_t *)data;
               ^~~~~~~~~~~~~~~~

Although the images are expected to be all aligned in this respect
use byte access on the data instead. This, beside fixing the alignment
issue also avoid problem with big endian machines (images in SPICE are
expected to have the alpha channel as the forth byte).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 14:17:39 +00:00
Frediano Ziglio
f34fbc1555 red-common: Avoid some not used warning using clang
clang reports lot of warnings like:

spicevmc.c:47:1: error: unused function 'RED_CHAR_DEVICE_SPICEVMC_CLASS' [-Werror,-Wunused-function]
SPICE_DECLARE_TYPE(RedCharDeviceSpiceVmc, red_char_device_spicevmc, CHAR_DEVICE_SPICEVMC);
^
./red-common.h:110:43: note: expanded from macro 'SPICE_DECLARE_TYPE'
    static inline ModuleObjName ## Class *G_PASTE(G_PASTE(RED_,OBJ_NAME),_CLASS)(void *klass) \
                                          ^

They are all static inline function and usually should not generate
warnings but for some reasons they do.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:50:31 +00:00
Frediano Ziglio
5d5a7bd181 sound: Avoid cast that could cause alignment problems
clang is reporting:

sound.c:292:16: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
        data = (uint32_t *)packet->data;
               ^~~~~~~~~~~~~~~~~~~~~~~~

however we are using memcpy to access "data" pointer so there's no
need to use uint32_t pointer. Also considering we don't do math with
that pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:39:54 +00:00
Frediano Ziglio
c4a0505f6e Avoid some alignment warnings using clang
clang reports may warnings like:

test-display-base.c:252:11: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    dst = (uint32_t *)bitmap;
          ^~~~~~~~~~~~~~~~~~

Use SPICE_ALIGNED_CAST/SPICE_UNALIGNED_CAST macros in common/mem.h to
mark the cast safe or possibly unsafe.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:35:46 +00:00
Frediano Ziglio
4a0149bb1f tests: Avoid some possible not initialized warning from Clang
Not really possible but clang raise these warnings:

test-sasl.c:555:13: error: variable 'is_ok' is uninitialized when used here [-Werror,-Wuninitialized]
        if (is_ok) {
            ^~~~~
test-sasl.c:553:22: note: initialize the variable 'is_ok' to silence this warning
        uint8_t is_ok;
                     ^
                      = '\0'

test-gst.c:792:18: error: variable 'height' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
    spice_assert(gst_structure_get_int(s, "width", &width) &&
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
    if G_LIKELY(x) { } else {                           \
                ^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
                                                           ^~~~
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^~~~
test-gst.c:799:17: note: uninitialized use occurs here
    bitmap->y = height;
                ^~~~~~
test-gst.c:792:18: note: remove the '&&' if its condition is always true
    spice_assert(gst_structure_get_int(s, "width", &width) &&
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
    if G_LIKELY(x) { } else {                           \
                ^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
                                                           ^
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^
test-gst.c:791:23: note: initialize the variable 'height' to silence this warning
    gint width, height;
                      ^
                       = 0

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:31:40 +00:00
Frediano Ziglio
a5b26585a1 replay: Do not use obsolete set_mm_time callback
Marked as obsolete with clang and some options is detected as
error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:31:40 +00:00
Frediano Ziglio
33f33ccc51 char-device: Avoid to use unaligned memory
This causes some warnings with clang:

char-device.c:898:29: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    write_to_dev_size_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
char-device.c:899:31: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    write_to_dev_tokens_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This also fixes some minor endianness issue (on big endian machine
integers were not properly encoded).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 13:31:29 +00:00
Frediano Ziglio
342ed06ad2 reds: Remove stream watch handling link in a single place
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-01-30 22:39:18 +00:00
Frediano Ziglio
32c467c2ee stream-channel: Tell client we are just streaming data
This give an hint to client which can optimise rendering.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-01-30 15:12:01 +00:00
Frediano Ziglio
72d095ac8c red-stream: Handle reading of 0 bytes in red_stream_async_read
Currently red_stream_async_read cannot handle read of 0 bytes.
This would cause a wrong assert in async_read_handler.
Fixing the assert would just make the code wrongly detect a
disconnection (usually a return of 0 from read is handled that
way but happens also if you try to read 0 bytes).
Current callers of these function does not pass 0 as size however
handling data protocols having data_length+data this can happen
and is handled manually in red_sasl_handle_auth_steplen.
Avoid needing manually to check for this condition.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-01-30 15:06:03 +00:00
Frediano Ziglio
6174bfe11e lz4-encoder: Remove useless header include
After 497b8042dc
("lz4-encoder: Use GUINT32_TO_BE instead of htonl") patch this header
is not needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-30 11:02:26 +00:00
Frediano Ziglio
1a7c715b10 dcc-send: Avoid to use unaligned memory
This causes some warnings with clang:

dcc-send.c:1799:28: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    num_surfaces_created = (uint32_t *)spice_marshaller_reserve_space(m2, sizeof(uint32_t));
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This also fixes some endianness issue (on big endian machine integers
were not properly encoded).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-29 21:12:16 +00:00
Frediano Ziglio
497b8042dc lz4-encoder: Use GUINT32_TO_BE instead of htonl
Just a style change, almost of the code use similar macros for such
tasks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-29 21:11:42 +00:00
Frediano Ziglio
03125ef950 utils: Use const for rgb32_data_has_alpha data argument
There's no reason to change data passed, the function just check
the alpha channel of the image.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-29 21:11:38 +00:00
Frediano Ziglio
8d79d8887d tests: Remove test-just-sockets-no-ssl
This call sequence is included in test-display-base used in different
tests, no reason to have this test.
Also this test is not actually used for automated tests.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-16 16:32:21 +00:00
Frediano Ziglio
5998e34ffb red-stream: Remove AsyncRead::stream
AsyncRead is always included in RedStream and there are only
a possible operation pending on a RedStream.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-16 14:11:16 +00:00
Frediano Ziglio
233f710ba9 red-stream: Reuse red_stream_disable_writev function
The same function is used to reset writev field in SASL code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-16 12:41:13 +00:00
Frediano Ziglio
3625f3cfd1 basic-event-loop: Document why code does not use default GLib context
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-16 12:40:35 +00:00
Frediano Ziglio
7a25e46c8b Minor compatibility with FreeBSD system
Some additional header are needed to avoid undefined types.
SOL_TCP and IPPROTO_TCP have the same value in Linux but SOL_TCP
is not defined in FreeBSD.
Provide pthread_setname_np using pthread_set_name_np (same parameters).

Patch is based on a patch from Oleg Ginzburg <olevole@olevole.ru>

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-15 16:52:57 +00:00
Frediano Ziglio
aac2460164 red-parse-qxl: Copy correctly brush position
This issue caused the glitches using the rectangular selection
tool in PaintShop 6.

The line was removed accidentally by "red_parse_qxl: fix throwing
away drawables that have masks" (812b65984d)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pavelgrunt@gmail.com>
2018-01-13 21:00:43 +00:00
Frediano Ziglio
55e4211456 test-display-base: Do not use obsolete set_mm_time callback
Marked as obsolete with clang and some options is detected as
error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-10 15:50:24 +00:00
Frediano Ziglio
6c416f5098 red-stream: Encapsulate all authentication state in RedSASLAuth
Instead of having half state in RedSASL and half in RedSASLAuth
move everything in RedSASLAuth. This also reduces memory usage
when we are using SASL but we finish the authentication step.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:11 +00:00
Frediano Ziglio
cb70583e5c red-stream: Unify start and step passes
Most of these function are identical.
Only difference were basically debugging message but now
with a proper tests are less important.
The mechname field is used to differentiate between first step and
following ones.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:08 +00:00
Frediano Ziglio
5c516a6e42 red-stream: Handle properly endianness in SASL code
All SPICE protocol is little endian, there's no agreement on other
endian and currently we support only little endian so make sure
this will work even possibly running on a big endian machine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:06 +00:00
Frediano Ziglio
5c438510cd Handle SASL initialisation mainly in red-stream.c
Asynchronous code jumping from a file to another is tedious to read
also having code handling the same stuff in two files does not look
a good design.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:04 +00:00
Frediano Ziglio
6543bef0cb test-sasl: Test how to server reports the failure
The server on failure can just disconnect the client or report the
error. The error report can be done using new protocol 2 or just
a number (like protocol 1).
Detect the failure report to make possible to check it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:02 +00:00
Frediano Ziglio
0e533dfec5 test-sasl: Add tests for different failures and cases
Use some flags to specify which behaviour to change and different test
cases to test them.
Some cases specify when client stop sending data at different steps of
the process.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-09 17:06:00 +00:00