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
e9636f4f
Unverified
Commit
e9636f4f
authored
Jan 27, 2021
by
Christian Brauner
Committed by
GitHub
Jan 27, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3634 from motiejus/mkdir-proc-sys
mkdir -p /proc /sys on container startup
parents
2c641705
493e00b6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
1 deletion
+64
-1
conf.c
src/lxc/conf.c
+18
-1
Makefile.am
src/tests/Makefile.am
+2
-0
lxc-test-procsys
src/tests/lxc-test-procsys
+44
-0
No files found.
src/lxc/conf.c
View file @
e9636f4f
...
...
@@ -3278,6 +3278,24 @@ int lxc_setup(struct lxc_handler *handler)
if
(
ret
<
0
)
return
log_error
(
-
1
,
"Failed to setup rootfs"
);
/* Create mountpoints for /proc and /sys. */
char
path
[
PATH_MAX
];
char
*
rootfs_path
=
lxc_conf
->
rootfs
.
path
?
lxc_conf
->
rootfs
.
mount
:
""
;
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/proc"
,
rootfs_path
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
return
log_error
(
-
1
,
"Path to /proc too long"
);
ret
=
mkdir
(
path
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create
\"
/proc
\"
directory"
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/sys"
,
rootfs_path
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
return
log_error
(
-
1
,
"Path to /sys too long"
);
ret
=
mkdir
(
path
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create
\"
/sys
\"
directory"
);
if
(
handler
->
nsfd
[
LXC_NS_UTS
]
==
-
EBADF
)
{
ret
=
setup_utsname
(
lxc_conf
->
utsname
);
if
(
ret
<
0
)
...
...
@@ -3344,7 +3362,6 @@ int lxc_setup(struct lxc_handler *handler)
if
(
lxc_conf
->
is_execute
)
{
if
(
execveat_supported
())
{
int
fd
;
char
path
[
PATH_MAX
];
ret
=
snprintf
(
path
,
PATH_MAX
,
SBINDIR
"/init.lxc.static"
);
if
(
ret
<
0
||
ret
>=
PATH_MAX
)
...
...
src/tests/Makefile.am
View file @
e9636f4f
...
...
@@ -620,6 +620,7 @@ bin_SCRIPTS += lxc-test-automount \
lxc-test-exit-code
\
lxc-test-no-new-privs
\
lxc-test-rootfs
\
lxc-test-procsys
\
lxc-test-usernsexec
if
DISTRO_UBUNTU
...
...
@@ -658,6 +659,7 @@ EXTRA_DIST = basic.c \
lxc-test-lxc-attach
\
lxc-test-automount
\
lxc-test-rootfs
\
lxc-test-procsys
\
lxc-test-autostart
\
lxc-test-apparmor-mount
\
lxc-test-apparmor-generated
\
...
...
src/tests/lxc-test-procsys
0 → 100755
View file @
e9636f4f
#!/bin/bash
# lxc: linux Container library
# Authors:
# Motiejus Jakštys <motiejus@jakstys.lt>
#
# Ensure that when /proc and/or /sys do not exist in the container,
# it is started successfully anyway.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
set
-ex
FAIL
()
{
echo
-n
"Failed "
>
&2
echo
"
$*
"
>
&2
lxc-destroy
-n
lxc-test-procsys
-f
exit
1
}
lxc-destroy
-n
lxc-test-procsys
-f
||
:
lxc-create
-t
busybox
-n
lxc-test-procsys
rmdir
/var/lib/lxc/lxc-test-procsys/rootfs/
{
proc,sys
}
lxc-start
-n
lxc-test-procsys
lxc-wait
-n
lxc-test-procsys
-s
RUNNING
||
FAIL
"waiting for busybox container to run"
lxc-attach
-n
lxc-test-procsys
--
sh
-c
'test -f /proc/version'
||
FAIL
"/proc/version not found"
lxc-attach
-n
lxc-test-procsys
--
sh
-c
'test -d /sys/fs'
||
FAIL
"/sys/fs not found"
lxc-destroy
-n
lxc-test-procsys
-f
exit
0
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