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
d56c2ee9
Unverified
Commit
d56c2ee9
authored
Feb 13, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
seccomp: convert to strequal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c61334a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
43 deletions
+43
-43
seccomp.c
src/lxc/seccomp.c
+43
-43
No files found.
src/lxc/seccomp.c
View file @
d56c2ee9
...
@@ -171,19 +171,19 @@ struct seccomp_v2_rule {
...
@@ -171,19 +171,19 @@ struct seccomp_v2_rule {
static
enum
scmp_compare
parse_v2_rule_op
(
char
*
s
)
static
enum
scmp_compare
parse_v2_rule_op
(
char
*
s
)
{
{
if
(
str
cmp
(
s
,
"SCMP_CMP_NE"
)
==
0
||
strcmp
(
s
,
"!="
)
==
0
)
if
(
str
equal
(
s
,
"SCMP_CMP_NE"
)
||
strequal
(
s
,
"!="
)
)
return
SCMP_CMP_NE
;
return
SCMP_CMP_NE
;
else
if
(
str
cmp
(
s
,
"SCMP_CMP_LT"
)
==
0
||
strcmp
(
s
,
"<"
)
==
0
)
else
if
(
str
equal
(
s
,
"SCMP_CMP_LT"
)
||
strequal
(
s
,
"<"
)
)
return
SCMP_CMP_LT
;
return
SCMP_CMP_LT
;
else
if
(
str
cmp
(
s
,
"SCMP_CMP_LE"
)
==
0
||
strcmp
(
s
,
"<="
)
==
0
)
else
if
(
str
equal
(
s
,
"SCMP_CMP_LE"
)
||
strequal
(
s
,
"<="
)
)
return
SCMP_CMP_LE
;
return
SCMP_CMP_LE
;
else
if
(
str
cmp
(
s
,
"SCMP_CMP_EQ"
)
==
0
||
strcmp
(
s
,
"=="
)
==
0
)
else
if
(
str
equal
(
s
,
"SCMP_CMP_EQ"
)
||
strequal
(
s
,
"=="
)
)
return
SCMP_CMP_EQ
;
return
SCMP_CMP_EQ
;
else
if
(
str
cmp
(
s
,
"SCMP_CMP_GE"
)
==
0
||
strcmp
(
s
,
">="
)
==
0
)
else
if
(
str
equal
(
s
,
"SCMP_CMP_GE"
)
||
strequal
(
s
,
">="
)
)
return
SCMP_CMP_GE
;
return
SCMP_CMP_GE
;
else
if
(
str
cmp
(
s
,
"SCMP_CMP_GT"
)
==
0
||
strcmp
(
s
,
">"
)
==
0
)
else
if
(
str
equal
(
s
,
"SCMP_CMP_GT"
)
||
strequal
(
s
,
">"
)
)
return
SCMP_CMP_GT
;
return
SCMP_CMP_GT
;
else
if
(
str
cmp
(
s
,
"SCMP_CMP_MASKED_EQ"
)
==
0
||
strcmp
(
s
,
"&="
)
==
0
)
else
if
(
str
equal
(
s
,
"SCMP_CMP_MASKED_EQ"
)
||
strequal
(
s
,
"&="
)
)
return
SCMP_CMP_MASKED_EQ
;
return
SCMP_CMP_MASKED_EQ
;
return
_SCMP_CMP_MAX
;
return
_SCMP_CMP_MAX
;
...
@@ -326,10 +326,10 @@ static int get_hostarch(void)
...
@@ -326,10 +326,10 @@ static int get_hostarch(void)
return
-
1
;
return
-
1
;
}
}
if
(
str
cmp
(
uts
.
machine
,
"i686"
)
==
0
)
if
(
str
equal
(
uts
.
machine
,
"i686"
)
)
return
lxc_seccomp_arch_i386
;
return
lxc_seccomp_arch_i386
;
/* no x32 kernels */
/* no x32 kernels */
else
if
(
str
cmp
(
uts
.
machine
,
"x86_64"
)
==
0
)
else
if
(
str
equal
(
uts
.
machine
,
"x86_64"
)
)
return
lxc_seccomp_arch_amd64
;
return
lxc_seccomp_arch_amd64
;
else
if
(
strncmp
(
uts
.
machine
,
"armv7"
,
5
)
==
0
)
else
if
(
strncmp
(
uts
.
machine
,
"armv7"
,
5
)
==
0
)
return
lxc_seccomp_arch_arm
;
return
lxc_seccomp_arch_arm
;
...
@@ -807,8 +807,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -807,8 +807,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
INFO
(
"Processing
\"
%s
\"
"
,
line
);
INFO
(
"Processing
\"
%s
\"
"
,
line
);
if
(
line
[
0
]
==
'['
)
{
if
(
line
[
0
]
==
'['
)
{
/* Read the architecture for next set of rules. */
/* Read the architecture for next set of rules. */
if
(
str
cmp
(
line
,
"[x86]"
)
==
0
||
if
(
str
equal
(
line
,
"[x86]"
)
||
str
cmp
(
line
,
"[X86]"
)
==
0
)
{
str
equal
(
line
,
"[X86]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_i386
&&
if
(
native_arch
!=
lxc_seccomp_arch_i386
&&
native_arch
!=
lxc_seccomp_arch_amd64
)
{
native_arch
!=
lxc_seccomp_arch_amd64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
...
@@ -816,29 +816,29 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -816,29 +816,29 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
cur_rule_arch
=
lxc_seccomp_arch_i386
;
cur_rule_arch
=
lxc_seccomp_arch_i386
;
}
else
if
(
str
cmp
(
line
,
"[x32]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[x32]"
)
||
str
cmp
(
line
,
"[X32]"
)
==
0
)
{
str
equal
(
line
,
"[X32]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_amd64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_amd64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
}
}
cur_rule_arch
=
lxc_seccomp_arch_x32
;
cur_rule_arch
=
lxc_seccomp_arch_x32
;
}
else
if
(
str
cmp
(
line
,
"[X86_64]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[X86_64]"
)
||
str
cmp
(
line
,
"[x86_64]"
)
==
0
)
{
str
equal
(
line
,
"[x86_64]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_amd64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_amd64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
}
}
cur_rule_arch
=
lxc_seccomp_arch_amd64
;
cur_rule_arch
=
lxc_seccomp_arch_amd64
;
}
else
if
(
str
cmp
(
line
,
"[all]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[all]"
)
||
str
cmp
(
line
,
"[ALL]"
)
==
0
)
{
str
equal
(
line
,
"[ALL]"
)
)
{
cur_rule_arch
=
lxc_seccomp_arch_all
;
cur_rule_arch
=
lxc_seccomp_arch_all
;
}
}
#ifdef SCMP_ARCH_ARM
#ifdef SCMP_ARCH_ARM
else
if
(
str
cmp
(
line
,
"[arm]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[arm]"
)
||
str
cmp
(
line
,
"[ARM]"
)
==
0
)
{
str
equal
(
line
,
"[ARM]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_arm
&&
if
(
native_arch
!=
lxc_seccomp_arch_arm
&&
native_arch
!=
lxc_seccomp_arch_arm64
)
{
native_arch
!=
lxc_seccomp_arch_arm64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
...
@@ -849,8 +849,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -849,8 +849,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_AARCH64
#ifdef SCMP_ARCH_AARCH64
else
if
(
str
cmp
(
line
,
"[arm64]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[arm64]"
)
||
str
cmp
(
line
,
"[ARM64]"
)
==
0
)
{
str
equal
(
line
,
"[ARM64]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_arm64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_arm64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
...
@@ -860,8 +860,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -860,8 +860,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_PPC64LE
#ifdef SCMP_ARCH_PPC64LE
else
if
(
str
cmp
(
line
,
"[ppc64le]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[ppc64le]"
)
||
str
cmp
(
line
,
"[PPC64LE]"
)
==
0
)
{
str
equal
(
line
,
"[PPC64LE]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_ppc64le
)
{
if
(
native_arch
!=
lxc_seccomp_arch_ppc64le
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
...
@@ -871,8 +871,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -871,8 +871,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_PPC64
#ifdef SCMP_ARCH_PPC64
else
if
(
str
cmp
(
line
,
"[ppc64]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[ppc64]"
)
||
str
cmp
(
line
,
"[PPC64]"
)
==
0
)
{
str
equal
(
line
,
"[PPC64]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_ppc64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_ppc64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
...
@@ -882,8 +882,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -882,8 +882,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_PPC
#ifdef SCMP_ARCH_PPC
else
if
(
str
cmp
(
line
,
"[ppc]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[ppc]"
)
||
str
cmp
(
line
,
"[PPC]"
)
==
0
)
{
str
equal
(
line
,
"[PPC]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_ppc
&&
if
(
native_arch
!=
lxc_seccomp_arch_ppc
&&
native_arch
!=
lxc_seccomp_arch_ppc64
)
{
native_arch
!=
lxc_seccomp_arch_ppc64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
...
@@ -894,24 +894,24 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -894,24 +894,24 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_MIPS
#ifdef SCMP_ARCH_MIPS
else
if
(
str
cmp
(
line
,
"[mips64]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[mips64]"
)
||
str
cmp
(
line
,
"[MIPS64]"
)
==
0
)
{
str
equal
(
line
,
"[MIPS64]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mips64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mips64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
}
}
cur_rule_arch
=
lxc_seccomp_arch_mips64
;
cur_rule_arch
=
lxc_seccomp_arch_mips64
;
}
else
if
(
str
cmp
(
line
,
"[mips64n32]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[mips64n32]"
)
||
str
cmp
(
line
,
"[MIPS64N32]"
)
==
0
)
{
str
equal
(
line
,
"[MIPS64N32]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mips64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mips64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
}
}
cur_rule_arch
=
lxc_seccomp_arch_mips64n32
;
cur_rule_arch
=
lxc_seccomp_arch_mips64n32
;
}
else
if
(
str
cmp
(
line
,
"[mips]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[mips]"
)
||
str
cmp
(
line
,
"[MIPS]"
)
==
0
)
{
str
equal
(
line
,
"[MIPS]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mips
&&
if
(
native_arch
!=
lxc_seccomp_arch_mips
&&
native_arch
!=
lxc_seccomp_arch_mips64
)
{
native_arch
!=
lxc_seccomp_arch_mips64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
...
@@ -919,24 +919,24 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -919,24 +919,24 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
cur_rule_arch
=
lxc_seccomp_arch_mips
;
cur_rule_arch
=
lxc_seccomp_arch_mips
;
}
else
if
(
str
cmp
(
line
,
"[mipsel64]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[mipsel64]"
)
||
str
cmp
(
line
,
"[MIPSEL64]"
)
==
0
)
{
str
equal
(
line
,
"[MIPSEL64]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mipsel64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mipsel64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
}
}
cur_rule_arch
=
lxc_seccomp_arch_mipsel64
;
cur_rule_arch
=
lxc_seccomp_arch_mipsel64
;
}
else
if
(
str
cmp
(
line
,
"[mipsel64n32]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[mipsel64n32]"
)
||
str
cmp
(
line
,
"[MIPSEL64N32]"
)
==
0
)
{
str
equal
(
line
,
"[MIPSEL64N32]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mipsel64
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mipsel64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
}
}
cur_rule_arch
=
lxc_seccomp_arch_mipsel64n32
;
cur_rule_arch
=
lxc_seccomp_arch_mipsel64n32
;
}
else
if
(
str
cmp
(
line
,
"[mipsel]"
)
==
0
||
}
else
if
(
str
equal
(
line
,
"[mipsel]"
)
||
str
cmp
(
line
,
"[MIPSEL]"
)
==
0
)
{
str
equal
(
line
,
"[MIPSEL]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_mipsel
&&
if
(
native_arch
!=
lxc_seccomp_arch_mipsel
&&
native_arch
!=
lxc_seccomp_arch_mipsel64
)
{
native_arch
!=
lxc_seccomp_arch_mipsel64
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
...
@@ -947,8 +947,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -947,8 +947,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_S390X
#ifdef SCMP_ARCH_S390X
else
if
(
str
cmp
(
line
,
"[s390x]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[s390x]"
)
||
str
cmp
(
line
,
"[S390X]"
)
==
0
)
{
str
equal
(
line
,
"[S390X]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_s390x
)
{
if
(
native_arch
!=
lxc_seccomp_arch_s390x
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
...
@@ -958,8 +958,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
...
@@ -958,8 +958,8 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
}
}
#endif
#endif
#ifdef SCMP_ARCH_S390
#ifdef SCMP_ARCH_S390
else
if
(
str
cmp
(
line
,
"[s390]"
)
==
0
||
else
if
(
str
equal
(
line
,
"[s390]"
)
||
strcmp
(
line
,
"[S390]"
)
==
0
)
{
strequal
(
line
,
"[S390]"
)
)
{
if
(
native_arch
!=
lxc_seccomp_arch_s390
)
{
if
(
native_arch
!=
lxc_seccomp_arch_s390
)
{
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
cur_rule_arch
=
lxc_seccomp_arch_unknown
;
continue
;
continue
;
...
...
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