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
be43adcd
Unverified
Commit
be43adcd
authored
Mar 29, 2021
by
Stéphane Graber
Committed by
GitHub
Mar 29, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3748 from brauner/2021-03-29/fixes
fixes & config key validation
parents
cc19bc54
ea60ca95
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
67 additions
and
27 deletions
+67
-27
configure.ac
configure.ac
+1
-1
compiler.h
src/lxc/compiler.h
+16
-7
conf.c
src/lxc/conf.c
+6
-2
conf.h
src/lxc/conf.h
+4
-2
confile.c
src/lxc/confile.c
+0
-0
confile.h
src/lxc/confile.h
+1
-0
confile_utils.c
src/lxc/confile_utils.c
+23
-8
confile_utils.h
src/lxc/confile_utils.h
+1
-0
initutils.c
src/lxc/initutils.c
+3
-1
lxccontainer.c
src/lxc/lxccontainer.c
+3
-0
parse_config_file.c
src/tests/parse_config_file.c
+9
-6
No files found.
configure.ac
View file @
be43adcd
...
@@ -629,7 +629,7 @@ AC_CHECK_DECLS([PR_SET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
...
@@ -629,7 +629,7 @@ AC_CHECK_DECLS([PR_SET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
AC_CHECK_DECLS([PR_GET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
AC_CHECK_DECLS([PR_GET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
# Check for some headers
# Check for some headers
AC_CHECK_HEADERS([pty.h sys/memfd.h sys/personality.h sys/resource.h sys/signalfd.h sys/timerfd.h utmpx.h])
AC_CHECK_HEADERS([pty.h sys/memfd.h sys/personality.h sys/resource.h sys/signalfd.h sys/timerfd.h utmpx.h
threads.h
])
AC_CHECK_HEADER([ifaddrs.h],
AC_CHECK_HEADER([ifaddrs.h],
AM_CONDITIONAL(HAVE_IFADDRS_H, true)
AM_CONDITIONAL(HAVE_IFADDRS_H, true)
...
...
src/lxc/compiler.h
View file @
be43adcd
...
@@ -12,14 +12,23 @@
...
@@ -12,14 +12,23 @@
#include "config.h"
#include "config.h"
#if
ndef thread_local
#if
defined(HAVE_THREADS_H)
#if __STDC_VERSION__ >= 201112L && \
#include <threads.h>
!(defined(__STDC_NO_THREADS__) || \
#define THREAD_LOCAL_STORAGE_SUPPORTED
(defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16)
)
#elif defined(thread_local
)
#define thread_local _Thread_local
#define THREAD_LOCAL_STORAGE_SUPPORTED
#else
#else
#define thread_local __thread
#if __STDC_VERSION__ >= 201112L && \
#endif
!(defined(__STDC_NO_THREADS__) || \
(defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16))
#define thread_local _Thread_local
#define THREAD_LOCAL_STORAGE_SUPPORTED
#else
#define thread_local __thread
#define THREAD_LOCAL_STORAGE_SUPPORTED
#endif
#endif
#endif
#if __GNUC__ >= 7
#if __GNUC__ >= 7
...
...
src/lxc/conf.c
View file @
be43adcd
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "af_unix.h"
#include "af_unix.h"
#include "caps.h"
#include "caps.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup.h"
#include "compiler.h"
#include "conf.h"
#include "conf.h"
#include "config.h"
#include "config.h"
#include "confile.h"
#include "confile.h"
...
@@ -99,11 +100,14 @@
...
@@ -99,11 +100,14 @@
lxc_log_define
(
conf
,
lxc
);
lxc_log_define
(
conf
,
lxc
);
/* The lxc_conf of the container currently being worked on in an API call.
/*
* The lxc_conf of the container currently being worked on in an API call.
* This is used in the error calls.
* This is used in the error calls.
*/
*/
#if
def HAVE_TLS
#if
defined(THREAD_LOCAL_STORAGE_SUPPORTED)
thread_local
struct
lxc_conf
*
current_config
;
thread_local
struct
lxc_conf
*
current_config
;
#elif defined(ENFORCE_THREAD_SAFETY)
#error ENFORCE_THREAD_SAFETY was set but cannot be guaranteed due to missing TLS
#else
#else
struct
lxc_conf
*
current_config
;
struct
lxc_conf
*
current_config
;
#endif
#endif
...
...
src/lxc/conf.h
View file @
be43adcd
...
@@ -474,10 +474,12 @@ struct lxc_conf {
...
@@ -474,10 +474,12 @@ struct lxc_conf {
__hidden
extern
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
size_t
buf_size
)
__hidden
extern
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
size_t
buf_size
)
__access_r
(
3
,
4
);
__access_r
(
3
,
4
);
#if
def HAVE_TLS
#if
defined(THREAD_LOCAL_STORAGE_SUPPORTED)
extern
thread_local
struct
lxc_conf
*
current_config
;
extern
thread_local
struct
lxc_conf
*
current_config
;
#elif defined(ENFORCE_THREAD_SAFETY)
#error ENFORCE_THREAD_SAFETY was set but cannot be guaranteed due to missing TLS
#else
#else
extern
struct
lxc_conf
*
current_config
;
struct
lxc_conf
*
current_config
;
#endif
#endif
__hidden
extern
int
run_lxc_hooks
(
const
char
*
name
,
char
*
hook
,
struct
lxc_conf
*
conf
,
char
*
argv
[]);
__hidden
extern
int
run_lxc_hooks
(
const
char
*
name
,
char
*
hook
,
struct
lxc_conf
*
conf
,
char
*
argv
[]);
...
...
src/lxc/confile.c
View file @
be43adcd
This diff is collapsed.
Click to expand it.
src/lxc/confile.h
View file @
be43adcd
...
@@ -34,6 +34,7 @@ typedef int (*config_clr_cb)(const char *key, struct lxc_conf *conf,
...
@@ -34,6 +34,7 @@ typedef int (*config_clr_cb)(const char *key, struct lxc_conf *conf,
struct
lxc_config_t
{
struct
lxc_config_t
{
char
*
name
;
char
*
name
;
bool
strict
;
config_set_cb
set
;
config_set_cb
set
;
config_get_cb
get
;
config_get_cb
get
;
config_clr_cb
clr
;
config_clr_cb
clr
;
...
...
src/lxc/confile_utils.c
View file @
be43adcd
...
@@ -403,26 +403,29 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
...
@@ -403,26 +403,29 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
}
}
}
}
static
void
lxc_free
_netdev
(
struct
lxc_netdev
*
netdev
)
void
lxc_clear
_netdev
(
struct
lxc_netdev
*
netdev
)
{
{
struct
lxc_list
*
cur
,
*
next
;
struct
lxc_list
*
cur
,
*
next
;
ssize_t
idx
;
if
(
!
netdev
)
if
(
!
netdev
)
return
;
return
;
free
(
netdev
->
upscript
);
idx
=
netdev
->
idx
;
free
(
netdev
->
downscript
);
free
(
netdev
->
hwaddr
);
free_disarm
(
netdev
->
upscript
);
free
(
netdev
->
mtu
);
free_disarm
(
netdev
->
downscript
);
free_disarm
(
netdev
->
hwaddr
);
free_disarm
(
netdev
->
mtu
);
free
(
netdev
->
ipv4_gateway
);
free
_disarm
(
netdev
->
ipv4_gateway
);
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv4
,
next
)
{
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv4
,
next
)
{
lxc_list_del
(
cur
);
lxc_list_del
(
cur
);
free
(
cur
->
elem
);
free
(
cur
->
elem
);
free
(
cur
);
free
(
cur
);
}
}
free
(
netdev
->
ipv6_gateway
);
free
_disarm
(
netdev
->
ipv6_gateway
);
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_del
(
cur
);
lxc_list_del
(
cur
);
free
(
cur
->
elem
);
free
(
cur
->
elem
);
...
@@ -448,7 +451,19 @@ static void lxc_free_netdev(struct lxc_netdev *netdev)
...
@@ -448,7 +451,19 @@ static void lxc_free_netdev(struct lxc_netdev *netdev)
}
}
}
}
free
(
netdev
);
memset
(
netdev
,
0
,
sizeof
(
struct
lxc_netdev
));
lxc_list_init
(
&
netdev
->
ipv4
);
lxc_list_init
(
&
netdev
->
ipv6
);
netdev
->
type
=
-
1
;
netdev
->
idx
=
idx
;
}
static
void
lxc_free_netdev
(
struct
lxc_netdev
*
netdev
)
{
if
(
netdev
)
{
lxc_clear_netdev
(
netdev
);
free
(
netdev
);
}
}
}
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
...
...
src/lxc/confile_utils.h
View file @
be43adcd
...
@@ -37,6 +37,7 @@ __hidden extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
...
@@ -37,6 +37,7 @@ __hidden extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
__hidden
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
__hidden
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
__hidden
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
__hidden
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
__hidden
extern
void
lxc_free_networks
(
struct
lxc_list
*
networks
);
__hidden
extern
void
lxc_free_networks
(
struct
lxc_list
*
networks
);
__hidden
extern
void
lxc_clear_netdev
(
struct
lxc_netdev
*
netdev
);
__hidden
extern
int
lxc_veth_mode_to_flag
(
int
*
mode
,
const
char
*
value
);
__hidden
extern
int
lxc_veth_mode_to_flag
(
int
*
mode
,
const
char
*
value
);
__hidden
extern
char
*
lxc_veth_flag_to_mode
(
int
mode
);
__hidden
extern
char
*
lxc_veth_flag_to_mode
(
int
mode
);
__hidden
extern
int
lxc_macvlan_mode_to_flag
(
int
*
mode
,
const
char
*
value
);
__hidden
extern
int
lxc_macvlan_mode_to_flag
(
int
*
mode
,
const
char
*
value
);
...
...
src/lxc/initutils.c
View file @
be43adcd
...
@@ -54,8 +54,10 @@ const char *lxc_global_config_value(const char *option_name)
...
@@ -54,8 +54,10 @@ const char *lxc_global_config_value(const char *option_name)
};
};
/* placed in the thread local storage pool for non-bionic targets */
/* placed in the thread local storage pool for non-bionic targets */
#if
def HAVE_TLS
#if
defined(THREAD_LOCAL_STORAGE_SUPPORTED)
static
thread_local
const
char
*
values
[
sizeof
(
options
)
/
sizeof
(
options
[
0
])]
=
{
0
};
static
thread_local
const
char
*
values
[
sizeof
(
options
)
/
sizeof
(
options
[
0
])]
=
{
0
};
#elif defined(ENFORCE_THREAD_SAFETY)
#error ENFORCE_THREAD_SAFETY was set but cannot be guaranteed due to missing TLS
#else
#else
static
const
char
*
values
[
sizeof
(
options
)
/
sizeof
(
options
[
0
])]
=
{
0
};
static
const
char
*
values
[
sizeof
(
options
)
/
sizeof
(
options
[
0
])]
=
{
0
};
#endif
#endif
...
...
src/lxc/lxccontainer.c
View file @
be43adcd
...
@@ -2315,6 +2315,9 @@ static bool add_to_clist(struct lxc_container ***list, struct lxc_container *c,
...
@@ -2315,6 +2315,9 @@ static bool add_to_clist(struct lxc_container ***list, struct lxc_container *c,
static
char
**
get_from_array
(
char
***
names
,
char
*
cname
,
int
size
)
static
char
**
get_from_array
(
char
***
names
,
char
*
cname
,
int
size
)
{
{
if
(
!*
names
)
return
NULL
;
return
(
char
**
)
bsearch
(
&
cname
,
*
names
,
size
,
sizeof
(
char
*
),
(
int
(
*
)(
const
void
*
,
const
void
*
))
string_cmp
);
return
(
char
**
)
bsearch
(
&
cname
,
*
names
,
size
,
sizeof
(
char
*
),
(
int
(
*
)(
const
void
*
,
const
void
*
))
string_cmp
);
}
}
...
...
src/tests/parse_config_file.c
View file @
be43adcd
...
@@ -877,15 +877,13 @@ int main(int argc, char *argv[])
...
@@ -877,15 +877,13 @@ int main(int argc, char *argv[])
goto
non_test_error
;
goto
non_test_error
;
}
}
ret
=
set_get_compare_clear_save_load
(
c
,
"lxc.hook.version"
,
"2"
,
tmpf
,
true
);
if
(
c
->
set_config_item
(
c
,
"lxc.hook.version"
,
"2"
))
{
if
(
ret
==
0
)
{
lxc_error
(
"%s
\n
"
,
"Managed to set to set invalid config item
\"
lxc.hook.version
\"
to
\"
2
\"
"
);
lxc_error
(
"%s
\n
"
,
"lxc.hook.version"
);
goto
non_test_error
;
goto
non_test_error
;
}
}
ret
=
set_get_compare_clear_save_load
(
c
,
"lxc.monitor.signal.pdeath"
,
"SIGKILL"
,
tmpf
,
true
);
if
(
!
c
->
set_config_item
(
c
,
"lxc.monitor.signal.pdeath"
,
"SIGKILL"
))
{
if
(
ret
==
0
)
{
lxc_error
(
"%s
\n
"
,
"Failed to set to set invalid config item
\"
lxc.monitor.signal.pdeath
\"
to
\"
SIGKILL
\"
"
);
lxc_error
(
"%s
\n
"
,
"lxc.hook.version"
);
goto
non_test_error
;
goto
non_test_error
;
}
}
...
@@ -904,6 +902,11 @@ int main(int argc, char *argv[])
...
@@ -904,6 +902,11 @@ int main(int argc, char *argv[])
return
-
1
;
return
-
1
;
}
}
if
(
c
->
set_config_item
(
c
,
"lxc.hook.versionasdfsadfsadf"
,
"1"
))
{
lxc_error
(
"%s
\n
"
,
"Managed to set to set invalid config item
\"
lxc.hook.versionasdfsadfsadf
\"
to
\"
2
\"
"
);
goto
non_test_error
;
}
fret
=
EXIT_SUCCESS
;
fret
=
EXIT_SUCCESS
;
non_test_error:
non_test_error:
...
...
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