Skip to content

Commit

Permalink
cmd/flux-proxy: add single byte auth response
Browse files Browse the repository at this point in the history
  • Loading branch information
garlick committed Feb 28, 2017
1 parent d2d2017 commit 3f306c0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cmd/builtin/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,19 @@ static int check_cred (proxy_ctx_t *ctx, int fd)
if (ucred.uid != ctx->session_owner) {
flux_log (ctx->h, LOG_ERR, "connect by uid=%d pid=%d denied",
ucred.uid, (int)ucred.pid);
errno = EPERM;
goto done;
}
rc = 0;
done:
return rc;
}

static int send_auth_response (int fd, unsigned char e)
{
return write (fd, &e, 1);
}

/* Accept a connection from new client.
*/
static void listener_cb (flux_reactor_t *r, flux_watcher_t *w,
Expand All @@ -708,9 +714,11 @@ static void listener_cb (flux_reactor_t *r, flux_watcher_t *w,
goto done;
}
if (check_cred (ctx, cfd) < 0) {
send_auth_response (cfd, errno);
close (cfd);
goto done;
}
send_auth_response (cfd, 0);
if (!(c = client_create (ctx, cfd, cfd))) {
close (cfd);
goto done;
Expand Down

0 comments on commit 3f306c0

Please sign in to comment.