Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
6e36c297
Unverified
Commit
6e36c297
authored
Jan 29, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: introduce sync_wait_fd() and sync_wake_fd()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
6e48e7c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
19 deletions
+24
-19
attach.c
src/lxc/attach.c
+24
-19
No files found.
src/lxc/attach.c
View file @
6e36c297
...
@@ -67,6 +67,26 @@ struct attach_context {
...
@@ -67,6 +67,26 @@ struct attach_context {
struct
lsm_ops
*
lsm_ops
;
struct
lsm_ops
*
lsm_ops
;
};
};
static
inline
bool
sync_wake_pid
(
int
fd
,
pid_t
pid
)
{
return
lxc_write_nointr
(
fd
,
&
pid
,
sizeof
(
pid_t
))
==
sizeof
(
pid_t
);
}
static
inline
bool
sync_wait_pid
(
int
fd
,
pid_t
*
pid
)
{
return
lxc_read_nointr
(
fd
,
pid
,
sizeof
(
pid_t
))
==
sizeof
(
pid_t
);
}
static
inline
bool
sync_wake_fd
(
int
fd
,
int
fd_send
)
{
return
lxc_abstract_unix_send_fds
(
fd
,
&
fd_send
,
1
,
NULL
,
0
)
>
0
;
}
static
inline
bool
sync_wait_fd
(
int
fd
,
int
*
fd_recv
)
{
return
lxc_abstract_unix_recv_fds
(
fd
,
fd_recv
,
1
,
NULL
,
0
)
>
0
;
}
static
struct
attach_context
*
alloc_attach_context
(
void
)
static
struct
attach_context
*
alloc_attach_context
(
void
)
{
{
return
zalloc
(
sizeof
(
struct
attach_context
));
return
zalloc
(
sizeof
(
struct
attach_context
));
...
@@ -803,11 +823,8 @@ __noreturn static void do_attach(struct attach_payload *ap)
...
@@ -803,11 +823,8 @@ __noreturn static void do_attach(struct attach_payload *ap)
* set{g,u}id().
* set{g,u}id().
*/
*/
if
(
needs_lsm
)
{
if
(
needs_lsm
)
{
ret
=
lxc_abstract_unix_recv_fds
(
ap
->
ipc_socket
,
&
lsm_fd
,
1
,
NULL
,
0
);
if
(
!
sync_wait_fd
(
ap
->
ipc_socket
,
&
lsm_fd
))
{
if
(
ret
<=
0
)
{
SYSERROR
(
"Failed to receive lsm label fd"
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to receive lsm label fd"
);
goto
on_error
;
goto
on_error
;
}
}
...
@@ -1027,16 +1044,6 @@ static inline void lxc_attach_terminal_close_log(struct lxc_terminal *terminal)
...
@@ -1027,16 +1044,6 @@ static inline void lxc_attach_terminal_close_log(struct lxc_terminal *terminal)
close_prot_errno_disarm
(
terminal
->
log_fd
);
close_prot_errno_disarm
(
terminal
->
log_fd
);
}
}
static
inline
bool
sync_wake_pid
(
int
fd
,
pid_t
pid
)
{
return
lxc_write_nointr
(
fd
,
&
pid
,
sizeof
(
pid_t
))
==
sizeof
(
pid_t
);
}
static
inline
bool
sync_wait_pid
(
int
fd
,
pid_t
*
pid
)
{
return
lxc_read_nointr
(
fd
,
pid
,
sizeof
(
pid_t
))
==
sizeof
(
pid_t
);
}
int
lxc_attach
(
struct
lxc_container
*
container
,
lxc_attach_exec_t
exec_function
,
int
lxc_attach
(
struct
lxc_container
*
container
,
lxc_attach_exec_t
exec_function
,
void
*
exec_payload
,
lxc_attach_options_t
*
options
,
void
*
exec_payload
,
lxc_attach_options_t
*
options
,
pid_t
*
attached_process
)
pid_t
*
attached_process
)
...
@@ -1375,10 +1382,8 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1375,10 +1382,8 @@ 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. */
ret
=
lxc_abstract_unix_send_fds
(
ipc_sockets
[
0
],
&
labelfd
,
1
,
NULL
,
0
);
if
(
!
sync_wake_fd
(
ipc_sockets
[
0
],
labelfd
))
{
if
(
ret
<=
0
)
{
SYSERROR
(
"Failed to send lsm label fd"
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to send lsm label fd"
);
goto
close_mainloop
;
goto
close_mainloop
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment