]> git.tue.mpg.de Git - paraslash.git/commitdiff
Use sideband also for "proceed" handshake.
authorAndre Noll <maan@systemlinux.org>
Thu, 22 Dec 2011 22:24:54 +0000 (23:24 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 5 May 2012 10:54:54 +0000 (12:54 +0200)
This adds sideband-aware code for the next step of the connection
handshake. If sideband connections are supported at both ends,
the server side sends an empty sideband packet with designator
SBD_PROCEED if the client was authenticated successfully.  When the
client receives this packet, it enters the CL_RECEIVED_PROCEED state,
just as with non-sideband connections.

client_common.c
command.c

index eea14fa8d3a461ce9862b38af3c35a8e807e3568..53f7b5a96e524214798e549d755141a5bb48c3ed 100644 (file)
@@ -355,6 +355,18 @@ static void client_post_select(struct sched *s, struct task *t)
                goto out;
        case CL_SENT_CH_RESPONSE: /* read server response */
                {
+               if (ct->use_sideband) {
+                       struct sb_buffer sbb;
+                       ret = recv_sb(ct, &s->rfds, &sbb);
+                       if (ret <= 0)
+                               goto out;
+                       free(sbb.iov.iov_base);
+                       if (sbb.band != SBD_PROCEED)
+                               ret = -E_BAD_BAND;
+                       else
+                               ct->status = CL_RECEIVED_PROCEED;
+                       goto out;
+               }
                ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n);
                if (ret < 0 || n == 0)
                        goto out;
index 5e13df66bce15a7e759ce1dd85347b9a176a5417..8deb69ce2f233ee7d0c691a62cebd2d8ded43ce1 100644 (file)
--- a/command.c
+++ b/command.c
@@ -975,7 +975,10 @@ __noreturn void handle_connect(int fd, const char *peername)
        /* init stream cipher keys with the second part of the random buffer */
        cc->scc.recv = sc_new(rand_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
        cc->scc.send = sc_new(rand_buf + CHALLENGE_SIZE + SESSION_KEY_LEN, SESSION_KEY_LEN);
-       ret = sc_send_buffer(&cc->scc, PROCEED_MSG);
+       if (cc->use_sideband)
+               ret = send_sb(&cc->scc, NULL, 0, SBD_PROCEED, false);
+       else
+               ret = sc_send_buffer(&cc->scc, PROCEED_MSG);
        if (ret < 0)
                goto net_err;
        ret = read_command(&cc->scc, &command);