*data_out = data;
*len_out = len;
}
+
+/*
+ * Acknowledgements are used to make the parent and child processes operate in
+ * lock-step. That way, if the child fails, the parent isn't several steps
+ * ahead before it finds out.
+ */
+
+void
+send_ack(int fd)
+{
+ rewrite(fd, "ack", 3);
+}
+
+void
+read_ack(int fd)
+{
+ char buf[3];
+
+ reread(fd, buf, 3);
+ assert(memcmp(buf, "ack", 3) == 0);
+}
void reread(int fd, void *buf, size_t len);
void send_data(int fd, const void *data, size_t len);
void read_data(int fd, void **data_out, size_t *len_out);
+void send_ack(int fd);
+void read_ack(int fd);
krb5_c_random_os_entropy(NULL, 0, &dummy);
read_lucid_context(&acceptor);
+ send_ack(STDOUT_FILENO);
read_wrap_token(acceptor);
+ send_ack(STDOUT_FILENO);
read_mic_token(acceptor);
+ send_ack(STDOUT_FILENO);
read_iov_token(acceptor);
+ send_ack(STDOUT_FILENO);
+
send_wrap_token(acceptor);
+ read_ack(STDIN_FILENO);
send_mic_token(acceptor);
+ read_ack(STDIN_FILENO);
send_iov_token(acceptor);
+ read_ack(STDIN_FILENO);
+
cleanup_context(acceptor);
return 0;
}
establish_contexts(argv[1], &initiator, &acceptor);
start_child(&to_child, &from_child, &child_pid);
+
send_lucid_context(acceptor, to_child);
+ read_ack(from_child);
send_wrap_token(initiator, to_child);
+ read_ack(from_child);
send_mic_token(initiator, to_child);
+ read_ack(from_child);
send_iov_token(initiator, to_child);
+ read_ack(from_child);
+
read_wrap_token(initiator, from_child);
+ send_ack(to_child);
read_mic_token(initiator, from_child);
+ send_ack(to_child);
read_iov_token(initiator, from_child);
+ send_ack(to_child);
+
cleanup_context(initiator);
close(to_child);
close(from_child);