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
39b3b69b
Unverified
Commit
39b3b69b
authored
Jan 29, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: rework attaching to namespace fds
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3a24f14e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
attach.c
src/lxc/attach.c
+7
-6
No files found.
src/lxc/attach.c
View file @
39b3b69b
...
@@ -277,7 +277,7 @@ static void put_attach_context(struct attach_context *ctx)
...
@@ -277,7 +277,7 @@ static void put_attach_context(struct attach_context *ctx)
free
(
ctx
);
free
(
ctx
);
}
}
static
int
lxc_attach_to_ns
(
pid_t
pid
,
struct
attach_context
*
ctx
)
static
int
attach_nsfds
(
struct
attach_context
*
ctx
)
{
{
for
(
int
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
for
(
int
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
int
ret
;
int
ret
;
...
@@ -287,11 +287,12 @@ static int lxc_attach_to_ns(pid_t pid, struct attach_context *ctx)
...
@@ -287,11 +287,12 @@ static int lxc_attach_to_ns(pid_t pid, struct attach_context *ctx)
ret
=
setns
(
ctx
->
ns_fd
[
i
],
ns_info
[
i
].
clone_flag
);
ret
=
setns
(
ctx
->
ns_fd
[
i
],
ns_info
[
i
].
clone_flag
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
return
log_error_errno
(
-
1
,
errno
,
errno
,
"Failed to attach to %s namespace of %d"
,
"Failed to attach to %s namespace of %d"
,
ns_info
[
i
].
proc_name
,
pid
);
ns_info
[
i
].
proc_name
,
ctx
->
init_
pid
);
DEBUG
(
"Attached to %s namespace of %d"
,
ns_info
[
i
].
proc_name
,
pid
);
DEBUG
(
"Attached to %s namespace of %d"
,
ns_info
[
i
].
proc_name
,
ctx
->
init_pid
);
}
}
return
0
;
return
0
;
...
@@ -1207,7 +1208,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1207,7 +1208,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
/* Attach now, create another subprocess later, since pid namespaces
/* Attach now, create another subprocess later, since pid namespaces
* only really affect the children of the current process.
* only really affect the children of the current process.
*/
*/
ret
=
lxc_attach_to_ns
(
ctx
->
init_pid
,
ctx
);
ret
=
attach_nsfds
(
ctx
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to enter namespaces"
);
ERROR
(
"Failed to enter namespaces"
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
...
...
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