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
643bcac9
Unverified
Commit
643bcac9
authored
May 13, 2018
by
Christian Brauner
Committed by
Christian Brauner
Jul 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: tweak mount injection tests
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c8c568c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
15 deletions
+36
-15
mount_injection.c
src/tests/mount_injection.c
+36
-15
No files found.
src/tests/mount_injection.c
View file @
643bcac9
...
@@ -73,29 +73,50 @@ static int find_in_proc_mounts(void *data)
...
@@ -73,29 +73,50 @@ static int find_in_proc_mounts(void *data)
{
{
char
buf
[
LXC_LINELEN
];
char
buf
[
LXC_LINELEN
];
FILE
*
f
;
FILE
*
f
;
struct
mountinfo_data
*
mdata
=
(
struct
mountinfo_data
*
)
data
;
struct
mountinfo_data
*
mdata
=
(
struct
mountinfo_data
*
)
data
;
fprintf
(
stderr
,
"%s"
,
mdata
->
message
);
fprintf
(
stderr
,
"%s"
,
mdata
->
message
);
f
=
fopen
(
"/proc/self/mountinfo"
,
"r"
);
f
=
fopen
(
"/proc/self/mountinfo"
,
"r"
);
if
(
!
f
)
if
(
!
f
)
return
0
;
return
0
;
while
(
fgets
(
buf
,
LXC_LINELEN
,
f
))
{
while
(
fgets
(
buf
,
LXC_LINELEN
,
f
))
{
if
(
comp_field
(
buf
,
mdata
->
mount_root
,
3
)
==
0
&&
comp_field
(
buf
,
mdata
->
mount_point
,
4
)
==
0
)
{
char
*
buf2
;
char
*
buf2
=
strchr
(
buf
,
'-'
);
if
(
comp_field
(
buf2
,
mdata
->
fstype
,
1
)
==
0
&&
comp_field
(
buf2
,
mdata
->
mount_source
,
2
)
==
0
)
{
/* checking mount_root is tricky since it will be prefixed with
fclose
(
f
);
* whatever path was the source of the mount in the original
fprintf
(
stderr
,
"PRESENT
\n
"
);
* mount namespace. So only verify it when we know that root is
if
(
mdata
->
should_be_present
)
* in fact "/".
_exit
(
EXIT_SUCCESS
);
*/
_exit
(
EXIT_FAILURE
);
if
(
mdata
->
mount_root
&&
comp_field
(
buf
,
mdata
->
mount_root
,
3
)
!=
0
)
}
continue
;
}
if
(
comp_field
(
buf
,
mdata
->
mount_point
,
4
)
!=
0
)
continue
;
if
(
!
mdata
->
fstype
||
!
mdata
->
mount_source
)
goto
on_success
;
buf2
=
strchr
(
buf
,
'-'
);
if
(
comp_field
(
buf2
,
mdata
->
fstype
,
1
)
!=
0
||
comp_field
(
buf2
,
mdata
->
mount_source
,
2
)
!=
0
)
continue
;
on_success:
fclose
(
f
);
fprintf
(
stderr
,
"PRESENT
\n
"
);
if
(
mdata
->
should_be_present
)
_exit
(
EXIT_SUCCESS
);
_exit
(
EXIT_FAILURE
);
}
}
fclose
(
f
);
fclose
(
f
);
fprintf
(
stderr
,
"MISSING
\n
"
);
fprintf
(
stderr
,
"MISSING
\n
"
);
if
(
!
mdata
->
should_be_present
)
if
(
!
mdata
->
should_be_present
)
_exit
(
EXIT_SUCCESS
);
_exit
(
EXIT_SUCCESS
);
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
}
}
...
@@ -113,7 +134,7 @@ static int check_containers_mountinfo(struct lxc_container *c, struct mountinfo_
...
@@ -113,7 +134,7 @@ static int check_containers_mountinfo(struct lxc_container *c, struct mountinfo_
ret
=
wait_for_pid
(
pid
);
ret
=
wait_for_pid
(
pid
);
if
(
ret
<
0
)
if
(
ret
<
0
)
fprintf
(
stderr
,
"Attached function failed"
);
fprintf
(
stderr
,
"Attached function failed
\n
"
);
return
ret
;
return
ret
;
}
}
...
@@ -139,9 +160,9 @@ static int perform_container_test(const char *name, const char *config_items[])
...
@@ -139,9 +160,9 @@ static int perform_container_test(const char *name, const char *config_items[])
.
message
=
""
,
.
message
=
""
,
.
should_be_present
=
true
.
should_be_present
=
true
},
dir
=
{
},
dir
=
{
.
mount_root
=
template_dir
,
.
mount_root
=
NULL
,
.
mount_point
=
template_dir
,
.
mount_point
=
template_dir
,
.
fstype
=
"ext4"
,
.
fstype
=
NULL
,
.
mount_source
=
NULL
,
.
mount_source
=
NULL
,
.
message
=
""
,
.
message
=
""
,
.
should_be_present
=
true
.
should_be_present
=
true
...
@@ -248,7 +269,7 @@ static int perform_container_test(const char *name, const char *config_items[])
...
@@ -248,7 +269,7 @@ static int perform_container_test(const char *name, const char *config_items[])
goto
out
;
goto
out
;
/* Check dir mounted */
/* Check dir mounted */
ret
=
c
->
mount
(
c
,
template_dir
,
template_dir
,
"ext4"
,
MS_BIND
,
NULL
,
&
mnt
);
ret
=
c
->
mount
(
c
,
template_dir
,
template_dir
,
NULL
,
MS_BIND
,
NULL
,
&
mnt
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Failed to mount
\"
%s
\"\n
"
,
template_dir
);
fprintf
(
stderr
,
"Failed to mount
\"
%s
\"\n
"
,
template_dir
);
goto
out
;
goto
out
;
...
...
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