Commit 3cc5de36 by Michel Normand Committed by Daniel Lezcano

check permissions when receiving command

report to command requester the errno if credential failure, rather than to only close the connection. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: 's avatarMichel Normand <normand@fr.ibm.com>
parent 724e753c
......@@ -128,7 +128,12 @@ static int command_handler(int fd, void *data,
struct lxc_handler *handler = data;
ret = lxc_af_unix_rcv_credential(fd, &request, sizeof(request));
if (ret < 0) {
if (ret < 0 && ret == -EACCES) {
/* we don't care for the peer, just send and close */
struct lxc_answer answer = { .ret = ret };
send(fd, &answer, sizeof(answer), 0);
goto out_close;
} else if (ret < 0) {
SYSERROR("failed to receive data on command socket");
goto out_close;
}
......
......@@ -51,6 +51,12 @@ extern int lxc_console(const char *name, int ttynum, int *fd)
return -1;
}
if (command.answer.ret) {
ERROR("console access denied: %s",
strerror(-command.answer.ret));
return -1;
}
*fd = command.answer.fd;
if (*fd <0) {
ERROR("unable to allocate fd for tty %d", ttynum);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment