Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#2013213) (Not only) CI and QoL backports #72

Merged
merged 41 commits into from Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6bc9ed1
test: check systemd RPM macros
mrc0mmand Mar 3, 2022
6513dc2
test: do not assume x86-64 arch in TEST-58-REPART
bluca Jan 12, 2022
52e39a6
tests: add repart tests for block devices with 1024, 2048, 4096 byte …
poettering Feb 7, 2022
5bc3403
test: accept both unpadded and padded partition sizes
mrc0mmand Feb 25, 2022
89e4b48
test: lvm 2.03.15 dropped the static autoactivation
mrc0mmand Feb 9, 2022
f91de02
test: accept GC'ed units in newer LVM
mrc0mmand Feb 10, 2022
0b8c410
shared: Add more dlopen() tests
DaanDeMeyer Mar 1, 2022
a819291
systemctl: Show how long a service ran for after it exited in status …
DaanDeMeyer Feb 22, 2022
822c454
time-util: introduce TIMESTAMP_UNIX
mrc0mmand Feb 21, 2022
654e059
systemctl,man: update docs for `--timestamp=`
mrc0mmand Feb 21, 2022
2dc95f3
systemctl: make `--timestamp=` affect the `show` verb as well
mrc0mmand Feb 18, 2022
f4e696c
tests: allow running all the services with SYSTEMD_LOG_LEVEL
evverx Feb 15, 2022
f87bb37
coredump: raise the coredump save size on 64bit systems to 32G (and l…
poettering Feb 8, 2022
656e997
repart: fix sector size handling
poettering Feb 4, 2022
56f5f91
mkdir: allow to create directory whose path contains symlink
yuwata Feb 2, 2022
e264233
mkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()
yuwata Feb 2, 2022
f9ee218
meson: move efi file lists closer to where they are used
keszybz Dec 23, 2021
8851b96
meson: move efi summary() section to src/boot/efi
keszybz Dec 23, 2021
8ca6af3
meson: report SBAT settings
keszybz Dec 23, 2021
6910002
boot: Build BCD parser only on arches supported by Windows
medhefgo Dec 28, 2021
b829ce8
meson: Remove efi-cc option
medhefgo Dec 29, 2021
0dd5009
meson: Get objcopy location from compiler
medhefgo Dec 29, 2021
2a189b0
meson: Use files() for source lists for boot and fundamental
medhefgo Jan 7, 2022
904ea22
meson: Use files() for tests
medhefgo Jan 11, 2022
b077278
tests: add fuzz-bcd
evverx Dec 26, 2021
a528bd7
meson: Use files() for fuzzers
medhefgo Jan 11, 2022
e3daea3
meson: Add check argument to remaining run_command() calls
medhefgo Jan 11, 2022
e9dad7e
meson: Use echo to list files
medhefgo Jan 11, 2022
fad282f
test: add a test for mkdir_p()
yuwata Feb 2, 2022
e72d700
util: another set of CVE-2021-4034 assert()s
poettering Feb 1, 2022
467e890
basic: update CIFS magic
mrc0mmand Jan 30, 2022
32fcbf3
shared: be extra paranoid and check if argc > 0
mrc0mmand Jan 28, 2022
8b3aef0
core: check if argc > 0 and argv[0] is set
yuwata Jan 30, 2022
c574399
core: check argc/argv uncoditionally
mrc0mmand Jan 30, 2022
d8c409b
test: temporary workaround for #21819
mrc0mmand Jan 27, 2022
56c7e61
test: don't leak local variable to outer scopes
mrc0mmand Jan 27, 2022
c8a106a
tree-wide: don't use strjoina() on getenv() values
anitazha Jan 26, 2022
3007634
man: clarify Environmentfile format
yonran Dec 27, 2021
71d49fc
test-load-fragment: add a basic test for config_parse_unit_env_file()
keszybz Jan 19, 2022
e256116
core/execute: use _cleanup_ in exec_context_load_environment()
keszybz Jan 19, 2022
b413585
test-env-file: add tests for quoting in env files
keszybz Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/unit_tests.sh
Expand Up @@ -20,6 +20,7 @@ ADDITIONAL_DEPS=(
perl
python3-libevdev
python3-pyparsing
rpm
zstd
)

Expand Down
2 changes: 1 addition & 1 deletion .semaphore/semaphore-runner.sh
Expand Up @@ -42,7 +42,7 @@ apt-get -q --allow-releaseinfo-change update
apt-get -y dist-upgrade
apt-get install -y eatmydata
# The following four are needed as long as these deps are not covered by Debian's own packaging
apt-get install -y fdisk tree libfdisk-dev libp11-kit-dev libssl-dev libpwquality-dev
apt-get install -y fdisk tree libfdisk-dev libp11-kit-dev libssl-dev libpwquality-dev rpm
apt-get purge --auto-remove -y unattended-upgrades
systemctl unmask systemd-networkd
systemctl enable systemd-networkd
Expand Down
2 changes: 1 addition & 1 deletion man/meson.build
Expand Up @@ -105,7 +105,7 @@ endforeach

############################################################

have_lxml = run_command(xml_helper_py).returncode() == 0
have_lxml = run_command(xml_helper_py, check: false).returncode() == 0
if not have_lxml
message('python-lxml not available, not making man page indices')
endif
Expand Down
7 changes: 7 additions & 0 deletions man/systemctl.xml
Expand Up @@ -2305,6 +2305,13 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
</varlistentry>
</variablelist>

<variablelist>
<varlistentry>
<term><option>unix</option></term>
<listitem><para><literal>@seconds-since-the-epoch</literal></para></listitem>
</varlistentry>
</variablelist>

<variablelist>
<varlistentry>
<term><option>us</option></term>
Expand Down
51 changes: 33 additions & 18 deletions man/systemd.exec.xml
Expand Up @@ -2485,18 +2485,39 @@ SystemCallErrorNumber=EPERM</programlisting>
<varlistentry>
<term><varname>EnvironmentFile=</varname></term>

<listitem><para>Similar to <varname>Environment=</varname> but reads the environment variables from a text
file. The text file should contain new-line-separated variable assignments. Empty lines, lines without an
<literal>=</literal> separator, or lines starting with ; or # will be ignored, which may be used for
commenting. A line ending with a backslash will be concatenated with the following one, allowing multiline
variable definitions. The parser strips leading and trailing whitespace from the values of assignments, unless
you use double quotes (").</para>

<para><ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C escapes</ulink>
are supported, but not
<ulink url="https://en.wikipedia.org/wiki/Control_character#In_ASCII">most control characters</ulink>.
<literal>\t</literal> and <literal>\n</literal> can be used to insert tabs and newlines within
<varname>EnvironmentFile=</varname>.</para>
<listitem><para>Similar to <varname>Environment=</varname> but reads the environment variables from a text file.
The text file should contain newline-separated variable assignments. Empty lines, lines without an
<literal>=</literal> separator, or lines starting with <literal>;</literal> or <literal>#</literal> will be
ignored, which may be used for commenting. The file must be UTF-8 encoded. Valid characters are <ulink
url="https://www.unicode.org/glossary/#unicode_scalar_value">unicode scalar values</ulink> other than <ulink
url="https://www.unicode.org/glossary/#noncharacter">noncharacters</ulink>, U+0000 NUL, and U+FEFF <ulink
url="https://www.unicode.org/glossary/#byte_order_mark">byte order mark</ulink>. Control codes other than NUL
are allowed.</para>

<para>In the file, an unquoted value after the <literal>=</literal> is parsed with the same backslash-escape
rules as <ulink
url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01">unquoted
text</ulink> in a POSIX shell, but unlike in a shell, interior whitespace is preserved and quotes after the
first non-whitespace character are preserved. Leading and trailing whitespace (space, tab, carriage return) is
discarded, but interior whitespace within the line is preserved verbatim. A line ending with a backslash will be
continued to the following one, with the newline itself discarded. A backslash
<literal>\</literal> followed by any character other than newline will preserve the following character, so that
<literal>\\</literal> will become the value <literal>\</literal>.</para>

<para>In the file, a <literal>'</literal>-quoted value after the <literal>=</literal> can span multiple lines
and contain any character verbatim other than single quote, like <ulink
url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_02">single-quoted
text</ulink> in a POSIX shell. No backslash-escape sequences are recognized. Leading and trailing whitespace
outside of the single quotes is discarded.</para>

<para>In the file, a <literal>"</literal>-quoted value after the <literal>=</literal> can span multiple lines,
and the same escape sequences are recognized as in <ulink
url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03">double-quoted
text</ulink> of a POSIX shell. Backslash (<literal>\</literal>) followed by any of <literal>"\`$</literal> will
preserve that character. A backslash followed by newline is a line continuation, and the newline itself is
discarded. A backslash followed by any other character is ignored; both the backslash and the following
character are preserved verbatim. Leading and trailing whitespace outside of the double quotes is
discarded.</para>

<para>The argument passed should be an absolute filename or wildcard expression, optionally prefixed with
<literal>-</literal>, which indicates that if the file does not exist, it will not be read and no error or
Expand Down Expand Up @@ -2529,12 +2550,6 @@ SystemCallErrorNumber=EPERM</programlisting>
<para>Variables set for invoked processes due to this setting are subject to being overridden by those
configured with <varname>Environment=</varname> or <varname>EnvironmentFile=</varname>.</para>

<para><ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C escapes</ulink>
are supported, but not
<ulink url="https://en.wikipedia.org/wiki/Control_character#In_ASCII">most control characters</ulink>.
<literal>\t</literal> and <literal>\n</literal> can be used to insert tabs and newlines within
<varname>EnvironmentFile=</varname>.</para>

<para>Example:
<programlisting>PassEnvironment=VAR1 VAR2 VAR3</programlisting>
passes three variables <literal>VAR1</literal>,
Expand Down
22 changes: 8 additions & 14 deletions meson.build
Expand Up @@ -43,6 +43,10 @@ endif
skip_deps = want_ossfuzz or want_libfuzzer
fuzzer_build = want_ossfuzz or want_libfuzzer

# Create a title-less summary section early, so it ends up first in the output.
# More items are added later after they have been detected.
summary({'build mode' : get_option('mode')})

#####################################################################

# Try to install the git pre-commit hook
Expand Down Expand Up @@ -3562,7 +3566,8 @@ foreach tuple : tests
parallel = tuple.length() > 7 ? tuple[7] : true
timeout = 30

name = sources[0].split('/')[-1].split('.')[0]
# FIXME: Use fs.stem() with meson >= 0.54.0
name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
if type.startswith('timeout=')
timeout = type.split('=')[1].to_int()
type = ''
Expand Down Expand Up @@ -3672,7 +3677,8 @@ foreach tuple : fuzzers
sources += 'src/fuzz/fuzz-main.c'
endif

name = sources[0].split('/')[-1].split('.')[0]
# FIXME: Use fs.stem() with meson >= 0.54.0
name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]

exe = executable(
name,
Expand Down Expand Up @@ -3902,7 +3908,6 @@ alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch
check : true).stdout().strip()

summary({
'build mode' : get_option('mode'),
'split /usr' : split_usr,
'split bin-sbin' : split_bin,
'prefix directory' : prefixdir,
Expand Down Expand Up @@ -3960,17 +3965,6 @@ summary({
# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}

if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_GNU_EFI') == 1
summary({
'EFI machine type' : efi_arch[0],
'EFI CC' : '@0@'.format(' '.join(efi_cc)),
'EFI LD' : efi_ld,
'EFI lds' : efi_lds,
'EFI crt0' : efi_crt0,
'EFI include directory' : efi_incdir},
section : 'Extensible Firmware Interface')
endif

found = []
missing = []

Expand Down
2 changes: 0 additions & 2 deletions meson_options.txt
Expand Up @@ -414,8 +414,6 @@ option('dbus', type : 'combo', choices : ['auto', 'true', 'false'],

option('gnu-efi', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'gnu-efi support for sd-boot')
option('efi-cc', type : 'array',
description : 'the compiler to use for EFI modules')
# Note that LLD does not support PE/COFF relocations
# https://lists.llvm.org/pipermail/llvm-dev/2021-March/149234.html
option('efi-ld', type : 'combo', choices : ['auto', 'bfd', 'gold'],
Expand Down
6 changes: 3 additions & 3 deletions src/analyze/meson.build
Expand Up @@ -13,9 +13,9 @@ systemd_analyze_sources = files('''
'''.split())

tests += [
[['src/analyze/test-verify.c',
'src/analyze/analyze-verify.c',
'src/analyze/analyze-verify.h'],
[files('test-verify.c',
'analyze-verify.c',
'analyze-verify.h'),
[libcore,
libshared],
[],
Expand Down
4 changes: 2 additions & 2 deletions src/basic/filesystems-gperf.gperf
Expand Up @@ -40,7 +40,7 @@ ceph, {CEPH_SUPER_MAGIC}
cgroup2, {CGROUP2_SUPER_MAGIC}
# note that the cgroupfs magic got reassigned from cpuset
cgroup, {CGROUP_SUPER_MAGIC}
cifs, {CIFS_MAGIC_NUMBER}
cifs, {CIFS_SUPER_MAGIC, SMB2_SUPER_MAGIC}
coda, {CODA_SUPER_MAGIC}
configfs, {CONFIGFS_MAGIC}
cramfs, {CRAMFS_MAGIC}
Expand Down Expand Up @@ -109,7 +109,7 @@ selinuxfs, {SELINUX_MAGIC}
shiftfs, {SHIFTFS_MAGIC}
smackfs, {SMACK_MAGIC}
# smb3 is an alias for cifs
smb3, {CIFS_MAGIC_NUMBER}
smb3, {CIFS_SUPER_MAGIC}
# smbfs was removed from the kernel in 2010, the magic remains
smbfs, {SMB_SUPER_MAGIC}
sockfs, {SOCKFS_MAGIC}
Expand Down
2 changes: 1 addition & 1 deletion src/basic/meson.build
Expand Up @@ -384,7 +384,7 @@ filesystem_includes = ['linux/magic.h',
'linux/gfs2_ondisk.h']

check_filesystems = find_program('check-filesystems.sh')
r = run_command([check_filesystems, cpp, 'filesystems-gperf.gperf'] + filesystem_includes)
r = run_command([check_filesystems, cpp, 'filesystems-gperf.gperf'] + filesystem_includes, check: false)
if r.returncode() != 0
error('found unknown filesystem(s) defined in kernel headers:\n\n' + r.stdout())
r.stdout()
Expand Down
11 changes: 8 additions & 3 deletions src/basic/missing_magic.h
Expand Up @@ -38,9 +38,14 @@
#define XFS_SB_MAGIC 0x58465342
#endif

/* Not exposed yet. Defined at fs/cifs/cifsglob.h */
#ifndef CIFS_MAGIC_NUMBER
#define CIFS_MAGIC_NUMBER 0xFF534D42
/* dea2903719283c156b53741126228c4a1b40440f (5.17) */
#ifndef CIFS_SUPER_MAGIC
#define CIFS_SUPER_MAGIC 0xFF534D42
#endif

/* dea2903719283c156b53741126228c4a1b40440f (5.17) */
#ifndef SMB2_SUPER_MAGIC
#define SMB2_SUPER_MAGIC 0xFE534D42
#endif

/* 257f871993474e2bde6c497b54022c362cf398e1 (4.5) */
Expand Down
4 changes: 2 additions & 2 deletions src/basic/mkdir.c
Expand Up @@ -42,7 +42,7 @@ int mkdir_safe_internal(
if ((flags & MKDIR_FOLLOW_SYMLINK) && S_ISLNK(st.st_mode)) {
_cleanup_free_ char *p = NULL;

r = chase_symlinks_and_stat(path, NULL, CHASE_NONEXISTENT, &p, &st, NULL);
r = chase_symlinks_and_stat(path, NULL, 0, &p, &st, NULL);
if (r < 0)
return r;
if (r == 0)
Expand Down Expand Up @@ -162,7 +162,7 @@ int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, uid_t ui

assert(_mkdirat != mkdirat);

r = mkdir_parents_internal(prefix, path, mode, uid, gid, flags, _mkdirat);
r = mkdir_parents_internal(prefix, path, mode, uid, gid, flags | MKDIR_FOLLOW_SYMLINK, _mkdirat);
if (r < 0)
return r;

Expand Down
8 changes: 6 additions & 2 deletions src/basic/path-lookup.c
Expand Up @@ -238,7 +238,7 @@ static int acquire_generator_dirs(
char **generator_early,
char **generator_late) {

_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL;
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *p = NULL;
const char *prefix;

assert(generator);
Expand All @@ -261,7 +261,11 @@ static int acquire_generator_dirs(
if (!e)
return -ENXIO;

prefix = strjoina(e, "/systemd");
p = path_join(e, "/systemd");
if (!p)
return -ENOMEM;

prefix = p;
}

x = path_join(prefix, "generator");
Expand Down
11 changes: 11 additions & 0 deletions src/basic/time-util.c
Expand Up @@ -320,11 +320,13 @@ char *format_timestamp_style(
time_t sec;
size_t n;
bool utc = false, us = false;
int r;

assert(buf);

switch (style) {
case TIMESTAMP_PRETTY:
case TIMESTAMP_UNIX:
break;
case TIMESTAMP_US:
us = true;
Expand All @@ -350,6 +352,14 @@ char *format_timestamp_style(
if (t <= 0 || t == USEC_INFINITY)
return NULL; /* Timestamp is unset */

if (style == TIMESTAMP_UNIX) {
r = snprintf(buf, l, "@" USEC_FMT, t / USEC_PER_SEC); /* round down µs → s */
if (r < 0 || (size_t) r >= l)
return NULL; /* Doesn't fit */

return buf;
}

/* Let's not format times with years > 9999 */
if (t > USEC_TIMESTAMP_FORMATTABLE_MAX) {
assert(l >= STRLEN("--- XXXX-XX-XX XX:XX:XX") + 1);
Expand Down Expand Up @@ -1632,6 +1642,7 @@ static const char* const timestamp_style_table[_TIMESTAMP_STYLE_MAX] = {
[TIMESTAMP_US] = "us",
[TIMESTAMP_UTC] = "utc",
[TIMESTAMP_US_UTC] = "us+utc",
[TIMESTAMP_UNIX] = "unix",
};

/* Use the macro for enum → string to allow for aliases */
Expand Down
1 change: 1 addition & 0 deletions src/basic/time-util.h
Expand Up @@ -34,6 +34,7 @@ typedef enum TimestampStyle {
TIMESTAMP_US,
TIMESTAMP_UTC,
TIMESTAMP_US_UTC,
TIMESTAMP_UNIX,
_TIMESTAMP_STYLE_MAX,
_TIMESTAMP_STYLE_INVALID = -EINVAL,
} TimestampStyle;
Expand Down
6 changes: 6 additions & 0 deletions src/basic/util.h
Expand Up @@ -9,6 +9,12 @@ extern int saved_argc;
extern char **saved_argv;

static inline void save_argc_argv(int argc, char **argv) {

/* Protect against CVE-2021-4034 style attacks */
assert_se(argc > 0);
assert_se(argv);
assert_se(argv[0]);

saved_argc = argc;
saved_argv = argv;
}
Expand Down
2 changes: 2 additions & 0 deletions src/boot/efi/boot.c
Expand Up @@ -1941,6 +1941,7 @@ static void config_entry_add_osx(Config *config) {
}

static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FILE *root_dir) {
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
_cleanup_freepool_ CHAR8 *bcd = NULL;
CHAR16 *title = NULL;
EFI_STATUS err;
Expand All @@ -1961,6 +1962,7 @@ static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FIL
config_entry_add_loader_auto(config, device, root_dir, NULL,
L"auto-windows", 'w', title ?: L"Windows Boot Manager",
L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
#endif
}

static void config_entry_add_linux(
Expand Down
26 changes: 26 additions & 0 deletions src/boot/efi/fuzz-bcd.c
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#include "alloc-util.h"
#include "fd-util.h"
#include "fuzz.h"
#include "utf8.h"

#include "bcd.c"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ void *p = NULL;

/* This limit was borrowed from src/boot/efi/boot.c */
if (size > 100*1024)
return 0;

if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);

p = memdup(data, size);
assert_se(p);

char16_t *title = get_bcd_title(p, size);
assert_se(!title || char16_strlen(title) >= 0);
return 0;
}