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
5b657f6b
Commit
5b657f6b
authored
Oct 06, 2015
by
Wolfgang Bumiller
Committed by
Stéphane Graber
Oct 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start.c:preserve_ns: added pid parameter
Signed-off-by:
Wolfgang Bumiller
<
w.bumiller@proxmox.com
>
Acked-by:
Serge E. Hallyn
<
serge.hallyn@ubuntu.com
>
parent
5406bd2c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
start.c
src/lxc/start.c
+6
-4
No files found.
src/lxc/start.c
View file @
5b657f6b
...
@@ -117,14 +117,15 @@ static void close_ns(int ns_fd[LXC_NS_MAX]) {
...
@@ -117,14 +117,15 @@ static void close_ns(int ns_fd[LXC_NS_MAX]) {
}
}
}
}
static
int
preserve_ns
(
int
ns_fd
[
LXC_NS_MAX
],
int
clone_flags
)
{
static
int
preserve_ns
(
int
ns_fd
[
LXC_NS_MAX
],
int
clone_flags
,
pid_t
pid
)
{
int
i
,
saved_errno
;
int
i
,
saved_errno
;
char
path
[
MAXPATHLEN
];
char
path
[
MAXPATHLEN
];
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
ns_fd
[
i
]
=
-
1
;
ns_fd
[
i
]
=
-
1
;
if
(
access
(
"/proc/self/ns"
,
X_OK
))
{
snprintf
(
path
,
MAXPATHLEN
,
"/proc/%d/ns"
,
pid
);
if
(
access
(
path
,
X_OK
))
{
WARN
(
"Kernel does not support attach; preserve_ns ignored"
);
WARN
(
"Kernel does not support attach; preserve_ns ignored"
);
return
0
;
return
0
;
}
}
...
@@ -132,7 +133,8 @@ static int preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags) {
...
@@ -132,7 +133,8 @@ static int preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags) {
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
((
clone_flags
&
ns_info
[
i
].
clone_flag
)
==
0
)
if
((
clone_flags
&
ns_info
[
i
].
clone_flag
)
==
0
)
continue
;
continue
;
snprintf
(
path
,
MAXPATHLEN
,
"/proc/self/ns/%s"
,
ns_info
[
i
].
proc_name
);
snprintf
(
path
,
MAXPATHLEN
,
"/proc/%d/ns/%s"
,
pid
,
ns_info
[
i
].
proc_name
);
ns_fd
[
i
]
=
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
ns_fd
[
i
]
=
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
if
(
ns_fd
[
i
]
<
0
)
if
(
ns_fd
[
i
]
<
0
)
goto
error
;
goto
error
;
...
@@ -953,7 +955,7 @@ static int lxc_spawn(struct lxc_handler *handler)
...
@@ -953,7 +955,7 @@ static int lxc_spawn(struct lxc_handler *handler)
INFO
(
"failed to pin the container's rootfs"
);
INFO
(
"failed to pin the container's rootfs"
);
}
}
if
(
preserve_ns
(
saved_ns_fd
,
preserve_mask
)
<
0
)
if
(
preserve_ns
(
saved_ns_fd
,
preserve_mask
,
getpid
()
)
<
0
)
goto
out_delete_net
;
goto
out_delete_net
;
if
(
attach_ns
(
handler
->
conf
->
inherit_ns_fd
)
<
0
)
if
(
attach_ns
(
handler
->
conf
->
inherit_ns_fd
)
<
0
)
goto
out_delete_net
;
goto
out_delete_net
;
...
...
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