/* 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. */
/* 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("Error using IPC to send child LSM fd (4): %s.",
- strerror(errno));
+ ERROR("Intended to send file descriptor %d: %s.", labelfd, strerror(saved_errno));
goto cleanup_error;
}
}
file = tmpfile();
if (!file) {
- ERROR("Could not create temporary file: %s.", strerror(errno));
+ int saved_errno = errno;
+ if (fd != -1)
+ close(fd);
+ ERROR("Could not create mount entry file: %s.", strerror(saved_errno));
return -1;
}
{
struct sockaddr sockaddr;
struct ifreq ifr;
- int ret, fd;
+ int ret, fd, saved_errno;
ret = lxc_convert_mac(hwaddr, &sockaddr);
if (ret) {
}
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);