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
a1387f5c
Commit
a1387f5c
authored
May 18, 2017
by
Serge Hallyn
Committed by
GitHub
May 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1575 from brauner/2017-05-18/fix_tmp_mount_proc
utils: fix lxc_mount_proc_if_needed()
parents
0cb5ac09
6b1ba5d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
utils.c
src/lxc/utils.c
+17
-16
No files found.
src/lxc/utils.c
View file @
a1387f5c
...
...
@@ -1758,9 +1758,8 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
int
lxc_mount_proc_if_needed
(
const
char
*
rootfs
)
{
char
path
[
MAXPATHLEN
];
char
link
[
20
];
int
link_to_pid
,
linklen
,
ret
;
int
mypid
;
int
link_to_pid
,
linklen
,
mypid
,
ret
;
char
link
[
LXC_NUMSTRLEN64
]
=
{
0
};
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/proc/self"
,
rootfs
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
...
...
@@ -1768,10 +1767,7 @@ int lxc_mount_proc_if_needed(const char *rootfs)
return
-
1
;
}
memset
(
link
,
0
,
20
);
linklen
=
readlink
(
path
,
link
,
20
);
mypid
=
(
int
)
getpid
();
INFO
(
"I am %d, /proc/self points to
\"
%s
\"
"
,
mypid
,
link
);
linklen
=
readlink
(
path
,
link
,
LXC_NUMSTRLEN64
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/proc"
,
rootfs
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
...
...
@@ -1784,24 +1780,29 @@ int lxc_mount_proc_if_needed(const char *rootfs)
if
(
mkdir
(
path
,
0755
)
&&
errno
!=
EEXIST
)
return
-
1
;
goto
domount
;
}
else
if
(
linklen
>=
LXC_NUMSTRLEN64
)
{
link
[
linklen
-
1
]
=
'\0'
;
ERROR
(
"readlink returned truncated content:
\"
%s
\"
"
,
link
);
return
-
1
;
}
mypid
=
getpid
();
INFO
(
"I am %d, /proc/self points to
\"
%s
\"
"
,
mypid
,
link
);
if
(
lxc_safe_int
(
link
,
&
link_to_pid
)
<
0
)
return
-
1
;
/* wrong /procs mounted */
if
(
link_to_pid
!=
mypid
)
{
/* ignore failure */
umount2
(
path
,
MNT_DETACH
);
goto
domount
;
}
/* correct procfs is already mounted */
if
(
link_to_pid
==
mypid
)
return
0
;
/* the right proc is already mounted */
return
0
;
ret
=
umount2
(
path
,
MNT_DETACH
);
if
(
ret
<
0
)
WARN
(
"failed to umount
\"
%s
\"
with MNT_DETACH"
,
path
);
domount
:
/* rootfs is NULL */
if
(
!
strcmp
(
rootfs
,
""
))
if
(
!
strcmp
(
rootfs
,
""
))
ret
=
mount
(
"proc"
,
path
,
"proc"
,
0
,
NULL
);
else
ret
=
safe_mount
(
"proc"
,
path
,
"proc"
,
0
,
NULL
,
rootfs
);
...
...
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