Compare commits
99 Commits
c4ae2704b7
...
1f4faf21e8
Author | SHA1 | Date |
---|---|---|
Lennart Poettering | 1f4faf21e8 | |
Lennart Poettering | 01262d0d9e | |
Lennart Poettering | 6305608f1c | |
Lennart Poettering | 4c287f9a0b | |
Lennart Poettering | fef7397022 | |
Frantisek Sumsal | 15529f5cea | |
Evgeny Vereshchagin | 6b8d32ea7b | |
Susant Sahani | ad1e288013 | |
Susant Sahani | c1c6ff10a1 | |
Susant Sahani | f6269fe7bb | |
Zbigniew Jędrzejewski-Szmek | 37bc9dcc09 | |
Zbigniew Jędrzejewski-Szmek | 29d4392ca0 | |
Zbigniew Jędrzejewski-Szmek | e7e9a9d0dc | |
Zbigniew Jędrzejewski-Szmek | 42b977810d | |
Zbigniew Jędrzejewski-Szmek | 8af10ca3fc | |
Zbigniew Jędrzejewski-Szmek | e2d612a8e4 | |
Zbigniew Jędrzejewski-Szmek | f4c7bf9e90 | |
Zbigniew Jędrzejewski-Szmek | 1506edca91 | |
Zbigniew Jędrzejewski-Szmek | 693ad298e9 | |
Zbigniew Jędrzejewski-Szmek | 108d00a6b2 | |
Zbigniew Jędrzejewski-Szmek | ec43f6862e | |
Zbigniew Jędrzejewski-Szmek | eb1290ef35 | |
Zbigniew Jędrzejewski-Szmek | b74a306197 | |
Zbigniew Jędrzejewski-Szmek | 9d84eb2053 | |
Zbigniew Jędrzejewski-Szmek | 8c3534b5db | |
Zbigniew Jędrzejewski-Szmek | 388b68a74f | |
Zbigniew Jędrzejewski-Szmek | de0162a95a | |
Zbigniew Jędrzejewski-Szmek | 4962ed9f33 | |
Zbigniew Jędrzejewski-Szmek | 8a59e79c09 | |
Zbigniew Jędrzejewski-Szmek | 50b836518c | |
Zbigniew Jędrzejewski-Szmek | 80c53fe7d5 | |
Zbigniew Jędrzejewski-Szmek | 70ce817ccb | |
Zbigniew Jędrzejewski-Szmek | bdfa9657d0 | |
Zbigniew Jędrzejewski-Szmek | 2c75449a38 | |
Zbigniew Jędrzejewski-Szmek | e29e4d5742 | |
Zbigniew Jędrzejewski-Szmek | 07d16f438a | |
Zbigniew Jędrzejewski-Szmek | d0ac89a1e8 | |
Zbigniew Jędrzejewski-Szmek | bdfd515ad1 | |
Zbigniew Jędrzejewski-Szmek | 0ac5dbf3ae | |
Zbigniew Jędrzejewski-Szmek | 2b2eefee06 | |
Zbigniew Jędrzejewski-Szmek | d48b27bffd | |
Zbigniew Jędrzejewski-Szmek | 7124ae207a | |
Zbigniew Jędrzejewski-Szmek | 4db7d044b8 | |
Zbigniew Jędrzejewski-Szmek | 534a42705b | |
Zbigniew Jędrzejewski-Szmek | 097d8c6eb7 | |
Zbigniew Jędrzejewski-Szmek | fbaa11372b | |
Zbigniew Jędrzejewski-Szmek | 01efa07960 | |
Zbigniew Jędrzejewski-Szmek | ff978cd24a | |
Zbigniew Jędrzejewski-Szmek | c8937bed08 | |
Zbigniew Jędrzejewski-Szmek | 048d52d51e | |
Zbigniew Jędrzejewski-Szmek | 7eeeab205d | |
Zbigniew Jędrzejewski-Szmek | e578ea4df4 | |
Zbigniew Jędrzejewski-Szmek | 94370e627f | |
Zbigniew Jędrzejewski-Szmek | 468874997a | |
Zbigniew Jędrzejewski-Szmek | dfa633ca6a | |
Zbigniew Jędrzejewski-Szmek | 68e2dc0f91 | |
Zbigniew Jędrzejewski-Szmek | 6e796683df | |
Zbigniew Jędrzejewski-Szmek | f4c40fd754 | |
Zbigniew Jędrzejewski-Szmek | 30b84c78ea | |
Zbigniew Jędrzejewski-Szmek | b49325d028 | |
Zbigniew Jędrzejewski-Szmek | c0b97b0fc8 | |
Zbigniew Jędrzejewski-Szmek | c1d6c135bc | |
Zbigniew Jędrzejewski-Szmek | e67a2644a8 | |
Zbigniew Jędrzejewski-Szmek | dce2b8ce48 | |
Zbigniew Jędrzejewski-Szmek | 9911131a60 | |
Zbigniew Jędrzejewski-Szmek | e5b0aaaf56 | |
Zbigniew Jędrzejewski-Szmek | 2b5981b40a | |
Zbigniew Jędrzejewski-Szmek | 1aa0f38491 | |
Zbigniew Jędrzejewski-Szmek | 4e2ac45a83 | |
Zbigniew Jędrzejewski-Szmek | 2c7519c036 | |
Zbigniew Jędrzejewski-Szmek | afd9c55dcc | |
Zbigniew Jędrzejewski-Szmek | e5badaf335 | |
Zbigniew Jędrzejewski-Szmek | d10029bba4 | |
Zbigniew Jędrzejewski-Szmek | 3ac189d8aa | |
Zbigniew Jędrzejewski-Szmek | 8c6d58f65d | |
Zbigniew Jędrzejewski-Szmek | 4110a6deb9 | |
Zbigniew Jędrzejewski-Szmek | e88302002f | |
Zbigniew Jędrzejewski-Szmek | c84752398b | |
Zbigniew Jędrzejewski-Szmek | 58a1bdb467 | |
Zbigniew Jędrzejewski-Szmek | 4caa1ac794 | |
Zbigniew Jędrzejewski-Szmek | 1c76b5b5bb | |
Zbigniew Jędrzejewski-Szmek | 1ed5556e56 | |
Zbigniew Jędrzejewski-Szmek | ed024e1d98 | |
Zbigniew Jędrzejewski-Szmek | 9901a6ad2e | |
Zbigniew Jędrzejewski-Szmek | 41b1b2a563 | |
Zbigniew Jędrzejewski-Szmek | 5964e39a69 | |
Zbigniew Jędrzejewski-Szmek | fe85f2bb9c | |
Susant Sahani | 2c649ca1c9 | |
Kevin Kuehler | 50dfca2eaf | |
Zbigniew Jędrzejewski-Szmek | 5f28f3ddaf | |
Zbigniew Jędrzejewski-Szmek | b6261be84d | |
Zbigniew Jędrzejewski-Szmek | 80769cb66c | |
Zbigniew Jędrzejewski-Szmek | f55198f034 | |
Zbigniew Jędrzejewski-Szmek | 7b43295346 | |
Mike Gilbert | 4b3abcd019 | |
Mike Gilbert | d7e38115cb | |
Dan Streetman | c5673ed0de | |
Dan Streetman | 2526af6ddd | |
Dan Streetman | 3d5f01383d |
|
@ -1,33 +0,0 @@
|
|||
base: ubuntu:16.04
|
||||
language: c
|
||||
setup:
|
||||
- sudo bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse' >>/etc/apt/sources.list"
|
||||
- sudo apt-get update -y
|
||||
- sudo apt-get build-dep -y systemd
|
||||
- sudo apt-get install -y python3-pip
|
||||
- sudo apt-get install -y libfdisk-dev libp11-kit-dev libssl-dev libpwquality-dev
|
||||
- pip3 install meson ninja
|
||||
- export PATH="$HOME/.local/bin/:$PATH"
|
||||
- CC=$FUZZ_CC CXX=$FUZZ_CXX meson -Dfuzzbuzz=true -Dfuzzbuzz-engine-dir=$(dirname "$FUZZ_ENGINE") -Dfuzzbuzz-engine=$(cut -d. -f1 <(basename "$FUZZ_ENGINE")) -Db_lundef=false ./build
|
||||
- ninja -v -C ./build fuzzers
|
||||
environment:
|
||||
targets:
|
||||
- name: fuzz-compress
|
||||
harness:
|
||||
binary: ./build/fuzz-compress
|
||||
- name: fuzz-unit-file
|
||||
harness:
|
||||
binary: ./build/fuzz-unit-file
|
||||
corpus: ./test/fuzz/fuzz-unit-file
|
||||
- name: fuzz-journald-syslog
|
||||
harness:
|
||||
binary: ./build/fuzz-journald-syslog
|
||||
corpus: ./test/fuzz/fuzz-journald-syslog
|
||||
- name: fuzz-netdev-parser
|
||||
harness:
|
||||
binary: ./build/fuzz-netdev-parser
|
||||
corpus: ./test/fuzz/fuzz-netdev-parser
|
||||
- name: fuzz-network-parser
|
||||
harness:
|
||||
binary: ./build/fuzz-network-parser
|
||||
corpus: ./test/fuzz/fuzz-network-parser
|
|
@ -141,6 +141,7 @@
|
|||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_TARGET</varname></term>
|
||||
<term><varname>$SYSTEMD_LOG_LEVEL</varname></term>
|
||||
<term><varname>$SYSTEMD_LOG_TIME</varname></term>
|
||||
<term><varname>$SYSTEMD_LOG_COLOR</varname></term>
|
||||
<term><varname>$SYSTEMD_LOG_LOCATION</varname></term>
|
||||
|
||||
|
|
|
@ -63,10 +63,11 @@
|
|||
<variablelist class='config-directives'>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>LogLevel=</varname></term>
|
||||
<term><varname>LogTarget=</varname></term>
|
||||
<term><varname>LogColor=</varname></term>
|
||||
<term><varname>LogLevel=</varname></term>
|
||||
<term><varname>LogLocation=</varname></term>
|
||||
<term><varname>LogTarget=</varname></term>
|
||||
<term><varname>LogTime=</varname></term>
|
||||
<term><varname>DumpCore=yes</varname></term>
|
||||
<term><varname>CrashChangeVT=no</varname></term>
|
||||
<term><varname>CrashShell=no</varname></term>
|
||||
|
|
|
@ -1910,6 +1910,16 @@
|
|||
<listitem><para>Similar to the <varname>DNS=</varname> settings described above, these
|
||||
settings configure whether and what POP3 server information shall be emitted as part of
|
||||
the DHCP lease. The same syntax, propagation semantics and defaults apply as for
|
||||
<term><varname>SMTPServers=</varname></term>
|
||||
<varname>DNS=</varname>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>SMTPServers=</varname></term>
|
||||
|
||||
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this
|
||||
setting configures whether and what SMTP server information shall be emitted as part of
|
||||
the DHCP lease. The same syntax, propagation semantics and defaults apply as for
|
||||
<varname>DNS=</varname>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -606,6 +606,13 @@
|
|||
<title>Environment</title>
|
||||
|
||||
<variablelist class='environment-variables'>
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_COLOR</varname></term>
|
||||
<listitem><para>Controls whether systemd highlights important
|
||||
log messages. This can be overridden with
|
||||
<option>--log-color</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_LEVEL</varname></term>
|
||||
<listitem><para>systemd reads the log level from this
|
||||
|
@ -613,6 +620,13 @@
|
|||
<option>--log-level=</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_LOCATION</varname></term>
|
||||
<listitem><para>Controls whether systemd prints the code
|
||||
location along with log messages. This can be overridden with
|
||||
<option>--log-location</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_TARGET</varname></term>
|
||||
<listitem><para>systemd reads the log target from this
|
||||
|
@ -621,17 +635,10 @@
|
|||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_COLOR</varname></term>
|
||||
<listitem><para>Controls whether systemd highlights important
|
||||
log messages. This can be overridden with
|
||||
<option>--log-color=</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_LOCATION</varname></term>
|
||||
<listitem><para>Controls whether systemd prints the code
|
||||
location along with log messages. This can be overridden with
|
||||
<option>--log-location=</option>.</para></listitem>
|
||||
<term><varname>$SYSTEMD_LOG_TIME</varname></term>
|
||||
<listitem><para>Controls whether systemd prefixes log
|
||||
messages with the current time. This can be overridden with
|
||||
<option>--log-time=</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -829,18 +836,21 @@
|
|||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>systemd.log_target=</varname></term>
|
||||
<term><varname>systemd.log_level=</varname></term>
|
||||
<term><varname>systemd.log_location=</varname></term>
|
||||
<term><varname>systemd.log_color</varname></term>
|
||||
<term><varname>systemd.log_level=</varname></term>
|
||||
<term><varname>systemd.log_location</varname></term>
|
||||
<term><varname>systemd.log_target=</varname></term>
|
||||
<term><varname>systemd.log_time</varname></term>
|
||||
|
||||
<listitem><para>Controls log output, with the same effect as the
|
||||
<varname>$SYSTEMD_LOG_TARGET</varname>,
|
||||
<varname>$SYSTEMD_LOG_COLOR</varname>,
|
||||
<varname>$SYSTEMD_LOG_LEVEL</varname>,
|
||||
<varname>$SYSTEMD_LOG_LOCATION</varname>,
|
||||
<varname>$SYSTEMD_LOG_COLOR</varname> environment variables described above.
|
||||
<varname>systemd.log_color</varname> can be specified without an argument,
|
||||
with the same effect as a positive boolean.</para></listitem>
|
||||
<varname>$SYSTEMD_LOG_TARGET</varname>,
|
||||
<varname>$SYSTEMD_LOG_TIME</varname>, environment variables described above.
|
||||
<varname>systemd.log_color</varname>, <varname>systemd.log_location</varname>, and
|
||||
<varname>systemd.log_time</varname> can be specified without an argument, with the
|
||||
same effect as a positive boolean.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -1135,9 +1145,10 @@
|
|||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--log-target=</option></term>
|
||||
<term><option>--log-color</option></term>
|
||||
|
||||
<listitem><para>Set log target. See <varname>systemd.log_target</varname> above.</para></listitem>
|
||||
<listitem><para>Highlight important log messages. See <varname>systemd.log_color</varname> above.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -1146,13 +1157,6 @@
|
|||
<listitem><para>Set log level. See <varname>systemd.log_level</varname> above.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--log-color</option></term>
|
||||
|
||||
<listitem><para>Highlight important log messages. See <varname>systemd.log_color</varname> above.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--log-location</option></term>
|
||||
|
||||
|
@ -1160,6 +1164,19 @@
|
|||
above.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--log-target=</option></term>
|
||||
|
||||
<listitem><para>Set log target. See <varname>systemd.log_target</varname> above.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--log-time=</option></term>
|
||||
|
||||
<listitem><para>Prefix messages with timestamp. See <varname>systemd.log_time</varname> above.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--machine-id=</option></term>
|
||||
|
||||
|
|
42
meson.build
42
meson.build
|
@ -39,20 +39,22 @@ conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
|
|||
|
||||
want_ossfuzz = get_option('oss-fuzz')
|
||||
want_libfuzzer = get_option('llvm-fuzz')
|
||||
want_fuzzbuzz = get_option('fuzzbuzz')
|
||||
if want_ossfuzz + want_libfuzzer + want_fuzzbuzz > 1
|
||||
error('only one of oss-fuzz, llvm-fuzz or fuzzbuzz can be specified')
|
||||
if want_ossfuzz + want_libfuzzer > 1
|
||||
error('only one of oss-fuzz or llvm-fuzz can be specified')
|
||||
endif
|
||||
|
||||
skip_deps = want_ossfuzz or want_libfuzzer
|
||||
fuzzer_build = want_ossfuzz or want_libfuzzer or want_fuzzbuzz
|
||||
fuzzer_build = want_ossfuzz or want_libfuzzer
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Try to install the git pre-commit hook
|
||||
git_hook = run_command(join_paths(project_source_root, 'tools/add-git-hook.sh'))
|
||||
if git_hook.returncode() == 0
|
||||
message(git_hook.stdout().strip())
|
||||
add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
|
||||
if add_git_hook_sh.found()
|
||||
git_hook = run_command(add_git_hook_sh)
|
||||
if git_hook.returncode() == 0
|
||||
message(git_hook.stdout().strip())
|
||||
endif
|
||||
endif
|
||||
|
||||
#####################################################################
|
||||
|
@ -322,8 +324,6 @@ if want_libfuzzer
|
|||
endif
|
||||
elif want_ossfuzz
|
||||
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
||||
elif want_fuzzbuzz
|
||||
fuzzing_engine = meson.get_compiler('cpp').find_library(get_option('fuzzbuzz-engine'), dirs: get_option('fuzzbuzz-engine-dir'))
|
||||
endif
|
||||
|
||||
# Those generate many false positives, and we do not want to change the code to
|
||||
|
@ -2506,7 +2506,7 @@ if conf.get('ENABLE_BINFMT') == 1
|
|||
endif
|
||||
|
||||
if conf.get('ENABLE_REPART') == 1
|
||||
executable('systemd-repart',
|
||||
exe = executable('systemd-repart',
|
||||
systemd_repart_sources,
|
||||
include_directories : includes,
|
||||
link_with : [libshared],
|
||||
|
@ -2518,6 +2518,12 @@ if conf.get('ENABLE_REPART') == 1
|
|||
install_rpath : rootlibexecdir,
|
||||
install : true,
|
||||
install_dir : rootbindir)
|
||||
|
||||
if want_tests != 'false'
|
||||
test('test-repart',
|
||||
test_repart_sh,
|
||||
args : exe.full_path())
|
||||
endif
|
||||
endif
|
||||
|
||||
if conf.get('ENABLE_VCONSOLE') == 1
|
||||
|
@ -2962,13 +2968,20 @@ if conf.get('ENABLE_NETWORKD') == 1
|
|||
install_dir : rootbindir)
|
||||
public_programs += exe
|
||||
|
||||
executable('systemd-network-generator',
|
||||
exe = executable('systemd-network-generator',
|
||||
network_generator_sources,
|
||||
include_directories : includes,
|
||||
link_with : [networkd_link_with],
|
||||
install_rpath : rootlibexecdir,
|
||||
install : true,
|
||||
install_dir : rootlibexecdir)
|
||||
|
||||
if want_tests != 'false'
|
||||
test('test-network-generator-conversion',
|
||||
test_network_generator_conversion_sh,
|
||||
# https://github.com/mesonbuild/meson/issues/2681
|
||||
args : exe.full_path())
|
||||
endif
|
||||
endif
|
||||
|
||||
executable('systemd-sulogin-shell',
|
||||
|
@ -3099,7 +3112,7 @@ foreach tuple : fuzzers
|
|||
incs = tuple.length() >= 5 ? tuple[4] : includes
|
||||
link_args = []
|
||||
|
||||
if want_ossfuzz or want_fuzzbuzz
|
||||
if want_ossfuzz
|
||||
dependencies += fuzzing_engine
|
||||
elif want_libfuzzer
|
||||
if fuzzing_engine.found()
|
||||
|
@ -3111,10 +3124,6 @@ foreach tuple : fuzzers
|
|||
sources += 'src/fuzz/fuzz-main.c'
|
||||
endif
|
||||
|
||||
if want_fuzzbuzz
|
||||
sources += 'src/fuzz/fuzzer-entry-point.c'
|
||||
endif
|
||||
|
||||
name = sources[0].split('/')[-1].split('.')[0]
|
||||
|
||||
fuzzer_exes += executable(
|
||||
|
@ -3474,6 +3483,7 @@ foreach tuple : [
|
|||
['debug siphash'],
|
||||
['valgrind', conf.get('VALGRIND') == 1],
|
||||
['trace logging', conf.get('LOG_TRACE') == 1],
|
||||
['install tests', install_tests],
|
||||
['link-udev-shared', get_option('link-udev-shared')],
|
||||
['link-systemctl-shared', get_option('link-systemctl-shared')],
|
||||
['link-networkd-shared', get_option('link-networkd-shared')],
|
||||
|
|
|
@ -354,9 +354,3 @@ option('oss-fuzz', type : 'boolean', value : 'false',
|
|||
description : 'build against oss-fuzz')
|
||||
option('llvm-fuzz', type : 'boolean', value : 'false',
|
||||
description : 'build against LLVM libFuzzer')
|
||||
option('fuzzbuzz', type : 'boolean', value : 'false',
|
||||
description : 'build against FuzzBuzz')
|
||||
option('fuzzbuzz-engine', type : 'string',
|
||||
description : 'the name of the FuzzBuzz fuzzing engine')
|
||||
option('fuzzbuzz-engine-dir', type : 'string',
|
||||
description : 'the directory where the FuzzBuzz fuzzing engine is')
|
||||
|
|
|
@ -17,7 +17,7 @@ PHASES=(${@:-SETUP RUN})
|
|||
create_container() {
|
||||
# create autopkgtest LXC image; this sometimes fails with "Unable to fetch
|
||||
# GPG key from keyserver", so retry a few times
|
||||
for retry in $(seq 5); do
|
||||
for retry in {1..5}; do
|
||||
sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH --keyserver hkp://keyserver.ubuntu.com:80 && break
|
||||
sleep $((retry*retry))
|
||||
done
|
||||
|
|
|
@ -51,6 +51,7 @@ static bool syslog_is_stream = false;
|
|||
|
||||
static bool show_color = false;
|
||||
static bool show_location = false;
|
||||
static bool show_time = false;
|
||||
|
||||
static bool upgrade_syslog_to_journal = false;
|
||||
static bool always_reopen_console = false;
|
||||
|
@ -332,8 +333,10 @@ static int write_to_console(
|
|||
const char *func,
|
||||
const char *buffer) {
|
||||
|
||||
char location[256], prefix[1 + DECIMAL_STR_MAX(int) + 2];
|
||||
struct iovec iovec[6] = {};
|
||||
char location[256],
|
||||
header_time[FORMAT_TIMESTAMP_MAX],
|
||||
prefix[1 + DECIMAL_STR_MAX(int) + 2];
|
||||
struct iovec iovec[8] = {};
|
||||
const char *on = NULL, *off = NULL;
|
||||
size_t n = 0;
|
||||
|
||||
|
@ -345,6 +348,13 @@ static int write_to_console(
|
|||
iovec[n++] = IOVEC_MAKE_STRING(prefix);
|
||||
}
|
||||
|
||||
if (show_time) {
|
||||
if (format_timestamp(header_time, sizeof(header_time), now(CLOCK_REALTIME))) {
|
||||
iovec[n++] = IOVEC_MAKE_STRING(header_time);
|
||||
iovec[n++] = IOVEC_MAKE_STRING(" ");
|
||||
}
|
||||
}
|
||||
|
||||
if (show_color)
|
||||
get_log_colors(LOG_PRI(level), &on, &off, NULL);
|
||||
|
||||
|
@ -1099,6 +1109,12 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
|
||||
if (log_show_location_from_string(value ?: "1") < 0)
|
||||
log_warning("Failed to parse log location setting '%s'. Ignoring.", value);
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "systemd.log_time")) {
|
||||
|
||||
if (log_show_time_from_string(value ?: "1") < 0)
|
||||
log_warning("Failed to parse log time setting '%s'. Ignoring.", value);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1130,6 +1146,10 @@ void log_parse_environment_realm(LogRealm realm) {
|
|||
e = getenv("SYSTEMD_LOG_LOCATION");
|
||||
if (e && log_show_location_from_string(e) < 0)
|
||||
log_warning("Failed to parse log location '%s'. Ignoring.", e);
|
||||
|
||||
e = getenv("SYSTEMD_LOG_TIME");
|
||||
if (e && log_show_time_from_string(e) < 0)
|
||||
log_warning("Failed to parse log time '%s'. Ignoring.", e);
|
||||
}
|
||||
|
||||
LogTarget log_get_target(void) {
|
||||
|
@ -1156,6 +1176,14 @@ bool log_get_show_location(void) {
|
|||
return show_location;
|
||||
}
|
||||
|
||||
void log_show_time(bool b) {
|
||||
show_time = b;
|
||||
}
|
||||
|
||||
bool log_get_show_time(void) {
|
||||
return show_time;
|
||||
}
|
||||
|
||||
int log_show_color_from_string(const char *e) {
|
||||
int t;
|
||||
|
||||
|
@ -1178,6 +1206,17 @@ int log_show_location_from_string(const char *e) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int log_show_time_from_string(const char *e) {
|
||||
int t;
|
||||
|
||||
t = parse_boolean(e);
|
||||
if (t < 0)
|
||||
return t;
|
||||
|
||||
log_show_time(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool log_on_console(void) {
|
||||
if (IN_SET(log_target, LOG_TARGET_CONSOLE,
|
||||
LOG_TARGET_CONSOLE_PREFIXED))
|
||||
|
|
|
@ -59,9 +59,12 @@ void log_show_color(bool b);
|
|||
bool log_get_show_color(void) _pure_;
|
||||
void log_show_location(bool b);
|
||||
bool log_get_show_location(void) _pure_;
|
||||
void log_show_time(bool b);
|
||||
bool log_get_show_time(void) _pure_;
|
||||
|
||||
int log_show_color_from_string(const char *e);
|
||||
int log_show_location_from_string(const char *e);
|
||||
int log_show_time_from_string(const char *e);
|
||||
|
||||
LogTarget log_get_target(void) _pure_;
|
||||
int log_get_max_level_realm(LogRealm realm) _pure_;
|
||||
|
|
|
@ -171,6 +171,7 @@ basic_sources = files('''
|
|||
process-util.h
|
||||
procfs-util.c
|
||||
procfs-util.h
|
||||
pthread-util.h
|
||||
quota-util.c
|
||||
quota-util.h
|
||||
random-util.c
|
||||
|
|
|
@ -1178,6 +1178,11 @@ int must_be_root(void) {
|
|||
return log_error_errno(SYNTHETIC_ERRNO(EPERM), "Need to be root.");
|
||||
}
|
||||
|
||||
static void restore_sigsetp(sigset_t **ssp) {
|
||||
if (*ssp)
|
||||
(void) sigprocmask(SIG_SETMASK, *ssp, NULL);
|
||||
}
|
||||
|
||||
int safe_fork_full(
|
||||
const char *name,
|
||||
const int except_fds[],
|
||||
|
@ -1187,7 +1192,8 @@ int safe_fork_full(
|
|||
|
||||
pid_t original_pid, pid;
|
||||
sigset_t saved_ss, ss;
|
||||
bool block_signals = false;
|
||||
_cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL;
|
||||
bool block_signals = false, block_all = false;
|
||||
int prio, r;
|
||||
|
||||
/* A wrapper around fork(), that does a couple of important initializations in addition to mere forking. Always
|
||||
|
@ -1202,7 +1208,7 @@ int safe_fork_full(
|
|||
* be sure that SIGTERMs are not lost we might send to the child. */
|
||||
|
||||
assert_se(sigfillset(&ss) >= 0);
|
||||
block_signals = true;
|
||||
block_signals = block_all = true;
|
||||
|
||||
} else if (flags & FORK_WAIT) {
|
||||
/* Let's block SIGCHLD at least, so that we can safely watch for the child process */
|
||||
|
@ -1212,28 +1218,31 @@ int safe_fork_full(
|
|||
block_signals = true;
|
||||
}
|
||||
|
||||
if (block_signals)
|
||||
if (block_signals) {
|
||||
if (sigprocmask(SIG_SETMASK, &ss, &saved_ss) < 0)
|
||||
return log_full_errno(prio, errno, "Failed to set signal mask: %m");
|
||||
saved_ssp = &saved_ss;
|
||||
}
|
||||
|
||||
if (flags & FORK_NEW_MOUNTNS)
|
||||
pid = raw_clone(SIGCHLD|CLONE_NEWNS);
|
||||
else
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
r = -errno;
|
||||
|
||||
if (block_signals) /* undo what we did above */
|
||||
(void) sigprocmask(SIG_SETMASK, &saved_ss, NULL);
|
||||
|
||||
return log_full_errno(prio, r, "Failed to fork: %m");
|
||||
}
|
||||
if (pid < 0)
|
||||
return log_full_errno(prio, errno, "Failed to fork: %m");
|
||||
if (pid > 0) {
|
||||
/* We are in the parent process */
|
||||
|
||||
log_debug("Successfully forked off '%s' as PID " PID_FMT ".", strna(name), pid);
|
||||
|
||||
if (flags & FORK_WAIT) {
|
||||
if (block_all) {
|
||||
/* undo everything except SIGCHLD */
|
||||
ss = saved_ss;
|
||||
assert_se(sigaddset(&ss, SIGCHLD) >= 0);
|
||||
(void) sigprocmask(SIG_SETMASK, &ss, NULL);
|
||||
}
|
||||
|
||||
r = wait_for_terminate_and_check(name, pid, (flags & FORK_LOG ? WAIT_LOG : 0));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -1241,9 +1250,6 @@ int safe_fork_full(
|
|||
return -EPROTO;
|
||||
}
|
||||
|
||||
if (block_signals) /* undo what we did above */
|
||||
(void) sigprocmask(SIG_SETMASK, &saved_ss, NULL);
|
||||
|
||||
if (ret_pid)
|
||||
*ret_pid = pid;
|
||||
|
||||
|
@ -1252,6 +1258,9 @@ int safe_fork_full(
|
|||
|
||||
/* We are in the child process */
|
||||
|
||||
/* Restore signal mask manually */
|
||||
saved_ssp = NULL;
|
||||
|
||||
if (flags & FORK_REOPEN_LOG) {
|
||||
/* Close the logs if requested, before we log anything. And make sure we reopen it if needed. */
|
||||
log_close();
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
static inline pthread_mutex_t* pthread_mutex_lock_assert(pthread_mutex_t *mutex) {
|
||||
assert_se(pthread_mutex_lock(mutex) == 0);
|
||||
return mutex;
|
||||
}
|
||||
|
||||
static inline void pthread_mutex_unlock_assertp(pthread_mutex_t **mutexp) {
|
||||
if (*mutexp)
|
||||
assert_se(pthread_mutex_unlock(*mutexp) == 0);
|
||||
}
|
|
@ -542,8 +542,9 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||
|
||||
DEFINE_SETTER(config_parse_level2, log_set_max_level_from_string, "log level");
|
||||
DEFINE_SETTER(config_parse_target, log_set_target_from_string, "target");
|
||||
DEFINE_SETTER(config_parse_color, log_show_color_from_string, "color" );
|
||||
DEFINE_SETTER(config_parse_color, log_show_color_from_string, "color");
|
||||
DEFINE_SETTER(config_parse_location, log_show_location_from_string, "location");
|
||||
DEFINE_SETTER(config_parse_time, log_show_time_from_string, "time");
|
||||
|
||||
static int config_parse_default_timeout_abort(
|
||||
const char *unit,
|
||||
|
@ -571,6 +572,7 @@ static int parse_config_file(void) {
|
|||
{ "Manager", "LogTarget", config_parse_target, 0, NULL },
|
||||
{ "Manager", "LogColor", config_parse_color, 0, NULL },
|
||||
{ "Manager", "LogLocation", config_parse_location, 0, NULL },
|
||||
{ "Manager", "LogTime", config_parse_time, 0, NULL },
|
||||
{ "Manager", "DumpCore", config_parse_bool, 0, &arg_dump_core },
|
||||
{ "Manager", "CrashChVT", /* legacy */ config_parse_crash_chvt, 0, &arg_crash_chvt },
|
||||
{ "Manager", "CrashChangeVT", config_parse_crash_chvt, 0, &arg_crash_chvt },
|
||||
|
@ -718,6 +720,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
ARG_LOG_TARGET,
|
||||
ARG_LOG_COLOR,
|
||||
ARG_LOG_LOCATION,
|
||||
ARG_LOG_TIME,
|
||||
ARG_UNIT,
|
||||
ARG_SYSTEM,
|
||||
ARG_USER,
|
||||
|
@ -745,6 +748,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
{ "log-target", required_argument, NULL, ARG_LOG_TARGET },
|
||||
{ "log-color", optional_argument, NULL, ARG_LOG_COLOR },
|
||||
{ "log-location", optional_argument, NULL, ARG_LOG_LOCATION },
|
||||
{ "log-time", optional_argument, NULL, ARG_LOG_TIME },
|
||||
{ "unit", required_argument, NULL, ARG_UNIT },
|
||||
{ "system", no_argument, NULL, ARG_SYSTEM },
|
||||
{ "user", no_argument, NULL, ARG_USER },
|
||||
|
@ -818,6 +822,18 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
|
||||
break;
|
||||
|
||||
case ARG_LOG_TIME:
|
||||
|
||||
if (optarg) {
|
||||
r = log_show_time_from_string(optarg);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse log time setting \"%s\": %m",
|
||||
optarg);
|
||||
} else
|
||||
log_show_time(true);
|
||||
|
||||
break;
|
||||
|
||||
case ARG_DEFAULT_STD_OUTPUT:
|
||||
r = exec_output_from_string(optarg);
|
||||
if (r < 0)
|
||||
|
@ -1037,6 +1053,7 @@ static int help(void) {
|
|||
" --log-level=LEVEL Set log level (debug, info, notice, warning, err, crit, alert, emerg)\n"
|
||||
" --log-color[=BOOL] Highlight important log messages\n"
|
||||
" --log-location[=BOOL] Include code location in log messages\n"
|
||||
" --log-time[=BOOL] Prefix log messages with current time\n"
|
||||
" --default-standard-output= Set default standard output for services\n"
|
||||
" --default-standard-error= Set default standard error output for services\n"
|
||||
"\nSee the %s for details.\n"
|
||||
|
@ -1419,6 +1436,9 @@ static int become_shutdown(
|
|||
if (log_get_show_location())
|
||||
command_line[pos++] = "--log-location";
|
||||
|
||||
if (log_get_show_time())
|
||||
command_line[pos++] = "--log-time";
|
||||
|
||||
if (streq(shutdown_verb, "exit")) {
|
||||
command_line[pos++] = "--exit-code";
|
||||
command_line[pos++] = exit_code;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#LogTarget=journal-or-kmsg
|
||||
#LogColor=yes
|
||||
#LogLocation=no
|
||||
#LogTime=no
|
||||
#DumpCore=yes
|
||||
#ShowStatus=yes
|
||||
#CrashChangeVT=no
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#LogTarget=console
|
||||
#LogColor=yes
|
||||
#LogLocation=no
|
||||
#LogTime=no
|
||||
#SystemCallArchitectures=
|
||||
#TimerSlackNSec=
|
||||
#StatusUnitFormat=@STATUS_UNIT_FORMAT_DEFAULT@
|
||||
|
|
|
@ -6,6 +6,3 @@
|
|||
|
||||
/* The entry point into the fuzzer */
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
||||
|
||||
/* https://docs.fuzzbuzz.io/developer-documentation/porting-targets-to-fuzzbuzz/libfuzzer-targets */
|
||||
int FuzzerEntrypoint(const uint8_t *data, size_t size);
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#include "fuzz.h"
|
||||
|
||||
int FuzzerEntrypoint(const uint8_t *data, size_t size) {
|
||||
return LLVMFuzzerTestOneInput(data, size);
|
||||
}
|
|
@ -509,14 +509,17 @@ static void raw_pull_job_on_finished(PullJob *j) {
|
|||
|
||||
raw_pull_report_progress(i, RAW_FINALIZING);
|
||||
|
||||
r = import_make_read_only_fd(i->raw_job->disk_fd);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
if (i->raw_job->etag) {
|
||||
/* Only make a read-only copy if ETag header is set. */
|
||||
r = import_make_read_only_fd(i->raw_job->disk_fd);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to rename raw file to %s: %m", i->final_path);
|
||||
goto finish;
|
||||
r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to rename raw file to %s: %m", i->final_path);
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
i->temp_path = mfree(i->temp_path);
|
||||
|
|
|
@ -64,6 +64,9 @@ struct sd_dhcp_lease {
|
|||
struct in_addr *pop3_server;
|
||||
size_t pop3_server_size;
|
||||
|
||||
struct in_addr *smtp_server;
|
||||
size_t smtp_server_size;
|
||||
|
||||
struct sd_dhcp_route *static_route;
|
||||
size_t static_route_size, static_route_allocated;
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ struct sd_dhcp_server {
|
|||
|
||||
char *timezone;
|
||||
|
||||
struct in_addr *ntp, *dns, *sip, *pop3_server;
|
||||
unsigned n_ntp, n_dns, n_sip, n_pop3_server;
|
||||
struct in_addr *ntp, *dns, *sip, *pop3_server, *smtp_server;
|
||||
unsigned n_ntp, n_dns, n_sip, n_pop3_server, n_smtp_server;
|
||||
|
||||
OrderedHashmap *extra_options;
|
||||
OrderedHashmap *vendor_options;
|
||||
|
|
|
@ -140,6 +140,17 @@ int sd_dhcp_lease_get_pop3_server(sd_dhcp_lease *lease, const struct in_addr **a
|
|||
return (int) lease->pop3_server_size;
|
||||
}
|
||||
|
||||
int sd_dhcp_lease_get_smtp_server(sd_dhcp_lease *lease, const struct in_addr **addr) {
|
||||
assert_return(lease, -EINVAL);
|
||||
assert_return(addr, -EINVAL);
|
||||
|
||||
if (lease->smtp_server_size <= 0)
|
||||
return -ENODATA;
|
||||
|
||||
*addr = lease->smtp_server;
|
||||
return (int) lease->smtp_server_size;
|
||||
}
|
||||
|
||||
int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname) {
|
||||
assert_return(lease, -EINVAL);
|
||||
assert_return(domainname, -EINVAL);
|
||||
|
@ -291,6 +302,7 @@ static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) {
|
|||
free(lease->ntp);
|
||||
free(lease->sip);
|
||||
free(lease->pop3_server);
|
||||
free(lease->smtp_server);
|
||||
free(lease->static_route);
|
||||
free(lease->client_id);
|
||||
free(lease->vendor_specific);
|
||||
|
@ -619,6 +631,12 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void
|
|||
log_debug_errno(r, "Failed to parse POP3 server, ignoring: %m");
|
||||
break;
|
||||
|
||||
case SD_DHCP_OPTION_SMTP_SERVER:
|
||||
r = lease_parse_in_addrs(option, len, &lease->smtp_server, &lease->smtp_server_size);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to parse SMTP server, ignoring: %m");
|
||||
break;
|
||||
|
||||
case SD_DHCP_OPTION_STATIC_ROUTE:
|
||||
r = lease_parse_routes(option, len, &lease->static_route, &lease->static_route_size, &lease->static_route_allocated);
|
||||
if (r < 0)
|
||||
|
@ -1056,6 +1074,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
|||
*ntp = NULL,
|
||||
*sip = NULL,
|
||||
*pop3_server = NULL,
|
||||
*smtp_server = NULL,
|
||||
*mtu = NULL,
|
||||
*routes = NULL,
|
||||
*domains = NULL,
|
||||
|
@ -1086,6 +1105,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
|||
"NTP", &ntp,
|
||||
"SIP", &sip,
|
||||
"POP3_SERVERS", &pop3_server,
|
||||
"SMTP_SERVERS", &smtp_server,
|
||||
"MTU", &mtu,
|
||||
"DOMAINNAME", &lease->domainname,
|
||||
"HOSTNAME", &lease->hostname,
|
||||
|
@ -1206,6 +1226,14 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
|||
lease->pop3_server_size = r;
|
||||
}
|
||||
|
||||
if (smtp_server) {
|
||||
r = deserialize_in_addrs(&lease->smtp_server, smtp_server);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to deserialize SMTP server %s, ignoring: %m", smtp_server);
|
||||
else
|
||||
lease->smtp_server_size = r;
|
||||
}
|
||||
|
||||
if (mtu) {
|
||||
r = safe_atou16(mtu, &lease->mtu);
|
||||
if (r < 0)
|
||||
|
|
|
@ -141,6 +141,7 @@ static sd_dhcp_server *dhcp_server_free(sd_dhcp_server *server) {
|
|||
free(server->ntp);
|
||||
free(server->sip);
|
||||
free(server->pop3_server);
|
||||
free(server->smtp_server);
|
||||
|
||||
hashmap_free(server->leases_by_client_id);
|
||||
|
||||
|
@ -523,6 +524,15 @@ static int server_send_ack(sd_dhcp_server *server, DHCPRequest *req,
|
|||
return r;
|
||||
}
|
||||
|
||||
if (server->n_smtp_server > 0) {
|
||||
r = dhcp_option_append(
|
||||
&packet->dhcp, req->max_optlen, &offset, 0,
|
||||
SD_DHCP_OPTION_SMTP_SERVER,
|
||||
sizeof(struct in_addr) * server->n_smtp_server, server->smtp_server);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (server->timezone) {
|
||||
r = dhcp_option_append(
|
||||
&packet->dhcp, req->max_optlen, &offset, 0,
|
||||
|
@ -1216,6 +1226,31 @@ int sd_dhcp_server_set_pop3_server(sd_dhcp_server *server, const struct in_addr
|
|||
return 1;
|
||||
}
|
||||
|
||||
int sd_dhcp_server_set_smtp_server(sd_dhcp_server *server, const struct in_addr smtp_server[], unsigned n) {
|
||||
assert_return(server, -EINVAL);
|
||||
assert_return(smtp_server || n <= 0, -EINVAL);
|
||||
|
||||
if (server->n_smtp_server == n &&
|
||||
memcmp(server->smtp_server, smtp_server, sizeof(struct in_addr) * n) == 0)
|
||||
return 0;
|
||||
|
||||
if (n <= 0) {
|
||||
server->smtp_server = mfree(server->smtp_server);
|
||||
server->n_smtp_server = 0;
|
||||
} else {
|
||||
struct in_addr *c;
|
||||
|
||||
c = newdup(struct in_addr, smtp_server, n);
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
|
||||
free_and_replace(server->smtp_server, c);
|
||||
server->n_smtp_server = n;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled) {
|
||||
assert_return(server, -EINVAL);
|
||||
|
||||
|
|
|
@ -260,6 +260,10 @@ _public_ int sd_network_link_get_pop3_servers(int ifindex, char ***pop3) {
|
|||
return network_link_get_strv(ifindex, "POP3_SERVERS", pop3);
|
||||
}
|
||||
|
||||
_public_ int sd_network_link_get_smtp_servers(int ifindex, char ***ret) {
|
||||
return network_link_get_strv(ifindex, "SMTP_SERVERS", ret);
|
||||
}
|
||||
|
||||
_public_ int sd_network_link_get_dns_default_route(int ifindex) {
|
||||
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
|
||||
_cleanup_free_ char *s = NULL;
|
||||
|
|
|
@ -1241,7 +1241,7 @@ static int link_status_one(
|
|||
const LinkInfo *info) {
|
||||
|
||||
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL,
|
||||
**pop3_server = NULL;
|
||||
**pop3_server = NULL, **smtp_server = NULL;
|
||||
_cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *tz = NULL;
|
||||
_cleanup_free_ char *t = NULL, *network = NULL;
|
||||
const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL;
|
||||
|
@ -1269,6 +1269,7 @@ static int link_status_one(
|
|||
(void) sd_network_link_get_ntp(info->ifindex, &ntp);
|
||||
(void) sd_network_link_get_sip(info->ifindex, &sip);
|
||||
(void) sd_network_link_get_pop3_servers(info->ifindex, &pop3_server);
|
||||
(void) sd_network_link_get_smtp_servers(info->ifindex, &smtp_server);
|
||||
|
||||
if (info->sd_device) {
|
||||
(void) sd_device_get_property_value(info->sd_device, "ID_NET_LINK_FILE", &link);
|
||||
|
@ -1832,6 +1833,9 @@ static int link_status_one(
|
|||
if (r < 0)
|
||||
return r;
|
||||
r = dump_list(table, "POP3 servers:", pop3_server);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = dump_list(table, "SMTP servers:", smtp_server);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = dump_ifindexes(table, "Carrier Bound To:", carrier_bound_to);
|
||||
|
|
|
@ -189,6 +189,55 @@ static int link_push_uplink_pop3_to_dhcp_server(Link *link, sd_dhcp_server *s) {
|
|||
return sd_dhcp_server_set_pop3_server(s, addresses, n_addresses);
|
||||
}
|
||||
|
||||
static int link_push_uplink_smtp_to_dhcp_server(Link *link, sd_dhcp_server *s) {
|
||||
_cleanup_free_ struct in_addr *addresses = NULL;
|
||||
size_t n_addresses = 0, n_allocated = 0;
|
||||
char **a;
|
||||
|
||||
if (!link->network)
|
||||
return 0;
|
||||
|
||||
log_link_debug(link, "Copying SMTP server information from link");
|
||||
|
||||
STRV_FOREACH(a, link->network->smtp) {
|
||||
union in_addr_union ia;
|
||||
|
||||
/* Only look for IPv4 addresses */
|
||||
if (in_addr_from_string(AF_INET, *a, &ia) <= 0)
|
||||
continue;
|
||||
|
||||
/* Never propagate obviously borked data */
|
||||
if (in4_addr_is_null(&ia.in) || in4_addr_is_localhost(&ia.in))
|
||||
continue;
|
||||
|
||||
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + 1))
|
||||
return log_oom();
|
||||
|
||||
addresses[n_addresses++] = ia.in;
|
||||
}
|
||||
|
||||
if (link->dhcp_lease) {
|
||||
const struct in_addr *da = NULL;
|
||||
int j, n;
|
||||
|
||||
n = sd_dhcp_lease_get_smtp_server(link->dhcp_lease, &da);
|
||||
if (n > 0) {
|
||||
|
||||
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
|
||||
return log_oom();
|
||||
|
||||
for (j = 0; j < n; j++)
|
||||
if (in4_addr_is_non_local(&da[j]))
|
||||
addresses[n_addresses++] = da[j];
|
||||
}
|
||||
}
|
||||
|
||||
if (n_addresses <= 0)
|
||||
return 0;
|
||||
|
||||
return sd_dhcp_server_set_smtp_server(s, addresses, n_addresses);
|
||||
}
|
||||
|
||||
static int link_push_uplink_sip_to_dhcp_server(Link *link, sd_dhcp_server *s) {
|
||||
_cleanup_free_ struct in_addr *addresses = NULL;
|
||||
size_t n_addresses = 0, n_allocated = 0;
|
||||
|
@ -330,21 +379,36 @@ int dhcp4_server_configure(Link *link) {
|
|||
log_link_warning_errno(link, r, "Failed to set SIP server for DHCP server, ignoring: %m");
|
||||
}
|
||||
|
||||
if (link->network->n_dhcp_server_pop3 > 0)
|
||||
r = sd_dhcp_server_set_pop3_server(link->dhcp_server, link->network->dhcp_server_pop3, link->network->n_dhcp_server_pop3);
|
||||
else {
|
||||
if (!acquired_uplink)
|
||||
uplink = manager_find_uplink(link->manager, link);
|
||||
if (link->network->n_dhcp_server_pop3 > 0)
|
||||
r = sd_dhcp_server_set_pop3_server(link->dhcp_server, link->network->dhcp_server_pop3, link->network->n_dhcp_server_pop3);
|
||||
else {
|
||||
if (!acquired_uplink)
|
||||
uplink = manager_find_uplink(link->manager, link);
|
||||
|
||||
if (!uplink) {
|
||||
log_link_debug(link, "Not emitting POP3 server information on link, couldn't find suitable uplink.");
|
||||
r = 0;
|
||||
} else
|
||||
r = link_push_uplink_pop3_to_dhcp_server(uplink, link->dhcp_server);
|
||||
if (!uplink) {
|
||||
log_link_debug(link, "Not emitting POP3 server information on link, couldn't find suitable uplink.");
|
||||
r = 0;
|
||||
} else
|
||||
r = link_push_uplink_pop3_to_dhcp_server(uplink, link->dhcp_server);
|
||||
}
|
||||
if (r < 0)
|
||||
log_link_warning_errno(link, r, "Failed to set POP3 server for DHCP server, ignoring: %m");
|
||||
|
||||
if (link->network->n_dhcp_server_smtp > 0)
|
||||
r = sd_dhcp_server_set_smtp_server(link->dhcp_server, link->network->dhcp_server_smtp, link->network->n_dhcp_server_smtp);
|
||||
else {
|
||||
if (!acquired_uplink)
|
||||
uplink = manager_find_uplink(link->manager, link);
|
||||
|
||||
if (!uplink) {
|
||||
log_link_debug(link, "Not emitting SMTP server information on link, couldn't find suitable uplink.");
|
||||
r = 0;
|
||||
} else
|
||||
r = link_push_uplink_smtp_to_dhcp_server(uplink, link->dhcp_server);
|
||||
}
|
||||
if (r < 0)
|
||||
log_link_warning_errno(link, r, "Failed to SMTP server for DHCP server, ignoring: %m");
|
||||
|
||||
}
|
||||
if (r < 0)
|
||||
log_link_warning_errno(link, r, "Failed to set POP3 server for DHCP server, ignoring: %m");
|
||||
|
||||
r = sd_dhcp_server_set_emit_router(link->dhcp_server, link->network->dhcp_server_emit_router);
|
||||
if (r < 0)
|
||||
|
@ -550,6 +614,8 @@ int config_parse_dhcp_server_sip(
|
|||
m[n->n_dhcp_server_sip++] = a.in;
|
||||
n->dhcp_server_sip = m;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_dhcp_server_pop3_servers(
|
||||
|
@ -602,4 +668,60 @@ int config_parse_dhcp_server_pop3_servers(
|
|||
m[n->n_dhcp_server_pop3++] = a.in;
|
||||
n->dhcp_server_pop3 = m;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_dhcp_server_smtp_servers(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Network *n = data;
|
||||
const char *p = rvalue;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *w = NULL;
|
||||
union in_addr_union a;
|
||||
struct in_addr *m;
|
||||
|
||||
r = extract_first_word(&p, &w, NULL, 0);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to extract word, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
r = in_addr_from_string(AF_INET, w, &a);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse SMTP server address '%s', ignoring: %m", w);
|
||||
continue;
|
||||
}
|
||||
|
||||
m = reallocarray(n->dhcp_server_smtp, n->n_dhcp_server_smtp + 1, sizeof(struct in_addr));
|
||||
if (!m)
|
||||
return log_oom();
|
||||
|
||||
m[n->n_dhcp_server_smtp++] = a.in;
|
||||
n->dhcp_server_smtp = m;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,3 +13,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_dns);
|
|||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_ntp);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_sip);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_pop3_servers);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_smtp_servers);
|
||||
|
|
|
@ -4106,6 +4106,12 @@ int link_save(Link *link) {
|
|||
space = false;
|
||||
fputstrv(f, link->network->pop3, NULL, &space);
|
||||
|
||||
fputc('\n', f);
|
||||
|
||||
fputs("SMTP_SERVERS=", f);
|
||||
space = false;
|
||||
fputstrv(f, link->network->smtp, NULL, &space);
|
||||
|
||||
if (link->dhcp_lease) {
|
||||
const struct in_addr *addresses;
|
||||
|
||||
|
@ -4115,6 +4121,15 @@ int link_save(Link *link) {
|
|||
space = true;
|
||||
}
|
||||
|
||||
if (link->dhcp_lease) {
|
||||
const struct in_addr *addresses;
|
||||
|
||||
r = sd_dhcp_lease_get_smtp_server(link->dhcp_lease, &addresses);
|
||||
if (r > 0)
|
||||
if (serialize_in_addrs(f, addresses, r, space, in4_addr_is_non_local) > 0)
|
||||
space = true;
|
||||
}
|
||||
|
||||
if (link->network->dhcp6_use_ntp && dhcp6_lease) {
|
||||
struct in6_addr *in6_addrs;
|
||||
char **hosts;
|
||||
|
|
|
@ -1490,7 +1490,7 @@ static int ordered_set_put_in4_addrv(OrderedSet *s,
|
|||
|
||||
static int manager_save(Manager *m) {
|
||||
_cleanup_ordered_set_free_free_ OrderedSet *dns = NULL, *ntp = NULL, *sip = NULL, *pop3 = NULL,
|
||||
*search_domains = NULL, *route_domains = NULL;
|
||||
*smtp = NULL, *search_domains = NULL, *route_domains = NULL;
|
||||
const char *operstate_str, *carrier_state_str, *address_state_str;
|
||||
LinkOperationalState operstate = LINK_OPERSTATE_OFF;
|
||||
LinkCarrierState carrier_state = LINK_CARRIER_STATE_OFF;
|
||||
|
@ -1521,6 +1521,10 @@ static int manager_save(Manager *m) {
|
|||
|
||||
pop3 = ordered_set_new(&string_hash_ops);
|
||||
if (!pop3)
|
||||
return -ENOMEM;
|
||||
|
||||
smtp = ordered_set_new(&string_hash_ops);
|
||||
if (!smtp)
|
||||
return -ENOMEM;
|
||||
|
||||
search_domains = ordered_set_new(&dns_name_hash_ops);
|
||||
|
@ -1598,7 +1602,6 @@ static int manager_save(Manager *m) {
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
r = sd_dhcp_lease_get_pop3_server(link->dhcp_lease, &addresses);
|
||||
if (r > 0) {
|
||||
r = ordered_set_put_in4_addrv(pop3, addresses, r, in4_addr_is_non_local);
|
||||
|
@ -1607,6 +1610,14 @@ static int manager_save(Manager *m) {
|
|||
} else if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = sd_dhcp_lease_get_smtp_server(link->dhcp_lease, &addresses);
|
||||
if (r > 0) {
|
||||
r = ordered_set_put_in4_addrv(smtp, addresses, r, in4_addr_is_non_local);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
|
||||
const char *domainname;
|
||||
char **domains = NULL;
|
||||
|
@ -1659,6 +1670,7 @@ static int manager_save(Manager *m) {
|
|||
ordered_set_print(f, "NTP=", ntp);
|
||||
ordered_set_print(f, "SIP=", sip);
|
||||
ordered_set_print(f, "POP3_SERVERS=", pop3);
|
||||
ordered_set_print(f, "SMTP_SERVERS=", smtp);
|
||||
ordered_set_print(f, "DOMAINS=", search_domains);
|
||||
ordered_set_print(f, "ROUTE_DOMAINS=", route_domains);
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ DHCPServer.NTP, config_parse_dhcp_server_ntp,
|
|||
DHCPServer.EmitSIP, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_sip)
|
||||
DHCPServer.SIP, config_parse_dhcp_server_sip, 0, 0
|
||||
DHCPServer.POP3Servers, config_parse_dhcp_server_pop3_servers, 0, 0
|
||||
DHCPServer.SMTPServers, config_parse_dhcp_server_smtp_servers, 0, 0
|
||||
DHCPServer.EmitRouter, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_router)
|
||||
DHCPServer.EmitTimezone, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_timezone)
|
||||
DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone)
|
||||
|
|
|
@ -652,6 +652,7 @@ static Network *network_free(Network *network) {
|
|||
strv_free(network->ntp);
|
||||
free(network->dns);
|
||||
strv_free(network->sip);
|
||||
strv_free(network->smtp);
|
||||
ordered_set_free_free(network->search_domains);
|
||||
ordered_set_free_free(network->route_domains);
|
||||
strv_free(network->bind_carrier);
|
||||
|
|
|
@ -150,6 +150,9 @@ struct Network {
|
|||
struct in_addr *dhcp_server_pop3;
|
||||
unsigned n_dhcp_server_pop3;
|
||||
|
||||
struct in_addr *dhcp_server_smtp;
|
||||
unsigned n_dhcp_server_smtp;
|
||||
|
||||
bool dhcp_server_emit_router;
|
||||
bool dhcp_server_emit_timezone;
|
||||
char *dhcp_server_timezone;
|
||||
|
@ -300,6 +303,7 @@ struct Network {
|
|||
char **ntp;
|
||||
char **sip;
|
||||
char **pop3;
|
||||
char **smtp;
|
||||
char **bind_carrier;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "group-record-nss.h"
|
||||
#include "macro.h"
|
||||
#include "nss-util.h"
|
||||
#include "pthread-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "strv.h"
|
||||
#include "user-util.h"
|
||||
|
@ -277,10 +278,11 @@ static enum nss_status nss_systemd_endent(GetentData *p) {
|
|||
|
||||
assert(p);
|
||||
|
||||
assert_se(pthread_mutex_lock(&p->mutex) == 0);
|
||||
_cleanup_(pthread_mutex_unlock_assertp) pthread_mutex_t *_l = NULL;
|
||||
_l = pthread_mutex_lock_assert(&p->mutex);
|
||||
|
||||
p->iterator = userdb_iterator_free(p->iterator);
|
||||
p->by_membership = false;
|
||||
assert_se(pthread_mutex_unlock(&p->mutex) == 0);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -294,45 +296,41 @@ enum nss_status _nss_systemd_endgrent(void) {
|
|||
}
|
||||
|
||||
enum nss_status _nss_systemd_setpwent(int stayopen) {
|
||||
enum nss_status ret;
|
||||
|
||||
PROTECT_ERRNO;
|
||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
||||
|
||||
if (userdb_nss_compat_is_enabled() <= 0)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
|
||||
assert_se(pthread_mutex_lock(&getpwent_data.mutex) == 0);
|
||||
_cleanup_(pthread_mutex_unlock_assertp) pthread_mutex_t *_l = NULL;
|
||||
int r;
|
||||
|
||||
_l = pthread_mutex_lock_assert(&getpwent_data.mutex);
|
||||
|
||||
getpwent_data.iterator = userdb_iterator_free(getpwent_data.iterator);
|
||||
getpwent_data.by_membership = false;
|
||||
|
||||
ret = userdb_all(nss_glue_userdb_flags(), &getpwent_data.iterator) < 0 ?
|
||||
NSS_STATUS_UNAVAIL : NSS_STATUS_SUCCESS;
|
||||
|
||||
assert_se(pthread_mutex_unlock(&getpwent_data.mutex) == 0);
|
||||
return ret;
|
||||
r = userdb_all(nss_glue_userdb_flags(), &getpwent_data.iterator);
|
||||
return r < 0 ? NSS_STATUS_UNAVAIL : NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status _nss_systemd_setgrent(int stayopen) {
|
||||
enum nss_status ret;
|
||||
|
||||
PROTECT_ERRNO;
|
||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
||||
|
||||
if (userdb_nss_compat_is_enabled() <= 0)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
|
||||
assert_se(pthread_mutex_lock(&getgrent_data.mutex) == 0);
|
||||
_cleanup_(pthread_mutex_unlock_assertp) pthread_mutex_t *_l = NULL;
|
||||
int r;
|
||||
|
||||
_l = pthread_mutex_lock_assert(&getgrent_data.mutex);
|
||||
|
||||
getgrent_data.iterator = userdb_iterator_free(getgrent_data.iterator);
|
||||
getpwent_data.by_membership = false;
|
||||
|
||||
ret = groupdb_all(nss_glue_userdb_flags(), &getgrent_data.iterator) < 0 ?
|
||||
NSS_STATUS_UNAVAIL : NSS_STATUS_SUCCESS;
|
||||
|
||||
assert_se(pthread_mutex_unlock(&getgrent_data.mutex) == 0);
|
||||
return ret;
|
||||
r = groupdb_all(nss_glue_userdb_flags(), &getgrent_data.iterator);
|
||||
return r < 0 ? NSS_STATUS_UNAVAIL : NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status _nss_systemd_getpwent_r(
|
||||
|
@ -341,7 +339,6 @@ enum nss_status _nss_systemd_getpwent_r(
|
|||
int *errnop) {
|
||||
|
||||
_cleanup_(user_record_unrefp) UserRecord *ur = NULL;
|
||||
enum nss_status ret;
|
||||
int r;
|
||||
|
||||
PROTECT_ERRNO;
|
||||
|
@ -359,40 +356,33 @@ enum nss_status _nss_systemd_getpwent_r(
|
|||
if (!r)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
|
||||
assert_se(pthread_mutex_lock(&getpwent_data.mutex) == 0);
|
||||
_cleanup_(pthread_mutex_unlock_assertp) pthread_mutex_t *_l = NULL;
|
||||
|
||||
_l = pthread_mutex_lock_assert(&getpwent_data.mutex);
|
||||
|
||||
if (!getpwent_data.iterator) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = EHOSTDOWN;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
r = userdb_iterator_get(getpwent_data.iterator, &ur);
|
||||
if (r == -ESRCH) {
|
||||
ret = NSS_STATUS_NOTFOUND;
|
||||
goto finish;
|
||||
}
|
||||
if (r == -ESRCH)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
r = nss_pack_user_record(ur, result, buffer, buflen);
|
||||
if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_TRYAGAIN;
|
||||
goto finish;
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
}
|
||||
|
||||
ret = NSS_STATUS_SUCCESS;
|
||||
|
||||
finish:
|
||||
assert_se(pthread_mutex_unlock(&getpwent_data.mutex) == 0);
|
||||
return ret;
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status _nss_systemd_getgrent_r(
|
||||
|
@ -402,7 +392,6 @@ enum nss_status _nss_systemd_getgrent_r(
|
|||
|
||||
_cleanup_(group_record_unrefp) GroupRecord *gr = NULL;
|
||||
_cleanup_free_ char **members = NULL;
|
||||
enum nss_status ret;
|
||||
int r;
|
||||
|
||||
PROTECT_ERRNO;
|
||||
|
@ -420,19 +409,20 @@ enum nss_status _nss_systemd_getgrent_r(
|
|||
if (!r)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
assert_se(pthread_mutex_lock(&getgrent_data.mutex) == 0);
|
||||
_cleanup_(pthread_mutex_unlock_assertp) pthread_mutex_t *_l = NULL;
|
||||
|
||||
_l = pthread_mutex_lock_assert(&getgrent_data.mutex);
|
||||
|
||||
if (!getgrent_data.iterator) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = EHOSTDOWN;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
if (!getgrent_data.by_membership) {
|
||||
r = groupdb_iterator_get(getgrent_data.iterator, &gr);
|
||||
if (r == -ESRCH) {
|
||||
/* So we finished iterating native groups now. let's now continue with iterating
|
||||
/* So we finished iterating native groups now. Let's now continue with iterating
|
||||
* native memberships, and generate additional group entries for any groups
|
||||
* referenced there that are defined in NSS only. This means for those groups there
|
||||
* will be two or more entries generated during iteration, but this is apparently how
|
||||
|
@ -444,23 +434,20 @@ enum nss_status _nss_systemd_getgrent_r(
|
|||
if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
getgrent_data.by_membership = true;
|
||||
} else if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
} else if (!STR_IN_SET(gr->group_name, root_group.gr_name, nobody_group.gr_name)) {
|
||||
r = membershipdb_by_group_strv(gr->group_name, nss_glue_userdb_flags(), &members);
|
||||
if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -472,15 +459,12 @@ enum nss_status _nss_systemd_getgrent_r(
|
|||
_cleanup_free_ char *user_name = NULL, *group_name = NULL;
|
||||
|
||||
r = membershipdb_iterator_get(getgrent_data.iterator, &user_name, &group_name);
|
||||
if (r == -ESRCH) {
|
||||
ret = NSS_STATUS_NOTFOUND;
|
||||
goto finish;
|
||||
}
|
||||
if (r == -ESRCH)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
if (STR_IN_SET(user_name, root_passwd.pw_name, nobody_passwd.pw_name))
|
||||
|
@ -494,8 +478,7 @@ enum nss_status _nss_systemd_getgrent_r(
|
|||
if (lock_fd < 0 && lock_fd != -EBUSY) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -lock_fd;
|
||||
ret = NSS_STATUS_UNAVAIL;
|
||||
goto finish;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,15 +508,10 @@ enum nss_status _nss_systemd_getgrent_r(
|
|||
if (r < 0) {
|
||||
UNPROTECT_ERRNO;
|
||||
*errnop = -r;
|
||||
ret = NSS_STATUS_TRYAGAIN;
|
||||
goto finish;
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
}
|
||||
|
||||
ret = NSS_STATUS_SUCCESS;
|
||||
|
||||
finish:
|
||||
assert_se(pthread_mutex_unlock(&getgrent_data.mutex) == 0);
|
||||
return ret;
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status _nss_systemd_initgroups_dyn(
|
||||
|
|
|
@ -3,3 +3,5 @@
|
|||
systemd_repart_sources = files('''
|
||||
repart.c
|
||||
'''.split())
|
||||
|
||||
test_repart_sh = find_program('test-repart.sh')
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
repart=$1
|
||||
test -x $repart
|
||||
|
||||
D=$(mktemp --directory)
|
||||
trap "rm -rf '$D'" EXIT INT QUIT PIPE
|
||||
mkdir -p $D/definitions
|
||||
|
||||
truncate -s 1G $D/zzz
|
||||
|
||||
SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8
|
||||
|
||||
$repart $D/zzz --empty=force --dry-run=no --seed=$SEED
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' > $D/empty
|
||||
|
||||
cmp $D/empty - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
unit: sectors
|
||||
first-lba: 2048
|
||||
last-lba: 2097118
|
||||
EOF
|
||||
|
||||
cat >$D/definitions/root.conf <<EOF
|
||||
[Partition]
|
||||
Type=root
|
||||
EOF
|
||||
|
||||
ln -s root.conf $D/definitions/root2.conf
|
||||
|
||||
cat >$D/definitions/home.conf <<EOF
|
||||
[Partition]
|
||||
Type=home
|
||||
EOF
|
||||
|
||||
cat > $D/definitions/swap.conf <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
PaddingMinBytes=92M
|
||||
EOF
|
||||
|
||||
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated
|
||||
|
||||
cmp $D/populated - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
unit: sectors
|
||||
first-lba: 2048
|
||||
last-lba: 2097118
|
||||
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
||||
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||
EOF
|
||||
|
||||
cat >$D/definitions/swap.conf <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
EOF
|
||||
|
||||
cat >$D/definitions/extra.conf <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
EOF
|
||||
|
||||
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated2
|
||||
|
||||
cmp $D/populated2 - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
unit: sectors
|
||||
first-lba: 2048
|
||||
last-lba: 2097118
|
||||
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
||||
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||
$D/zzz5 : start= 1908696, size= 188416, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
|
||||
EOF
|
||||
|
||||
truncate -s 2G $D/zzz
|
||||
|
||||
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated3
|
||||
|
||||
cmp $D/populated3 - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
unit: sectors
|
||||
first-lba: 2048
|
||||
last-lba: 4194270
|
||||
$D/zzz1 : start= 2048, size= 591856, type=933AC7E1-2EB4-4F13-B844-0E14E2AEF915, uuid=A6005774-F558-4330-A8E5-D6D2C01C01D6, name="home"
|
||||
$D/zzz2 : start= 593904, size= 591856, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=CE9C76EB-A8F1-40FF-813C-11DCA6C0A55B, name="root-x86-64"
|
||||
$D/zzz3 : start= 1185760, size= 591864, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709, uuid=AC60A837-550C-43BD-B5C4-9CB73B884E79, name="root-x86-64-2"
|
||||
$D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2AA78CDB-59C7-4173-AF11-C7453737A5D1, name="swap"
|
||||
$D/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=03477476-06AD-44E8-9EF4-BC2BD7771289, name="linux-generic"
|
||||
EOF
|
|
@ -92,7 +92,6 @@ static void test_packet_from_file(const char* filename, bool canonical) {
|
|||
|
||||
int main(int argc, char **argv) {
|
||||
int i, N;
|
||||
_cleanup_free_ char *pkts_glob = NULL;
|
||||
_cleanup_globfree_ glob_t g = {};
|
||||
char **fnames;
|
||||
|
||||
|
@ -102,7 +101,8 @@ int main(int argc, char **argv) {
|
|||
N = argc - 1;
|
||||
fnames = argv + 1;
|
||||
} else {
|
||||
pkts_glob = path_join(get_testdata_dir(), "test-resolve/*.pkts");
|
||||
_cleanup_free_ char *pkts_glob = NULL;
|
||||
assert_se(get_testdata_dir("test-resolve/*.pkts", &pkts_glob) >= 0);
|
||||
assert_se(glob(pkts_glob, GLOB_NOSORT, NULL, &g) == 0);
|
||||
N = g.gl_pathc;
|
||||
fnames = g.gl_pathv;
|
||||
|
|
|
@ -58,21 +58,25 @@ static void load_testdata_env(void) {
|
|||
setenv(*k, *v, 0);
|
||||
}
|
||||
|
||||
const char* get_testdata_dir(void) {
|
||||
const char *env;
|
||||
int get_testdata_dir(const char *suffix, char **ret) {
|
||||
const char *dir;
|
||||
char *p;
|
||||
|
||||
load_testdata_env();
|
||||
|
||||
/* if the env var is set, use that */
|
||||
env = getenv("SYSTEMD_TEST_DATA");
|
||||
if (!env)
|
||||
env = SYSTEMD_TEST_DATA;
|
||||
if (access(env, F_OK) < 0) {
|
||||
fprintf(stderr, "ERROR: $SYSTEMD_TEST_DATA directory [%s] does not exist\n", env);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
dir = getenv("SYSTEMD_TEST_DATA");
|
||||
if (!dir)
|
||||
dir = SYSTEMD_TEST_DATA;
|
||||
if (access(dir, F_OK) < 0)
|
||||
return log_error_errno(errno, "ERROR: $SYSTEMD_TEST_DATA directory [%s] not accesible: %m", dir);
|
||||
|
||||
return env;
|
||||
p = path_join(dir, suffix);
|
||||
if (!p)
|
||||
return log_oom();
|
||||
|
||||
*ret = p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* get_catalog_dir(void) {
|
||||
|
|
|
@ -20,7 +20,7 @@ static inline bool manager_errno_skip_test(int r) {
|
|||
|
||||
char* setup_fake_runtime_dir(void);
|
||||
int enter_cgroup_subroot(char **ret_cgroup);
|
||||
const char* get_testdata_dir(void);
|
||||
int get_testdata_dir(const char *suffix, char **ret);
|
||||
const char* get_catalog_dir(void);
|
||||
bool slow_tests_enabled(void);
|
||||
void test_setup_logging(int level);
|
||||
|
|
|
@ -51,6 +51,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
ARG_LOG_TARGET,
|
||||
ARG_LOG_COLOR,
|
||||
ARG_LOG_LOCATION,
|
||||
ARG_LOG_TIME,
|
||||
ARG_EXIT_CODE,
|
||||
ARG_TIMEOUT,
|
||||
};
|
||||
|
@ -60,6 +61,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
{ "log-target", required_argument, NULL, ARG_LOG_TARGET },
|
||||
{ "log-color", optional_argument, NULL, ARG_LOG_COLOR },
|
||||
{ "log-location", optional_argument, NULL, ARG_LOG_LOCATION },
|
||||
{ "log-time", optional_argument, NULL, ARG_LOG_TIME },
|
||||
{ "exit-code", required_argument, NULL, ARG_EXIT_CODE },
|
||||
{ "timeout", required_argument, NULL, ARG_TIMEOUT },
|
||||
{}
|
||||
|
@ -110,6 +112,17 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
|
||||
break;
|
||||
|
||||
case ARG_LOG_TIME:
|
||||
|
||||
if (optarg) {
|
||||
r = log_show_time_from_string(optarg);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to parse log time setting %s, ignoring: %m", optarg);
|
||||
} else
|
||||
log_show_time(true);
|
||||
|
||||
break;
|
||||
|
||||
case ARG_EXIT_CODE:
|
||||
r = safe_atou8(optarg, &arg_exit_code);
|
||||
if (r < 0)
|
||||
|
|
|
@ -83,6 +83,7 @@ enum {
|
|||
SD_DHCP_OPTION_REBINDING_T2_TIME = 59,
|
||||
SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
|
||||
SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61,
|
||||
SD_DHCP_OPTION_SMTP_SERVER = 69,
|
||||
SD_DHCP_OPTION_POP3_SERVER = 70,
|
||||
SD_DHCP_OPTION_USER_CLASS = 77,
|
||||
SD_DHCP_OPTION_FQDN = 81,
|
||||
|
|
|
@ -46,6 +46,7 @@ int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr);
|
|||
int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||
int sd_dhcp_lease_get_sip(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||
int sd_dhcp_lease_get_pop3_server(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||
int sd_dhcp_lease_get_smtp_server(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||
int sd_dhcp_lease_get_mtu(sd_dhcp_lease *lease, uint16_t *mtu);
|
||||
int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname);
|
||||
int sd_dhcp_lease_get_search_domains(sd_dhcp_lease *lease, char ***domains);
|
||||
|
|
|
@ -51,6 +51,7 @@ int sd_dhcp_server_set_dns(sd_dhcp_server *server, const struct in_addr dns[], u
|
|||
int sd_dhcp_server_set_ntp(sd_dhcp_server *server, const struct in_addr ntp[], unsigned n);
|
||||
int sd_dhcp_server_set_sip(sd_dhcp_server *server, const struct in_addr sip[], unsigned n);
|
||||
int sd_dhcp_server_set_pop3_server(sd_dhcp_server *server, const struct in_addr pop3_server[], unsigned n);
|
||||
int sd_dhcp_server_set_smtp_server(sd_dhcp_server *server, const struct in_addr smtp_server[], unsigned n);
|
||||
int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled);
|
||||
|
||||
int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v);
|
||||
|
|
|
@ -170,6 +170,9 @@ int sd_network_link_get_sip_servers(int ifindex, char ***sip);
|
|||
/* Get the pop3 servers for a given link. */
|
||||
int sd_network_link_get_pop3_servers(int ifindex, char ***pop3);
|
||||
|
||||
/* Get the SMTP servers for a given link. */
|
||||
int sd_network_link_get_smtp_servers(int ifindex, char ***smtp);
|
||||
|
||||
/* Get whether this link shall be used as 'default route' for DNS queries */
|
||||
int sd_network_link_get_dns_default_route(int ifindex);
|
||||
|
||||
|
|
|
@ -1026,10 +1026,7 @@ tests += [
|
|||
|
||||
]
|
||||
|
||||
# test-bus-vtable-cc.cc is a symlink and symlinks get lost in containers on FuzzBuzz.
|
||||
# The issue has been reported to the developers of FuzzBuzz and hopefully will be fixed soon.
|
||||
# In the meantime, let's just skip the symlink there.
|
||||
if cxx_cmd != '' and not want_fuzzbuzz
|
||||
if cxx_cmd != ''
|
||||
tests += [
|
||||
[['src/libsystemd/sd-bus/test-bus-vtable-cc.cc'],
|
||||
[],
|
||||
|
|
|
@ -48,7 +48,9 @@ int main(int argc, char *argv[]) {
|
|||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, &p);
|
||||
|
|
|
@ -38,7 +38,9 @@ static int test_cgroup_mask(void) {
|
|||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
/* Prepare the manager. */
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES)) {
|
||||
|
|
|
@ -22,7 +22,9 @@ static int test_default_memory_low(void) {
|
|||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES)) {
|
||||
|
|
|
@ -26,8 +26,11 @@ int main(int argc, char *argv[]) {
|
|||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (manager_errno_skip_test(r))
|
||||
return log_tests_skipped_errno(r, "manager_new");
|
||||
|
|
|
@ -806,7 +806,6 @@ static int run_tests(UnitFileScope scope, const test_entry tests[], char **patte
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
|
||||
_cleanup_free_ char *test_execute_path = NULL;
|
||||
|
||||
static const test_entry user_tests[] = {
|
||||
entry(test_exec_basic),
|
||||
|
@ -878,9 +877,10 @@ int main(int argc, char *argv[]) {
|
|||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("test-execute/", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
test_execute_path = path_join(get_testdata_dir(), "test-execute");
|
||||
assert_se(set_unit_path(test_execute_path) >= 0);
|
||||
|
||||
/* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test
|
||||
* cases, otherwise (and if they are present in the environment),
|
||||
|
|
|
@ -444,20 +444,20 @@ static void test_write_string_file_verify(void) {
|
|||
_cleanup_free_ char *buf = NULL, *buf2 = NULL;
|
||||
int r;
|
||||
|
||||
assert_se(read_one_line_file("/proc/cmdline", &buf) >= 0);
|
||||
assert_se(read_one_line_file("/proc/version", &buf) >= 0);
|
||||
assert_se(buf2 = strjoin(buf, "\n"));
|
||||
|
||||
r = write_string_file("/proc/cmdline", buf, 0);
|
||||
r = write_string_file("/proc/version", buf, 0);
|
||||
assert_se(IN_SET(r, -EACCES, -EIO));
|
||||
r = write_string_file("/proc/cmdline", buf2, 0);
|
||||
r = write_string_file("/proc/version", buf2, 0);
|
||||
assert_se(IN_SET(r, -EACCES, -EIO));
|
||||
|
||||
assert_se(write_string_file("/proc/cmdline", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
|
||||
assert_se(write_string_file("/proc/cmdline", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
|
||||
assert_se(write_string_file("/proc/version", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
|
||||
assert_se(write_string_file("/proc/version", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
|
||||
|
||||
r = write_string_file("/proc/cmdline", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE);
|
||||
r = write_string_file("/proc/version", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE);
|
||||
assert_se(IN_SET(r, -EACCES, -EIO));
|
||||
assert_se(write_string_file("/proc/cmdline", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE) == 0);
|
||||
assert_se(write_string_file("/proc/version", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE) == 0);
|
||||
}
|
||||
|
||||
static void test_load_env_file_pairs(void) {
|
||||
|
@ -757,7 +757,7 @@ static void test_read_line3(void) {
|
|||
_cleanup_free_ char *line = NULL;
|
||||
int r;
|
||||
|
||||
f = fopen("/proc/cmdline", "re");
|
||||
f = fopen("/proc/uptime", "re");
|
||||
if (!f && IN_SET(errno, ENOENT, EPERM))
|
||||
return;
|
||||
assert_se(f);
|
||||
|
|
|
@ -25,7 +25,7 @@ static void test_basic_parsing(void) {
|
|||
_cleanup_free_ char *journal_data_path = NULL;
|
||||
int r;
|
||||
|
||||
journal_data_path = path_join(get_testdata_dir(), "journal-data/journal-1.txt");
|
||||
assert_se(get_testdata_dir("journal-data/journal-1.txt", &journal_data_path) >= 0);
|
||||
imp.fd = open(journal_data_path, O_RDONLY|O_CLOEXEC);
|
||||
assert_se(imp.fd >= 0);
|
||||
|
||||
|
@ -56,7 +56,7 @@ static void test_bad_input(void) {
|
|||
_cleanup_free_ char *journal_data_path = NULL;
|
||||
int r;
|
||||
|
||||
journal_data_path = path_join(get_testdata_dir(), "journal-data/journal-2.txt");
|
||||
assert_se(get_testdata_dir("journal-data/journal-1.txt", &journal_data_path) >= 0);
|
||||
imp.fd = open(journal_data_path, O_RDONLY|O_CLOEXEC);
|
||||
assert_se(imp.fd >= 0);
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
test_path = path_join(get_testdata_dir(), "test-path");
|
||||
assert_se(get_testdata_dir("test-path", &test_path) >= 0);
|
||||
assert_se(set_unit_path(test_path) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
|
|
|
@ -25,8 +25,11 @@ int main(int argc, char *argv[]) {
|
|||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (manager_errno_skip_test(r))
|
||||
return log_tests_skipped_errno(r, "manager_new");
|
||||
|
|
|
@ -674,7 +674,7 @@ static void test_strv_push_prepend(void) {
|
|||
|
||||
log_info("/* %s */", __func__);
|
||||
|
||||
a = strv_new("foo", "bar", "three");
|
||||
assert_se(a = strv_new("foo", "bar", "three"));
|
||||
|
||||
assert_se(strv_push_prepend(&a, strdup("first")) >= 0);
|
||||
assert_se(streq(a[0], "first"));
|
||||
|
|
|
@ -15,8 +15,10 @@ static void test_mount_points_list(const char *fname) {
|
|||
|
||||
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/self/mountinfo");
|
||||
|
||||
if (fname)
|
||||
fname = testdata_fname = path_join(get_testdata_dir(), fname);
|
||||
if (fname) {
|
||||
assert_se(get_testdata_dir(fname, &testdata_fname) >= 0);
|
||||
fname = testdata_fname;
|
||||
}
|
||||
|
||||
LIST_HEAD_INIT(mp_list_head);
|
||||
assert_se(mount_points_list_get(fname, &mp_list_head) >= 0);
|
||||
|
@ -37,8 +39,10 @@ static void test_swap_list(const char *fname) {
|
|||
|
||||
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/swaps");
|
||||
|
||||
if (fname)
|
||||
fname = testdata_fname = path_join(get_testdata_dir(), fname);
|
||||
if (fname) {
|
||||
assert_se(get_testdata_dir(fname, &testdata_fname) >= 0);
|
||||
fname = testdata_fname;
|
||||
}
|
||||
|
||||
LIST_HEAD_INIT(mp_list_head);
|
||||
assert_se(swap_list_get(fname, &mp_list_head) >= 0);
|
||||
|
|
|
@ -20,7 +20,10 @@ int main(int argc, char *argv[]) {
|
|||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units/", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
assert_se(manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m) >= 0);
|
||||
|
|
|
@ -10,10 +10,10 @@ ninja: no work to do.
|
|||
--x-- Running TEST-01-BASIC --x--
|
||||
+ make -C TEST-01-BASIC BUILD_DIR=/home/zbyszek/src/systemd/build clean setup run
|
||||
make: Entering directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC'
|
||||
TEST CLEANUP: Basic systemd setup
|
||||
TEST SETUP: Basic systemd setup
|
||||
TEST-01-BASIC CLEANUP: Basic systemd setup
|
||||
TEST-01-BASIC SETUP: Basic systemd setup
|
||||
...
|
||||
TEST RUN: Basic systemd setup [OK]
|
||||
TEST-01-BASIC RUN: Basic systemd setup [OK]
|
||||
make: Leaving directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC'
|
||||
--x-- Result of TEST-01-BASIC: 0 --x--
|
||||
--x-- Running TEST-02-CRYPTSETUP --x--
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
BUILD_DIR=$(shell ../../tools/find-build-dir.sh)
|
||||
|
||||
all setup run:
|
||||
all setup run clean clean-again:
|
||||
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
|
||||
|
||||
clean clean-again:
|
||||
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --clean
|
||||
|
||||
.PHONY: all setup run clean clean-again
|
||||
|
|
|
@ -1,34 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="Basic systemd setup"
|
||||
IMAGE_NAME="basic"
|
||||
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
|
||||
TEST_REQUIRE_INSTALL_TESTS=0
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
test_create_image() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -e -x -c 'systemctl --state=failed --no-legend --no-pager > /failed ; systemctl daemon-reload ; echo OK > /testok'
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
# install tests manually so the test is functional even when -Dinstall-tests=false
|
||||
mkdir -p $initdir/usr/lib/systemd/tests/testdata/units/
|
||||
cp -v $(dirname $0)/../units/{testsuite-01,end}.service $initdir/usr/lib/systemd/tests/testdata/units/
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 01
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="cryptsetup systemd setup"
|
||||
IMAGE_NAME="cryptsetup"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_qemu() {
|
||||
ret=1
|
||||
mkdir -p $initdir
|
||||
mount ${LOOPDEV}p1 $initdir
|
||||
mount_initdir
|
||||
[[ -e $initdir/testok ]] && ret=0
|
||||
[[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR
|
||||
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
|
||||
mount /dev/mapper/varcrypt $initdir/var
|
||||
cp -a $initdir/var/log/journal $TESTDIR
|
||||
umount $initdir/var
|
||||
umount $initdir
|
||||
rm -r $initdir/var/log/journal/*
|
||||
_umount_dir $initdir/var
|
||||
_umount_dir $initdir
|
||||
cryptsetup luksClose /dev/mapper/varcrypt
|
||||
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
||||
ls -l $TESTDIR/journal/*/*.journal
|
||||
|
@ -23,8 +24,7 @@ check_result_qemu() {
|
|||
return $ret
|
||||
}
|
||||
|
||||
|
||||
test_setup() {
|
||||
test_create_image() {
|
||||
create_empty_image_rootdir
|
||||
echo -n test >$TESTDIR/keyfile
|
||||
cryptsetup -q luksFormat --pbkdf pbkdf2 --pbkdf-force-iterations 1000 ${LOOPDEV}p2 $TESTDIR/keyfile
|
||||
|
@ -42,25 +42,12 @@ test_setup() {
|
|||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -x -c 'systemctl --state=failed --no-legend --no-pager > /failed ; echo OK > /testok'
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
|
||||
install_dmevent
|
||||
generate_module_dependencies
|
||||
cat >$initdir/etc/crypttab <<EOF
|
||||
$DM_NAME UUID=$ID_FS_UUID /etc/varkey
|
||||
EOF
|
||||
echo -n test > $initdir/etc/varkey
|
||||
echo -n test >$initdir/etc/varkey
|
||||
cat $initdir/etc/crypttab | ddebug
|
||||
|
||||
cat >>$initdir/etc/fstab <<EOF
|
||||
|
@ -82,8 +69,8 @@ test_cleanup() {
|
|||
}
|
||||
|
||||
test_setup_cleanup() {
|
||||
cleanup_root_var
|
||||
_test_setup_cleanup
|
||||
cleanup_root_var || :
|
||||
cleanup_initdir
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 02
|
||||
|
|
|
@ -5,36 +5,4 @@ TEST_NO_QEMU=1
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-jobs.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
# copy the units used by this test
|
||||
cp $TEST_BASE_DIR/{hello.service,sleep.service,hello-after-sleep.target,unstoppable.service} \
|
||||
$initdir/etc/systemd/system
|
||||
cp test-jobs.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 03
|
||||
|
|
|
@ -4,41 +4,4 @@ TEST_DESCRIPTION="Journal-related tests"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-journal.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat >$initdir/etc/systemd/system/forever-print-hola.service <<EOF
|
||||
[Unit]
|
||||
Description=ForeverPrintHola service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/sh -x -c 'while :; do printf "Hola\n" || touch /i-lose-my-logs; sleep 1; done'
|
||||
EOF
|
||||
|
||||
cp test-journal.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 04
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
[[ "$(systemctl show -p DefaultLimitNOFILESoft)" = "DefaultLimitNOFILESoft=10000" ]]
|
||||
[[ "$(systemctl show -p DefaultLimitNOFILE)" = "DefaultLimitNOFILE=16384" ]]
|
||||
|
||||
[[ "$(systemctl show -p LimitNOFILESoft testsuite.service)" = "LimitNOFILESoft=10000" ]]
|
||||
[[ "$(systemctl show -p LimitNOFILE testsuite.service)" = "LimitNOFILE=16384" ]]
|
||||
|
||||
[[ "$(ulimit -n -S)" = "10000" ]]
|
||||
[[ "$(ulimit -n -H)" = "16384" ]]
|
||||
|
||||
touch /testok
|
|
@ -4,37 +4,4 @@ TEST_DESCRIPTION="Resource limits-related tests"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
cat >$initdir/etc/systemd/system.conf <<EOF
|
||||
[Manager]
|
||||
DefaultLimitNOFILE=10000:16384
|
||||
EOF
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-rlimits.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cp test-rlimits.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 05
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="SELinux tests"
|
||||
IMAGE_NAME="selinux"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
# Requirements:
|
||||
|
@ -15,60 +16,16 @@ test -f /usr/share/selinux/devel/include/system/systemd.if || exit 0
|
|||
SETUP_SELINUX=yes
|
||||
KERNEL_APPEND="$KERNEL_APPEND selinux=1 security=selinux"
|
||||
|
||||
test_setup() {
|
||||
test_create_image() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat <<EOF >$initdir/etc/systemd/system/testsuite.service
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-selinux-checks.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat <<EOF >$initdir/etc/systemd/system/hola.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/echo Start Hola
|
||||
ExecReload=/bin/echo Reload Hola
|
||||
ExecStop=/bin/echo Stop Hola
|
||||
RemainAfterExit=yes
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
|
||||
cat <<EOF >$initdir/etc/systemd/system/load-systemd-test-module.service
|
||||
[Unit]
|
||||
Description=Load systemd-test module
|
||||
DefaultDependencies=no
|
||||
Requires=local-fs.target
|
||||
Conflicts=shutdown.target
|
||||
After=local-fs.target
|
||||
Before=sysinit.target shutdown.target autorelabel.service
|
||||
ConditionSecurity=selinux
|
||||
ConditionPathExists=|/.load-systemd-test-module
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -x -c 'echo 0 >/sys/fs/selinux/enforce && cd /systemd-test-module && make -f /usr/share/selinux/devel/Makefile load && rm /.load-systemd-test-module'
|
||||
Type=oneshot
|
||||
TimeoutSec=0
|
||||
RemainAfterExit=yes
|
||||
EOF
|
||||
|
||||
touch $initdir/.load-systemd-test-module
|
||||
mkdir -p $initdir/etc/systemd/system/basic.target.wants
|
||||
ln -fs load-systemd-test-module.service $initdir/etc/systemd/system/basic.target.wants/load-systemd-test-module.service
|
||||
|
||||
local _modules_dir=/var/lib/selinux
|
||||
rm -rf $initdir/$_modules_dir
|
||||
if ! cp -ar $_modules_dir $initdir/$_modules_dir; then
|
||||
|
@ -87,11 +44,10 @@ EOF
|
|||
mkdir $initdir/systemd-test-module
|
||||
cp systemd_test.te $initdir/systemd-test-module
|
||||
cp systemd_test.if $initdir/systemd-test-module
|
||||
cp test-selinux-checks.sh $initdir
|
||||
dracut_install -o sesearch
|
||||
dracut_install runcon
|
||||
dracut_install checkmodule semodule semodule_package m4 make /usr/libexec/selinux/hll/pp load_policy sefcontext_compile
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 06
|
||||
|
|
|
@ -7,32 +7,4 @@ TEST_NO_QEMU=1
|
|||
|
||||
NSPAWN_TIMEOUT=30
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-segfault.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cp test-segfault.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 07
|
||||
|
|
|
@ -1,70 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
|
||||
IMAGE_NAME="test08"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=300
|
||||
FSTYPE=ext4
|
||||
|
||||
test_setup() {
|
||||
test_create_image() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -x -c 'mount -o remount,rw /dev/sda1 && echo OK > /testok; systemctl poweroff'
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
rm $initdir/etc/fstab
|
||||
cat >$initdir/etc/systemd/system/-.mount <<EOF
|
||||
[Unit]
|
||||
Before=local-fs.target
|
||||
|
||||
[Mount]
|
||||
What=/dev/sda1
|
||||
Where=/
|
||||
Type=ext4
|
||||
Options=errors=remount-ro,noatime
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs.target
|
||||
Alias=root.mount
|
||||
EOF
|
||||
|
||||
cat >$initdir/etc/systemd/system/systemd-remount-fs.service <<EOF
|
||||
[Unit]
|
||||
DefaultDependencies=no
|
||||
Conflicts=shutdown.target
|
||||
After=systemd-fsck-root.service
|
||||
Before=local-fs-pre.target local-fs.target shutdown.target
|
||||
Wants=local-fs-pre.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/bin/systemctl reload /
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
ln -s /etc/systemd/system/-.mount $initdir/etc/systemd/system/root.mount
|
||||
mkdir -p $initdir/etc/systemd/system/local-fs.target.wants
|
||||
ln -s /etc/systemd/system/-.mount $initdir/etc/systemd/system/local-fs.target.wants/-.mount
|
||||
|
||||
mask_supporting_services
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 08
|
||||
|
|
|
@ -6,32 +6,4 @@ TEST_NO_NSPAWN=1
|
|||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=300
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<'EOF'
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -c '>/testok'
|
||||
RemainAfterExit=yes
|
||||
ExecStop=/bin/sh -c 'kill -SEGV $$$$'
|
||||
TimeoutStopSec=270s
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 09
|
||||
|
|
|
@ -4,45 +4,4 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
dracut_install true rm socat
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<'EOF'
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -e -x -c 'rm -f /tmp/nonexistent; systemctl start test.socket; printf x > test.file; socat -t20 OPEN:test.file UNIX-CONNECT:/run/test.ctl; >/testok'
|
||||
EOF
|
||||
|
||||
cat >$initdir/etc/systemd/system/test.socket <<'EOF'
|
||||
[Socket]
|
||||
ListenStream=/run/test.ctl
|
||||
EOF
|
||||
|
||||
cat > $initdir/etc/systemd/system/test.service <<'EOF'
|
||||
[Unit]
|
||||
Requires=test.socket
|
||||
ConditionPathExistsGlob=/tmp/nonexistent
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/true
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 10
|
||||
|
|
|
@ -5,58 +5,4 @@ TEST_NO_NSPAWN=1
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
dracut_install false touch
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-fail-on-restart.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat >$initdir/etc/systemd/system/fail-on-restart.service <<EOF
|
||||
[Unit]
|
||||
Description=Fail on restart
|
||||
StartLimitIntervalSec=1m
|
||||
StartLimitBurst=3
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/false
|
||||
Restart=always
|
||||
EOF
|
||||
|
||||
|
||||
cat >$initdir/test-fail-on-restart.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
systemctl start fail-on-restart.service
|
||||
active_state=$(systemctl show --property ActiveState fail-on-restart.service)
|
||||
while [[ "$active_state" == "ActiveState=activating" || "$active_state" == "ActiveState=active" ]]; do
|
||||
sleep 1
|
||||
active_state=$(systemctl show --property ActiveState fail-on-restart.service)
|
||||
done
|
||||
systemctl is-failed fail-on-restart.service || exit 1
|
||||
touch /testok
|
||||
EOF
|
||||
|
||||
chmod 0755 $initdir/test-fail-on-restart.sh
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 11
|
||||
|
|
|
@ -5,85 +5,4 @@ TEST_NO_QEMU=1
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
dracut_install cat mv stat nc
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-socket-group.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat >$initdir/test-socket-group.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
U=/run/systemd/system/test.socket
|
||||
cat <<'EOL' >$U
|
||||
[Unit]
|
||||
Description=Test socket
|
||||
[Socket]
|
||||
Accept=yes
|
||||
ListenStream=/run/test.socket
|
||||
SocketGroup=adm
|
||||
SocketMode=0660
|
||||
EOL
|
||||
|
||||
cat <<'EOL' > /run/systemd/system/test@.service
|
||||
[Unit]
|
||||
Description=Test service
|
||||
[Service]
|
||||
StandardInput=socket
|
||||
ExecStart=/bin/sh -x -c cat
|
||||
EOL
|
||||
|
||||
systemctl start test.socket
|
||||
systemctl is-active test.socket
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
echo A | nc -w1 -U /run/test.socket
|
||||
|
||||
mv $U ${U}.disabled
|
||||
systemctl daemon-reload
|
||||
systemctl is-active test.socket
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
echo B | nc -w1 -U /run/test.socket && exit 1
|
||||
|
||||
mv ${U}.disabled $U
|
||||
systemctl daemon-reload
|
||||
systemctl is-active test.socket
|
||||
echo C | nc -w1 -U /run/test.socket && exit 1
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
|
||||
systemctl restart test.socket
|
||||
systemctl is-active test.socket
|
||||
echo D | nc -w1 -U /run/test.socket
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
|
||||
|
||||
touch /testok
|
||||
EOF
|
||||
|
||||
chmod 0755 $initdir/test-socket-group.sh
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 12
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
BUILD_DIR=$(shell ../../tools/find-build-dir.sh)
|
||||
|
||||
all setup run:
|
||||
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
|
||||
|
||||
clean clean-again:
|
||||
@basedir=../.. TEST_BASE_DIR=../ ./test.sh --clean
|
||||
@rm -f has-overflow
|
||||
|
||||
.PHONY: all setup run clean clean-again
|
|
@ -0,0 +1 @@
|
|||
../TEST-01-BASIC/Makefile
|
|
@ -1,193 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="systemd-nspawn smoke test"
|
||||
IMAGE_NAME=nspawn
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
test_create_image() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
dracut_install busybox chmod rmdir unshare ip sysctl
|
||||
|
||||
cp create-busybox-container $initdir/
|
||||
|
||||
./create-busybox-container $initdir/nc-container
|
||||
../create-busybox-container $initdir/nc-container
|
||||
initdir="$initdir/nc-container" dracut_install nc ip
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-nspawn.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat >$initdir/test-nspawn.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
export SYSTEMD_LOG_LEVEL=debug
|
||||
|
||||
# check cgroup-v2
|
||||
is_v2_supported=no
|
||||
mkdir -p /tmp/cgroup2
|
||||
if mount -t cgroup2 cgroup2 /tmp/cgroup2; then
|
||||
is_v2_supported=yes
|
||||
umount /tmp/cgroup2
|
||||
fi
|
||||
rmdir /tmp/cgroup2
|
||||
|
||||
# check cgroup namespaces
|
||||
is_cgns_supported=no
|
||||
if [[ -f /proc/1/ns/cgroup ]]; then
|
||||
is_cgns_supported=yes
|
||||
fi
|
||||
|
||||
is_user_ns_supported=no
|
||||
# On some systems (e.g. CentOS 7) the default limit for user namespaces
|
||||
# is set to 0, which causes the following unshare syscall to fail, even
|
||||
# with enabled user namespaces support. By setting this value explicitly
|
||||
# we can ensure the user namespaces support to be detected correctly.
|
||||
sysctl -w user.max_user_namespaces=10000
|
||||
if unshare -U sh -c :; then
|
||||
is_user_ns_supported=yes
|
||||
fi
|
||||
|
||||
function check_bind_tmp_path {
|
||||
# https://github.com/systemd/systemd/issues/4789
|
||||
local _root="/var/lib/machines/bind-tmp-path"
|
||||
/create-busybox-container "$_root"
|
||||
>/tmp/bind
|
||||
systemd-nspawn --register=no -D "$_root" --bind=/tmp/bind /bin/sh -c 'test -e /tmp/bind'
|
||||
}
|
||||
|
||||
function check_norbind {
|
||||
# https://github.com/systemd/systemd/issues/13170
|
||||
local _root="/var/lib/machines/norbind-path"
|
||||
mkdir -p /tmp/binddir/subdir
|
||||
echo -n "outer" > /tmp/binddir/subdir/file
|
||||
mount -t tmpfs tmpfs /tmp/binddir/subdir
|
||||
echo -n "inner" > /tmp/binddir/subdir/file
|
||||
/create-busybox-container "$_root"
|
||||
systemd-nspawn --register=no -D "$_root" --bind=/tmp/binddir:/mnt:norbind /bin/sh -c 'CONTENT=$(cat /mnt/subdir/file); if [[ $CONTENT != "outer" ]]; then echo "*** unexpected content: $CONTENT"; return 1; fi'
|
||||
}
|
||||
|
||||
function check_notification_socket {
|
||||
# https://github.com/systemd/systemd/issues/4944
|
||||
local _cmd='echo a | $(busybox which nc) -U -u -w 1 /run/systemd/nspawn/notify'
|
||||
systemd-nspawn --register=no -D /nc-container /bin/sh -x -c "$_cmd"
|
||||
systemd-nspawn --register=no -D /nc-container -U /bin/sh -x -c "$_cmd"
|
||||
}
|
||||
|
||||
function run {
|
||||
if [[ "$1" = "yes" && "$is_v2_supported" = "no" ]]; then
|
||||
printf "Unified cgroup hierarchy is not supported. Skipping.\n" >&2
|
||||
return 0
|
||||
fi
|
||||
if [[ "$2" = "yes" && "$is_cgns_supported" = "no" ]]; then
|
||||
printf "CGroup namespaces are not supported. Skipping.\n" >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
local _root="/var/lib/machines/unified-$1-cgns-$2-api-vfs-writable-$3"
|
||||
/create-busybox-container "$_root"
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -b
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" --private-network -b
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -U -b; then
|
||||
[[ "$is_user_ns_supported" = "yes" && "$3" = "network" ]] && return 1
|
||||
else
|
||||
[[ "$is_user_ns_supported" = "no" && "$3" = "network" ]] && return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" --private-network -U -b; then
|
||||
[[ "$is_user_ns_supported" = "yes" && "$3" = "yes" ]] && return 1
|
||||
else
|
||||
[[ "$is_user_ns_supported" = "no" && "$3" = "yes" ]] && return 1
|
||||
fi
|
||||
|
||||
local _netns_opt="--network-namespace-path=/proc/self/ns/net"
|
||||
|
||||
# --network-namespace-path and network-related options cannot be used together
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-interface=lo -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-macvlan=lo -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-ipvlan=lo -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-veth -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-veth-extra=lo -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-bridge=lo -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --network-zone=zone -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# allow combination of --network-namespace-path and --private-network
|
||||
if ! SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --private-network -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# test --network-namespace-path works with a network namespace created by "ip netns"
|
||||
ip netns add nspawn_test
|
||||
_netns_opt="--network-namespace-path=/run/netns/nspawn_test"
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" /bin/ip a | grep -v -E '^1: lo.*UP'
|
||||
local r=$?
|
||||
ip netns del nspawn_test
|
||||
|
||||
if [ $r -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_bind_tmp_path
|
||||
|
||||
check_norbind
|
||||
|
||||
check_notification_socket
|
||||
|
||||
for api_vfs_writable in yes no network; do
|
||||
run no no $api_vfs_writable
|
||||
run yes no $api_vfs_writable
|
||||
run no yes $api_vfs_writable
|
||||
run yes yes $api_vfs_writable
|
||||
done
|
||||
|
||||
touch /testok
|
||||
EOF
|
||||
|
||||
chmod 0755 $initdir/test-nspawn.sh
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 13
|
||||
|
|
|
@ -1,78 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="/etc/machine-id testing"
|
||||
IMAGE_NAME=badid
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
test_create_image() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
printf "556f48e837bc4424a710fa2e2c9d3e3c\ne3d\n" >$initdir/etc/machine-id
|
||||
dracut_install mount cmp
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -e -x -c '/test-machine-id-setup.sh; systemctl --state=failed --no-legend --no-pager > /failed ; echo OK > /testok'
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat >$initdir/test-machine-id-setup.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
function setup_root {
|
||||
local _root="$1"
|
||||
mkdir -p "$_root"
|
||||
mount -t tmpfs tmpfs "$_root"
|
||||
mkdir -p "$_root/etc" "$_root/run"
|
||||
}
|
||||
|
||||
function check {
|
||||
printf "Expected\n"
|
||||
cat "$1"
|
||||
printf "\nGot\n"
|
||||
cat "$2"
|
||||
cmp "$1" "$2"
|
||||
}
|
||||
|
||||
r="$(pwd)/overwrite-broken-machine-id"
|
||||
setup_root "$r"
|
||||
systemd-machine-id-setup --print --root "$r"
|
||||
echo abc >>"$r/etc/machine-id"
|
||||
id=$(systemd-machine-id-setup --print --root "$r")
|
||||
echo $id >expected
|
||||
check expected "$r/etc/machine-id"
|
||||
|
||||
r="$(pwd)/transient-machine-id"
|
||||
setup_root "$r"
|
||||
systemd-machine-id-setup --print --root "$r"
|
||||
echo abc >>"$r/etc/machine-id"
|
||||
mount -o remount,ro "$r"
|
||||
mount -t tmpfs tmpfs "$r/run"
|
||||
transient_id=$(systemd-machine-id-setup --print --root "$r")
|
||||
mount -o remount,rw "$r"
|
||||
commited_id=$(systemd-machine-id-setup --print --commit --root "$r")
|
||||
[[ "$transient_id" = "$commited_id" ]]
|
||||
check "$r/etc/machine-id" "$r/run/machine-id"
|
||||
EOF
|
||||
chmod +x $initdir/test-machine-id-setup.sh
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 14
|
||||
|
|
|
@ -5,18 +5,4 @@ TEST_NO_QEMU=1
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
# create the basic filesystem layout
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# import the test scripts in the rootfs and plug them in systemd
|
||||
cp testsuite.service $initdir/etc/systemd/system/
|
||||
cp test-dropin.sh $initdir/
|
||||
setup_testsuite
|
||||
|
||||
# create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 15
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-dropin.sh
|
||||
Type=oneshot
|
|
@ -6,30 +6,4 @@ TEST_NO_QEMU=1
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
for s in success-all success-start success-stop success-runtime \
|
||||
fail-start fail-stop fail-runtime
|
||||
do
|
||||
cp testsuite-${s}.service ${initdir}/etc/systemd/system
|
||||
done
|
||||
cp testsuite.service ${initdir}/etc/systemd/system
|
||||
|
||||
cp extend_timeout_test_service.sh ${initdir}/
|
||||
cp assess.sh ${initdir}/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 16
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
[Unit]
|
||||
Description=Testsuite: Assess all other testsuite-*.services worked as expected
|
||||
|
||||
Wants=testsuite-success-all.service
|
||||
Wants=testsuite-success-start.service
|
||||
Wants=testsuite-success-runtime.service
|
||||
Wants=testsuite-success-stop.service
|
||||
Wants=testsuite-fail-start.service
|
||||
Wants=testsuite-fail-stop.service
|
||||
Wants=testsuite-fail-runtime.service
|
||||
StopWhenUnneeded=yes
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
TimeoutStartSec=infinity
|
||||
ExecStartPre=/assess.sh
|
||||
ExecStart=/bin/true
|
|
@ -6,29 +6,4 @@ TEST_NO_NSPAWN=1
|
|||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=300
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 17
|
||||
|
|
|
@ -5,31 +5,4 @@ TEST_DESCRIPTION="FailureAction= operation"
|
|||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=600
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 18
|
||||
|
|
|
@ -7,29 +7,4 @@ TEST_NO_NSPAWN=1
|
|||
QEMU_TIMEOUT=600
|
||||
UNIFIED_CGROUP_HIERARCHY=yes
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 19
|
||||
|
|
|
@ -4,34 +4,4 @@ TEST_DESCRIPTION="test changing main PID"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
Before=getty-pre.target
|
||||
Wants=getty-pre.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
NotifyAccess=all
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 20
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="Sysuser-related tests"
|
||||
|
||||
IMAGE_NAME=sysusers
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
|
|
|
@ -2,30 +2,6 @@
|
|||
set -e
|
||||
TEST_DESCRIPTION="Tmpfiles related tests"
|
||||
TEST_NO_QEMU=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
# create the basic filesystem layout
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
inst_binary mv
|
||||
inst_binary stat
|
||||
inst_binary seq
|
||||
inst_binary xargs
|
||||
inst_binary mkfifo
|
||||
inst_binary readlink
|
||||
|
||||
# setup the testsuite service
|
||||
cp testsuite.service $initdir/etc/systemd/system/
|
||||
setup_testsuite
|
||||
|
||||
mkdir -p $initdir/testsuite
|
||||
cp run-tmpfiles-tests.sh $initdir/testsuite/
|
||||
cp test-*.sh $initdir/testsuite/
|
||||
|
||||
# create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 22
|
||||
|
|
|
@ -1,33 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="test Type=exec"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 23
|
||||
|
|
|
@ -3,34 +3,43 @@ set -e
|
|||
TEST_DESCRIPTION="Run unit tests under containers"
|
||||
RUN_IN_UNPRIVILEGED_CONTAINER=yes
|
||||
|
||||
# embed some newlines in the kernel command line to stress our test suite
|
||||
KERNEL_APPEND="
|
||||
|
||||
frobnicate!
|
||||
|
||||
$KERNEL_APPEND
|
||||
"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
check_result_nspawn() {
|
||||
local _ret=1
|
||||
[[ -e $TESTDIR/$1/testok ]] && _ret=0
|
||||
if [[ -s $TESTDIR/$1/failed ]]; then
|
||||
[[ -e $1/testok ]] && _ret=0
|
||||
if [[ -s $1/failed ]]; then
|
||||
_ret=$(($_ret+1))
|
||||
echo "=== Failed test log ==="
|
||||
cat $TESTDIR/$1/failed
|
||||
cat $1/failed
|
||||
else
|
||||
if [[ -s $TESTDIR/$1/skipped ]]; then
|
||||
if [[ -s $1/skipped ]]; then
|
||||
echo "=== Skipped test log =="
|
||||
cat $TESTDIR/$1/skipped
|
||||
cat $1/skipped
|
||||
fi
|
||||
if [[ -s $TESTDIR/$1/testok ]]; then
|
||||
if [[ -s $1/testok ]]; then
|
||||
echo "=== Passed tests ==="
|
||||
cat $TESTDIR/$1/testok
|
||||
cat $1/testok
|
||||
fi
|
||||
fi
|
||||
cp -a $TESTDIR/$1/var/log/journal $TESTDIR
|
||||
cp -a $1/var/log/journal $TESTDIR
|
||||
rm -r $1/var/log/journal/*
|
||||
_umount_dir $initdir
|
||||
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
|
||||
return $_ret
|
||||
}
|
||||
|
||||
check_result_qemu() {
|
||||
local _ret=1
|
||||
mkdir -p $initdir
|
||||
mount ${LOOPDEV}p1 $initdir
|
||||
mount_initdir
|
||||
[[ -e $initdir/testok ]] && _ret=0
|
||||
if [[ -s $initdir/failed ]]; then
|
||||
_ret=$(($_ret+1))
|
||||
|
@ -47,55 +56,10 @@ check_result_qemu() {
|
|||
fi
|
||||
fi
|
||||
cp -a $initdir/var/log/journal $TESTDIR
|
||||
umount $initdir
|
||||
rm -r $initdir/var/log/journal/*
|
||||
_umount_dir $initdir
|
||||
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
|
||||
return $_ret
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
if type -P meson && [[ "$(meson configure $BUILD_DIR | grep install-tests | awk '{ print $2 }')" != "true" ]]; then
|
||||
dfatal "Needs to be built with -Dinstall-tests=true"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
for i in getfacl dirname basename capsh cut rev stat mktemp rmdir ionice unshare uname tr awk getent diff xzcat lz4cat; do
|
||||
inst_binary $i
|
||||
done
|
||||
|
||||
inst /etc/hosts
|
||||
|
||||
setup_basic_environment
|
||||
install_keymaps yes
|
||||
install_zoneinfo
|
||||
# Install nproc to determine # of CPUs for correct parallelization
|
||||
inst_binary nproc
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
|
||||
# mask some services that we do not want to run in these tests
|
||||
ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service
|
||||
ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
|
||||
ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 24
|
||||
|
|
|
@ -4,30 +4,4 @@ TEST_DESCRIPTION="test importd"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
dracut_install dd gunzip mv tar diff
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 25
|
||||
|
|
|
@ -4,29 +4,4 @@ TEST_DESCRIPTION="test setenv"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 26
|
||||
|
|
|
@ -4,31 +4,4 @@ TEST_DESCRIPTION="test StandardOutput=file:"
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
inst_binary cmp
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 27
|
||||
|
|
|
@ -5,52 +5,4 @@ RUN_IN_UNPRIVILEGED_CONTAINER=yes
|
|||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
# Create what will eventually be our root filesystem onto an overlay
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# Set up the services.
|
||||
cat >$initdir/etc/systemd/system/specifier-j-wants.service << EOF
|
||||
[Unit]
|
||||
Description=Wants with percent-j specifier
|
||||
Wants=specifier-j-depends-%j.service
|
||||
After=specifier-j-depends-%j.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=test -f /tmp/test-specifier-j-%j
|
||||
ExecStart=/bin/sh -c 'echo OK > /testok'
|
||||
EOF
|
||||
cat >$initdir/etc/systemd/system/specifier-j-depends-wants.service << EOF
|
||||
[Unit]
|
||||
Description=Dependent service for percent-j specifier
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=touch /tmp/test-specifier-j-wants
|
||||
EOF
|
||||
cat >$initdir/etc/systemd/system/testsuite.service << EOF
|
||||
[Unit]
|
||||
Description=Testsuite: Ensure %j Wants directives work
|
||||
Wants=specifier-j-wants.service
|
||||
After=specifier-j-wants.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/true
|
||||
EOF
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 28
|
||||
|
|
|
@ -6,29 +6,4 @@ TEST_NO_NSPAWN=1
|
|||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=300
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 29
|
||||
|
|
|
@ -2,42 +2,6 @@
|
|||
set -e
|
||||
TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange="
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
inst_any /usr/share/zoneinfo/Europe/Kiev
|
||||
inst_any /usr/share/zoneinfo/Europe/Berlin
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# extend the watchdog
|
||||
mkdir -p $initdir/etc/systemd/system/systemd-timedated.service.d
|
||||
cat >$initdir/etc/systemd/system/systemd-timedated.service.d/watchdog.conf <<EOF
|
||||
[Service]
|
||||
WatchdogSec=10min
|
||||
EOF
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 30
|
||||
|
|
|
@ -6,29 +6,4 @@ TEST_NO_NSPAWN=1
|
|||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=300
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 31
|
||||
|
|
|
@ -2,35 +2,8 @@
|
|||
set -e
|
||||
TEST_DESCRIPTION="test OOM killer logic"
|
||||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
UNIFIED_CGROUP_HIERARCHY=yes
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/testsuite.sh
|
||||
Type=oneshot
|
||||
MemoryAccounting=yes
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 32
|
||||
|
|
|
@ -3,33 +3,6 @@
|
|||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
set -e
|
||||
TEST_DESCRIPTION="test CleanUnit"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
) || return 1
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 33
|
||||
|
|
|
@ -1,33 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUser=0 and back"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
||||
(
|
||||
LOG_LEVEL=5
|
||||
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/bash -x /testsuite.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
cp testsuite.sh $initdir/
|
||||
|
||||
setup_testsuite
|
||||
)
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 34
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../TEST-01-BASIC/Makefile
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TEST_DESCRIPTION="network-generator tests"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
mkdir -p $TESTDIR/run/systemd/network
|
||||
}
|
||||
|
||||
test_run() {
|
||||
local generator
|
||||
|
||||
if [[ -x $BUILD_DIR/systemd-network-generator ]]; then
|
||||
generator=$BUILD_DIR/systemd-network-generator
|
||||
elif [[ -x /usr/lib/systemd/systemd-network-generator ]]; then
|
||||
generator=/usr/lib/systemd/systemd-network-generator
|
||||
elif [[ -x /lib/systemd/systemd-network-generator ]]; then
|
||||
generator=/lib/systemd/systemd-network-generator
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for f in test-*.input; do
|
||||
echo "*** Running $f"
|
||||
rm -f $TESTDIR/run/systemd/network/*
|
||||
$generator --root $TESTDIR -- $(cat $f)
|
||||
|
||||
if ! diff -u $TESTDIR/run/systemd/network ${f%.input}.expected; then
|
||||
echo "**** Unexpected output for $f"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
do_test "$@"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue