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
3cc629fe
Unverified
Commit
3cc629fe
authored
Feb 21, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attach: cleanup macros in_same_namespace
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
fd2a88b1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
23 deletions
+9
-23
attach.c
src/lxc/attach.c
+9
-23
No files found.
src/lxc/attach.c
View file @
3cc629fe
...
...
@@ -157,7 +157,8 @@ static void lxc_proc_put_context_info(struct lxc_proc_context_info *ctx)
*/
static
int
in_same_namespace
(
pid_t
pid1
,
pid_t
pid2
,
const
char
*
ns
)
{
int
ns_fd1
=
-
1
,
ns_fd2
=
-
1
,
ret
=
-
1
;
__do_close_prot_errno
int
ns_fd1
=
-
1
,
ns_fd2
=
-
1
;
int
ret
=
-
1
;
int
saved_errno
;
struct
stat
ns_st1
,
ns_st2
;
...
...
@@ -169,42 +170,27 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
if
(
errno
==
ENOENT
)
return
-
EINVAL
;
goto
out
;
return
-
1
;
}
ns_fd2
=
lxc_preserve_ns
(
pid2
,
ns
);
if
(
ns_fd2
<
0
)
goto
out
;
return
-
1
;
ret
=
fstat
(
ns_fd1
,
&
ns_st1
);
if
(
ret
<
0
)
goto
out
;
return
-
1
;
ret
=
fstat
(
ns_fd2
,
&
ns_st2
);
if
(
ret
<
0
)
goto
out
;
return
-
1
;
/* processes are in the same namespace */
if
((
ns_st1
.
st_dev
==
ns_st2
.
st_dev
)
&&
(
ns_st1
.
st_ino
==
ns_st2
.
st_ino
))
{
ret
=
-
EINVAL
;
goto
out
;
}
if
((
ns_st1
.
st_dev
==
ns_st2
.
st_dev
)
&&
(
ns_st1
.
st_ino
==
ns_st2
.
st_ino
))
return
-
EINVAL
;
/* processes are in different namespaces */
ret
=
ns_fd2
;
ns_fd2
=
-
1
;
out:
saved_errno
=
errno
;
if
(
ns_fd1
>=
0
)
close
(
ns_fd1
);
if
(
ns_fd2
>=
0
)
close
(
ns_fd2
);
errno
=
saved_errno
;
return
ret
;
return
move_fd
(
ns_fd2
);
}
static
int
lxc_attach_to_ns
(
pid_t
pid
,
struct
lxc_proc_context_info
*
ctx
)
...
...
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