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
28dcf2fe
Unverified
Commit
28dcf2fe
authored
Jul 03, 2018
by
2xsec
Committed by
Christian Brauner
Jul 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: cleanup get_item.c
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
a95b215c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
get_item.c
src/tests/get_item.c
+50
-1
No files found.
src/tests/get_item.c
View file @
28dcf2fe
...
@@ -49,11 +49,13 @@ int main(int argc, char *argv[])
...
@@ -49,11 +49,13 @@ int main(int argc, char *argv[])
lxc_error
(
"%s
\n
"
,
"Failed to set lxc.log.syslog.
\n
"
);
lxc_error
(
"%s
\n
"
,
"Failed to set lxc.log.syslog.
\n
"
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.log.syslog"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.log.syslog"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
lxc_error
(
"Failed to retrieve lxc.log.syslog: %d.
\n
"
,
ret
);
lxc_error
(
"Failed to retrieve lxc.log.syslog: %d.
\n
"
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"local0"
)
!=
0
)
{
if
(
strcmp
(
v2
,
"local0"
)
!=
0
)
{
lxc_error
(
"Expected: local0 == %s.
\n
"
,
v2
);
lxc_error
(
"Expected: local0 == %s.
\n
"
,
v2
);
goto
out
;
goto
out
;
...
@@ -71,6 +73,7 @@ int main(int argc, char *argv[])
...
@@ -71,6 +73,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set hook.pre-start
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set hook.pre-start
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.hook.pre-start"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.hook.pre-start"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.hook.pre-start) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.hook.pre-start) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -89,6 +92,7 @@ int main(int argc, char *argv[])
...
@@ -89,6 +92,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set tty
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set tty
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.tty.max"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.tty.max"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.tty) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.tty) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -100,6 +104,7 @@ int main(int argc, char *argv[])
...
@@ -100,6 +104,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set arch
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set arch
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.arch"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.arch"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.arch) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.arch) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -111,6 +116,7 @@ int main(int argc, char *argv[])
...
@@ -111,6 +116,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set init_uid
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set init_uid
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.init.uid"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.init.uid"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.init_uid) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.init_uid) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -122,6 +128,7 @@ int main(int argc, char *argv[])
...
@@ -122,6 +128,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set init_gid
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set init_gid
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.init.gid"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.init.gid"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.init_gid) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.init_gid) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -132,12 +139,13 @@ int main(int argc, char *argv[])
...
@@ -132,12 +139,13 @@ int main(int argc, char *argv[])
#define HNAME "hostname1"
#define HNAME "hostname1"
// demonstrate proper usage:
// demonstrate proper usage:
char
*
alloced
;
char
*
alloced
;
int
len
;
if
(
!
c
->
set_config_item
(
c
,
"lxc.uts.name"
,
HNAME
))
{
if
(
!
c
->
set_config_item
(
c
,
"lxc.uts.name"
,
HNAME
))
{
fprintf
(
stderr
,
"%d: failed to set utsname
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set utsname
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
int
len
;
len
=
c
->
get_config_item
(
c
,
"lxc.uts.name"
,
NULL
,
0
);
// query the size of the string
len
=
c
->
get_config_item
(
c
,
"lxc.uts.name"
,
NULL
,
0
);
// query the size of the string
if
(
len
<
0
)
{
if
(
len
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.utsname) returned %d
\n
"
,
__LINE__
,
len
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.utsname) returned %d
\n
"
,
__LINE__
,
len
);
...
@@ -151,6 +159,7 @@ int main(int argc, char *argv[])
...
@@ -151,6 +159,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to allocate %d bytes for utsname
\n
"
,
__LINE__
,
len
);
fprintf
(
stderr
,
"%d: failed to allocate %d bytes for utsname
\n
"
,
__LINE__
,
len
);
goto
out
;
goto
out
;
}
}
// now pass in the malloc'd array, and pass in length of string + 1: again
// now pass in the malloc'd array, and pass in length of string + 1: again
// because we need room for the trailing \0
// because we need room for the trailing \0
ret
=
c
->
get_config_item
(
c
,
"lxc.uts.name"
,
alloced
,
len
+
1
);
ret
=
c
->
get_config_item
(
c
,
"lxc.uts.name"
,
alloced
,
len
+
1
);
...
@@ -158,6 +167,7 @@ int main(int argc, char *argv[])
...
@@ -158,6 +167,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(lxc.utsname) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.utsname) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
alloced
,
HNAME
)
!=
0
||
ret
!=
len
)
{
if
(
strcmp
(
alloced
,
HNAME
)
!=
0
||
ret
!=
len
)
{
fprintf
(
stderr
,
"lxc.utsname returned wrong value: %d %s not %d %s
\n
"
,
ret
,
alloced
,
len
,
HNAME
);
fprintf
(
stderr
,
"lxc.utsname returned wrong value: %d %s not %d %s
\n
"
,
ret
,
alloced
,
len
,
HNAME
);
goto
out
;
goto
out
;
...
@@ -169,6 +179,7 @@ int main(int argc, char *argv[])
...
@@ -169,6 +179,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set mount.entry
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set mount.entry
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.mount.entry"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.mount.entry"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.mount.entry) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.mount.entry) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -186,11 +197,13 @@ int main(int argc, char *argv[])
...
@@ -186,11 +197,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set limit.nofile
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set limit.nofile
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.prlimit.nofile"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.prlimit.nofile"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.prlimit.nofile) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.prlimit.nofile) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"1234:unlimited"
))
{
if
(
strcmp
(
v2
,
"1234:unlimited"
))
{
fprintf
(
stderr
,
"%d: lxc.prlimit.nofile returned wrong value: %d %s not 14 1234:unlimited
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: lxc.prlimit.nofile returned wrong value: %d %s not 14 1234:unlimited
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
...
@@ -201,11 +214,13 @@ int main(int argc, char *argv[])
...
@@ -201,11 +214,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set limit.stack
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set limit.stack
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.prlimit.stack"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.prlimit.stack"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.prlimit.stack) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.prlimit.stack) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"unlimited"
))
{
if
(
strcmp
(
v2
,
"unlimited"
))
{
fprintf
(
stderr
,
"%d: lxc.prlimit.stack returned wrong value: %d %s not 9 unlimited
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: lxc.prlimit.stack returned wrong value: %d %s not 9 unlimited
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
...
@@ -219,6 +234,7 @@ int main(int argc, char *argv[])
...
@@ -219,6 +234,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(limit) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(limit) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v3
,
ALL_LIMITS
))
{
if
(
strcmp
(
v3
,
ALL_LIMITS
))
{
fprintf
(
stderr
,
"%d: lxc.prlimit returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
ALL_LIMITS
)
-
1
,
ALL_LIMITS
);
fprintf
(
stderr
,
"%d: lxc.prlimit returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
ALL_LIMITS
)
-
1
,
ALL_LIMITS
);
goto
out
;
goto
out
;
...
@@ -229,11 +245,13 @@ int main(int argc, char *argv[])
...
@@ -229,11 +245,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed clearing limit.nofile
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing limit.nofile
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.prlimit"
,
v3
,
2047
);
ret
=
c
->
get_config_item
(
c
,
"lxc.prlimit"
,
v3
,
2047
);
if
(
ret
!=
sizeof
(
LIMIT_STACK
)
-
1
)
{
if
(
ret
!=
sizeof
(
LIMIT_STACK
)
-
1
)
{
fprintf
(
stderr
,
"%d: get_config_item(limit) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(limit) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v3
,
LIMIT_STACK
))
{
if
(
strcmp
(
v3
,
LIMIT_STACK
))
{
fprintf
(
stderr
,
"%d: lxc.prlimit returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
LIMIT_STACK
)
-
1
,
LIMIT_STACK
);
fprintf
(
stderr
,
"%d: lxc.prlimit returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
LIMIT_STACK
)
-
1
,
LIMIT_STACK
);
goto
out
;
goto
out
;
...
@@ -253,11 +271,13 @@ int main(int argc, char *argv[])
...
@@ -253,11 +271,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set lxc.sysctl.net.ipv4.ip_forward
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set lxc.sysctl.net.ipv4.ip_forward
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.sysctl.net.ipv4.ip_forward"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.sysctl.net.ipv4.ip_forward"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.sysctl.net.ipv4.ip_forward) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.sysctl.net.ipv4.ip_forward) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"1"
))
{
if
(
strcmp
(
v2
,
"1"
))
{
fprintf
(
stderr
,
"%d: lxc.sysctl.net.ipv4.ip_forward returned wrong value: %d %s not 1
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: lxc.sysctl.net.ipv4.ip_forward returned wrong value: %d %s not 1
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
...
@@ -268,11 +288,13 @@ int main(int argc, char *argv[])
...
@@ -268,11 +288,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set lxc.sysctl.net.core.somaxconn
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set lxc.sysctl.net.core.somaxconn
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.sysctl.net.core.somaxconn"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.sysctl.net.core.somaxconn"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.sysctl.net.core.somaxconn) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.sysctl.net.core.somaxconn) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"256"
))
{
if
(
strcmp
(
v2
,
"256"
))
{
fprintf
(
stderr
,
"%d: lxc.sysctl.net.core.somaxconn returned wrong value: %d %s not 256
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: lxc.sysctl.net.core.somaxconn returned wrong value: %d %s not 256
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
...
@@ -284,6 +306,7 @@ int main(int argc, char *argv[])
...
@@ -284,6 +306,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(sysctl) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(sysctl) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v3
,
ALL_SYSCTLS
))
{
if
(
strcmp
(
v3
,
ALL_SYSCTLS
))
{
fprintf
(
stderr
,
"%d: lxc.sysctl returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
ALL_SYSCTLS
)
-
1
,
ALL_SYSCTLS
);
fprintf
(
stderr
,
"%d: lxc.sysctl returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
ALL_SYSCTLS
)
-
1
,
ALL_SYSCTLS
);
goto
out
;
goto
out
;
...
@@ -294,11 +317,13 @@ int main(int argc, char *argv[])
...
@@ -294,11 +317,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed clearing lxc.sysctl.net.ipv4.ip_forward
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing lxc.sysctl.net.ipv4.ip_forward
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.sysctl"
,
v3
,
2047
);
ret
=
c
->
get_config_item
(
c
,
"lxc.sysctl"
,
v3
,
2047
);
if
(
ret
!=
sizeof
(
SYSCTL_SOMAXCONN
)
-
1
)
{
if
(
ret
!=
sizeof
(
SYSCTL_SOMAXCONN
)
-
1
)
{
fprintf
(
stderr
,
"%d: get_config_item(sysctl) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(sysctl) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v3
,
SYSCTL_SOMAXCONN
))
{
if
(
strcmp
(
v3
,
SYSCTL_SOMAXCONN
))
{
fprintf
(
stderr
,
"%d: lxc.sysctl returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
SYSCTL_SOMAXCONN
)
-
1
,
SYSCTL_SOMAXCONN
);
fprintf
(
stderr
,
"%d: lxc.sysctl returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
SYSCTL_SOMAXCONN
)
-
1
,
SYSCTL_SOMAXCONN
);
goto
out
;
goto
out
;
...
@@ -324,6 +349,7 @@ int main(int argc, char *argv[])
...
@@ -324,6 +349,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(lxc.proc.setgroups) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.proc.setgroups) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"allow"
))
{
if
(
strcmp
(
v2
,
"allow"
))
{
fprintf
(
stderr
,
"%d: lxc.proc.setgroups returned wrong value: %d %s not 10
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: lxc.proc.setgroups returned wrong value: %d %s not 10
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
...
@@ -340,6 +366,7 @@ int main(int argc, char *argv[])
...
@@ -340,6 +366,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(lxc.proc.oom_score_adj) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.proc.oom_score_adj) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v2
,
"10"
))
{
if
(
strcmp
(
v2
,
"10"
))
{
fprintf
(
stderr
,
"%d: lxc.proc.oom_score_adj returned wrong value: %d %s not 10
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: lxc.proc.oom_score_adj returned wrong value: %d %s not 10
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
...
@@ -351,6 +378,7 @@ int main(int argc, char *argv[])
...
@@ -351,6 +378,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(proc) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(proc) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v3
,
ALL_PROCS
))
{
if
(
strcmp
(
v3
,
ALL_PROCS
))
{
fprintf
(
stderr
,
"%d: lxc.proc returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
ALL_PROCS
)
-
1
,
ALL_PROCS
);
fprintf
(
stderr
,
"%d: lxc.proc returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
ALL_PROCS
)
-
1
,
ALL_PROCS
);
goto
out
;
goto
out
;
...
@@ -361,11 +389,13 @@ int main(int argc, char *argv[])
...
@@ -361,11 +389,13 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed clearing lxc.proc.setgroups
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing lxc.proc.setgroups
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.proc"
,
v3
,
2047
);
ret
=
c
->
get_config_item
(
c
,
"lxc.proc"
,
v3
,
2047
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(proc) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(proc) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
strcmp
(
v3
,
PROC_OOM_SCORE_ADJ
))
{
if
(
strcmp
(
v3
,
PROC_OOM_SCORE_ADJ
))
{
fprintf
(
stderr
,
"%d: lxc.proc returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
PROC_OOM_SCORE_ADJ
)
-
1
,
PROC_OOM_SCORE_ADJ
);
fprintf
(
stderr
,
"%d: lxc.proc returned wrong value: %d %s not %d %s
\n
"
,
__LINE__
,
ret
,
v3
,
(
int
)
sizeof
(
PROC_OOM_SCORE_ADJ
)
-
1
,
PROC_OOM_SCORE_ADJ
);
goto
out
;
goto
out
;
...
@@ -376,6 +406,7 @@ int main(int argc, char *argv[])
...
@@ -376,6 +406,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set aa_profile
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set aa_profile
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.apparmor.profile"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.apparmor.profile"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.aa_profile) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.aa_profile) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -397,6 +428,7 @@ int main(int argc, char *argv[])
...
@@ -397,6 +428,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: error opening lxc_container %s
\n
"
,
__LINE__
,
MYNAME
);
fprintf
(
stderr
,
"%d: error opening lxc_container %s
\n
"
,
__LINE__
,
MYNAME
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
createl
(
c
,
"busybox"
,
NULL
,
NULL
,
0
,
NULL
))
{
if
(
!
c
->
createl
(
c
,
"busybox"
,
NULL
,
NULL
,
0
,
NULL
))
{
fprintf
(
stderr
,
"%d: failed to create a trusty container
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to create a trusty container
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
...
@@ -414,17 +446,20 @@ int main(int argc, char *argv[])
...
@@ -414,17 +446,20 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: get_config_item(lxc.cap.drop) with NULL returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.cap.drop) with NULL returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.cap.drop"
,
v1
,
1
);
ret
=
c
->
get_config_item
(
c
,
"lxc.cap.drop"
,
v1
,
1
);
if
(
ret
<
5
||
ret
>
255
)
{
if
(
ret
<
5
||
ret
>
255
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.cap.drop) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.cap.drop) returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.cap.drop"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.cap.drop"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.cap.drop) returned %d %s
\n
"
,
__LINE__
,
ret
,
v2
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.cap.drop) returned %d %s
\n
"
,
__LINE__
,
ret
,
v2
);
goto
out
;
goto
out
;
}
}
printf
(
"%d: get_config_item(lxc.cap.drop) returned %d %s
\n
"
,
__LINE__
,
ret
,
v2
);
printf
(
"%d: get_config_item(lxc.cap.drop) returned %d %s
\n
"
,
__LINE__
,
ret
,
v2
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item(lxc.net) returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item(lxc.net) returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -436,18 +471,22 @@ int main(int argc, char *argv[])
...
@@ -436,18 +471,22 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed to set lxc.net.0.type
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set lxc.net.0.type
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.link"
,
"lxcbr0"
))
{
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.link"
,
"lxcbr0"
))
{
fprintf
(
stderr
,
"%d: failed to set network.link
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set network.link
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.flags"
,
"up"
))
{
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.flags"
,
"up"
))
{
fprintf
(
stderr
,
"%d: failed to set network.flags
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set network.flags
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.hwaddr"
,
"00:16:3e:xx:xx:xx"
))
{
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.hwaddr"
,
"00:16:3e:xx:xx:xx"
))
{
fprintf
(
stderr
,
"%d: failed to set network.hwaddr
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set network.hwaddr
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.ipv4.address"
,
"10.2.3.4"
))
{
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.ipv4.address"
,
"10.2.3.4"
))
{
fprintf
(
stderr
,
"%d: failed to set ipv4
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed to set ipv4
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
...
@@ -458,10 +497,12 @@ int main(int argc, char *argv[])
...
@@ -458,10 +497,12 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: lxc.net.0.ipv4 returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: lxc.net.0.ipv4 returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
clear_config_item
(
c
,
"lxc.net.0.ipv4.address"
))
{
if
(
!
c
->
clear_config_item
(
c
,
"lxc.net.0.ipv4.address"
))
{
fprintf
(
stderr
,
"%d: failed clearing all ipv4 entries
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing all ipv4 entries
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.net.0.ipv4.address"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net.0.ipv4.address"
,
v2
,
255
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
fprintf
(
stderr
,
"%d: after clearing ipv4 entries get_item(lxc.network.0.ipv4 returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: after clearing ipv4 entries get_item(lxc.network.0.ipv4 returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -478,10 +519,12 @@ int main(int argc, char *argv[])
...
@@ -478,10 +519,12 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: lxc.net.0.ipv4.gateway returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: lxc.net.0.ipv4.gateway returned %d
\n
"
,
__LINE__
,
ret
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.ipv4.gateway"
,
""
))
{
if
(
!
c
->
set_config_item
(
c
,
"lxc.net.0.ipv4.gateway"
,
""
))
{
fprintf
(
stderr
,
"%d: failed clearing ipv4.gateway
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing ipv4.gateway
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.net.0.ipv4.gateway"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net.0.ipv4.gateway"
,
v2
,
255
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
fprintf
(
stderr
,
"%d: after clearing ipv4.gateway get_item(lxc.network.0.ipv4.gateway returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: after clearing ipv4.gateway get_item(lxc.network.0.ipv4.gateway returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -494,6 +537,7 @@ int main(int argc, char *argv[])
...
@@ -494,6 +537,7 @@ int main(int argc, char *argv[])
goto
out
;
goto
out
;
}
}
printf
(
"%d: get_config_item (link) returned %d %s
\n
"
,
__LINE__
,
ret
,
v2
);
printf
(
"%d: get_config_item (link) returned %d %s
\n
"
,
__LINE__
,
ret
,
v2
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net.0.name"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net.0.name"
,
v2
,
255
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"%d: get_config_item returned %d
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: get_config_item returned %d
\n
"
,
__LINE__
,
ret
);
...
@@ -505,6 +549,7 @@ int main(int argc, char *argv[])
...
@@ -505,6 +549,7 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: clear_config_item failed
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: clear_config_item failed
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
ret
=
c
->
get_config_item
(
c
,
"lxc.net"
,
v2
,
255
);
ret
=
c
->
get_config_item
(
c
,
"lxc.net"
,
v2
,
255
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
fprintf
(
stderr
,
"%d: network was not actually cleared (get_network returned %d)
\n
"
,
__LINE__
,
ret
);
fprintf
(
stderr
,
"%d: network was not actually cleared (get_network returned %d)
\n
"
,
__LINE__
,
ret
);
...
@@ -529,14 +574,17 @@ int main(int argc, char *argv[])
...
@@ -529,14 +574,17 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"%d: failed clearing lxc.cgroup
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing lxc.cgroup
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
clear_config_item
(
c
,
"lxc.cap.drop"
))
{
if
(
!
c
->
clear_config_item
(
c
,
"lxc.cap.drop"
))
{
fprintf
(
stderr
,
"%d: failed clearing lxc.cap.drop
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing lxc.cap.drop
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
clear_config_item
(
c
,
"lxc.mount.entry"
))
{
if
(
!
c
->
clear_config_item
(
c
,
"lxc.mount.entry"
))
{
fprintf
(
stderr
,
"%d: failed clearing lxc.mount.entry
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing lxc.mount.entry
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
clear_config_item
(
c
,
"lxc.hook"
))
{
if
(
!
c
->
clear_config_item
(
c
,
"lxc.hook"
))
{
fprintf
(
stderr
,
"%d: failed clearing lxc.hook
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: failed clearing lxc.hook
\n
"
,
__LINE__
);
goto
out
;
goto
out
;
...
@@ -554,6 +602,7 @@ int main(int argc, char *argv[])
...
@@ -554,6 +602,7 @@ int main(int argc, char *argv[])
printf
(
"All get_item tests passed
\n
"
);
printf
(
"All get_item tests passed
\n
"
);
fret
=
EXIT_SUCCESS
;
fret
=
EXIT_SUCCESS
;
out:
out:
if
(
c
)
{
if
(
c
)
{
c
->
destroy
(
c
);
c
->
destroy
(
c
);
...
...
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