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
5032bf39
Unverified
Commit
5032bf39
authored
Feb 18, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start: simplify
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
03760215
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
25 deletions
+12
-25
start.c
src/lxc/start.c
+12
-25
No files found.
src/lxc/start.c
View file @
5032bf39
...
...
@@ -129,39 +129,39 @@ static void print_top_failing_dir(const char *path)
}
}
static
void
close_ns
(
int
ns_fd
[
LXC_NS_MAX
]
)
static
void
lxc_put_nsfds
(
struct
lxc_handler
*
handler
)
{
int
i
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
(
ns_
fd
[
i
]
<
0
)
if
(
handler
->
ns
fd
[
i
]
<
0
)
continue
;
close
(
ns_
fd
[
i
]);
ns_
fd
[
i
]
=
-
EBADF
;
close
(
handler
->
ns
fd
[
i
]);
handler
->
ns
fd
[
i
]
=
-
EBADF
;
}
}
/*
preserve_n
s: open /proc/@pid/ns/@ns for each namespace specified
/*
lxc_preserve_namespace
s: open /proc/@pid/ns/@ns for each namespace specified
* in clone_flags.
* Return true on success, false on failure.
*/
static
bool
preserve_ns
(
int
ns_fd
[
LXC_NS_MAX
]
,
int
clone_flags
,
pid_t
pid
)
static
bool
lxc_preserve_namespaces
(
struct
lxc_handler
*
handler
,
int
clone_flags
,
pid_t
pid
)
{
int
i
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
ns_
fd
[
i
]
=
-
EBADF
;
handler
->
ns
fd
[
i
]
=
-
EBADF
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
((
clone_flags
&
ns_info
[
i
].
clone_flag
)
==
0
)
continue
;
ns_
fd
[
i
]
=
lxc_preserve_ns
(
pid
,
ns_info
[
i
].
proc_name
);
if
(
ns_
fd
[
i
]
<
0
)
handler
->
ns
fd
[
i
]
=
lxc_preserve_ns
(
pid
,
ns_info
[
i
].
proc_name
);
if
(
handler
->
ns
fd
[
i
]
<
0
)
goto
error
;
DEBUG
(
"Preserved %s namespace via fd %d"
,
ns_info
[
i
].
proc_name
,
ns_
fd
[
i
]);
DEBUG
(
"Preserved %s namespace via fd %d"
,
ns_info
[
i
].
proc_name
,
handler
->
ns
fd
[
i
]);
}
return
true
;
...
...
@@ -173,7 +173,7 @@ error:
else
SYSERROR
(
"Failed to open file descriptor for %s namespace"
,
ns_info
[
i
].
proc_name
);
close_ns
(
ns_fd
);
lxc_put_nsfds
(
handler
);
return
false
;
}
...
...
@@ -609,19 +609,6 @@ void lxc_zero_handler(struct lxc_handler *handler)
handler
->
sync_sock
[
1
]
=
-
1
;
}
static
void
lxc_put_nsfds
(
struct
lxc_handler
*
handler
)
{
int
i
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
(
handler
->
nsfd
[
i
]
<
0
)
continue
;
close
(
handler
->
nsfd
[
i
]);
handler
->
nsfd
[
i
]
=
-
EBADF
;
}
}
void
lxc_free_handler
(
struct
lxc_handler
*
handler
)
{
if
(
handler
->
pinfd
>=
0
)
...
...
@@ -1550,7 +1537,7 @@ static int lxc_spawn(struct lxc_handler *handler)
if
(
handler
->
on_clone_flags
&
ns_info
[
i
].
clone_flag
)
INFO
(
"Cloned %s"
,
ns_info
[
i
].
flag_name
);
if
(
!
preserve_ns
(
handler
->
nsfd
,
handler
->
on_clone_flags
,
handler
->
pid
))
{
if
(
!
lxc_preserve_namespaces
(
handler
,
handler
->
on_clone_flags
,
handler
->
pid
))
{
ERROR
(
"Failed to preserve cloned namespaces for lxc.hook.stop"
);
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