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
6b7386e5
Unverified
Commit
6b7386e5
authored
Jul 21, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: hide unnecessary symbols
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3d565ecc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
192 additions
and
81 deletions
+192
-81
Makefile.am
src/lxc/Makefile.am
+46
-23
utils.h
src/lxc/utils.h
+48
-49
Makefile.am
src/tests/Makefile.am
+98
-9
No files found.
src/lxc/Makefile.am
View file @
6b7386e5
...
@@ -356,7 +356,8 @@ lxc_attach_SOURCES = tools/lxc_attach.c \
...
@@ -356,7 +356,8 @@ lxc_attach_SOURCES = tools/lxc_attach.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_attach_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_attach_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -387,7 +388,8 @@ lxc_autostart_SOURCES = tools/lxc_autostart.c \
...
@@ -387,7 +388,8 @@ lxc_autostart_SOURCES = tools/lxc_autostart.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_autostart_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_autostart_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -418,7 +420,8 @@ lxc_cgroup_SOURCES = tools/lxc_cgroup.c \
...
@@ -418,7 +420,8 @@ lxc_cgroup_SOURCES = tools/lxc_cgroup.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_cgroup_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_cgroup_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -449,7 +452,8 @@ lxc_config_SOURCES = tools/lxc_config.c \
...
@@ -449,7 +452,8 @@ lxc_config_SOURCES = tools/lxc_config.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_config_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_config_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -480,7 +484,8 @@ lxc_console_SOURCES = tools/lxc_console.c \
...
@@ -480,7 +484,8 @@ lxc_console_SOURCES = tools/lxc_console.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_console_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_console_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -511,7 +516,8 @@ lxc_destroy_SOURCES = tools/lxc_destroy.c \
...
@@ -511,7 +516,8 @@ lxc_destroy_SOURCES = tools/lxc_destroy.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_destroy_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_destroy_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -542,7 +548,8 @@ lxc_device_SOURCES = tools/lxc_device.c \
...
@@ -542,7 +548,8 @@ lxc_device_SOURCES = tools/lxc_device.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_device_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_device_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -573,7 +580,8 @@ lxc_execute_SOURCES = tools/lxc_execute.c \
...
@@ -573,7 +580,8 @@ lxc_execute_SOURCES = tools/lxc_execute.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_execute_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_execute_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -604,7 +612,8 @@ lxc_freeze_SOURCES = tools/lxc_freeze.c \
...
@@ -604,7 +612,8 @@ lxc_freeze_SOURCES = tools/lxc_freeze.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_freeze_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_freeze_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -635,7 +644,8 @@ lxc_info_SOURCES = tools/lxc_info.c \
...
@@ -635,7 +644,8 @@ lxc_info_SOURCES = tools/lxc_info.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_info_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_info_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -667,7 +677,8 @@ lxc_monitor_SOURCES = tools/lxc_monitor.c \
...
@@ -667,7 +677,8 @@ lxc_monitor_SOURCES = tools/lxc_monitor.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_monitor_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_monitor_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -699,7 +710,8 @@ lxc_ls_SOURCES = tools/lxc_ls.c \
...
@@ -699,7 +710,8 @@ lxc_ls_SOURCES = tools/lxc_ls.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_ls_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_ls_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -731,7 +743,8 @@ lxc_copy_SOURCES = tools/lxc_copy.c \
...
@@ -731,7 +743,8 @@ lxc_copy_SOURCES = tools/lxc_copy.c \
storage/storage_utils.c storage/storage_utils.h
\
storage/storage_utils.c storage/storage_utils.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_copy_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_copy_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -762,7 +775,8 @@ lxc_start_SOURCES = tools/lxc_start.c \
...
@@ -762,7 +775,8 @@ lxc_start_SOURCES = tools/lxc_start.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_start_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_start_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -793,7 +807,8 @@ lxc_stop_SOURCES = tools/lxc_stop.c \
...
@@ -793,7 +807,8 @@ lxc_stop_SOURCES = tools/lxc_stop.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_stop_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_stop_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -824,7 +839,8 @@ lxc_top_SOURCES = tools/lxc_top.c \
...
@@ -824,7 +839,8 @@ lxc_top_SOURCES = tools/lxc_top.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_top_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_top_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -855,7 +871,8 @@ lxc_unfreeze_SOURCES = tools/lxc_unfreeze.c \
...
@@ -855,7 +871,8 @@ lxc_unfreeze_SOURCES = tools/lxc_unfreeze.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_unfreeze_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_unfreeze_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -888,7 +905,8 @@ lxc_unshare_SOURCES = tools/lxc_unshare.c \
...
@@ -888,7 +905,8 @@ lxc_unshare_SOURCES = tools/lxc_unshare.c \
sync.c sync.h
\
sync.c sync.h
\
syscall_numbers.h
\
syscall_numbers.h
\
syscall_wrappers.h
\
syscall_wrappers.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_unshare_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_unshare_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -919,7 +937,8 @@ lxc_wait_SOURCES = tools/lxc_wait.c \
...
@@ -919,7 +937,8 @@ lxc_wait_SOURCES = tools/lxc_wait.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_wait_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_wait_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -951,7 +970,8 @@ lxc_create_SOURCES = tools/lxc_create.c \
...
@@ -951,7 +970,8 @@ lxc_create_SOURCES = tools/lxc_create.c \
storage/storage_utils.c storage/storage_utils.h
\
storage/storage_utils.c storage/storage_utils.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_create_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_create_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -982,7 +1002,8 @@ lxc_snapshot_SOURCES = tools/lxc_snapshot.c \
...
@@ -982,7 +1002,8 @@ lxc_snapshot_SOURCES = tools/lxc_snapshot.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_snapshot_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_snapshot_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -1013,7 +1034,8 @@ lxc_checkpoint_SOURCES = tools/lxc_checkpoint.c \
...
@@ -1013,7 +1034,8 @@ lxc_checkpoint_SOURCES = tools/lxc_checkpoint.c \
state.c state.h
\
state.c state.h
\
string_utils.c string_utils.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
sync.c sync.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_checkpoint_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_checkpoint_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
@@ -1102,7 +1124,8 @@ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \
...
@@ -1102,7 +1124,8 @@ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \
sync.c sync.h
\
sync.c sync.h
\
syscall_numbers.h
\
syscall_numbers.h
\
syscall_wrappers.h
\
syscall_wrappers.h
\
terminal.c terminal.h
terminal.c terminal.h
\
utils.c utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_user_nic_SOURCES
+=
seccomp.c lxcseccomp.h
lxc_user_nic_SOURCES
+=
seccomp.c lxcseccomp.h
endif
endif
...
...
src/lxc/utils.h
View file @
6b7386e5
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include <sys/vfs.h>
#include <sys/vfs.h>
#include <unistd.h>
#include <unistd.h>
#include "compiler.h"
#include "file_utils.h"
#include "file_utils.h"
#include "initutils.h"
#include "initutils.h"
#include "macro.h"
#include "macro.h"
...
@@ -29,10 +30,10 @@
...
@@ -29,10 +30,10 @@
#include "string_utils.h"
#include "string_utils.h"
/* returns 1 on success, 0 if there were any failures */
/* returns 1 on success, 0 if there were any failures */
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
__hidden
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
extern
int
get_u16
(
unsigned
short
*
val
,
const
char
*
arg
,
int
base
);
__hidden
extern
int
get_u16
(
unsigned
short
*
val
,
const
char
*
arg
,
int
base
);
extern
int
mkdir_p
(
const
char
*
dir
,
mode_t
mode
);
__hidden
extern
int
mkdir_p
(
const
char
*
dir
,
mode_t
mode
);
extern
char
*
get_rundir
(
void
);
__hidden
extern
char
*
get_rundir
(
void
);
/* Define getline() if missing from the C library */
/* Define getline() if missing from the C library */
#ifndef HAVE_GETLINE
#ifndef HAVE_GETLINE
...
@@ -64,14 +65,14 @@ struct lxc_popen_FILE {
...
@@ -64,14 +65,14 @@ struct lxc_popen_FILE {
* Returns pointer to struct lxc_popen_FILE, that should be freed with lxc_pclose().
* Returns pointer to struct lxc_popen_FILE, that should be freed with lxc_pclose().
* On error returns NULL.
* On error returns NULL.
*/
*/
extern
struct
lxc_popen_FILE
*
lxc_popen
(
const
char
*
command
);
__hidden
extern
struct
lxc_popen_FILE
*
lxc_popen
(
const
char
*
command
);
/* pclose() replacement to be used on struct lxc_popen_FILE *,
/* pclose() replacement to be used on struct lxc_popen_FILE *,
* returned by lxc_popen().
* returned by lxc_popen().
* Waits for associated process to terminate, returns its exit status and
* Waits for associated process to terminate, returns its exit status and
* frees resources, pointed to by struct lxc_popen_FILE *.
* frees resources, pointed to by struct lxc_popen_FILE *.
*/
*/
extern
int
lxc_pclose
(
struct
lxc_popen_FILE
*
fp
);
__hidden
extern
int
lxc_pclose
(
struct
lxc_popen_FILE
*
fp
);
static
inline
void
__auto_lxc_pclose__
(
struct
lxc_popen_FILE
**
f
)
static
inline
void
__auto_lxc_pclose__
(
struct
lxc_popen_FILE
**
f
)
{
{
...
@@ -83,16 +84,16 @@ static inline void __auto_lxc_pclose__(struct lxc_popen_FILE **f)
...
@@ -83,16 +84,16 @@ static inline void __auto_lxc_pclose__(struct lxc_popen_FILE **f)
/*
/*
* wait on a child we forked
* wait on a child we forked
*/
*/
extern
int
wait_for_pid
(
pid_t
pid
);
__hidden
extern
int
wait_for_pid
(
pid_t
pid
);
extern
int
lxc_wait_for_pid_status
(
pid_t
pid
);
__hidden
extern
int
lxc_wait_for_pid_status
(
pid_t
pid
);
extern
int
wait_for_pidfd
(
int
pidfd
);
__hidden
extern
int
wait_for_pidfd
(
int
pidfd
);
#if HAVE_OPENSSL
#if HAVE_OPENSSL
extern
int
sha1sum_file
(
char
*
fnam
,
unsigned
char
*
md_value
,
unsigned
int
*
md_len
);
__hidden
extern
int
sha1sum_file
(
char
*
fnam
,
unsigned
char
*
md_value
,
unsigned
int
*
md_len
);
#endif
#endif
/* initialize rand with urandom */
/* initialize rand with urandom */
extern
int
randseed
(
bool
);
__hidden
extern
int
randseed
(
bool
);
/* are we unprivileged with respect to our namespaces */
/* are we unprivileged with respect to our namespaces */
inline
static
bool
am_guest_unpriv
(
void
)
{
inline
static
bool
am_guest_unpriv
(
void
)
{
...
@@ -126,52 +127,51 @@ inline static bool am_host_unpriv(void)
...
@@ -126,52 +127,51 @@ inline static bool am_host_unpriv(void)
/*
/*
* parse /proc/self/uid_map to find what @orig maps to
* parse /proc/self/uid_map to find what @orig maps to
*/
*/
extern
uid_t
get_ns_uid
(
uid_t
orig
);
__hidden
extern
uid_t
get_ns_uid
(
uid_t
orig
);
/*
/*
* parse /proc/self/gid_map to find what @orig maps to
* parse /proc/self/gid_map to find what @orig maps to
*/
*/
extern
gid_t
get_ns_gid
(
gid_t
orig
);
__hidden
extern
gid_t
get_ns_gid
(
gid_t
orig
);
extern
bool
dir_exists
(
const
char
*
path
);
__hidden
extern
bool
dir_exists
(
const
char
*
path
);
#define FNV1A_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
#define FNV1A_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
extern
uint64_t
fnv_64a_buf
(
void
*
buf
,
size_t
len
,
uint64_t
hval
);
__hidden
extern
uint64_t
fnv_64a_buf
(
void
*
buf
,
size_t
len
,
uint64_t
hval
);
extern
bool
is_shared_mountpoint
(
const
char
*
path
);
__hidden
extern
bool
is_shared_mountpoint
(
const
char
*
path
);
extern
int
detect_shared_rootfs
(
void
);
__hidden
extern
int
detect_shared_rootfs
(
void
);
extern
bool
detect_ramfs_rootfs
(
void
);
__hidden
extern
bool
detect_ramfs_rootfs
(
void
);
extern
char
*
on_path
(
const
char
*
cmd
,
const
char
*
rootfs
);
__hidden
extern
char
*
on_path
(
const
char
*
cmd
,
const
char
*
rootfs
);
extern
bool
cgns_supported
(
void
);
__hidden
extern
bool
cgns_supported
(
void
);
extern
char
*
choose_init
(
const
char
*
rootfs
);
__hidden
extern
char
*
choose_init
(
const
char
*
rootfs
);
extern
bool
switch_to_ns
(
pid_t
pid
,
const
char
*
ns
);
__hidden
extern
bool
switch_to_ns
(
pid_t
pid
,
const
char
*
ns
);
extern
char
*
get_template_path
(
const
char
*
t
);
__hidden
extern
char
*
get_template_path
(
const
char
*
t
);
extern
int
safe_mount
(
const
char
*
src
,
const
char
*
dest
,
const
char
*
fstype
,
__hidden
extern
int
safe_mount
(
const
char
*
src
,
const
char
*
dest
,
const
char
*
fstype
,
unsigned
long
flags
,
const
void
*
data
,
unsigned
long
flags
,
const
void
*
data
,
const
char
*
rootfs
);
const
char
*
rootfs
);
__hidden
extern
int
lxc_mount_proc_if_needed
(
const
char
*
rootfs
);
extern
int
lxc_mount_proc_if_needed
(
const
char
*
rootfs
);
__hidden
extern
int
open_devnull
(
void
);
extern
int
open_devnull
(
void
);
__hidden
extern
int
set_stdfds
(
int
fd
);
extern
int
set_stdfds
(
int
fd
);
__hidden
extern
int
null_stdfds
(
void
);
extern
int
null_stdfds
(
void
);
__hidden
extern
int
lxc_preserve_ns
(
const
int
pid
,
const
char
*
ns
);
extern
int
lxc_preserve_ns
(
const
int
pid
,
const
char
*
ns
);
/* Check whether a signal is blocked by a process. */
/* Check whether a signal is blocked by a process. */
extern
bool
task_blocks_signal
(
pid_t
pid
,
int
signal
);
__hidden
extern
bool
task_blocks_signal
(
pid_t
pid
,
int
signal
);
/* Switch to a new uid and gid.
/* Switch to a new uid and gid.
* If LXC_INVALID_{G,U}ID is passed then the set{g,u}id() will not be called.
* If LXC_INVALID_{G,U}ID is passed then the set{g,u}id() will not be called.
*/
*/
extern
bool
lxc_switch_uid_gid
(
uid_t
uid
,
gid_t
gid
);
__hidden
extern
bool
lxc_switch_uid_gid
(
uid_t
uid
,
gid_t
gid
);
extern
bool
lxc_setgroups
(
int
size
,
gid_t
list
[]);
__hidden
extern
bool
lxc_setgroups
(
int
size
,
gid_t
list
[]);
/* Find an unused loop device and associate it with source. */
/* Find an unused loop device and associate it with source. */
extern
int
lxc_prepare_loop_dev
(
const
char
*
source
,
char
*
loop_dev
,
int
flags
);
__hidden
extern
int
lxc_prepare_loop_dev
(
const
char
*
source
,
char
*
loop_dev
,
int
flags
);
/* Clear all mounts on a given node.
/* Clear all mounts on a given node.
* >= 0 successfully cleared. The number returned is the number of umounts
* >= 0 successfully cleared. The number returned is the number of umounts
* performed.
* performed.
* < 0 error umounting. Return -errno.
* < 0 error umounting. Return -errno.
*/
*/
extern
int
lxc_unstack_mountpoint
(
const
char
*
path
,
bool
lazy
);
__hidden
extern
int
lxc_unstack_mountpoint
(
const
char
*
path
,
bool
lazy
);
/*
/*
* run_command runs a command and collect it's std{err,out} output in buf.
* run_command runs a command and collect it's std{err,out} output in buf.
...
@@ -185,8 +185,7 @@ extern int lxc_unstack_mountpoint(const char *path, bool lazy);
...
@@ -185,8 +185,7 @@ extern int lxc_unstack_mountpoint(const char *path, bool lazy);
* function must exec.
* function must exec.
* @param[in] args Arguments to be passed to child_fn.
* @param[in] args Arguments to be passed to child_fn.
*/
*/
extern
int
run_command
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
__hidden
extern
int
run_command
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
);
void
*
args
);
/*
/*
* run_command runs a command and collect it's std{err,out} output in buf, returns exit status.
* run_command runs a command and collect it's std{err,out} output in buf, returns exit status.
...
@@ -200,10 +199,10 @@ extern int run_command(char *buf, size_t buf_size, int (*child_fn)(void *),
...
@@ -200,10 +199,10 @@ extern int run_command(char *buf, size_t buf_size, int (*child_fn)(void *),
* function must exec.
* function must exec.
* @param[in] args Arguments to be passed to child_fn.
* @param[in] args Arguments to be passed to child_fn.
*/
*/
extern
int
run_command_status
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
__hidden
extern
int
run_command_status
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
);
void
*
args
);
extern
bool
lxc_nic_exists
(
char
*
nic
);
__hidden
extern
bool
lxc_nic_exists
(
char
*
nic
);
static
inline
uint64_t
lxc_getpagesize
(
void
)
static
inline
uint64_t
lxc_getpagesize
(
void
)
{
{
...
@@ -224,16 +223,16 @@ static inline uint64_t lxc_getpagesize(void)
...
@@ -224,16 +223,16 @@ static inline uint64_t lxc_getpagesize(void)
* If the caller passes in 0 they will receive 0 in return since this is invalid
* If the caller passes in 0 they will receive 0 in return since this is invalid
* input and 0 is not a power of 2.
* input and 0 is not a power of 2.
*/
*/
extern
uint64_t
lxc_find_next_power2
(
uint64_t
n
);
__hidden
extern
uint64_t
lxc_find_next_power2
(
uint64_t
n
);
/* Set a signal the child process will receive after the parent has died. */
/* Set a signal the child process will receive after the parent has died. */
extern
int
lxc_set_death_signal
(
int
signal
,
pid_t
parent
,
int
parent_status_fd
);
__hidden
extern
int
lxc_set_death_signal
(
int
signal
,
pid_t
parent
,
int
parent_status_fd
);
extern
int
fd_cloexec
(
int
fd
,
bool
cloexec
);
__hidden
extern
int
fd_cloexec
(
int
fd
,
bool
cloexec
);
extern
int
lxc_rm_rf
(
const
char
*
dirname
);
__hidden
extern
int
lxc_rm_rf
(
const
char
*
dirname
);
extern
int
lxc_setup_keyring
(
char
*
keyring_label
);
__hidden
extern
int
lxc_setup_keyring
(
char
*
keyring_label
);
extern
bool
lxc_can_use_pidfd
(
int
pidfd
);
__hidden
extern
bool
lxc_can_use_pidfd
(
int
pidfd
);
extern
int
fix_stdio_permissions
(
uid_t
uid
);
__hidden
extern
int
fix_stdio_permissions
(
uid_t
uid
);
static
inline
bool
uid_valid
(
uid_t
uid
)
static
inline
bool
uid_valid
(
uid_t
uid
)
{
{
...
...
src/tests/Makefile.am
View file @
6b7386e5
...
@@ -32,12 +32,43 @@ lxc_test_api_reboot_SOURCES = api_reboot.c \
...
@@ -32,12 +32,43 @@ lxc_test_api_reboot_SOURCES = api_reboot.c \
../lxc/state.c ../lxc/state.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_test_api_reboot_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
lxc_test_api_reboot_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
endif
lxc_test_apparmor_SOURCES
=
aa.c
lxc_test_apparmor_SOURCES
=
aa.c
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/caps.c ../lxc/caps.h
\
../lxc/commands.c ../lxc/commands.h
\
../lxc/commands_utils.c ../lxc/commands_utils.h
\
../lxc/conf.c ../lxc/conf.h
\
../lxc/confile.c ../lxc/confile.h
\
../lxc/confile_utils.c ../lxc/confile_utils.h
\
../lxc/error.c ../lxc/error.h
\
../lxc/file_utils.c ../lxc/file_utils.h
\
../lxc/initutils.c ../lxc/initutils.h
\
../lxc/log.c ../lxc/log.h
\
../lxc/lxclock.c ../lxc/lxclock.h
\
../lxc/mainloop.c ../lxc/mainloop.h
\
../lxc/monitor.c ../lxc/monitor.h
\
../lxc/namespace.c ../lxc/namespace.h
\
../lxc/network.c ../lxc/network.h
\
../lxc/nl.c ../lxc/nl.h
\
../lxc/parse.c ../lxc/parse.h
\
../lxc/process_utils.c ../lxc/process_utils.h
\
../lxc/ringbuf.c ../lxc/ringbuf.h
\
../lxc/start.c ../lxc/start.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
lxc_test_apparmor_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
lxc_test_attach_SOURCES
=
attach.c
\
lxc_test_attach_SOURCES
=
attach.c
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/caps.c ../lxc/caps.h
\
../lxc/caps.c ../lxc/caps.h
\
...
@@ -63,7 +94,8 @@ lxc_test_attach_SOURCES = attach.c \
...
@@ -63,7 +94,8 @@ lxc_test_attach_SOURCES = attach.c \
../lxc/state.c ../lxc/state.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_test_attach_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
lxc_test_attach_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
endif
...
@@ -94,7 +126,8 @@ lxc_test_cgpath_SOURCES = cgpath.c \
...
@@ -94,7 +126,8 @@ lxc_test_cgpath_SOURCES = cgpath.c \
../lxc/state.c ../lxc/state.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_test_cgpath_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
lxc_test_cgpath_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
endif
...
@@ -127,7 +160,8 @@ lxc_test_config_jump_table_SOURCES = config_jump_table.c \
...
@@ -127,7 +160,8 @@ lxc_test_config_jump_table_SOURCES = config_jump_table.c \
../lxc/state.c ../lxc/state.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_test_config_jump_table_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
lxc_test_config_jump_table_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
endif
...
@@ -144,17 +178,70 @@ lxc_test_getkeys_SOURCES = getkeys.c
...
@@ -144,17 +178,70 @@ lxc_test_getkeys_SOURCES = getkeys.c
lxc_test_get_item_SOURCES
=
get_item.c
lxc_test_get_item_SOURCES
=
get_item.c
lxc_test_list_SOURCES
=
list.c
lxc_test_list_SOURCES
=
list.c
lxc_test_locktests_SOURCES
=
locktests.c
\
lxc_test_locktests_SOURCES
=
locktests.c
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/caps.c ../lxc/caps.h
\
../lxc/caps.c ../lxc/caps.h
\
../lxc/commands.c ../lxc/commands.h
\
../lxc/commands_utils.c ../lxc/commands_utils.h
\
../lxc/conf.c ../lxc/conf.h
\
../lxc/confile.c ../lxc/confile.h
\
../lxc/confile_utils.c ../lxc/confile_utils.h
\
../lxc/error.c ../lxc/error.h
\
../lxc/file_utils.c ../lxc/file_utils.h
\
../lxc/file_utils.c ../lxc/file_utils.h
\
../lxc/initutils.c ../lxc/initutils.h
\
../lxc/log.c ../lxc/log.h
\
../lxc/log.c ../lxc/log.h
\
../lxc/lxclock.c ../lxc/lxclock.h
\
../lxc/lxclock.c ../lxc/lxclock.h
\
../lxc/string_utils.c ../lxc/string_utils.h
../lxc/mainloop.c ../lxc/mainloop.h
\
../lxc/monitor.c ../lxc/monitor.h
\
../lxc/namespace.c ../lxc/namespace.h
\
../lxc/network.c ../lxc/network.h
\
../lxc/nl.c ../lxc/nl.h
\
../lxc/parse.c ../lxc/parse.h
\
../lxc/process_utils.c ../lxc/process_utils.h
\
../lxc/ringbuf.c ../lxc/ringbuf.h
\
../lxc/start.c ../lxc/start.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
lxc_test_locktests_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
lxc_test_lxcpath_SOURCES
=
lxcpath.c
lxc_test_lxcpath_SOURCES
=
lxcpath.c
lxc_test_may_control_SOURCES
=
may_control.c
lxc_test_may_control_SOURCES
=
may_control.c
lxc_test_mount_injection_SOURCES
=
mount_injection.c
\
lxc_test_mount_injection_SOURCES
=
mount_injection.c
\
lxctest.h
\
lxctest.h
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/caps.c ../lxc/caps.h
\
../lxc/commands.c ../lxc/commands.h
\
../lxc/commands_utils.c ../lxc/commands_utils.h
\
../lxc/conf.c ../lxc/conf.h
\
../lxc/confile.c ../lxc/confile.h
\
../lxc/confile_utils.c ../lxc/confile_utils.h
\
../lxc/error.c ../lxc/error.h
\
../lxc/file_utils.c ../lxc/file_utils.h
\
../lxc/file_utils.c ../lxc/file_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
../lxc/initutils.c ../lxc/initutils.h
\
../lxc/log.c ../lxc/log.h
\
../lxc/lxclock.c ../lxc/lxclock.h
\
../lxc/mainloop.c ../lxc/mainloop.h
\
../lxc/monitor.c ../lxc/monitor.h
\
../lxc/namespace.c ../lxc/namespace.h
\
../lxc/network.c ../lxc/network.h
\
../lxc/nl.c ../lxc/nl.h
\
../lxc/parse.c ../lxc/parse.h
\
../lxc/process_utils.c ../lxc/process_utils.h
\
../lxc/ringbuf.c ../lxc/ringbuf.h
\
../lxc/start.c ../lxc/start.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
lxc_test_mount_injection_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
lxc_test_parse_config_file_SOURCES
=
parse_config_file.c
\
lxc_test_parse_config_file_SOURCES
=
parse_config_file.c
\
lxctest.h
\
lxctest.h
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/af_unix.c ../lxc/af_unix.h
\
...
@@ -181,7 +268,8 @@ lxc_test_parse_config_file_SOURCES = parse_config_file.c \
...
@@ -181,7 +268,8 @@ lxc_test_parse_config_file_SOURCES = parse_config_file.c \
../lxc/state.c ../lxc/state.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_test_parse_config_file_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
lxc_test_parse_config_file_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
endif
...
@@ -235,7 +323,8 @@ lxc_test_utils_SOURCES = lxc-test-utils.c \
...
@@ -235,7 +323,8 @@ lxc_test_utils_SOURCES = lxc-test-utils.c \
../lxc/state.c ../lxc/state.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
if
ENABLE_SECCOMP
if
ENABLE_SECCOMP
lxc_test_utils_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
lxc_test_utils_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
endif
...
...
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