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
fc2ad9dc
Unverified
Commit
fc2ad9dc
authored
Apr 29, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: tweak lxc_mount_proc_if_needed()
Create /proc directory if it doesn't exist. Closes #1475. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
943144d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
utils.c
src/lxc/utils.c
+18
-7
No files found.
src/lxc/utils.c
View file @
fc2ad9dc
...
@@ -1766,37 +1766,48 @@ int lxc_mount_proc_if_needed(const char *rootfs)
...
@@ -1766,37 +1766,48 @@ int lxc_mount_proc_if_needed(const char *rootfs)
SYSERROR
(
"proc path name too long"
);
SYSERROR
(
"proc path name too long"
);
return
-
1
;
return
-
1
;
}
}
memset
(
link
,
0
,
20
);
memset
(
link
,
0
,
20
);
linklen
=
readlink
(
path
,
link
,
20
);
linklen
=
readlink
(
path
,
link
,
20
);
mypid
=
(
int
)
getpid
();
mypid
=
(
int
)
getpid
();
INFO
(
"I am %d, /proc/self points to '%s'"
,
mypid
,
link
);
INFO
(
"I am %d, /proc/self points to
\"
%s
\"
"
,
mypid
,
link
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/proc"
,
rootfs
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/proc"
,
rootfs
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
SYSERROR
(
"proc path name too long"
);
SYSERROR
(
"proc path name too long"
);
return
-
1
;
return
-
1
;
}
}
if
(
linklen
<
0
)
/* /proc not mounted */
/* /proc not mounted */
if
(
linklen
<
0
)
{
if
(
mkdir
(
path
,
0755
)
&&
errno
!=
EEXIST
)
return
-
1
;
goto
domount
;
goto
domount
;
}
if
(
lxc_safe_int
(
link
,
&
link_to_pid
)
<
0
)
if
(
lxc_safe_int
(
link
,
&
link_to_pid
)
<
0
)
return
-
1
;
return
-
1
;
/* wrong /procs mounted */
if
(
link_to_pid
!=
mypid
)
{
if
(
link_to_pid
!=
mypid
)
{
/*
wrong /procs mounted
*/
/*
ignore failure
*/
umount2
(
path
,
MNT_DETACH
);
/* ignore failure */
umount2
(
path
,
MNT_DETACH
);
goto
domount
;
goto
domount
;
}
}
/* the right proc is already mounted */
/* the right proc is already mounted */
return
0
;
return
0
;
domount
:
domount
:
if
(
!
strcmp
(
rootfs
,
""
))
/* rootfs is NULL */
/* rootfs is NULL */
if
(
!
strcmp
(
rootfs
,
""
))
ret
=
mount
(
"proc"
,
path
,
"proc"
,
0
,
NULL
);
ret
=
mount
(
"proc"
,
path
,
"proc"
,
0
,
NULL
);
else
else
ret
=
safe_mount
(
"proc"
,
path
,
"proc"
,
0
,
NULL
,
rootfs
);
ret
=
safe_mount
(
"proc"
,
path
,
"proc"
,
0
,
NULL
,
rootfs
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
INFO
(
"
M
ounted /proc in container for security transition"
);
INFO
(
"
m
ounted /proc in container for security transition"
);
return
1
;
return
1
;
}
}
...
...
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