conf: move file descriptor synchronization with parent into single function

parent 493ae3fe
...@@ -1184,7 +1184,7 @@ on_error: ...@@ -1184,7 +1184,7 @@ on_error:
return -1; return -1;
} }
int lxc_send_ttys_to_parent(struct lxc_handler *handler) static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
{ {
int ret = -1; int ret = -1;
...@@ -1750,7 +1750,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler) ...@@ -1750,7 +1750,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
return 0; return 0;
} }
int lxc_send_devpts_to_parent(struct lxc_handler *handler) static int lxc_send_devpts_to_parent(struct lxc_handler *handler)
{ {
int ret; int ret;
...@@ -4078,6 +4078,32 @@ int lxc_sync_fds_parent(struct lxc_handler *handler) ...@@ -4078,6 +4078,32 @@ int lxc_sync_fds_parent(struct lxc_handler *handler)
return 0; return 0;
} }
int lxc_sync_fds_child(struct lxc_handler *handler)
{
int ret;
ret = lxc_seccomp_send_notifier_fd(&handler->conf->seccomp, handler->data_sock[0]);
if (ret < 0)
return syserror_ret(ret, "Failed to send seccomp notify fd to parent");
ret = lxc_send_devpts_to_parent(handler);
if (ret < 0)
return syserror_ret(ret, "Failed to send seccomp devpts fd to parent");
ret = lxc_send_ttys_to_parent(handler);
if (ret < 0)
return syserror_ret(ret, "Failed to send tty file descriptors to parent");
if (handler->ns_clone_flags & CLONE_NEWNET) {
ret = lxc_network_send_name_and_ifindex_to_parent(handler);
if (ret < 0)
return syserror_ret(ret, "Failed to send network device names and ifindices to parent");
}
TRACE("Finished syncing file descriptors with parent");
return 0;
}
int lxc_setup(struct lxc_handler *handler) int lxc_setup(struct lxc_handler *handler)
{ {
int ret; int ret;
......
...@@ -517,8 +517,6 @@ __hidden extern int lxc_idmapped_mounts_parent(struct lxc_handler *handler); ...@@ -517,8 +517,6 @@ __hidden extern int lxc_idmapped_mounts_parent(struct lxc_handler *handler);
__hidden extern int lxc_map_ids(struct lxc_list *idmap, pid_t pid); __hidden extern int lxc_map_ids(struct lxc_list *idmap, pid_t pid);
__hidden extern int lxc_create_tty(const char *name, struct lxc_conf *conf); __hidden extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
__hidden extern void lxc_delete_tty(struct lxc_tty_info *ttys); __hidden extern void lxc_delete_tty(struct lxc_tty_info *ttys);
__hidden extern int lxc_send_ttys_to_parent(struct lxc_handler *handler);
__hidden extern int lxc_send_devpts_to_parent(struct lxc_handler *handler);
__hidden extern int lxc_clear_config_caps(struct lxc_conf *c); __hidden extern int lxc_clear_config_caps(struct lxc_conf *c);
__hidden extern int lxc_clear_config_keepcaps(struct lxc_conf *c); __hidden extern int lxc_clear_config_keepcaps(struct lxc_conf *c);
__hidden extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version); __hidden extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version);
...@@ -583,6 +581,7 @@ static inline int chown_mapped_root(const char *path, const struct lxc_conf *con ...@@ -583,6 +581,7 @@ static inline int chown_mapped_root(const char *path, const struct lxc_conf *con
} }
__hidden extern int lxc_sync_fds_parent(struct lxc_handler *handler); __hidden extern int lxc_sync_fds_parent(struct lxc_handler *handler);
__hidden extern int lxc_sync_fds_child(struct lxc_handler *handler);
static inline const char *get_rootfs_mnt(const struct lxc_rootfs *rootfs) static inline const char *get_rootfs_mnt(const struct lxc_rootfs *rootfs)
{ {
......
...@@ -1330,32 +1330,12 @@ static int do_start(void *data) ...@@ -1330,32 +1330,12 @@ static int do_start(void *data)
if (!lxc_sync_barrier_parent(handler, START_SYNC_CGROUP_LIMITS)) if (!lxc_sync_barrier_parent(handler, START_SYNC_CGROUP_LIMITS))
goto out_warn_father; goto out_warn_father;
ret = lxc_seccomp_send_notifier_fd(&handler->conf->seccomp, data_sock0); ret = lxc_sync_fds_child(handler);
if (ret < 0) { if (ret < 0) {
SYSERROR("Failed to send seccomp notify fd to parent"); SYSERROR("Failed to sync file descriptors with parent");
goto out_warn_father; goto out_warn_father;
} }
ret = lxc_send_devpts_to_parent(handler);
if (ret < 0) {
SYSERROR("Failed to send seccomp devpts fd to parent");
goto out_warn_father;
}
ret = lxc_send_ttys_to_parent(handler);
if (ret < 0) {
SYSERROR("Failed to send tty file descriptors to parent");
goto out_warn_father;
}
if (handler->ns_clone_flags & CLONE_NEWNET) {
ret = lxc_network_send_name_and_ifindex_to_parent(handler);
if (ret < 0) {
SYSERROR("Failed to send network device names and ifindices to parent");
goto out_warn_father;
}
}
if (!lxc_sync_wait_parent(handler, START_SYNC_READY_START)) if (!lxc_sync_wait_parent(handler, START_SYNC_READY_START))
goto out_warn_father; goto out_warn_father;
......
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