Skip to content

Commit

Permalink
Merge pull request #2451 from brauner/2018-07-06/bugfixes
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
stgraber committed Jul 6, 2018
2 parents 5e64d01 + 57b1ab6 commit 7cb6d1b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/lxc/commands.c
Expand Up @@ -206,7 +206,7 @@ static int lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)
{
ssize_t ret;

ret = send(fd, rsp, sizeof(*rsp), 0);
ret = send(fd, rsp, sizeof(*rsp), MSG_NOSIGNAL);
if (ret < 0 || (size_t)ret != sizeof(*rsp)) {
SYSERROR("Failed to send command response %zd", ret);
return -1;
Expand All @@ -215,7 +215,7 @@ static int lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)
if (!rsp->data || rsp->datalen <= 0)
return 0;

ret = send(fd, rsp->data, rsp->datalen, 0);
ret = send(fd, rsp->data, rsp->datalen, MSG_NOSIGNAL);
if (ret < 0 || ret != (ssize_t)rsp->datalen) {
SYSWARN("Failed to send command response data %zd", ret);
return -1;
Expand Down
6 changes: 3 additions & 3 deletions src/lxc/network.c
Expand Up @@ -3094,7 +3094,7 @@ int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
if (netdev->type != LXC_NET_VETH)
continue;

ret = send(data_sock, netdev->name, IFNAMSIZ, 0);
ret = send(data_sock, netdev->name, IFNAMSIZ, MSG_NOSIGNAL);
if (ret < 0)
return -1;
TRACE("Sent network device name \"%s\" to child", netdev->name);
Expand Down Expand Up @@ -3142,14 +3142,14 @@ int lxc_network_send_name_and_ifindex_to_parent(struct lxc_handler *handler)
struct lxc_netdev *netdev = iterator->elem;

/* Send network device name in the child's namespace to parent. */
ret = send(data_sock, netdev->name, IFNAMSIZ, 0);
ret = send(data_sock, netdev->name, IFNAMSIZ, MSG_NOSIGNAL);
if (ret < 0)
return -1;

/* Send network device ifindex in the child's namespace to
* parent.
*/
ret = send(data_sock, &netdev->ifindex, sizeof(netdev->ifindex), 0);
ret = send(data_sock, &netdev->ifindex, sizeof(netdev->ifindex), MSG_NOSIGNAL);
if (ret < 0)
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lxc/nl.c
Expand Up @@ -229,7 +229,7 @@ extern int netlink_send(struct nl_handler *handler, struct nlmsg *nlmsg)
nladdr.nl_pid = 0;
nladdr.nl_groups = 0;

ret = sendmsg(handler->fd, &msg, 0);
ret = sendmsg(handler->fd, &msg, MSG_NOSIGNAL);
if (ret < 0)
return -errno;

Expand Down
13 changes: 7 additions & 6 deletions src/lxc/start.c
Expand Up @@ -208,9 +208,9 @@ static bool lxc_try_preserve_namespaces(struct lxc_handler *handler,
return true;
}

static int match_fd(int fd)
static inline bool match_stdfds(int fd)
{
return (fd == 0 || fd == 1 || fd == 2);
return (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO);
}

int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
Expand Down Expand Up @@ -277,7 +277,7 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
if (current_config && fd == current_config->logfd)
continue;

if (match_fd(fd))
if (match_stdfds(fd))
continue;

if (closeall) {
Expand All @@ -301,9 +301,10 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,

static int setup_signal_fd(sigset_t *oldmask)
{
int ret, sig;
int ret;
int sig;
sigset_t mask;
int signals[] = {SIGBUS, SIGILL, SIGSEGV, SIGWINCH};
const int signals[] = {SIGBUS, SIGILL, SIGSEGV, SIGWINCH};

/* Block everything except serious error signals. */
ret = sigfillset(&mask);
Expand Down Expand Up @@ -451,7 +452,7 @@ int lxc_serve_state_clients(const char *name, struct lxc_handler *handler,
lxc_state2str(state), client->clientfd);

again:
ret = send(client->clientfd, &msg, sizeof(msg), 0);
ret = send(client->clientfd, &msg, sizeof(msg), MSG_NOSIGNAL);
if (ret <= 0) {
if (errno == EINTR) {
TRACE("Caught EINTR; retrying");
Expand Down

0 comments on commit 7cb6d1b

Please sign in to comment.