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
bb956bfc
Unverified
Commit
bb956bfc
authored
Dec 09, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile_utils: cleanup lxc_inherit_namespace()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
60e7645a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
confile_utils.c
src/lxc/confile_utils.c
+8
-8
utils.c
src/lxc/utils.c
+2
-4
No files found.
src/lxc/confile_utils.c
View file @
bb956bfc
...
...
@@ -878,8 +878,9 @@ static int lxc_container_name_to_pid(const char *lxcname_or_pid,
int
lxc_inherit_namespace
(
const
char
*
nsfd_path
,
const
char
*
lxcpath
,
const
char
*
namespace
)
{
__do_free
char
*
dup
=
NULL
;
int
fd
,
pid
;
char
*
dup
,
*
lastslash
;
char
*
lastslash
;
if
(
nsfd_path
[
0
]
==
'/'
)
{
return
open
(
nsfd_path
,
O_RDONLY
|
O_CLOEXEC
);
...
...
@@ -889,21 +890,20 @@ int lxc_inherit_namespace(const char *nsfd_path, const char *lxcpath,
if
(
lastslash
)
{
dup
=
strdup
(
nsfd_path
);
if
(
!
dup
)
return
-
1
;
return
ret_errno
(
ENOMEM
)
;
dup
[
lastslash
-
nsfd_path
]
=
'\0'
;
pid
=
lxc_container_name_to_pid
(
lastslash
+
1
,
dup
);
free
(
dup
);
}
else
{
pid
=
lxc_container_name_to_pid
(
nsfd_path
,
lxcpath
);
lxcpath
=
lastslash
+
1
;
nsfd_path
=
lastslash
+
1
;
}
pid
=
lxc_container_name_to_pid
(
nsfd_path
,
lxcpath
);
if
(
pid
<
0
)
return
-
1
;
return
pid
;
fd
=
lxc_preserve_ns
(
pid
,
namespace
);
if
(
fd
<
0
)
return
-
1
;
return
-
errno
;
return
fd
;
}
...
...
src/lxc/utils.c
View file @
bb956bfc
...
...
@@ -1372,10 +1372,8 @@ int lxc_preserve_ns(const int pid, const char *ns)
ret
=
snprintf
(
path
,
__NS_PATH_LEN
,
"/proc/%d/ns%s%s"
,
pid
,
!
ns
||
strcmp
(
ns
,
""
)
==
0
?
""
:
"/"
,
!
ns
||
strcmp
(
ns
,
""
)
==
0
?
""
:
ns
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
__NS_PATH_LEN
)
{
errno
=
EFBIG
;
return
-
1
;
}
if
(
ret
<
0
||
(
size_t
)
ret
>=
__NS_PATH_LEN
)
return
ret_errno
(
EIO
);
return
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
}
...
...
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