The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/1351
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Save errno across some calls to close() since it can be interrupted. Signed-off-by: Wolfgang Bumiller <wry....@bumiller.com>
From fad6ef95ff55e72fa629affef6d31b1e666c995d Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller <wry....@bumiller.com> Date: Sat, 10 Dec 2016 10:18:27 +0100 Subject: [PATCH] conf, attach: save errno across call to close Save errno across some calls to close() since it can be interrupted. Signed-off-by: Wolfgang Bumiller <wry....@bumiller.com> --- src/lxc/attach.c | 5 +++-- src/lxc/conf.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index aee9963..9497148 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -972,7 +972,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun /* Open LSM fd and send it to child. */ if ((options->namespaces & CLONE_NEWNS) && (options->attach_flags & LXC_ATTACH_LSM) && init_ctx->lsm_label) { - int on_exec; + int on_exec, saved_errno; int labelfd = -1; on_exec = options->attach_flags & LXC_ATTACH_LSM_EXEC ? 1 : 0; /* Open fd for the LSM security module. */ @@ -982,9 +982,10 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun /* Send child fd of the LSM security module to write to. */ ret = lxc_abstract_unix_send_fd(ipc_sockets[0], labelfd, NULL, 0); + saved_errno = errno; close(labelfd); if (ret <= 0) { - ERROR("Intended to send file descriptor %d: %s.", labelfd, strerror(errno)); + ERROR("Intended to send file descriptor %d: %s.", labelfd, strerror(saved_errno)); goto on_error; } } diff --git a/src/lxc/conf.c b/src/lxc/conf.c index dbc459d..7d20b55 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -2018,9 +2018,10 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount) } if (!file) { + int saved_errno = errno; if (fd != -1) close(fd); - ERROR("Could not create mount entry file: %s.", strerror(errno)); + ERROR("Could not create mount entry file: %s.", strerror(saved_errno)); return NULL; } @@ -2188,7 +2189,7 @@ static int setup_hw_addr(char *hwaddr, const char *ifname) { struct sockaddr sockaddr; struct ifreq ifr; - int ret, fd; + int ret, fd, saved_errno; ret = lxc_convert_mac(hwaddr, &sockaddr); if (ret) { @@ -2208,9 +2209,10 @@ static int setup_hw_addr(char *hwaddr, const char *ifname) } ret = ioctl(fd, SIOCSIFHWADDR, &ifr); + saved_errno = errno; close(fd); if (ret) - ERROR("ioctl failure : %s", strerror(errno)); + ERROR("ioctl failure : %s", strerror(saved_errno)); DEBUG("mac address '%s' on '%s' has been setup", hwaddr, ifr.ifr_name);
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel