1 From 105ec17dbcad4fc48183a824df13b825974848bb Mon Sep 17 00:00:00 2001
2 From: Christian Brauner <christian.brauner@ubuntu.com>
3 Date: Mon, 23 Oct 2017 13:41:33 +0200
4 Subject: [PATCH 09/13] console: non-functional changes
6 Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
8 src/lxc/console.c | 39 +++++++++++++++++++++++----------------
9 1 file changed, 23 insertions(+), 16 deletions(-)
11 diff --git a/src/lxc/console.c b/src/lxc/console.c
12 index c8e545eb..3592662b 100644
13 --- a/src/lxc/console.c
14 +++ b/src/lxc/console.c
15 @@ -498,9 +498,13 @@ out:
17 void lxc_console_delete(struct lxc_console *console)
19 - if (console->tios && console->peer >= 0 &&
20 - tcsetattr(console->peer, TCSAFLUSH, console->tios))
21 - WARN("failed to set old terminal settings");
24 + if (console->tios && console->peer >= 0) {
25 + ret = tcsetattr(console->peer, TCSAFLUSH, console->tios);
27 + WARN("%s - Failed to set old terminal settings", strerror(errno));
32 @@ -509,7 +513,6 @@ void lxc_console_delete(struct lxc_console *console)
33 close(console->slave);
34 if (console->log_fd >= 0)
35 close(console->log_fd);
40 @@ -518,57 +521,61 @@ void lxc_console_delete(struct lxc_console *console)
42 int lxc_console_create(struct lxc_conf *conf)
44 + int ret, saved_errno;
45 struct lxc_console *console = &conf->console;
48 if (!conf->rootfs.path) {
49 - INFO("container does not have a rootfs, console device will be shared with the host");
50 + INFO("Container does not have a rootfs. The console will be "
51 + "shared with the host");
55 if (console->path && !strcmp(console->path, "none")) {
56 - INFO("no console requested");
57 + INFO("No console was requested");
62 ret = openpty(&console->master, &console->slave, console->name, NULL, NULL);
63 + saved_errno = errno;
66 - SYSERROR("failed to allocate a pty");
67 + ERROR("%s - Failed to allocate a pty", strerror(saved_errno));
71 - if (fcntl(console->master, F_SETFD, FD_CLOEXEC)) {
72 - SYSERROR("failed to set console master to close-on-exec");
73 + ret = fcntl(console->master, F_SETFD, FD_CLOEXEC);
75 + SYSERROR("Failed to set FD_CLOEXEC flag on console master");
79 - if (fcntl(console->slave, F_SETFD, FD_CLOEXEC)) {
80 - SYSERROR("failed to set console slave to close-on-exec");
81 + ret = fcntl(console->slave, F_SETFD, FD_CLOEXEC);
83 + SYSERROR("Failed to set FD_CLOEXEC flag on console slave");
87 ret = lxc_console_peer_default(console);
89 - ERROR("failed to allocate peer tty device");
90 + ERROR("Failed to allocate a peer pty device");
94 if (console->log_path) {
95 console->log_fd = lxc_unpriv(open(console->log_path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600));
96 if (console->log_fd < 0) {
97 - SYSERROR("failed to open console log file \"%s\"", console->log_path);
98 + SYSERROR("Failed to open console log file \"%s\"", console->log_path);
101 - DEBUG("using \"%s\" as console log file", console->log_path);
102 + DEBUG("Using \"%s\" as console log file", console->log_path);
108 lxc_console_delete(console);
113 int lxc_console_set_stdfds(int fd)