attach: use dummy macros to make it easier to follow sync logic

parent 6e36c297
...@@ -823,7 +823,7 @@ __noreturn static void do_attach(struct attach_payload *ap) ...@@ -823,7 +823,7 @@ __noreturn static void do_attach(struct attach_payload *ap)
* set{g,u}id(). * set{g,u}id().
*/ */
if (needs_lsm) { if (needs_lsm) {
if (!sync_wait_fd(ap->ipc_socket, &lsm_fd)) { if (!sync_wait_fd(ap->ipc_socket, ATTACH_SYNC_LSM(&lsm_fd))) {
SYSERROR("Failed to receive lsm label fd"); SYSERROR("Failed to receive lsm label fd");
goto on_error; goto on_error;
} }
...@@ -1265,7 +1265,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, ...@@ -1265,7 +1265,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
lxc_attach_terminal_close_pts(&terminal); lxc_attach_terminal_close_pts(&terminal);
/* Tell grandparent the pid of the pid of the newly created child. */ /* Tell grandparent the pid of the pid of the newly created child. */
if (!sync_wake_pid(ipc_sockets[1], pid)) { if (!sync_wake_pid(ipc_sockets[1], ATTACH_SYNC_PID(pid))) {
/* If this really happens here, this is very unfortunate, since /* If this really happens here, this is very unfortunate, since
* the parent will not know the pid of the attached process and * the parent will not know the pid of the attached process and
* will not be able to wait for it (and we won't either due to * will not be able to wait for it (and we won't either due to
...@@ -1345,7 +1345,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, ...@@ -1345,7 +1345,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
TRACE("Told intermediate process to start initializing"); TRACE("Told intermediate process to start initializing");
/* Get pid of attached process from intermediate process. */ /* Get pid of attached process from intermediate process. */
if (!sync_wait_pid(ipc_sockets[0], &attached_pid)) if (!sync_wait_pid(ipc_sockets[0], ATTACH_SYNC_PID(&attached_pid)))
goto close_mainloop; goto close_mainloop;
TRACE("Received pid %d of attached process in parent pid namespace", attached_pid); TRACE("Received pid %d of attached process in parent pid namespace", attached_pid);
...@@ -1382,7 +1382,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, ...@@ -1382,7 +1382,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
TRACE("Opened LSM label file descriptor %d", labelfd); TRACE("Opened LSM label file descriptor %d", labelfd);
/* Send child fd of the LSM security module to write to. */ /* Send child fd of the LSM security module to write to. */
if (!sync_wake_fd(ipc_sockets[0], labelfd)) { if (!sync_wake_fd(ipc_sockets[0], ATTACH_SYNC_LSM(labelfd))) {
SYSERROR("Failed to send lsm label fd"); SYSERROR("Failed to send lsm label fd");
goto close_mainloop; goto close_mainloop;
} }
......
...@@ -29,6 +29,9 @@ enum /* attach */ { ...@@ -29,6 +29,9 @@ enum /* attach */ {
ATTACH_SYNC_CGROUP = 0, ATTACH_SYNC_CGROUP = 0,
}; };
#define ATTACH_SYNC_PID(x) (x)
#define ATTACH_SYNC_LSM(x) (x)
__hidden extern bool lxc_sync_init(struct lxc_handler *handler); __hidden extern bool lxc_sync_init(struct lxc_handler *handler);
__hidden extern void lxc_sync_fini(struct lxc_handler *); __hidden extern void lxc_sync_fini(struct lxc_handler *);
__hidden extern void lxc_sync_fini_parent(struct lxc_handler *); __hidden extern void lxc_sync_fini_parent(struct lxc_handler *);
......
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