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
ebb7d1d4
Unverified
Commit
ebb7d1d4
authored
Feb 13, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: convert to strequal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
12359bb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
conf.c
src/lxc/conf.c
+27
-27
No files found.
src/lxc/conf.c
View file @
ebb7d1d4
...
@@ -380,7 +380,7 @@ int run_script_argv(const char *name, unsigned int hook_version,
...
@@ -380,7 +380,7 @@ int run_script_argv(const char *name, unsigned int hook_version,
return
log_error_errno
(
-
1
,
errno
,
"Failed to set environment variable: LXC_HOOK_SECTION=%s"
,
section
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to set environment variable: LXC_HOOK_SECTION=%s"
,
section
);
TRACE
(
"Set environment variable: LXC_HOOK_SECTION=%s"
,
section
);
TRACE
(
"Set environment variable: LXC_HOOK_SECTION=%s"
,
section
);
if
(
str
cmp
(
section
,
"net"
)
==
0
)
{
if
(
str
equal
(
section
,
"net"
)
)
{
char
*
parent
;
char
*
parent
;
if
(
!
argv
||
!
argv
[
0
])
if
(
!
argv
||
!
argv
[
0
])
...
@@ -393,17 +393,17 @@ int run_script_argv(const char *name, unsigned int hook_version,
...
@@ -393,17 +393,17 @@ int run_script_argv(const char *name, unsigned int hook_version,
parent
=
argv
[
1
]
?
argv
[
1
]
:
""
;
parent
=
argv
[
1
]
?
argv
[
1
]
:
""
;
if
(
str
cmp
(
argv
[
0
],
"macvlan"
)
==
0
)
{
if
(
str
equal
(
argv
[
0
],
"macvlan"
)
)
{
ret
=
setenv
(
"LXC_NET_PARENT"
,
parent
,
1
);
ret
=
setenv
(
"LXC_NET_PARENT"
,
parent
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to set environment variable: LXC_NET_PARENT=%s"
,
parent
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to set environment variable: LXC_NET_PARENT=%s"
,
parent
);
TRACE
(
"Set environment variable: LXC_NET_PARENT=%s"
,
parent
);
TRACE
(
"Set environment variable: LXC_NET_PARENT=%s"
,
parent
);
}
else
if
(
str
cmp
(
argv
[
0
],
"phys"
)
==
0
)
{
}
else
if
(
str
equal
(
argv
[
0
],
"phys"
)
)
{
ret
=
setenv
(
"LXC_NET_PARENT"
,
parent
,
1
);
ret
=
setenv
(
"LXC_NET_PARENT"
,
parent
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to set environment variable: LXC_NET_PARENT=%s"
,
parent
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to set environment variable: LXC_NET_PARENT=%s"
,
parent
);
TRACE
(
"Set environment variable: LXC_NET_PARENT=%s"
,
parent
);
TRACE
(
"Set environment variable: LXC_NET_PARENT=%s"
,
parent
);
}
else
if
(
str
cmp
(
argv
[
0
],
"veth"
)
==
0
)
{
}
else
if
(
str
equal
(
argv
[
0
],
"veth"
)
)
{
char
*
peer
=
argv
[
2
]
?
argv
[
2
]
:
""
;
char
*
peer
=
argv
[
2
]
?
argv
[
2
]
:
""
;
ret
=
setenv
(
"LXC_NET_PEER"
,
peer
,
1
);
ret
=
setenv
(
"LXC_NET_PEER"
,
peer
,
1
);
...
@@ -493,8 +493,8 @@ int lxc_rootfs_prepare(struct lxc_rootfs *rootfs, bool userns)
...
@@ -493,8 +493,8 @@ int lxc_rootfs_prepare(struct lxc_rootfs *rootfs, bool userns)
if
(
rootfs
->
path
)
{
if
(
rootfs
->
path
)
{
if
(
rootfs
->
bdev_type
&&
if
(
rootfs
->
bdev_type
&&
(
!
strcmp
(
rootfs
->
bdev_type
,
"overlay"
)
||
(
strequal
(
rootfs
->
bdev_type
,
"overlay"
)
||
!
strcmp
(
rootfs
->
bdev_type
,
"overlayfs"
)))
strequal
(
rootfs
->
bdev_type
,
"overlayfs"
)))
return
log_trace_errno
(
0
,
EINVAL
,
"Not pinning on stacking filesystem"
);
return
log_trace_errno
(
0
,
EINVAL
,
"Not pinning on stacking filesystem"
);
dfd_path
=
open_at
(
-
EBADF
,
rootfs
->
path
,
PROTECT_OPATH_FILE
,
0
,
0
);
dfd_path
=
open_at
(
-
EBADF
,
rootfs
->
path
,
PROTECT_OPATH_FILE
,
0
,
0
);
...
@@ -1356,10 +1356,10 @@ static int lxc_chroot(const struct lxc_rootfs *rootfs)
...
@@ -1356,10 +1356,10 @@ static int lxc_chroot(const struct lxc_rootfs *rootfs)
*
slider2
=
'\0'
;
*
slider2
=
'\0'
;
*
slider1
=
'.'
;
*
slider1
=
'.'
;
if
(
str
cmp
(
slider1
+
1
,
"/"
)
==
0
)
if
(
str
equal
(
slider1
+
1
,
"/"
)
)
continue
;
continue
;
if
(
str
cmp
(
slider1
+
1
,
"/proc"
)
==
0
)
if
(
str
equal
(
slider1
+
1
,
"/proc"
)
)
continue
;
continue
;
ret
=
umount2
(
slider1
,
MNT_DETACH
);
ret
=
umount2
(
slider1
,
MNT_DETACH
);
...
@@ -1640,7 +1640,7 @@ static int setup_personality(int persona)
...
@@ -1640,7 +1640,7 @@ static int setup_personality(int persona)
static
inline
bool
wants_console
(
const
struct
lxc_terminal
*
terminal
)
static
inline
bool
wants_console
(
const
struct
lxc_terminal
*
terminal
)
{
{
return
!
terminal
->
path
||
strcmp
(
terminal
->
path
,
"none"
);
return
!
terminal
->
path
||
!
strequal
(
terminal
->
path
,
"none"
);
}
}
static
int
lxc_bind_mount_console
(
const
struct
lxc_terminal
*
console
,
static
int
lxc_bind_mount_console
(
const
struct
lxc_terminal
*
console
,
...
@@ -2396,11 +2396,11 @@ static int parse_cap(const char *cap)
...
@@ -2396,11 +2396,11 @@ static int parse_cap(const char *cap)
size_t
end
=
sizeof
(
caps_opt
)
/
sizeof
(
caps_opt
[
0
]);
size_t
end
=
sizeof
(
caps_opt
)
/
sizeof
(
caps_opt
[
0
]);
char
*
ptr
=
NULL
;
char
*
ptr
=
NULL
;
if
(
str
cmp
(
cap
,
"none"
)
==
0
)
if
(
str
equal
(
cap
,
"none"
)
)
return
-
2
;
return
-
2
;
for
(
i
=
0
;
i
<
end
;
i
++
)
{
for
(
i
=
0
;
i
<
end
;
i
++
)
{
if
(
strcmp
(
cap
,
caps_opt
[
i
].
name
))
if
(
!
strequal
(
cap
,
caps_opt
[
i
].
name
))
continue
;
continue
;
capid
=
caps_opt
[
i
].
value
;
capid
=
caps_opt
[
i
].
value
;
...
@@ -2519,7 +2519,7 @@ static int parse_resource(const char *res)
...
@@ -2519,7 +2519,7 @@ static int parse_resource(const char *res)
int
resid
=
-
1
;
int
resid
=
-
1
;
for
(
i
=
0
;
i
<
sizeof
(
limit_opt
)
/
sizeof
(
limit_opt
[
0
]);
++
i
)
for
(
i
=
0
;
i
<
sizeof
(
limit_opt
)
/
sizeof
(
limit_opt
[
0
]);
++
i
)
if
(
str
cmp
(
res
,
limit_opt
[
i
].
name
)
==
0
)
if
(
str
equal
(
res
,
limit_opt
[
i
].
name
)
)
return
limit_opt
[
i
].
value
;
return
limit_opt
[
i
].
value
;
/* Try to see if it's numeric, so the user may specify
/* Try to see if it's numeric, so the user may specify
...
@@ -3560,7 +3560,7 @@ int run_lxc_hooks(const char *name, char *hookname, struct lxc_conf *conf,
...
@@ -3560,7 +3560,7 @@ int run_lxc_hooks(const char *name, char *hookname, struct lxc_conf *conf,
int
which
;
int
which
;
for
(
which
=
0
;
which
<
NUM_LXC_HOOKS
;
which
++
)
{
for
(
which
=
0
;
which
<
NUM_LXC_HOOKS
;
which
++
)
{
if
(
str
cmp
(
hookname
,
lxchook_names
[
which
])
==
0
)
if
(
str
equal
(
hookname
,
lxchook_names
[
which
])
)
break
;
break
;
}
}
...
@@ -3664,7 +3664,7 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version)
...
@@ -3664,7 +3664,7 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version)
return
-
EINVAL
;
return
-
EINVAL
;
}
}
if
(
str
cmp
(
key
,
global_token
)
==
0
)
if
(
str
equal
(
key
,
global_token
)
)
all
=
true
;
all
=
true
;
else
if
(
strncmp
(
key
,
namespaced_token
,
namespaced_token_len
)
==
0
)
else
if
(
strncmp
(
key
,
namespaced_token
,
namespaced_token_len
)
==
0
)
k
+=
namespaced_token_len
;
k
+=
namespaced_token_len
;
...
@@ -3674,7 +3674,7 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version)
...
@@ -3674,7 +3674,7 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version)
lxc_list_for_each_safe
(
it
,
list
,
next
)
{
lxc_list_for_each_safe
(
it
,
list
,
next
)
{
struct
lxc_cgroup
*
cg
=
it
->
elem
;
struct
lxc_cgroup
*
cg
=
it
->
elem
;
if
(
!
all
&&
strcmp
(
cg
->
subsystem
,
k
)
!=
0
)
if
(
!
all
&&
!
strequal
(
cg
->
subsystem
,
k
)
)
continue
;
continue
;
lxc_list_del
(
it
);
lxc_list_del
(
it
);
...
@@ -3704,7 +3704,7 @@ int lxc_clear_limits(struct lxc_conf *c, const char *key)
...
@@ -3704,7 +3704,7 @@ int lxc_clear_limits(struct lxc_conf *c, const char *key)
const
char
*
k
=
NULL
;
const
char
*
k
=
NULL
;
bool
all
=
false
;
bool
all
=
false
;
if
(
str
cmp
(
key
,
"lxc.limit"
)
==
0
||
strcmp
(
key
,
"lxc.prlimit"
)
==
0
)
if
(
str
equal
(
key
,
"lxc.limit"
)
||
strequal
(
key
,
"lxc.prlimit"
)
)
all
=
true
;
all
=
true
;
else
if
(
strncmp
(
key
,
"lxc.limit."
,
STRLITERALLEN
(
"lxc.limit."
))
==
0
)
else
if
(
strncmp
(
key
,
"lxc.limit."
,
STRLITERALLEN
(
"lxc.limit."
))
==
0
)
k
=
key
+
STRLITERALLEN
(
"lxc.limit."
);
k
=
key
+
STRLITERALLEN
(
"lxc.limit."
);
...
@@ -3716,7 +3716,7 @@ int lxc_clear_limits(struct lxc_conf *c, const char *key)
...
@@ -3716,7 +3716,7 @@ int lxc_clear_limits(struct lxc_conf *c, const char *key)
lxc_list_for_each_safe
(
it
,
&
c
->
limits
,
next
)
{
lxc_list_for_each_safe
(
it
,
&
c
->
limits
,
next
)
{
struct
lxc_limit
*
lim
=
it
->
elem
;
struct
lxc_limit
*
lim
=
it
->
elem
;
if
(
!
all
&&
strcmp
(
lim
->
resource
,
k
)
!=
0
)
if
(
!
all
&&
!
strequal
(
lim
->
resource
,
k
)
)
continue
;
continue
;
lxc_list_del
(
it
);
lxc_list_del
(
it
);
...
@@ -3734,7 +3734,7 @@ int lxc_clear_sysctls(struct lxc_conf *c, const char *key)
...
@@ -3734,7 +3734,7 @@ int lxc_clear_sysctls(struct lxc_conf *c, const char *key)
const
char
*
k
=
NULL
;
const
char
*
k
=
NULL
;
bool
all
=
false
;
bool
all
=
false
;
if
(
str
cmp
(
key
,
"lxc.sysctl"
)
==
0
)
if
(
str
equal
(
key
,
"lxc.sysctl"
)
)
all
=
true
;
all
=
true
;
else
if
(
strncmp
(
key
,
"lxc.sysctl."
,
STRLITERALLEN
(
"lxc.sysctl."
))
==
0
)
else
if
(
strncmp
(
key
,
"lxc.sysctl."
,
STRLITERALLEN
(
"lxc.sysctl."
))
==
0
)
k
=
key
+
STRLITERALLEN
(
"lxc.sysctl."
);
k
=
key
+
STRLITERALLEN
(
"lxc.sysctl."
);
...
@@ -3744,7 +3744,7 @@ int lxc_clear_sysctls(struct lxc_conf *c, const char *key)
...
@@ -3744,7 +3744,7 @@ int lxc_clear_sysctls(struct lxc_conf *c, const char *key)
lxc_list_for_each_safe
(
it
,
&
c
->
sysctls
,
next
)
{
lxc_list_for_each_safe
(
it
,
&
c
->
sysctls
,
next
)
{
struct
lxc_sysctl
*
elem
=
it
->
elem
;
struct
lxc_sysctl
*
elem
=
it
->
elem
;
if
(
!
all
&&
strcmp
(
elem
->
key
,
k
)
!=
0
)
if
(
!
all
&&
!
strequal
(
elem
->
key
,
k
)
)
continue
;
continue
;
lxc_list_del
(
it
);
lxc_list_del
(
it
);
...
@@ -3763,7 +3763,7 @@ int lxc_clear_procs(struct lxc_conf *c, const char *key)
...
@@ -3763,7 +3763,7 @@ int lxc_clear_procs(struct lxc_conf *c, const char *key)
const
char
*
k
=
NULL
;
const
char
*
k
=
NULL
;
bool
all
=
false
;
bool
all
=
false
;
if
(
str
cmp
(
key
,
"lxc.proc"
)
==
0
)
if
(
str
equal
(
key
,
"lxc.proc"
)
)
all
=
true
;
all
=
true
;
else
if
(
strncmp
(
key
,
"lxc.proc."
,
STRLITERALLEN
(
"lxc.proc."
))
==
0
)
else
if
(
strncmp
(
key
,
"lxc.proc."
,
STRLITERALLEN
(
"lxc.proc."
))
==
0
)
k
=
key
+
STRLITERALLEN
(
"lxc.proc."
);
k
=
key
+
STRLITERALLEN
(
"lxc.proc."
);
...
@@ -3773,7 +3773,7 @@ int lxc_clear_procs(struct lxc_conf *c, const char *key)
...
@@ -3773,7 +3773,7 @@ int lxc_clear_procs(struct lxc_conf *c, const char *key)
lxc_list_for_each_safe
(
it
,
&
c
->
procs
,
next
)
{
lxc_list_for_each_safe
(
it
,
&
c
->
procs
,
next
)
{
struct
lxc_proc
*
proc
=
it
->
elem
;
struct
lxc_proc
*
proc
=
it
->
elem
;
if
(
!
all
&&
strcmp
(
proc
->
filename
,
k
)
!=
0
)
if
(
!
all
&&
!
strequal
(
proc
->
filename
,
k
)
)
continue
;
continue
;
lxc_list_del
(
it
);
lxc_list_del
(
it
);
...
@@ -3838,7 +3838,7 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
...
@@ -3838,7 +3838,7 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
const
char
*
k
=
NULL
;
const
char
*
k
=
NULL
;
bool
all
=
false
,
done
=
false
;
bool
all
=
false
,
done
=
false
;
if
(
str
cmp
(
key
,
"lxc.hook"
)
==
0
)
if
(
str
equal
(
key
,
"lxc.hook"
)
)
all
=
true
;
all
=
true
;
else
if
(
strncmp
(
key
,
"lxc.hook."
,
STRLITERALLEN
(
"lxc.hook."
))
==
0
)
else
if
(
strncmp
(
key
,
"lxc.hook."
,
STRLITERALLEN
(
"lxc.hook."
))
==
0
)
k
=
key
+
STRLITERALLEN
(
"lxc.hook."
);
k
=
key
+
STRLITERALLEN
(
"lxc.hook."
);
...
@@ -3846,7 +3846,7 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
...
@@ -3846,7 +3846,7 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
return
-
1
;
return
-
1
;
for
(
i
=
0
;
i
<
NUM_LXC_HOOKS
;
i
++
)
{
for
(
i
=
0
;
i
<
NUM_LXC_HOOKS
;
i
++
)
{
if
(
all
||
str
cmp
(
k
,
lxchook_names
[
i
])
==
0
)
{
if
(
all
||
str
equal
(
k
,
lxchook_names
[
i
])
)
{
lxc_list_for_each_safe
(
it
,
&
c
->
hooks
[
i
],
next
)
{
lxc_list_for_each_safe
(
it
,
&
c
->
hooks
[
i
],
next
)
{
lxc_list_del
(
it
);
lxc_list_del
(
it
);
free
(
it
->
elem
);
free
(
it
->
elem
);
...
@@ -4847,7 +4847,7 @@ void suggest_default_idmap(void)
...
@@ -4847,7 +4847,7 @@ void suggest_default_idmap(void)
*
p
=
'\0'
;
*
p
=
'\0'
;
p
++
;
p
++
;
if
(
strcmp
(
line
,
uname
))
if
(
!
strequal
(
line
,
uname
))
continue
;
continue
;
p2
=
strchr
(
p
,
':'
);
p2
=
strchr
(
p
,
':'
);
...
@@ -4884,7 +4884,7 @@ void suggest_default_idmap(void)
...
@@ -4884,7 +4884,7 @@ void suggest_default_idmap(void)
*
p
=
'\0'
;
*
p
=
'\0'
;
p
++
;
p
++
;
if
(
strcmp
(
line
,
uname
))
if
(
!
strequal
(
line
,
uname
))
continue
;
continue
;
p2
=
strchr
(
p
,
':'
);
p2
=
strchr
(
p
,
':'
);
...
@@ -4952,10 +4952,10 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list *cgroup_settings)
...
@@ -4952,10 +4952,10 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list *cgroup_settings)
item
->
elem
=
it
->
elem
;
item
->
elem
=
it
->
elem
;
cg
=
it
->
elem
;
cg
=
it
->
elem
;
if
(
str
cmp
(
cg
->
subsystem
,
"memory.memsw.limit_in_bytes"
)
==
0
)
{
if
(
str
equal
(
cg
->
subsystem
,
"memory.memsw.limit_in_bytes"
)
)
{
/* Store the memsw_limit location */
/* Store the memsw_limit location */
memsw_limit
=
item
;
memsw_limit
=
item
;
}
else
if
(
str
cmp
(
cg
->
subsystem
,
"memory.limit_in_bytes"
)
==
0
&&
}
else
if
(
str
equal
(
cg
->
subsystem
,
"memory.limit_in_bytes"
)
&&
memsw_limit
!=
NULL
)
{
memsw_limit
!=
NULL
)
{
/* lxc.cgroup.memory.memsw.limit_in_bytes is found
/* lxc.cgroup.memory.memsw.limit_in_bytes is found
* before lxc.cgroup.memory.limit_in_bytes, swap these
* before lxc.cgroup.memory.limit_in_bytes, swap these
...
...
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