mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-04-28 22:34:09 +00:00
Merge pull request #3963 from brauner/2021-09-03.build
build: add basic meson support
This commit is contained in:
commit
9985804066
@ -44,6 +44,7 @@ AC_CANONICAL_HOST
|
||||
AM_PROG_CC_C_O
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_SYS_LARGEFILE
|
||||
AC_GNU_SOURCE
|
||||
|
||||
# Test if we have a new enough compiler.
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <../src/config.h>
|
||||
|
||||
#if IS_BIONIC
|
||||
#include <../src/include/lxcmntent.h>
|
||||
#include "lxcmntent.h"
|
||||
#else
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
|
693
meson.build
Normal file
693
meson.build
Normal file
@ -0,0 +1,693 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
project('lxc', 'c',
|
||||
version : '4.0.0',
|
||||
license : 'LGPLv2+',
|
||||
default_options: [
|
||||
'b_colorout=always',
|
||||
'b_asneeded=true',
|
||||
'b_pie=true',
|
||||
'c_std=gnu11',
|
||||
'warning_level=2',
|
||||
],
|
||||
meson_version : '>= 0.46',
|
||||
)
|
||||
|
||||
liblxc_version = '4.0.0'
|
||||
|
||||
conf = configuration_data()
|
||||
conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxc/introduction/')
|
||||
conf.set('PROJECT_VERSION', meson.project_version(),
|
||||
description : 'Numerical project version (used where a simple number is expected)')
|
||||
conf.set('_GNU_SOURCE', true)
|
||||
conf.set('__STDC_FORMAT_MACROS', true)
|
||||
|
||||
version_data = configuration_data()
|
||||
version_data.set('LXC_VERSION_MAJOR', '4')
|
||||
version_data.set('LXC_VERSION_MINOR', '0')
|
||||
version_data.set('LXC_VERSION_MICRO', '7')
|
||||
version_data.set('LXC_ABI', '4.0.7')
|
||||
version_data.set('LXC_DEVEL', '1')
|
||||
version_data.set('LXC_VERSION', '4.0.7-devel')
|
||||
|
||||
project_source_root = meson.current_source_dir()
|
||||
project_build_root = meson.current_build_dir()
|
||||
|
||||
# join_paths ignores the preceding arguments if an absolute component is
|
||||
# encountered, so this should canonicalize various paths when they are
|
||||
# absolute or relative.
|
||||
prefixdir = get_option('prefix')
|
||||
bindir = join_paths(prefixdir, get_option('bindir'))
|
||||
datadir = join_paths(prefixdir, get_option('datadir'))
|
||||
docdir = join_paths(prefixdir, get_option('docdir'))
|
||||
includedir = join_paths(prefixdir, get_option('includedir'))
|
||||
libdir = join_paths(prefixdir, get_option('libdir'))
|
||||
libexecdir = join_paths(prefixdir, get_option('libexecdir'))
|
||||
localstatedir = join_paths('/', get_option('localstatedir'))
|
||||
sbindir = join_paths(prefixdir, get_option('sbindir'))
|
||||
sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
|
||||
|
||||
apparmorcachedir = get_option('apparmor-cache-dir')
|
||||
cgrouppattern = get_option('cgroup-pattern')
|
||||
globalconfig = get_option('global-config')
|
||||
|
||||
logpath = get_option('log-path')
|
||||
lxcpathprefix = get_option('config-path')
|
||||
rootfsmount = get_option('rootfs-mount-dir')
|
||||
runtimepath = join_paths(prefixdir, get_option('runtime-path'))
|
||||
|
||||
conf.set_quoted('BINDIR', bindir)
|
||||
conf.set_quoted('DATADIR', datadir)
|
||||
conf.set_quoted('DOCDIR', docdir)
|
||||
conf.set_quoted('INCLUDEDIR', includedir)
|
||||
conf.set_quoted('LOCALSTATEDIR', localstatedir)
|
||||
conf.set_quoted('LIBDIR', libdir)
|
||||
conf.set_quoted('LIBEXECDIR', libexecdir)
|
||||
conf.set_quoted('SBINDIR', sbindir)
|
||||
conf.set_quoted('SYSCONFDIR', sysconfdir)
|
||||
|
||||
conf.set_quoted('LXCINITDIR', libexecdir)
|
||||
conf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
|
||||
conf.set_quoted('RUNTIME_PATH', runtimepath)
|
||||
|
||||
lxcdefaultconfig = join_paths(sysconfdir, 'lxc/default.conf')
|
||||
conf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
|
||||
|
||||
lxcapparmorcachedir = join_paths(localstatedir, apparmorcachedir)
|
||||
conf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
|
||||
|
||||
lxcrootfsmount = join_paths(prefixdir, rootfsmount)
|
||||
conf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
|
||||
|
||||
lxcglobalconfig = join_paths(sysconfdir, globalconfig)
|
||||
conf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
|
||||
|
||||
lxclogpath = join_paths(localstatedir, logpath)
|
||||
conf.set_quoted('LOGPATH', lxclogpath)
|
||||
|
||||
lxcpath = join_paths(localstatedir, lxcpathprefix)
|
||||
conf.set_quoted('LXCPATH', lxcpath)
|
||||
|
||||
lxctemplateconfig = join_paths(datadir, 'lxc/config')
|
||||
conf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfig)
|
||||
|
||||
lxctemplatedir = join_paths(datadir, 'lxc/templates')
|
||||
conf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
|
||||
|
||||
lxchookdir = join_paths(datadir, 'lxc/hooks')
|
||||
conf.set_quoted('LXCHOOKDIR', lxchookdir)
|
||||
|
||||
lxchookbindir = join_paths(libexecdir, 'lxc/hooks')
|
||||
conf.set_quoted('LXCBINHOOKDIR', lxchookbindir)
|
||||
|
||||
# AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date --utc --date=@${SOURCE_DATE_EPOCH:-$(date +%s)} '+%Y-%m-%d')")
|
||||
# AS_AC_EXPAND(LXC_USERNIC_CONF, "$with_usernic_conf")
|
||||
# AS_AC_EXPAND(LXC_USERNIC_DB, "$with_usernic_db")
|
||||
# AS_AC_EXPAND(LXC_DISTRO_SYSCONF, "$distrosysconf")
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
pkgconfig = import('pkgconfig')
|
||||
|
||||
possible_cc_flags = [
|
||||
'-Wvla',
|
||||
'-Wimplicit-fallthrough=5',
|
||||
'-Wcast-align',
|
||||
'-Wstrict-prototypes',
|
||||
'-fno-strict-aliasing',
|
||||
'-fstack-clash-protection',
|
||||
'-fstack-protector-strong',
|
||||
'--param=ssp-buffer-size=4',
|
||||
'--mcet -fcf-protection',
|
||||
'-Werror=implicit-function-declaration',
|
||||
'-Wlogical-op',
|
||||
'-Wmissing-include-dirs',
|
||||
'-Wold-style-definition',
|
||||
'-Winit-self',
|
||||
'-Wunused-but-set-variable',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wfloat-equal',
|
||||
'-Wsuggest-attribute=noreturn',
|
||||
'-Werror=return-type',
|
||||
'-Werror=incompatible-pointer-types',
|
||||
'-Wformat=2',
|
||||
'-Wshadow',
|
||||
'-Wendif-labels',
|
||||
'-Werror=overflow',
|
||||
'-fdiagnostics-show-option',
|
||||
'-Werror=shift-count-overflow',
|
||||
'-Werror=shift-overflow=2',
|
||||
'-Wdate-time',
|
||||
'-Wnested-externs',
|
||||
'-fasynchronous-unwind-tables',
|
||||
'-fexceptions',
|
||||
'-Warray-bounds',
|
||||
'-Wrestrict',
|
||||
'-Wreturn-local-addr',
|
||||
'-fsanitize=cfi',
|
||||
'-Wstringop-overflow',
|
||||
]
|
||||
|
||||
possible_link_flags = [
|
||||
'-Wl,--gc-sections',
|
||||
'-Wl,-z,relro',
|
||||
'-Wl,-z,now',
|
||||
'-Wl,-fuse-ld=gold',
|
||||
]
|
||||
|
||||
if meson.version().version_compare('>=0.46')
|
||||
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
|
||||
else
|
||||
add_project_link_arguments(possible_link_flags, language : 'c')
|
||||
endif
|
||||
|
||||
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
|
||||
|
||||
foreach header : ['sys/resource.h',
|
||||
'sys/memfd.h',
|
||||
'sys/personality.h',
|
||||
'sys/signalfd.h',
|
||||
'sys/timerfd.h',
|
||||
'pty.h',
|
||||
'utmpx.h',
|
||||
]
|
||||
|
||||
conf.set10('HAVE_' + header.underscorify().to_upper(),
|
||||
cc.has_header(header))
|
||||
endforeach
|
||||
|
||||
decl_headers = '''
|
||||
#include <uchar.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/openat2.h>
|
||||
#include <linux/sched.h>
|
||||
'''
|
||||
|
||||
foreach decl : [
|
||||
'__aligned_u64',
|
||||
'struct mount_attr',
|
||||
'struct open_how',
|
||||
'struct clone_args',
|
||||
]
|
||||
|
||||
# We get -1 if the size cannot be determined
|
||||
if cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
|
||||
conf.set10('HAVE_' + decl.underscorify().to_upper(), true)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
foreach ident : [
|
||||
['memfd_create', '''#include <sys/mman.h>'''],
|
||||
['gettid', '''#include <sys/types.h>
|
||||
#include <unistd.h>'''],
|
||||
['pivot_root', '''#include <stdlib.h>
|
||||
#include <unistd.h>'''], # no known header declares pivot_root
|
||||
['setns', '''#include <sched.h>'''],
|
||||
['renameat2', '''#include <stdio.h>
|
||||
#include <fcntl.h>'''],
|
||||
['kcmp', '''#include <linux/kcmp.h>'''],
|
||||
['keyctl', '''#include <sys/types.h>
|
||||
#include <keyutils.h>'''],
|
||||
['bpf', '''#include <sys/syscall.h>
|
||||
#include <unistd.h>'''],
|
||||
['statx', '''#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>'''],
|
||||
['pidfd_send_signal', '''#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>'''],
|
||||
['pidfd_open', '''#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>'''],
|
||||
['execveat', '''#include <unistd.h>'''],
|
||||
['close_range', '''#include <unistd.h>'''],
|
||||
['mount_setattr', '''#include <sys/mount.h>'''],
|
||||
['move_mount', '''#include <sys/mount.h>'''],
|
||||
['open_tree', '''#include <sys/mount.h>'''],
|
||||
['strlcpy', '''#include <string.h>'''],
|
||||
['strlcat', '''#include <string.h>'''],
|
||||
['sethostname', '''#include <unistd.h>'''],
|
||||
['faccessat', '''#include <fcntl.h>
|
||||
#include <unistd.h>'''],
|
||||
['unshare', '''#include <sched.h>'''],
|
||||
['prlimit', '''#include <sys/time.h>
|
||||
#include <sys/resource.h>'''],
|
||||
['prlimit64', '''#include <sys/time.h>
|
||||
#include <sys/resource.h>'''],
|
||||
]
|
||||
|
||||
if cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_' + ident[0].to_upper(), true)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
sh = find_program('sh')
|
||||
git = find_program('git', required : false)
|
||||
time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"').stdout().strip()
|
||||
if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0
|
||||
# If we're in a git repository, use the creation time of the latest git tag.
|
||||
latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags').stdout().strip()
|
||||
time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag).stdout()
|
||||
endif
|
||||
time_epoch = time_epoch.to_int()
|
||||
conf.set('TIME_EPOCH', time_epoch)
|
||||
|
||||
threads = dependency('threads')
|
||||
libseccomp = dependency('libseccomp')
|
||||
if libseccomp.found()
|
||||
conf.set10('HAVE_SECCOMP', libseccomp.found())
|
||||
|
||||
if libseccomp.version().version_compare('>=2.5.0')
|
||||
# https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a
|
||||
conf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
|
||||
endif
|
||||
|
||||
if libseccomp.version().version_compare('>=2.0.0')
|
||||
# https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0
|
||||
conf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
|
||||
endif
|
||||
|
||||
seccomp_headers = '''
|
||||
#include <seccomp.h>
|
||||
'''
|
||||
foreach decl : [
|
||||
'scmp_filter_ctx',
|
||||
'struct seccomp_notif_sizes',
|
||||
'struct clone_args',
|
||||
]
|
||||
|
||||
# We get -1 if the size cannot be determined
|
||||
if cc.sizeof(decl, prefix : seccomp_headers, args : '-D_GNU_SOURCE') > 0
|
||||
conf.set10('HAVE_' + decl.underscorify().to_upper(), true)
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
|
||||
libselinux = dependency('libselinux', required : false)
|
||||
if libselinux.found()
|
||||
conf.set10('HAVE_SELINUX', libselinux.found())
|
||||
endif
|
||||
|
||||
libapparmor = dependency('libapparmor', required : false)
|
||||
if libapparmor.found()
|
||||
conf.set10('HAVE_APPARMOR', libapparmor.found())
|
||||
endif
|
||||
|
||||
libopenssl = dependency('openssl', required : false)
|
||||
if libopenssl.found()
|
||||
conf.set10('HAVE_OPENSSL', libopenssl.found())
|
||||
endif
|
||||
|
||||
libcap = dependency('libcap', required : false)
|
||||
if not libcap.found()
|
||||
# Compat with Ubuntu 14.04 which ships libcap w/o .pc file
|
||||
libcap = cc.find_library('cap', required : false)
|
||||
endif
|
||||
|
||||
if libcap.found()
|
||||
conf.set10('HAVE_LIBCAP', libcap.found())
|
||||
endif
|
||||
|
||||
basic_includes = include_directories(
|
||||
'src',
|
||||
'src/include',
|
||||
'.')
|
||||
|
||||
liblxc_includes = [basic_includes, include_directories(
|
||||
'src/lxc/cgroups',
|
||||
'src/lxc/lsm',
|
||||
'src/lxc/storage')]
|
||||
|
||||
add_project_arguments('-include', 'config.h', language : 'c')
|
||||
|
||||
subdir('src/include')
|
||||
subdir('src/lxc')
|
||||
subdir('src/lxc/tools')
|
||||
|
||||
config_h = configure_file(
|
||||
output : 'config.h',
|
||||
configuration : conf)
|
||||
|
||||
liblxc = shared_library(
|
||||
'lxc',
|
||||
version : liblxc_version,
|
||||
include_directories : tools_liblxc_includes,
|
||||
link_args : ['-DPIC'],
|
||||
c_args : ['-DPIC'],
|
||||
link_whole : [liblxc_static],
|
||||
dependencies : [threads,
|
||||
libseccomp,
|
||||
libcap,
|
||||
libopenssl,
|
||||
libselinux,
|
||||
libapparmor],
|
||||
install : true)
|
||||
|
||||
liblxc_dep = declare_dependency(
|
||||
link_with: liblxc,
|
||||
dependencies : [threads,
|
||||
libseccomp,
|
||||
libcap,
|
||||
libopenssl,
|
||||
libselinux,
|
||||
libapparmor])
|
||||
|
||||
public_programs = []
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-autostart',
|
||||
tools_lxc_autostart_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-cgroup',
|
||||
tools_lxc_cgroup_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-checkpoint',
|
||||
tools_lxc_checkpoint_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-config',
|
||||
tools_lxc_config_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-console',
|
||||
tools_lxc_console_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-copy',
|
||||
tools_lxc_copy_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-create',
|
||||
tools_lxc_create_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-destroy',
|
||||
tools_lxc_destroy_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-device',
|
||||
tools_lxc_device_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-execute',
|
||||
tools_lxc_execute_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-freeze',
|
||||
tools_lxc_freeze_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-info',
|
||||
tools_lxc_info_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-ls',
|
||||
tools_lxc_ls_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-monitor',
|
||||
tools_lxc_monitor_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-snapshot',
|
||||
tools_lxc_snapshot_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-start',
|
||||
tools_lxc_start_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-stop',
|
||||
tools_lxc_stop_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-top',
|
||||
tools_lxc_top_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-unfreeze',
|
||||
tools_lxc_unfreeze_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-unshare',
|
||||
tools_lxc_unshare_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
public_programs += executable(
|
||||
'lxc-wait',
|
||||
tools_lxc_wait_sources,
|
||||
include_directories : tools_liblxc_includes,
|
||||
dependencies : liblxc_dep,
|
||||
install : true)
|
||||
|
||||
found_syscalls = []
|
||||
missing_syscalls = []
|
||||
|
||||
foreach tuple : [
|
||||
['fexecve'],
|
||||
['memfd_create'],
|
||||
['gettid'],
|
||||
['pivot_root'],
|
||||
['setns'],
|
||||
['renameat2'],
|
||||
['kcmp'],
|
||||
['keyctl'],
|
||||
['bpf'],
|
||||
['statx'],
|
||||
['pidfd_send_signal'],
|
||||
['pidfd_open'],
|
||||
['execveat'],
|
||||
['close_range'],
|
||||
['mount_setattr'],
|
||||
['move_mount'],
|
||||
['open_tree'],
|
||||
['strlcpy'],
|
||||
['strlcat'],
|
||||
['sethostname'],
|
||||
['faccessat'],
|
||||
['unshare'],
|
||||
['prlimit'],
|
||||
['prlimit64'],
|
||||
]
|
||||
|
||||
if tuple.length() >= 2
|
||||
cond = tuple[1]
|
||||
else
|
||||
ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
|
||||
ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
|
||||
cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
|
||||
endif
|
||||
if cond
|
||||
found_syscalls += tuple[0]
|
||||
else
|
||||
missing_syscalls += tuple[0]
|
||||
endif
|
||||
endforeach
|
||||
|
||||
found_types = []
|
||||
missing_types = []
|
||||
|
||||
foreach tuple : [
|
||||
['scmp_filter_ctx'],
|
||||
['struct seccomp_notif_sizes'],
|
||||
['struct clone_args'],
|
||||
['__aligned_u64'],
|
||||
['struct mount_attr'],
|
||||
['struct open_how'],
|
||||
]
|
||||
|
||||
if tuple.length() >= 2
|
||||
cond = tuple[1]
|
||||
else
|
||||
ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
|
||||
ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
|
||||
cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
|
||||
endif
|
||||
if cond
|
||||
found_types += tuple[0]
|
||||
else
|
||||
missing_types += tuple[0]
|
||||
endif
|
||||
endforeach
|
||||
|
||||
found_headers = []
|
||||
missing_headers = []
|
||||
|
||||
foreach tuple : [
|
||||
['sys/resource.h'],
|
||||
['sys/memfd.h'],
|
||||
['sys/personality.h'],
|
||||
['sys/signalfd.h'],
|
||||
['sys/timerfd.h'],
|
||||
['pty.h'],
|
||||
['utmpx.h' ],
|
||||
]
|
||||
|
||||
if tuple.length() >= 2
|
||||
cond = tuple[1]
|
||||
else
|
||||
ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
|
||||
ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
|
||||
cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
|
||||
endif
|
||||
if cond
|
||||
found_headers += tuple[0]
|
||||
else
|
||||
missing_headers += tuple[0]
|
||||
endif
|
||||
endforeach
|
||||
|
||||
found_deps = []
|
||||
missing_deps = []
|
||||
|
||||
foreach tuple : [
|
||||
['AppArmor'],
|
||||
['SECCOMP'],
|
||||
['SELinux'],
|
||||
['libcap'],
|
||||
['openssl'],
|
||||
]
|
||||
|
||||
if tuple.length() >= 2
|
||||
cond = tuple[1]
|
||||
else
|
||||
ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
|
||||
ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
|
||||
cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
|
||||
endif
|
||||
if cond
|
||||
found_deps += tuple[0]
|
||||
else
|
||||
missing_deps += tuple[0]
|
||||
endif
|
||||
endforeach
|
||||
|
||||
status = [
|
||||
'@0@ @1@'.format(meson.project_name(), meson.project_version()),
|
||||
|
||||
'Meson version: @0@'.format(meson.version()),
|
||||
|
||||
'prefix directory: @0@'.format(prefixdir),
|
||||
'bin directory: @0@'.format(bindir),
|
||||
'data directory: @0@'.format(datadir),
|
||||
'doc directory: @0@'.format(docdir),
|
||||
'include directory: @0@'.format(includedir),
|
||||
'lib directory: @0@'.format(libdir),
|
||||
'libexec directory: @0@'.format(libexecdir),
|
||||
'local state directory: @0@'.format(localstatedir),
|
||||
'sbin directory: @0@'.format(sbindir),
|
||||
'sysconf directory: @0@'.format(sysconfdir),
|
||||
|
||||
'lxc cgroup pattern: @0@'.format(cgrouppattern),
|
||||
'lxc init directory: @0@'.format(libexecdir),
|
||||
'runtime path: @0@'.format(runtimepath),
|
||||
|
||||
'lxc default config: @0@'.format(lxcdefaultconfig),
|
||||
'lxc global config: @0@'.format(lxcglobalconfig),
|
||||
'lxc hook directory: @0@'.format(lxchookdir),
|
||||
'lxc hook bin directory: @0@'.format(lxchookbindir),
|
||||
'lxc rootfs mount directory: @0@'.format(lxcrootfsmount),
|
||||
'log path: @0@'.format(lxclogpath),
|
||||
'lxc path: @0@'.format(lxcpath),
|
||||
'lxc template config: @0@'.format(lxctemplateconfig),
|
||||
'lxc template directory: @0@'.format(lxctemplatedir)]
|
||||
|
||||
alt_time_epoch = run_command('date', '-Is', '-u', '-d',
|
||||
'@@0@'.format(time_epoch)).stdout().strip()
|
||||
status += [
|
||||
'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
|
||||
|
||||
status += [
|
||||
'',
|
||||
'supported dependencies: @0@'.format(', '.join(found_deps)),
|
||||
'',
|
||||
'unsupported dependencies: @0@'.format(', '.join(missing_deps)),
|
||||
'']
|
||||
|
||||
status += [
|
||||
'',
|
||||
'supported headers: @0@'.format(', '.join(found_headers)),
|
||||
'',
|
||||
'unsupported headers: @0@'.format(', '.join(missing_headers)),
|
||||
'']
|
||||
|
||||
status += [
|
||||
'',
|
||||
'supported calls: @0@'.format(', '.join(found_syscalls)),
|
||||
'',
|
||||
'unsupported calls: @0@'.format(', '.join(missing_syscalls)),
|
||||
'']
|
||||
|
||||
status += [
|
||||
'',
|
||||
'supported types: @0@'.format(', '.join(found_types)),
|
||||
'',
|
||||
'unsupported types: @0@'.format(', '.join(missing_types)),
|
||||
'']
|
||||
|
||||
message('\n '.join(status))
|
32
meson_options.txt
Normal file
32
meson_options.txt
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- mode: meson -*-
|
||||
|
||||
option('tests', type : 'boolean', value: 'false',
|
||||
description : 'enable tests')
|
||||
|
||||
option('runtime-path', type : 'string', value : '/run',
|
||||
description : 'the runtime directory')
|
||||
|
||||
option('init-script', type : 'combo',
|
||||
choices : ['systemd', 'sysvinit', 'openrc', 'upstart'], value : 'systemd',
|
||||
description : 'init script')
|
||||
|
||||
option('apparmor-cache-dir', type : 'string', value : 'cache/lxc/apparmor',
|
||||
description : 'the AppArmor cache directory')
|
||||
|
||||
option('rootfs-mount-dir', type : 'string', value : 'lib/x86_64-linux-gnu/lxc',
|
||||
description : 'the rootfs mount directory')
|
||||
|
||||
option('cgroup-pattern', type : 'string', value : '',
|
||||
description : 'the rootfs mount directory')
|
||||
|
||||
option('log-path', type : 'string', value : 'log/lxc',
|
||||
description : 'the rootfs mount directory')
|
||||
|
||||
option('config-path', type : 'string', value : 'lib/lxc',
|
||||
description : 'the rootfs mount directory')
|
||||
|
||||
option('global-config', type : 'string', value : 'lxc/lxc.conf',
|
||||
description : 'the rootfs mount directory')
|
||||
|
||||
option('docdir', type : 'string',
|
||||
description : 'documentation directory')
|
@ -125,8 +125,10 @@ struct mntent *getmntent_r(FILE *stream, struct mntent *mp, char *buffer, int bu
|
||||
switch (ret) {
|
||||
case 0:
|
||||
mp->mnt_freq = 0;
|
||||
break;
|
||||
case 1:
|
||||
mp->mnt_passno = 0;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
95
src/include/meson.build
Normal file
95
src/include/meson.build
Normal file
@ -0,0 +1,95 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
include_sources = files(
|
||||
'bpf.h',
|
||||
'bpf_common.h',
|
||||
'netns_ifaddrs.c',
|
||||
'netns_ifaddrs.h')
|
||||
|
||||
if cc.has_function('getline', prefix : '#include <stdio.h>', args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_GETLINE', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'getline.c',
|
||||
'getline.h')
|
||||
endif
|
||||
|
||||
if cc.has_function('fexecve', prefix : '#include <unistd.h>', args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_FEXECVE', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'fexecve.c',
|
||||
'fexecve.h')
|
||||
endif
|
||||
|
||||
|
||||
getgr_headers = '''
|
||||
#include <sys/types.h>
|
||||
#include <grp.h>
|
||||
'''
|
||||
|
||||
if cc.has_function('getgrgid_r', prefix : getgr_headers, args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_GETGRGID_R', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'getgrgid_r.c',
|
||||
'getgrgid_r.h')
|
||||
endif
|
||||
|
||||
mntent_headers = '''
|
||||
#include <stdio.h>
|
||||
#include <mntent.h>
|
||||
'''
|
||||
|
||||
have_hasmntopt = cc.has_function('hasmntopt', prefix : mntent_headers, args : '-D_GNU_SOURCE')
|
||||
if have_hasmntopt
|
||||
conf.set10('HAVE_HASMNTOPT', true)
|
||||
endif
|
||||
|
||||
have_setmntent = cc.has_function('setmntent', prefix : mntent_headers, args : '-D_GNU_SOURCE')
|
||||
if have_setmntent
|
||||
conf.set10('HAVE_SETMNTENT', true)
|
||||
endif
|
||||
|
||||
have_endmntent = cc.has_function('endmntent', prefix : mntent_headers, args : '-D_GNU_SOURCE')
|
||||
if have_endmntent
|
||||
conf.set10('HAVE_ENDMNTENT', true)
|
||||
endif
|
||||
|
||||
if have_hasmntopt == false or have_setmntent == false or have_endmntent == false
|
||||
include_sources += files(
|
||||
'lxcmntent.c',
|
||||
'lxcmntent.h')
|
||||
endif
|
||||
|
||||
if cc.has_function('strlcpy', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_STRLCPY', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'strlcpy.c',
|
||||
'strlcpy.h')
|
||||
endif
|
||||
|
||||
if cc.has_function('strlcat', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_STRLCAT', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'strlcat.c',
|
||||
'strlcat.h')
|
||||
endif
|
||||
|
||||
if cc.has_function('strchrnul', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_STRCHRNUL', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'strchrnul.c',
|
||||
'strchrnul.h')
|
||||
endif
|
||||
|
||||
if cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE')
|
||||
conf.set10('HAVE_OPENPTY', true)
|
||||
else
|
||||
include_sources += files(
|
||||
'openpty.c',
|
||||
'openpty.h')
|
||||
endif
|
@ -31,7 +31,7 @@
|
||||
#define __NETLINK_ALIGN(len) (((len) + 3) & ~3)
|
||||
|
||||
#define __NLMSG_OK(nlh, end) \
|
||||
((char *)(end) - (char *)(nlh) >= sizeof(struct nlmsghdr))
|
||||
((size_t)((char *)(end) - (char *)(nlh)) >= sizeof(struct nlmsghdr))
|
||||
|
||||
#define __NLMSG_NEXT(nlh) \
|
||||
(struct nlmsghdr *)((char *)(nlh) + __NETLINK_ALIGN((nlh)->nlmsg_len))
|
||||
@ -50,7 +50,7 @@
|
||||
(struct rtattr *)((char *)(rta) + __NETLINK_ALIGN((rta)->rta_len))
|
||||
|
||||
#define __RTA_OK(nlh, end) \
|
||||
((char *)(end) - (char *)(rta) >= sizeof(struct rtattr))
|
||||
((size_t)((char *)(end) - (char *)(rta)) >= sizeof(struct rtattr))
|
||||
|
||||
#define __NLMSG_RTAOK(rta, nlh) __RTA_OK(rta, __NLMSG_DATAEND(nlh))
|
||||
|
||||
|
@ -230,6 +230,7 @@ AM_CFLAGS += -DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \
|
||||
-DSBINDIR=\"$(SBINDIR)\" \
|
||||
-DAPPARMOR_CACHE_DIR=\"$(APPARMOR_CACHE_DIR)\" \
|
||||
-I $(top_srcdir)/src \
|
||||
-I $(top_srcdir)/src/include \
|
||||
-I $(top_srcdir)/src/lxc \
|
||||
-I $(top_srcdir)/src/lxc/storage \
|
||||
-I $(top_srcdir)/src/lxc/cgroups
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
@ -15,7 +14,6 @@
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
@ -23,7 +21,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(af_unix, lxc);
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_AF_UNIX_H
|
||||
#define __LXC_AF_UNIX_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <stddef.h>
|
||||
|
@ -3,11 +3,11 @@
|
||||
#ifndef __LXC_API_EXTENSIONS_H
|
||||
#define __LXC_API_EXTENSIONS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
* api_extensions is the list of all API extensions in the order they were
|
||||
* added.
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
@ -22,7 +21,7 @@
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lxc/lxccontainer.h>
|
||||
#include "attach.h"
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "attach.h"
|
||||
@ -31,7 +30,6 @@
|
||||
#include "cgroups/cgroup_utils.h"
|
||||
#include "commands.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile.h"
|
||||
#include "log.h"
|
||||
#include "lsm/lsm.h"
|
||||
@ -163,7 +161,7 @@ static inline bool sync_wait_fd(int fd, int *fd_recv)
|
||||
return lxc_abstract_unix_recv_one_fd(fd, fd_recv, NULL, 0) > 0;
|
||||
}
|
||||
|
||||
static bool attach_lsm(lxc_attach_options_t *options)
|
||||
static inline bool attach_lsm(lxc_attach_options_t *options)
|
||||
{
|
||||
return (options->attach_flags & (LXC_ATTACH_LSM | LXC_ATTACH_LSM_LABEL));
|
||||
}
|
||||
@ -1797,7 +1795,7 @@ int lxc_attach_run_shell(void* payload)
|
||||
struct passwd pwent;
|
||||
struct passwd *pwentp = NULL;
|
||||
char *user_shell;
|
||||
size_t bufsize;
|
||||
ssize_t bufsize;
|
||||
int ret;
|
||||
|
||||
/* Ignore payload parameter. */
|
||||
@ -1806,7 +1804,7 @@ int lxc_attach_run_shell(void* payload)
|
||||
uid = getuid();
|
||||
|
||||
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
if (bufsize == -1)
|
||||
if (bufsize < 0)
|
||||
bufsize = 1024;
|
||||
|
||||
buf = malloc(bufsize);
|
||||
|
@ -3,10 +3,13 @@
|
||||
#ifndef __LXC_ATTACH_H
|
||||
#define __LXC_ATTACH_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <lxc/attach_options.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "lxc.h"
|
||||
|
||||
#include "compiler.h"
|
||||
#include "namespace.h"
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
@ -11,7 +10,6 @@
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "caps.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
|
@ -3,9 +3,10 @@
|
||||
#ifndef __LXC_CAPS_H
|
||||
#define __LXC_CAPS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "compiler.h"
|
||||
|
||||
#if HAVE_LIBCAP
|
||||
|
@ -14,10 +14,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@ -54,11 +50,11 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#include "include/strlcat.h"
|
||||
#include "strlcat.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(cgfsng, cgroup);
|
||||
@ -163,7 +159,7 @@ int prepare_cgroup_fd(const struct cgroup_ops *ops, struct cgroup_fd *fd, bool l
|
||||
* The client requested that the controller must be in a specific
|
||||
* cgroup version.
|
||||
*/
|
||||
if (fd->type != 0 && fd->type != h->fs_type)
|
||||
if (fd->type != 0 && (cgroupfs_type_magic_t)fd->type != h->fs_type)
|
||||
return ret_errno(EINVAL);
|
||||
|
||||
if (limit)
|
||||
@ -2132,7 +2128,7 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t
|
||||
* that a short write would cause a buffer overrun. So be on
|
||||
* the safe side.
|
||||
*/
|
||||
if (ret < STRLITERALLEN(".lxc-/cgroup.procs"))
|
||||
if ((size_t)ret < STRLITERALLEN(".lxc-/cgroup.procs"))
|
||||
return log_error_errno(-EINVAL, EINVAL, "Unexpected short write would cause buffer-overrun");
|
||||
|
||||
slash += (ret - STRLITERALLEN("/cgroup.procs"));
|
||||
@ -2208,11 +2204,11 @@ static int cgroup_attach_move_into_leaf(const struct lxc_conf *conf,
|
||||
pidstr_len = sprintf(pidstr, INT64_FMT, (int64_t)pid);
|
||||
|
||||
ret = lxc_write_nointr(target_fd0, pidstr, pidstr_len);
|
||||
if (ret > 0 && ret == pidstr_len)
|
||||
if (ret > 0 && (size_t)ret == pidstr_len)
|
||||
return log_debug(0, "Moved process into target cgroup via fd %d", target_fd0);
|
||||
|
||||
ret = lxc_write_nointr(target_fd1, pidstr, pidstr_len);
|
||||
if (ret > 0 && ret == pidstr_len)
|
||||
if (ret > 0 && (size_t)ret == pidstr_len)
|
||||
return log_debug(0, "Moved process into target cgroup via fd %d", target_fd1);
|
||||
|
||||
return log_debug_errno(-1, errno, "Failed to move process into target cgroup via fd %d and %d",
|
||||
@ -2437,7 +2433,8 @@ static int device_cgroup_parse_access(struct device_item *device, const char *va
|
||||
static int device_cgroup_rule_parse(struct device_item *device, const char *key,
|
||||
const char *val)
|
||||
{
|
||||
int count, ret;
|
||||
size_t count;
|
||||
int ret;
|
||||
char temp[50];
|
||||
|
||||
if (strequal("devices.allow", key))
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include "cgroup2_devices.h"
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "initutils.h"
|
||||
#include "memory_utils.h"
|
||||
#include "log.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_CGROUP_H
|
||||
#define __LXC_CGROUP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <linux/types.h>
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
/* Parts of this taken from systemd's implementation. */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
@ -16,7 +15,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cgroup2_devices.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef __LXC_CGROUP2_DEVICES_H
|
||||
#define __LXC_CGROUP2_DEVICES_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
@ -18,14 +20,13 @@
|
||||
#include "cgroup.h"
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "list.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
#include "syscall_numbers.h"
|
||||
|
||||
#include "include/bpf.h"
|
||||
#include "include/bpf_common.h"
|
||||
#include "bpf.h"
|
||||
#include "bpf_common.h"
|
||||
|
||||
#ifndef HAVE_BPF
|
||||
static inline int bpf_lxc(int cmd, union bpf_attr *attr, size_t size)
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -11,7 +10,6 @@
|
||||
|
||||
#include "cgroup.h"
|
||||
#include "cgroup_utils.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_CGROUP_UTILS_H
|
||||
#define __LXC_CGROUP_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lxc/lxccontainer.h>
|
||||
#include <lxc/version.h>
|
||||
#include "lxc.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lxc/lxccontainer.h>
|
||||
#include "lxc.h"
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "config.h"
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#define usernic_debug_stream(stream, format, ...) \
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <caps.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -22,7 +21,6 @@
|
||||
#include "commands.h"
|
||||
#include "commands_utils.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile.h"
|
||||
#include "log.h"
|
||||
#include "lxc.h"
|
||||
@ -253,14 +251,14 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
|
||||
case LXC_CMD_GET_CGROUP_FD: /* data */
|
||||
__fallthrough;
|
||||
case LXC_CMD_GET_LIMIT_CGROUP_FD: /* data */
|
||||
if (rsp->datalen > sizeof(struct cgroup_fd))
|
||||
if ((size_t)rsp->datalen > sizeof(struct cgroup_fd))
|
||||
return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
|
||||
|
||||
/* Don't pointlessly allocate. */
|
||||
rsp->data = (void *)cmd->req.data;
|
||||
break;
|
||||
case LXC_CMD_GET_CGROUP_CTX: /* data */
|
||||
if (rsp->datalen > sizeof(struct cgroup_ctx))
|
||||
if ((size_t)rsp->datalen > sizeof(struct cgroup_ctx))
|
||||
return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
|
||||
|
||||
/* Don't pointlessly allocate. */
|
||||
@ -1489,7 +1487,7 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
|
||||
if (log->read)
|
||||
rsp.data = lxc_ringbuf_get_read_addr(buf);
|
||||
|
||||
if (log->read_max > 0 && (log->read_max <= rsp.datalen))
|
||||
if (log->read_max > 0 && (log->read_max <= (uint64_t)rsp.datalen))
|
||||
rsp.datalen = log->read_max;
|
||||
|
||||
/* there's nothing to read */
|
||||
|
@ -3,14 +3,17 @@
|
||||
#ifndef __LXC_COMMANDS_H
|
||||
#define __LXC_COMMANDS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lxc.h"
|
||||
|
||||
#include "compiler.h"
|
||||
#include "cgroups/cgroup.h"
|
||||
#include "lxccontainer.h"
|
||||
#include "macro.h"
|
||||
#include "state.h"
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS /* Required for PRIu64 to work. */
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
@ -13,10 +11,10 @@
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "attach_options.h"
|
||||
#include "af_unix.h"
|
||||
#include "commands.h"
|
||||
#include "commands_utils.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "initutils.h"
|
||||
#include "log.h"
|
||||
@ -129,7 +127,7 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen,
|
||||
* ret >= len. This means lxcpath and name are too long. We need to
|
||||
* hash both.
|
||||
*/
|
||||
if (ret >= len) {
|
||||
if ((size_t)ret >= len) {
|
||||
tmplen = strlen(name) + strlen(lxcpath) + 2;
|
||||
tmppath = must_realloc(NULL, tmplen);
|
||||
ret = strnprintf(tmppath, tmplen, "%s/%s", lxcpath, name);
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_COMMANDS_UTILS_H
|
||||
#define __LXC_COMMANDS_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "state.h"
|
||||
|
@ -3,15 +3,11 @@
|
||||
#ifndef __LXC_COMPILER_H
|
||||
#define __LXC_COMPILER_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef thread_local
|
||||
#if __STDC_VERSION__ >= 201112L && \
|
||||
!(defined(__STDC_NO_THREADS__) || \
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@ -34,12 +33,11 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "af_unix.h"
|
||||
#include "caps.h"
|
||||
#include "cgroups/cgroup.h"
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile.h"
|
||||
#include "confile_utils.h"
|
||||
#include "error.h"
|
||||
@ -75,7 +73,7 @@
|
||||
#if HAVE_OPENPTY
|
||||
#include <pty.h>
|
||||
#else
|
||||
#include <../include/openpty.h>
|
||||
#include "openpty.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBCAP
|
||||
@ -83,25 +81,25 @@
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#include "include/strlcat.h"
|
||||
#include "strlcat.h"
|
||||
#endif
|
||||
|
||||
#if IS_BIONIC
|
||||
#include <../include/lxcmntent.h>
|
||||
#include "lxcmntent.h"
|
||||
#else
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_PRLIMIT) && defined(HAVE_PRLIMIT64)
|
||||
#include <../include/prlimit.h>
|
||||
#include "prlimit.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCHRNUL
|
||||
#include "include/strchrnul.h"
|
||||
#include "strchrnul.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(conf, lxc);
|
||||
@ -185,7 +183,7 @@ static struct mount_opt propagation_opt[] = {
|
||||
{ "rshared", 0, true, MS_SHARED, MS_SHARED | MS_REC },
|
||||
{ "rslave", 0, true, MS_SLAVE, MS_SLAVE | MS_REC },
|
||||
{ "runbindable", 0, true, MS_UNBINDABLE, MS_UNBINDABLE | MS_REC },
|
||||
{ NULL, 0, 0 },
|
||||
{ NULL, 0, false, 0, 0 },
|
||||
};
|
||||
|
||||
static struct caps_opt caps_opt[] = {
|
||||
@ -885,7 +883,7 @@ static const struct dev_symlinks dev_symlinks[] = {
|
||||
|
||||
static int lxc_setup_dev_symlinks(const struct lxc_rootfs *rootfs)
|
||||
{
|
||||
for (int i = 0; i < sizeof(dev_symlinks) / sizeof(dev_symlinks[0]); i++) {
|
||||
for (size_t i = 0; i < sizeof(dev_symlinks) / sizeof(dev_symlinks[0]); i++) {
|
||||
int ret;
|
||||
struct stat s;
|
||||
const struct dev_symlinks *d = &dev_symlinks[i];
|
||||
@ -974,7 +972,7 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
|
||||
if (!conf->rootfs.path)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < ttys->max; i++) {
|
||||
for (size_t i = 0; i < ttys->max; i++) {
|
||||
__do_close int fd_to = -EBADF;
|
||||
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||
|
||||
@ -982,7 +980,7 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
|
||||
char *tty_name, *tty_path;
|
||||
|
||||
ret = strnprintf(rootfs->buf, sizeof(rootfs->buf),
|
||||
"/dev/%s/tty%d", ttydir, i + 1);
|
||||
"/dev/%s/tty%zu", ttydir, i + 1);
|
||||
if (ret < 0)
|
||||
return ret_errno(-EIO);
|
||||
|
||||
@ -1028,7 +1026,7 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
|
||||
rootfs->dfd_dev, tty_name,
|
||||
rootfs->dfd_dev, tty_path);
|
||||
} else {
|
||||
ret = strnprintf(rootfs->buf, sizeof(rootfs->buf), "tty%d", i + 1);
|
||||
ret = strnprintf(rootfs->buf, sizeof(rootfs->buf), "tty%zu", i + 1);
|
||||
if (ret < 0)
|
||||
return ret_errno(-EIO);
|
||||
|
||||
@ -1107,7 +1105,7 @@ void lxc_delete_tty(struct lxc_tty_info *ttys)
|
||||
if (!ttys || !ttys->tty)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < ttys->max; i++) {
|
||||
for (size_t i = 0; i < ttys->max; i++) {
|
||||
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||
close_prot_errno_disarm(tty->ptx);
|
||||
close_prot_errno_disarm(tty->pty);
|
||||
@ -1118,7 +1116,6 @@ void lxc_delete_tty(struct lxc_tty_info *ttys)
|
||||
|
||||
static int __lxc_send_ttys_to_parent(struct lxc_handler *handler)
|
||||
{
|
||||
int i;
|
||||
int ret = -1;
|
||||
struct lxc_conf *conf = handler->conf;
|
||||
struct lxc_tty_info *ttys = &conf->ttys;
|
||||
@ -1127,7 +1124,7 @@ static int __lxc_send_ttys_to_parent(struct lxc_handler *handler)
|
||||
if (ttys->max == 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < ttys->max; i++) {
|
||||
for (size_t i = 0; i < ttys->max; i++) {
|
||||
int ttyfds[2];
|
||||
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||
|
||||
@ -1298,7 +1295,7 @@ enum {
|
||||
|
||||
static int lxc_fill_autodev(struct lxc_rootfs *rootfs)
|
||||
{
|
||||
int i, ret;
|
||||
int ret;
|
||||
mode_t cmask;
|
||||
int use_mknod = LXC_DEVNODE_MKNOD;
|
||||
|
||||
@ -1308,7 +1305,7 @@ static int lxc_fill_autodev(struct lxc_rootfs *rootfs)
|
||||
INFO("Populating \"/dev\"");
|
||||
|
||||
cmask = umask(S_IXUSR | S_IXGRP | S_IXOTH);
|
||||
for (i = 0; i < sizeof(lxc_devices) / sizeof(lxc_devices[0]); i++) {
|
||||
for (size_t i = 0; i < sizeof(lxc_devices) / sizeof(lxc_devices[0]); i++) {
|
||||
const struct lxc_device_node *device = &lxc_devices[i];
|
||||
|
||||
if (use_mknod >= LXC_DEVNODE_MKNOD) {
|
||||
@ -2247,7 +2244,7 @@ static int parse_vfs_attr(struct lxc_mount_options *opts, char *opt, size_t size
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mo->flag == ~0)
|
||||
if (mo->flag == (__u64)~0)
|
||||
return log_info(0, "Ignoring %s mount option", mo->name);
|
||||
|
||||
if (mo->clear) {
|
||||
@ -2803,7 +2800,7 @@ FILE *make_anonymous_mount_file(const struct list_head *mount_entries,
|
||||
len = strlen(entry->val);
|
||||
|
||||
ret = lxc_write_nointr(fd, entry->val, len);
|
||||
if (ret != len)
|
||||
if (ret < 0 || (size_t)ret != len)
|
||||
return NULL;
|
||||
|
||||
ret = lxc_write_nointr(fd, "\n", 1);
|
||||
@ -2979,7 +2976,7 @@ static int __lxc_idmapped_mounts_child(struct lxc_handler *handler, FILE *f)
|
||||
/* Set propagation mount options. */
|
||||
if (opts.attr.propagation) {
|
||||
attr = (struct lxc_mount_attr) {
|
||||
attr.propagation = opts.attr.propagation,
|
||||
.propagation = opts.attr.propagation,
|
||||
};
|
||||
|
||||
ret = mount_setattr(fd_from,
|
||||
@ -3438,7 +3435,7 @@ int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf,
|
||||
return log_error_errno(-1, errno, "Failed to open \"%s\"", path);
|
||||
|
||||
ret = lxc_write_nointr(fd, buf, buf_size);
|
||||
if (ret != buf_size)
|
||||
if (ret < 0 || (size_t)ret != buf_size)
|
||||
return log_error_errno(-1, errno, "Failed to write %cid mapping to \"%s\"",
|
||||
idtype == ID_TYPE_UID ? 'u' : 'g', path);
|
||||
|
||||
@ -3509,7 +3506,9 @@ static struct id_map *find_mapped_hostid_entry(const struct list_head *idmap,
|
||||
|
||||
int lxc_map_ids(struct list_head *idmap, pid_t pid)
|
||||
{
|
||||
int hostuid, hostgid, fill, left;
|
||||
int fill, left;
|
||||
uid_t hostuid;
|
||||
gid_t hostgid;
|
||||
char u_or_g;
|
||||
char *pos;
|
||||
char cmd_output[PATH_MAX];
|
||||
@ -3718,7 +3717,7 @@ static int lxc_transient_proc(struct lxc_rootfs *rootfs)
|
||||
return log_error_errno(-errno, errno, "Failed to create %d(proc)", rootfs->dfd_mnt);
|
||||
|
||||
goto domount;
|
||||
} else if (link_len >= sizeof(link)) {
|
||||
} else if ((size_t)link_len >= sizeof(link)) {
|
||||
return log_error_errno(-EIO, EIO, "Truncated link target");
|
||||
}
|
||||
link[link_len] = '\0';
|
||||
@ -4116,14 +4115,14 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
|
||||
if (!info_new->tty)
|
||||
return ret_errno(ENOMEM);
|
||||
|
||||
for (int i = 0; i < ttys_max; i++) {
|
||||
for (size_t i = 0; i < ttys_max; i++) {
|
||||
terminal_info = &info_new->tty[i];
|
||||
terminal_info->busy = -1;
|
||||
terminal_info->ptx = -EBADF;
|
||||
terminal_info->pty = -EBADF;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ttys_max; i++) {
|
||||
for (size_t i = 0; i < ttys_max; i++) {
|
||||
int ptx = -EBADF, pty = -EBADF;
|
||||
|
||||
ret = lxc_abstract_unix_recv_two_fds(sock, &ptx, &pty);
|
||||
@ -5521,11 +5520,11 @@ static char *getuname(void)
|
||||
__do_free char *buf = NULL;
|
||||
struct passwd pwent;
|
||||
struct passwd *pwentp = NULL;
|
||||
size_t bufsize;
|
||||
ssize_t bufsize;
|
||||
int ret;
|
||||
|
||||
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
if (bufsize == -1)
|
||||
if (bufsize < 0)
|
||||
bufsize = 1024;
|
||||
|
||||
buf = zalloc(bufsize);
|
||||
@ -5549,11 +5548,11 @@ static char *getgname(void)
|
||||
__do_free char *buf = NULL;
|
||||
struct group grent;
|
||||
struct group *grentp = NULL;
|
||||
size_t bufsize;
|
||||
ssize_t bufsize;
|
||||
int ret;
|
||||
|
||||
bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
|
||||
if (bufsize == -1)
|
||||
if (bufsize < 0)
|
||||
bufsize = 1024;
|
||||
|
||||
buf = zalloc(bufsize);
|
||||
|
@ -3,9 +3,8 @@
|
||||
#ifndef __LXC_CONF_H
|
||||
#define __LXC_CONF_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <linux/magic.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
@ -18,7 +17,6 @@
|
||||
#include "attach_options.h"
|
||||
#include "caps.h"
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
#include "hlist.h"
|
||||
#include "list.h"
|
||||
#include "lxcseccomp.h"
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
@ -21,30 +19,32 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile.h"
|
||||
#include "confile_utils.h"
|
||||
#include "../include/netns_ifaddrs.h"
|
||||
#include "netns_ifaddrs.h"
|
||||
#include "log.h"
|
||||
#include "lxcseccomp.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
#include "network.h"
|
||||
#include "parse.h"
|
||||
#include "storage/storage.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#include "include/strlcat.h"
|
||||
#include "strlcat.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
lxc_log_define(confile, lxc);
|
||||
@ -2540,7 +2540,7 @@ static int set_config_console_buffer_size(const char *key, const char *value,
|
||||
if (buffer_size == 0)
|
||||
return ret_errno(EINVAL);
|
||||
|
||||
if (buffer_size != size)
|
||||
if (buffer_size != (uint64_t)size)
|
||||
NOTICE("Passed size was not a power of 2. Rounding log size to next power of two: %" PRIu64 " bytes", buffer_size);
|
||||
|
||||
lxc_conf->console.buffer_size = buffer_size;
|
||||
@ -2585,7 +2585,7 @@ static int set_config_console_size(const char *key, const char *value,
|
||||
if (log_size == 0)
|
||||
return ret_errno(EINVAL);
|
||||
|
||||
if (log_size != size)
|
||||
if (log_size != (uint64_t)size)
|
||||
NOTICE("Passed size was not a power of 2. Rounding log size to next power of two: %" PRIu64 " bytes", log_size);
|
||||
|
||||
lxc_conf->console.log_size = log_size;
|
||||
@ -3216,7 +3216,7 @@ int lxc_config_parse_arch(const char *arch, signed long *persona)
|
||||
{ "x86_64", PER_LINUX },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(pername); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(pername); i++) {
|
||||
if (!strequal(pername[i].name, arch))
|
||||
continue;
|
||||
|
||||
@ -4508,7 +4508,7 @@ static int get_config_init_groups(const char *key, char *retv, int inlen,
|
||||
if (c->init_groups.size == 0)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < c->init_groups.size; i++)
|
||||
for (size_t i = 0; i < c->init_groups.size; i++)
|
||||
strprint(retv, inlen, "%s%d", (i > 0) ? "," : "",
|
||||
c->init_groups.list[i]);
|
||||
|
||||
|
@ -3,11 +3,12 @@
|
||||
#ifndef __LXC_CONFILE_H
|
||||
#define __LXC_CONFILE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <lxc/attach_options.h>
|
||||
#include <lxc/lxccontainer.h>
|
||||
#include "lxc.h"
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
|
@ -1,23 +1,22 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lxc.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile.h"
|
||||
#include "confile_utils.h"
|
||||
#include "error.h"
|
||||
#include "list.h"
|
||||
#include "lxc.h"
|
||||
#include "log.h"
|
||||
#include "lxccontainer.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
#include "network.h"
|
||||
@ -25,7 +24,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(confile_utils, lxc);
|
||||
@ -799,7 +798,7 @@ int lxc_get_conf_str(char *retv, int inlen, const char *value)
|
||||
return 0;
|
||||
|
||||
value_len = strlen(value);
|
||||
if (retv && inlen >= value_len + 1)
|
||||
if (retv && (size_t)inlen >= value_len + 1)
|
||||
memcpy(retv, value, value_len + 1);
|
||||
|
||||
return value_len;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_CONFILE_UTILS_H
|
||||
#define __LXC_CONFILE_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <linux/limits.h>
|
||||
#include <sched.h>
|
||||
@ -14,10 +13,11 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "attach_options.h"
|
||||
|
||||
#include "cgroup.h"
|
||||
#include "commands.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "criu.h"
|
||||
#include "log.h"
|
||||
#include "lxc.h"
|
||||
@ -29,13 +29,13 @@
|
||||
#include "utils.h"
|
||||
|
||||
#if IS_BIONIC
|
||||
#include <../include/lxcmntent.h>
|
||||
#include "lxcmntent.h"
|
||||
#else
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#define CRIU_VERSION "2.0"
|
||||
@ -335,7 +335,7 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
||||
WARN("No cgroup controllers configured in container's cgroup %s", cgroup_base_path);
|
||||
ret = sprintf(buf, "%s", cgroup_base_path);
|
||||
}
|
||||
if (ret < 0 || ret >= sizeof(buf))
|
||||
if (ret < 0 || (size_t)ret >= sizeof(buf))
|
||||
return log_error_errno(-EIO, EIO, "sprintf of cgroup root arg failed");
|
||||
|
||||
DECLARE_ARG("--cgroup-root");
|
||||
@ -443,7 +443,7 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
||||
char ghost_limit[32];
|
||||
|
||||
ret = sprintf(ghost_limit, "%"PRIu64, opts->user->ghost_limit);
|
||||
if (ret < 0 || ret >= sizeof(ghost_limit))
|
||||
if (ret < 0 || (size_t)ret >= sizeof(ghost_limit))
|
||||
return log_error_errno(-EIO, EIO, "Failed to print ghost limit %"PRIu64, opts->user->ghost_limit);
|
||||
|
||||
DECLARE_ARG("--ghost-limit");
|
||||
|
@ -3,9 +3,11 @@
|
||||
#ifndef __LXC_CRIU_H
|
||||
#define __LXC_CRIU_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <lxc/lxccontainer.h>
|
||||
#include "lxc.h"
|
||||
|
||||
__hidden extern bool __criu_pre_dump(struct lxc_container *c, struct migrate_opts *opts);
|
||||
__hidden extern bool __criu_dump(struct lxc_container *c, struct migrate_opts *opts);
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_ERROR_UTILS_H
|
||||
#define __LXC_ERROR_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -11,7 +10,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "start.h"
|
||||
#include "process_utils.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/magic.h>
|
||||
@ -13,7 +12,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
@ -259,14 +257,19 @@ bool file_exists(const char *f)
|
||||
int print_to_file(const char *file, const char *content)
|
||||
{
|
||||
__do_fclose FILE *f = NULL;
|
||||
int ret = 0;
|
||||
int ret;
|
||||
size_t len;
|
||||
|
||||
f = fopen(file, "we");
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
if (fprintf(f, "%s", content) != strlen(content))
|
||||
len = strlen(content);
|
||||
ret = fprintf(f, "%s", content);
|
||||
if (ret < 0 || (size_t)ret != len)
|
||||
ret = -1;
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -593,8 +596,7 @@ FILE *fdopen_at(int dfd, const char *path, const char *mode,
|
||||
int timens_offset_write(clockid_t clk_id, int64_t s_offset, int64_t ns_offset)
|
||||
{
|
||||
__do_close int fd = -EBADF;
|
||||
int ret;
|
||||
ssize_t len;
|
||||
ssize_t len, ret;
|
||||
char buf[INTTYPE_TO_STRLEN(int) +
|
||||
STRLITERALLEN(" ") + INTTYPE_TO_STRLEN(int64_t) +
|
||||
STRLITERALLEN(" ") + INTTYPE_TO_STRLEN(int64_t) + 1];
|
||||
@ -611,7 +613,7 @@ int timens_offset_write(clockid_t clk_id, int64_t s_offset, int64_t ns_offset)
|
||||
return ret_errno(EFBIG);
|
||||
|
||||
ret = lxc_write_nointr(fd, buf, len);
|
||||
if (ret < 0 || (size_t)ret != len)
|
||||
if (ret < 0 || ret != len)
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_FILE_UTILS_H
|
||||
#define __LXC_FILE_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@ -12,11 +11,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "attach_options.h"
|
||||
#include "cgroups/cgroup.h"
|
||||
#include "cgroups/cgroup_utils.h"
|
||||
#include "commands.h"
|
||||
#include "commands_utils.h"
|
||||
#include "config.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "lxc.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/prctl.h>
|
||||
@ -11,7 +10,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
#include "error.h"
|
||||
#include "file_utils.h"
|
||||
#include "initutils.h"
|
||||
@ -20,7 +18,7 @@
|
||||
#include "process_utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
static char *copy_global_config_value(char *p)
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_INITUTILS_H
|
||||
#define __LXC_INITUTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
@ -15,8 +17,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cgroups/cgroup.h"
|
||||
#include "compiler.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_LIST_H
|
||||
#define __LXC_LIST_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "memory_utils.h"
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS /* Required for PRIu64 to work. */
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
@ -18,16 +16,16 @@
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lxc.h"
|
||||
|
||||
#include "caps.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "lxccontainer.h"
|
||||
#include "memory_utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_DLOG
|
||||
|
@ -3,9 +3,8 @@
|
||||
#ifndef __LXC_LOG_H
|
||||
#define __LXC_LOG_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@ -18,7 +17,6 @@
|
||||
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 02000000
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -15,7 +14,6 @@
|
||||
#include "caps.h"
|
||||
#include "cgroups/cgroup_utils.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "initutils.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
@ -406,7 +404,7 @@ static int __apparmor_process_label_open(struct lsm_ops *ops, pid_t pid, int o_f
|
||||
|
||||
/* first try the apparmor subdir */
|
||||
ret = snprintf(path, LXC_LSMATTRLEN, "/proc/%d/attr/apparmor/current", pid);
|
||||
if (ret < 0 || ret >= LXC_LSMATTRLEN)
|
||||
if (ret < 0 || (size_t)ret >= LXC_LSMATTRLEN)
|
||||
return -1;
|
||||
|
||||
labelfd = open(path, o_flags);
|
||||
@ -417,7 +415,7 @@ static int __apparmor_process_label_open(struct lsm_ops *ops, pid_t pid, int o_f
|
||||
|
||||
/* fallback to legacy global attr directory */
|
||||
ret = snprintf(path, LXC_LSMATTRLEN, "/proc/%d/attr/current", pid);
|
||||
if (ret < 0 || ret >= LXC_LSMATTRLEN)
|
||||
if (ret < 0 || (size_t)ret >= LXC_LSMATTRLEN)
|
||||
return -1;
|
||||
|
||||
labelfd = open(path, o_flags);
|
||||
@ -721,13 +719,12 @@ static void append_all_remount_rules(char **profile, size_t *size)
|
||||
const size_t buf_append_pos = strlen(buf);
|
||||
|
||||
const size_t opt_count = ARRAY_SIZE(REMOUNT_OPTIONS);
|
||||
size_t opt_bits;
|
||||
|
||||
must_append_sized(profile, size,
|
||||
"# allow various ro-bind-*re*mounts\n",
|
||||
sizeof("# allow various ro-bind-*re*mounts\n")-1);
|
||||
|
||||
for (opt_bits = 0; opt_bits != 1 << opt_count; ++opt_bits) {
|
||||
for (size_t opt_bits = 0; opt_bits != (size_t)1 << opt_count; ++opt_bits) {
|
||||
size_t at = buf_append_pos;
|
||||
unsigned bit = 1;
|
||||
size_t o;
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mount.h>
|
||||
@ -11,7 +10,6 @@
|
||||
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "lsm.h"
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_LSM_H
|
||||
#define __LXC_LSM_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
struct lxc_conf;
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -1,11 +1,9 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "lsm/lsm.h"
|
||||
|
||||
static char *nop_process_label_get(struct lsm_ops *ops, pid_t pid)
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <selinux/selinux.h>
|
||||
#include <stdbool.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "lsm.h"
|
||||
@ -136,7 +134,7 @@ static int selinux_process_label_fd_get(struct lsm_ops *ops, pid_t pid, bool on_
|
||||
ret = snprintf(path, LXC_LSMATTRLEN, "/proc/%d/attr/exec", pid);
|
||||
else
|
||||
ret = snprintf(path, LXC_LSMATTRLEN, "/proc/%d/attr/current", pid);
|
||||
if (ret < 0 || ret >= LXC_LSMATTRLEN)
|
||||
if (ret < 0 || (size_t)ret >= LXC_LSMATTRLEN)
|
||||
return -1;
|
||||
|
||||
labelfd = open(path, O_RDWR);
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_LXC_H
|
||||
#define __LXC_LXC_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -12,6 +14,9 @@ extern "C" {
|
||||
#include <sys/select.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "attach_options.h"
|
||||
#include "lxccontainer.h"
|
||||
|
||||
#include "compiler.h"
|
||||
#include "memory_utils.h"
|
||||
#include "state.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@ -25,7 +24,9 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/netns_ifaddrs.h"
|
||||
#include "lxc.h"
|
||||
|
||||
#include "netns_ifaddrs.h"
|
||||
#include "af_unix.h"
|
||||
#include "api_extensions.h"
|
||||
#include "attach.h"
|
||||
@ -34,7 +35,6 @@
|
||||
#include "commands.h"
|
||||
#include "commands_utils.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile.h"
|
||||
#include "confile_utils.h"
|
||||
#include "criu.h"
|
||||
@ -42,7 +42,6 @@
|
||||
#include "initutils.h"
|
||||
#include "log.h"
|
||||
#include "lxc.h"
|
||||
#include "lxccontainer.h"
|
||||
#include "lxclock.h"
|
||||
#include "memory_utils.h"
|
||||
#include "monitor.h"
|
||||
@ -1625,13 +1624,12 @@ static bool create_run_template(struct lxc_container *c, char *tpath,
|
||||
|
||||
static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
|
||||
{
|
||||
long flen;
|
||||
size_t len;
|
||||
ssize_t len, flen;
|
||||
char *contents;
|
||||
FILE *f;
|
||||
int ret = -1;
|
||||
ssize_t nbytes;
|
||||
#if HAVE_OPENSSL
|
||||
int i;
|
||||
unsigned int md_len = 0;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
char *tpath;
|
||||
@ -1709,7 +1707,7 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
|
||||
|
||||
#if HAVE_OPENSSL
|
||||
fprintf(f, "# Template script checksum (SHA-1): ");
|
||||
for (i=0; i<md_len; i++)
|
||||
for (size_t i = 0; i < md_len; i++)
|
||||
fprintf(f, "%02x", md_value[i]);
|
||||
fprintf(f, "\n");
|
||||
#endif
|
||||
@ -1717,7 +1715,8 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
|
||||
fprintf(f, "\n# Uncomment the following line to support nesting containers:\n");
|
||||
fprintf(f, "#lxc.include = " LXCTEMPLATECONFIG "/nesting.conf\n");
|
||||
fprintf(f, "# (Be aware this has security implications)\n\n");
|
||||
if (fwrite(contents, 1, flen, f) != flen) {
|
||||
nbytes = fwrite(contents, 1, flen, f);
|
||||
if (nbytes < 0 || nbytes != flen) {
|
||||
SYSERROR("Writing original contents");
|
||||
free(contents);
|
||||
fclose(f);
|
||||
@ -2469,7 +2468,7 @@ static char **do_lxcapi_get_ips(struct lxc_container *c, const char *interface,
|
||||
if (family && !strequal(family, "inet6"))
|
||||
continue;
|
||||
|
||||
if (((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id != scope)
|
||||
if (((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id != (uint32_t)scope)
|
||||
continue;
|
||||
|
||||
address_ptr_tmp = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
|
||||
@ -4268,8 +4267,11 @@ static char *get_timestamp(char* snappath, char *name)
|
||||
if (len > 0) {
|
||||
s = malloc(len+1);
|
||||
if (s) {
|
||||
ssize_t nbytes;
|
||||
|
||||
s[len] = '\0';
|
||||
if (fread(s, 1, len, fin) != len)
|
||||
nbytes = fread(s, 1, len, fin);
|
||||
if (nbytes < 0 || nbytes != (ssize_t)len)
|
||||
return log_error_errno(NULL, errno, "reading timestamp");
|
||||
}
|
||||
}
|
||||
@ -5471,13 +5473,13 @@ int list_defined_containers(const char *lxcpath, char ***names,
|
||||
|
||||
free_bad:
|
||||
if (names && *names) {
|
||||
for (int i = 0; i < name_array_len; i++)
|
||||
for (size_t i = 0; i < name_array_len; i++)
|
||||
free((*names)[i]);
|
||||
free(*names);
|
||||
}
|
||||
|
||||
if (cret && *cret) {
|
||||
for (int i = 0; i < ct_array_len; i++)
|
||||
for (size_t i = 0; i < ct_array_len; i++)
|
||||
lxc_container_put((*cret)[i]);
|
||||
free(*cret);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_CONTAINER_H
|
||||
#define __LXC_CONTAINER_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
@ -12,9 +11,8 @@
|
||||
#include <sys/file.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lxc/lxccontainer.h>
|
||||
#include "lxc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "lxclock.h"
|
||||
#include "memory_utils.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_LXCLOCK_H
|
||||
#define __LXC_LXCLOCK_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <string.h>
|
||||
|
@ -3,9 +3,8 @@
|
||||
#ifndef __LXC_LXCSECCOMP_H
|
||||
#define __LXC_LXCSECCOMP_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_SECCOMP
|
||||
#include <linux/seccomp.h>
|
||||
@ -18,7 +17,6 @@
|
||||
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "memory_utils.h"
|
||||
|
||||
struct lxc_conf;
|
||||
|
@ -3,10 +3,8 @@
|
||||
#ifndef __LXC_MACRO_H
|
||||
#define __LXC_MACRO_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "config.h"
|
||||
|
||||
#include <asm/types.h>
|
||||
#include <limits.h>
|
||||
#include <linux/if_link.h>
|
||||
@ -22,7 +20,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <sys/epoll.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "mainloop.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_MAINLOOP_H
|
||||
#define __LXC_MAINLOOP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compiler.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_MEMORY_UTILS_H
|
||||
#define __LXC_MEMORY_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
131
src/lxc/meson.build
Normal file
131
src/lxc/meson.build
Normal file
@ -0,0 +1,131 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
liblxcfs_version_file = configure_file(
|
||||
configuration : version_data,
|
||||
input : 'version.h.in',
|
||||
output : 'version.h')
|
||||
|
||||
liblxc_sources = files(
|
||||
'cgroups/cgfsng.c',
|
||||
'cgroups/cgroup.c',
|
||||
'cgroups/cgroup.h',
|
||||
'cgroups/cgroup2_devices.c',
|
||||
'cgroups/cgroup2_devices.h',
|
||||
'cgroups/cgroup_utils.c',
|
||||
'cgroups/cgroup_utils.h',
|
||||
'lsm/apparmor.c',
|
||||
'lsm/lsm.c',
|
||||
'lsm/lsm.h',
|
||||
'lsm/nop.c',
|
||||
'lsm/selinux.c',
|
||||
'storage/btrfs.c',
|
||||
'storage/btrfs.h',
|
||||
'storage/dir.c',
|
||||
'storage/dir.h',
|
||||
'storage/loop.c',
|
||||
'storage/loop.h',
|
||||
'storage/lvm.c',
|
||||
'storage/lvm.h',
|
||||
'storage/nbd.c',
|
||||
'storage/nbd.h',
|
||||
'storage/overlay.c',
|
||||
'storage/overlay.h',
|
||||
'storage/rbd.c',
|
||||
'storage/rbd.h',
|
||||
'storage/rsync.c',
|
||||
'storage/rsync.h',
|
||||
'storage/storage.c',
|
||||
'storage/storage.h',
|
||||
'storage/storage_utils.c',
|
||||
'storage/storage_utils.h',
|
||||
'storage/zfs.c',
|
||||
'storage/zfs.h',
|
||||
'af_unix.c',
|
||||
'af_unix.h',
|
||||
'api_extensions.h',
|
||||
'attach.c',
|
||||
'attach.h',
|
||||
'attach_options.h',
|
||||
'caps.c',
|
||||
'caps.h',
|
||||
'commands.c',
|
||||
'commands.h',
|
||||
'commands_utils.c',
|
||||
'commands_utils.h',
|
||||
'compiler.h',
|
||||
'conf.c',
|
||||
'conf.h',
|
||||
'confile.c',
|
||||
'confile.h',
|
||||
'confile_utils.c',
|
||||
'confile_utils.h',
|
||||
'criu.c',
|
||||
'criu.h',
|
||||
'error.c',
|
||||
'error.h',
|
||||
'error_utils.h',
|
||||
'execute.c',
|
||||
'file_utils.c',
|
||||
'file_utils.h',
|
||||
'freezer.c',
|
||||
'hlist.h',
|
||||
'initutils.c',
|
||||
'initutils.h',
|
||||
'list.h',
|
||||
'log.c',
|
||||
'log.h',
|
||||
'lxc.h',
|
||||
'lxccontainer.c',
|
||||
'lxccontainer.h',
|
||||
'lxclock.c',
|
||||
'lxclock.h',
|
||||
'lxcseccomp.h',
|
||||
'macro.h',
|
||||
'mainloop.c',
|
||||
'mainloop.h',
|
||||
'memory_utils.h',
|
||||
'monitor.c',
|
||||
'monitor.h',
|
||||
'mount_utils.c',
|
||||
'mount_utils.h',
|
||||
'namespace.c',
|
||||
'namespace.h',
|
||||
'network.c',
|
||||
'network.h',
|
||||
'nl.c',
|
||||
'nl.h',
|
||||
'parse.c',
|
||||
'parse.h',
|
||||
'process_utils.c',
|
||||
'process_utils.h',
|
||||
'rexec.c',
|
||||
'rexec.h',
|
||||
'ringbuf.c',
|
||||
'ringbuf.h',
|
||||
'rtnl.c',
|
||||
'rtnl.h',
|
||||
'seccomp.c',
|
||||
'start.c',
|
||||
'start.h',
|
||||
'state.c',
|
||||
'state.h',
|
||||
'string_utils.c',
|
||||
'string_utils.h',
|
||||
'sync.c',
|
||||
'sync.h',
|
||||
'syscall_numbers.h',
|
||||
'syscall_wrappers.h',
|
||||
'terminal.c',
|
||||
'terminal.h',
|
||||
'utils.c',
|
||||
'utils.h',
|
||||
'uuid.c',
|
||||
'uuid.h')
|
||||
|
||||
liblxc_static = static_library(
|
||||
'lxc_static',
|
||||
liblxc_sources + include_sources,
|
||||
install : false,
|
||||
include_directories : liblxc_includes,
|
||||
dependencies : [threads],
|
||||
c_args : '-fvisibility=default')
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
@ -22,7 +21,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "config.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "lxclock.h"
|
||||
@ -33,7 +31,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(monitor, lxc);
|
||||
@ -224,7 +222,6 @@ int lxc_monitor_open(const char *lxcpath)
|
||||
int lxc_monitor_read_fdset(struct pollfd *fds, nfds_t nfds, struct lxc_msg *msg,
|
||||
int timeout)
|
||||
{
|
||||
long i;
|
||||
int ret;
|
||||
|
||||
ret = poll(fds, nfds, timeout * 1000);
|
||||
@ -236,7 +233,7 @@ int lxc_monitor_read_fdset(struct pollfd *fds, nfds_t nfds, struct lxc_msg *msg,
|
||||
/* Only read from the first ready fd, the others will remain ready for
|
||||
* when this routine is called again.
|
||||
*/
|
||||
for (i = 0; i < nfds; i++) {
|
||||
for (size_t i = 0; i < nfds; i++) {
|
||||
if (fds[i].revents != 0) {
|
||||
fds[i].revents = 0;
|
||||
ret = recv(fds[i].fd, msg, sizeof(*msg), 0);
|
||||
@ -327,8 +324,9 @@ int lxc_monitord_spawn(const char *lxcpath)
|
||||
* synced with the child process. the if-empty-statement
|
||||
* construct is to quiet the warn-unused-result warning.
|
||||
*/
|
||||
if (lxc_read_nointr(pipefd[0], &c, 1))
|
||||
if (lxc_read_nointr(pipefd[0], &c, 1)) {
|
||||
;
|
||||
}
|
||||
|
||||
close(pipefd[0]);
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_MONITOR_H
|
||||
#define __LXC_MONITOR_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <poll.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_MOUNT_UTILS_H
|
||||
#define __LXC_MOUNT_UTILS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
@ -13,7 +12,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "memory_utils.h"
|
||||
#include "namespace.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_NAMESPACE_H
|
||||
#define __LXC_NAMESPACE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@ -26,10 +25,9 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/netns_ifaddrs.h"
|
||||
#include "netns_ifaddrs.h"
|
||||
#include "af_unix.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
@ -42,7 +40,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(network, lxc);
|
||||
@ -2518,7 +2516,7 @@ static int ifa_get_local_ip(int family, struct nlmsghdr *msg, void **res)
|
||||
* the address length is correct, but check here just in
|
||||
* case.
|
||||
*/
|
||||
if (RTA_PAYLOAD(rta) != addrlen)
|
||||
if (RTA_PAYLOAD(rta) != (unsigned int)addrlen)
|
||||
return -1;
|
||||
|
||||
/* We might have found an IFA_ADDRESS before, which we
|
||||
@ -2621,7 +2619,7 @@ static int ip_addr_get(int family, int ifindex, void **res)
|
||||
return ret_errno(EINVAL);
|
||||
|
||||
ifa = (struct ifaddrmsg *)NLMSG_DATA(msg);
|
||||
if (ifa->ifa_index == ifindex) {
|
||||
if (ifa->ifa_index == (__u32)ifindex) {
|
||||
if (ifa_get_local_ip(family, msg, res) < 0)
|
||||
return ret_errno(EINVAL);
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_NETWORK_H
|
||||
#define __LXC_NETWORK_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/types.h>
|
||||
#include <stdbool.h>
|
||||
|
12
src/lxc/nl.c
12
src/lxc/nl.c
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
@ -13,7 +12,6 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "nl.h"
|
||||
|
||||
@ -42,7 +40,7 @@ static int nla_put(struct nlmsg *nlmsg, int attr,
|
||||
size_t rtalen = RTA_LENGTH(len);
|
||||
size_t tlen = NLMSG_ALIGN(nlmsg->nlmsghdr->nlmsg_len) + RTA_ALIGN(rtalen);
|
||||
|
||||
if (tlen > nlmsg->cap)
|
||||
if (tlen > (size_t)nlmsg->cap)
|
||||
return ret_errno(ENOMEM);
|
||||
|
||||
rta = NLMSG_TAIL(nlmsg->nlmsghdr);
|
||||
@ -122,7 +120,7 @@ void *nlmsg_reserve(struct nlmsg *nlmsg, size_t len)
|
||||
size_t nlmsg_len = nlmsg->nlmsghdr->nlmsg_len;
|
||||
size_t tlen = NLMSG_ALIGN(len);
|
||||
|
||||
if (nlmsg_len + tlen > nlmsg->cap)
|
||||
if (nlmsg_len + tlen > (size_t)nlmsg->cap)
|
||||
return ret_set_errno(NULL, ENOMEM);
|
||||
|
||||
buf = ((char *)(nlmsg->nlmsghdr)) + nlmsg_len;
|
||||
@ -188,7 +186,7 @@ again:
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
if (msg.msg_flags & MSG_TRUNC && (ret == nlmsghdr->nlmsg_len))
|
||||
if (msg.msg_flags & MSG_TRUNC && ((__u32)ret == nlmsghdr->nlmsg_len))
|
||||
return ret_errno(EMSGSIZE);
|
||||
|
||||
return ret;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_NL_H
|
||||
#define __LXC_NL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "compiler.h"
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@ -23,7 +22,6 @@
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
@ -34,11 +32,11 @@
|
||||
#include <security/pam_modules.h>
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#include "include/strlcat.h"
|
||||
#include "strlcat.h"
|
||||
#endif
|
||||
|
||||
#define pam_cgfs_debug_stream(stream, format, ...) \
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sendfile.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_PARSE_H
|
||||
#define __LXC_PARSE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "process_utils.h"
|
||||
|
@ -3,9 +3,8 @@
|
||||
#ifndef __LXC_PROCESS_UTILS_H
|
||||
#define __LXC_PROCESS_UTILS_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <linux/sched.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
@ -16,7 +15,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "config.h"
|
||||
#include "syscall_numbers.h"
|
||||
|
||||
#ifndef CSIGNAL
|
||||
|
@ -1,15 +1,13 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "file_utils.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
@ -19,7 +17,7 @@
|
||||
#include "syscall_wrappers.h"
|
||||
|
||||
#if IS_BIONIC
|
||||
#include "../include/fexecve.h"
|
||||
#include "fexecve.h"
|
||||
#endif
|
||||
|
||||
#define LXC_MEMFD_REXEC_SEALS \
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_REXEC_H
|
||||
#define __LXC_REXEC_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
__hidden extern int lxc_rexec(const char *memfd_name);
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
@ -13,7 +11,6 @@
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "ringbuf.h"
|
||||
#include "syscall_wrappers.h"
|
||||
#include "utils.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_RINGBUF_H
|
||||
#define __LXC_RINGBUF_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "nl.h"
|
||||
#include "rtnl.h"
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_RTNL_H
|
||||
#define __LXC_RTNL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
/*
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <seccomp.h>
|
||||
#include <stdio.h>
|
||||
@ -11,11 +10,11 @@
|
||||
#include <sys/mount.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "lxc.h"
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "commands.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "lxccontainer.h"
|
||||
#include "lxcseccomp.h"
|
||||
#include "mainloop.h"
|
||||
#include "memory_utils.h"
|
||||
@ -93,9 +92,9 @@ static const char *get_action_name(uint32_t action)
|
||||
return "invalid action";
|
||||
}
|
||||
|
||||
static uint32_t get_v2_default_action(char *line)
|
||||
static int32_t get_v2_default_action(char *line)
|
||||
{
|
||||
uint32_t ret_action = -1;
|
||||
int32_t ret_action = -1;
|
||||
|
||||
while (*line == ' ')
|
||||
line++;
|
||||
@ -129,7 +128,7 @@ static uint32_t get_v2_default_action(char *line)
|
||||
return ret_action;
|
||||
}
|
||||
|
||||
static uint32_t get_v2_action(char *line, uint32_t def_action)
|
||||
static int32_t get_v2_action(char *line, uint32_t def_action)
|
||||
{
|
||||
char *p;
|
||||
uint32_t ret;
|
||||
@ -264,13 +263,14 @@ static int parse_v2_rules(char *line, uint32_t def_action,
|
||||
return -1;
|
||||
|
||||
/* read optional action which follows the syscall */
|
||||
rules->action = get_v2_action(tmp, def_action);
|
||||
if (rules->action == -1) {
|
||||
ret = get_v2_action(tmp, def_action);
|
||||
if (ret == -1) {
|
||||
ERROR("Failed to interpret action");
|
||||
ret = -1;
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
rules->action = ret;
|
||||
|
||||
ret = 0;
|
||||
rules->args_num = 0;
|
||||
if (!strchr(tmp, '['))
|
||||
@ -496,7 +496,7 @@ enum lxc_seccomp_rule_status_t {
|
||||
static enum lxc_seccomp_rule_status_t do_resolve_add_rule(uint32_t arch, char *line, scmp_filter_ctx ctx,
|
||||
struct seccomp_v2_rule *rule)
|
||||
{
|
||||
int i, nr, ret;
|
||||
int nr, ret;
|
||||
struct scmp_arg_cmp arg_cmp[6];
|
||||
|
||||
ret = seccomp_arch_exist(ctx, arch);
|
||||
@ -543,8 +543,8 @@ static enum lxc_seccomp_rule_status_t do_resolve_add_rule(uint32_t arch, char *l
|
||||
}
|
||||
|
||||
memset(&arg_cmp, 0, sizeof(arg_cmp));
|
||||
for (i = 0; i < rule->args_num; i++) {
|
||||
INFO("arg_cmp[%d]: SCMP_CMP(%u, %llu, %llu, %llu)", i,
|
||||
for (size_t i = 0; i < rule->args_num; i++) {
|
||||
INFO("arg_cmp[%zu]: SCMP_CMP(%u, %llu, %llu, %llu)", i,
|
||||
rule->args_value[i].index,
|
||||
(long long unsigned int)rule->args_value[i].op,
|
||||
(long long unsigned int)rule->args_value[i].mask,
|
||||
@ -618,7 +618,7 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
|
||||
char *p;
|
||||
enum lxc_hostarch_t cur_rule_arch, native_arch;
|
||||
bool denylist = false;
|
||||
uint32_t default_policy_action = -1, default_rule_action = -1;
|
||||
int32_t default_policy_action = -1, default_rule_action = -1;
|
||||
struct seccomp_v2_rule rule;
|
||||
struct scmp_ctx_info {
|
||||
uint32_t architectures[3];
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -25,7 +24,10 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lxc.h"
|
||||
|
||||
#include "af_unix.h"
|
||||
#include "attach_options.h"
|
||||
#include "caps.h"
|
||||
#include "cgroups/cgroup.h"
|
||||
#include "cgroups/cgroup_utils.h"
|
||||
@ -33,14 +35,12 @@
|
||||
#include "commands_utils.h"
|
||||
#include "compiler.h"
|
||||
#include "conf.h"
|
||||
#include "config.h"
|
||||
#include "confile_utils.h"
|
||||
#include "error.h"
|
||||
#include "file_utils.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "lsm/lsm.h"
|
||||
#include "lxccontainer.h"
|
||||
#include "lxclock.h"
|
||||
#include "lxcseccomp.h"
|
||||
#include "macro.h"
|
||||
@ -63,7 +63,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(start, lxc);
|
||||
@ -316,7 +316,7 @@ restart:
|
||||
|
||||
#endif
|
||||
|
||||
if (fd <= listen_fds_max) {
|
||||
if ((size_t)fd <= listen_fds_max) {
|
||||
INFO("Inheriting fd %d (using the LISTEN_FDS environment variable)", fd);
|
||||
continue;
|
||||
}
|
||||
@ -354,7 +354,7 @@ static int setup_signal_fd(sigset_t *oldmask)
|
||||
if (ret < 0)
|
||||
return -EBADF;
|
||||
|
||||
for (int sig = 0; sig < (sizeof(signals) / sizeof(signals[0])); sig++) {
|
||||
for (size_t sig = 0; sig < (sizeof(signals) / sizeof(signals[0])); sig++) {
|
||||
ret = sigdelset(&mask, signals[sig]);
|
||||
if (ret < 0)
|
||||
return -EBADF;
|
||||
@ -445,7 +445,7 @@ static int signal_handler(int fd, uint32_t events, void *data,
|
||||
/* More robustness, protect ourself from a SIGCHLD sent
|
||||
* by a process different from the container init.
|
||||
*/
|
||||
if (siginfo.ssi_pid != hdlr->pid) {
|
||||
if ((__u64)siginfo.ssi_pid != (__u64)hdlr->pid) {
|
||||
NOTICE("Received %d from pid %d instead of container init %d",
|
||||
siginfo.ssi_signo, siginfo.ssi_pid, hdlr->pid);
|
||||
return hdlr->init_died ? LXC_MAINLOOP_CLOSE
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_START_H
|
||||
#define __LXC_START_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <linux/sched.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@ -19,7 +18,6 @@
|
||||
#include "cgroup.h"
|
||||
#include "commands.h"
|
||||
#include "commands_utils.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "lxc.h"
|
||||
#include "monitor.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_STATE_H
|
||||
#define __LXC_STATE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#define MAX_STATE_LENGTH (8 + 1)
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
@ -18,7 +17,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "btrfs.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "memory_utils.h"
|
||||
#include "rsync.h"
|
||||
@ -26,11 +24,11 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#include "include/strlcat.h"
|
||||
#include "strlcat.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(btrfs, lxc);
|
||||
@ -687,11 +685,11 @@ static void free_btrfs_tree(struct my_btrfs_tree *tree)
|
||||
static bool do_remove_btrfs_children(struct my_btrfs_tree *tree, u64 root_id,
|
||||
const char *path)
|
||||
{
|
||||
int i, ret;
|
||||
int ret;
|
||||
char *newpath;
|
||||
size_t len;
|
||||
|
||||
for (i = 0; i < tree->num; i++) {
|
||||
for (int i = 0; i < tree->num; i++) {
|
||||
if (tree->nodes[i].parentid == root_id) {
|
||||
if (!tree->nodes[i].dirname) {
|
||||
WARN("Odd condition: child objid with no name under %s", path);
|
||||
@ -706,7 +704,7 @@ static bool do_remove_btrfs_children(struct my_btrfs_tree *tree, u64 root_id,
|
||||
}
|
||||
|
||||
ret = snprintf(newpath, len, "%s/%s", path, tree->nodes[i].dirname);
|
||||
if (ret < 0 || ret >= len) {
|
||||
if (ret < 0 || (size_t)ret >= len) {
|
||||
free(newpath);
|
||||
return false;
|
||||
}
|
||||
@ -739,7 +737,7 @@ static int btrfs_lxc_rm_rf(const char *path)
|
||||
struct btrfs_ioctl_search_header sh;
|
||||
struct btrfs_root_ref *ref;
|
||||
struct my_btrfs_tree *tree;
|
||||
int ret, e, i;
|
||||
int ret, e;
|
||||
unsigned long off = 0;
|
||||
u16 name_len;
|
||||
u64 dir_id;
|
||||
@ -802,7 +800,7 @@ static int btrfs_lxc_rm_rf(const char *path)
|
||||
break;
|
||||
|
||||
off = 0;
|
||||
for (i = 0; i < sk->nr_items; i++) {
|
||||
for (size_t i = 0; i < sk->nr_items; i++) {
|
||||
memcpy(&sh, args.buf + off, sizeof(sh));
|
||||
off += sizeof(sh);
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_BTRFS_H
|
||||
#define __LXC_BTRFS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <linux/types.h> /* __le64, __l32 ... */
|
||||
#include <stdbool.h>
|
||||
|
@ -1,13 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "memory_utils.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_DIR_H
|
||||
#define __LXC_DIR_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
@ -15,7 +13,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "loop.h"
|
||||
#include "memory_utils.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_LOOP_H
|
||||
#define __LXC_LOOP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "config.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@ -13,7 +11,6 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "lvm.h"
|
||||
#include "memory_utils.h"
|
||||
@ -275,10 +272,10 @@ int lvm_compare_lv_attr(const char *path, int pos, const char expected)
|
||||
return 0;
|
||||
|
||||
len = strlen(output);
|
||||
while (start < len && output[start] == ' ')
|
||||
while ((size_t)start < len && output[start] == ' ')
|
||||
start++;
|
||||
|
||||
if (start + pos < len && output[start + pos] == expected)
|
||||
if ((size_t)(start + pos) < len && output[start + pos] == expected)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef __LXC_LVM_H
|
||||
#define __LXC_LVM_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -12,7 +11,6 @@
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "memory_utils.h"
|
||||
#include "nbd.h"
|
||||
@ -22,7 +20,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include "include/strlcpy.h"
|
||||
#include "strlcpy.h"
|
||||
#endif
|
||||
|
||||
lxc_log_define(nbd, lxc);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user