Re: [PATCH spice-server v3 06/12] test-sasl: Base test, connect using SASL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 22, 2017 at 10:07:07AM +0000, Frediano Ziglio wrote:
> Create a thread that emulate a client and start SASL authentication

".. that emulates .."

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/tests/test-sasl.c | 236 ++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 235 insertions(+), 1 deletion(-)
> 
> diff --git a/server/tests/test-sasl.c b/server/tests/test-sasl.c
> index 4b1d778c0..3973ebdcd 100644
> --- a/server/tests/test-sasl.c
> +++ b/server/tests/test-sasl.c
> +static size_t
> +do_readwrite_all(int fd, const void *buf, const size_t len, bool do_write)
> +{
> +    size_t written = 0;

I'd rename "written" to "byte_count" or something more neutral given
that you do both reads and writes with this function.

> +    while (written < len) {
> +        int l;
> +        if (do_write) {
> +            l = write(fd, (const char *) buf + written, len - written);
> +        } else {
> +            l = read(fd, (char *) buf + written, len - written);
> +            if (l == 0) {
> +                return written;
> +            }
> +        }
> +        if (l < 0 && errno == EINTR) {
> +            continue;
> +        }
> +        if (l < 0) {
> +            return l;
> +        }
> +        written += l;
> +    }
> +    return written;
> +}
> +
> +static void *
> +client_emulator(void *arg)
> +{
> +    int sock = GPOINTER_TO_INT(arg);
> +
> +    // send initial message
> +    write_all(sock, &initial_message, sizeof(initial_message));
> +
> +    // server replies link ack with rsa, etc, similar to above beside
> +    // fixed fields
> +    struct {
> +        SpiceLinkHeader header;
> +        SpiceLinkReply ack;
> +    } msg;
> +    SPICE_VERIFY(sizeof(msg) == sizeof(SpiceLinkHeader) + sizeof(SpiceLinkReply));
> +    read_all(sock, &msg, sizeof(msg));
> +    uint32_t num_caps = GUINT32_FROM_LE(msg.ack.num_common_caps) + GUINT32_FROM_LE(msg.ack.num_channel_caps);
> +    for (; num_caps; --num_caps) {
> +        uint32_t cap;
> +        read_all(sock, &cap, sizeof(cap));
> +    }

I think I'd prefer a while loop here. Can you at least add an explicit
condition? (num_caps > 0)
> +
> +    // client have to send a SpiceLinkAuthMechanism (just uin32 with

s/uin32/uint32/

I changed a bit some of the things introduced by that patch in my answer
to patch 08. Looks good otherwise.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]