<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
img {
max-width: 100%;
height: auto;
}
p.details {
font-style:italic;
color:#777
}
.footer p {
font-size:small;
color:#777
}
pre.commit-message {
white-space: pre-wrap;
}
.file-stats a {
text-decoration: none;
}
.file-stats .new-file {
color: #090;
}
.file-stats .deleted-file {
color: #B00;
}
</style>
<body>
<div class='content'>
<h3>Justin Mitchell pushed to branch master at <a href="https://projects.sucs.org/arthur/mw">Justin Mitchell / mw</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/264828c9efdc4cc0718f4560ce49b52bd6cadbed">264828c9</a></strong>
<div>
<span>by Justin Mitchell</span>
<i>at 2015-10-06T12:00:57Z</i>
</div>
<pre class='commit-message'>IPC_HELLO was broken by the changes to PROTOCOL</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/ipc.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/server/PROTOCOL
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
src/server/servsock.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/arthur/mw/commit/264828c9efdc4cc0718f4560ce49b52bd6cadbed#diff-0'>
<strong>
src/ipc.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/ipc.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/ipc.c
</span><span style="color: #aaaaaa">@@ -63,7 +63,8 @@ void ipc_connect(const char *target)
</span> ipcsock->state = IPCSTATE_CONNECTED;
ipc_message_t * msg = ipcmsg_create(IPC_HELLO, userposn);
- ipcmsg_append(msg, &userposn, sizeof(userposn));
<span style="color: #000000;background-color: #ddffdd">+ uint32_t pid = getpid();
+ ipcmsg_append(msg, &pid, sizeof(pid));
</span> const char *nonce = get_nonce();
ipcmsg_append(msg, nonce, strlen(nonce));
ipcmsg_send(msg, ipcsock);
</code></pre>
<br>
</li>
<li id='diff-1'>
<a href='https://projects.sucs.org/arthur/mw/commit/264828c9efdc4cc0718f4560ce49b52bd6cadbed#diff-1'>
<strong>
src/server/PROTOCOL
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/server/PROTOCOL
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/server/PROTOCOL
</span><span style="color: #aaaaaa">@@ -20,7 +20,7 @@ IPC_* codes using FCC are json formatted messages.
</span>
IPC_HELLO - Login to the server, start a session
Body: (binary)
- userid - 4 bytes - offset in users db
<span style="color: #000000;background-color: #ddffdd">+ pid - 4 bytes - Process / Session ID
</span> nonce - to end - unique version string for server
Response:
none
</code></pre>
<br>
</li>
<li id='diff-2'>
<a href='https://projects.sucs.org/arthur/mw/commit/264828c9efdc4cc0718f4560ce49b52bd6cadbed#diff-2'>
<strong>
src/server/servsock.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/server/servsock.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/server/servsock.c
</span><span style="color: #aaaaaa">@@ -264,20 +264,24 @@ void process_msg(ipc_connection_t *conn, ipc_message_t *msg)
</span> /* client just told us who they are */
if (msg->head.type == IPC_HELLO) {
int wfd;
- memcpy(&conn->addr, &msg->head.src, sizeof(conn->addr));
if (msg->bodylen < 4) {
printf("Invalid HELO from fd=%d. dropping.\n", conn->fd);
ipcmsg_destroy(msg);
drop_connection(conn);
return;
}
<span style="color: #000000;background-color: #ddffdd">+ /* user id / userposn is in the header src */
+ memcpy(&conn->user, &(msg->head.src), sizeof(conn->user));
+ /* first 4 bytes of body are PID / Session ID */
+ memcpy(&conn->addr, msg->body, sizeof(conn->addr));
+ /* rest of body is the NONCE,
+ * check this to make sure we have a matching client */
</span> if (!match_nonce(&msg->body[4])) {
printf("Mismatched nonce from fd=%d. dropping.\n", conn->fd);
ipcmsg_destroy(msg);
drop_connection(conn);
return;
}
- memcpy(&conn->user, msg->body, sizeof(conn->user));
printf("WHO Add: pid=%d posn=%d\n", conn->addr, conn->user);
wfd = who_open(O_RDWR);
who_add(wfd, conn->addr, conn->user);
</code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://projects.sucs.org/arthur/mw/commit/264828c9efdc4cc0718f4560ce49b52bd6cadbed">View it on GitLab</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://projects.sucs.org/arthur/mw/commit/264828c9efdc4cc0718f4560ce49b52bd6cadbed"}}</script>
</p>
</div>
</body>
</html>