1
0
mirror of https://github.com/systemd/systemd synced 2026-04-11 01:24:50 +02:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Scott Worley
77ec2816c6 timedatectl: Uniform commas in NTPMessage output 2021-12-21 09:46:19 +09:00
Frantisek Sumsal
2cb726adf5 test: tweak the path trigger limit a bit when collecting coverage
Basically the same thing as in e70103e, but for TEST-63. Uses
directives introduced by 47dba9f.

Follow-up to aaae822.
2021-12-20 22:05:14 +00:00
Zbigniew Jędrzejewski-Szmek
28be02e005 NEWS: add missing noun 2021-12-20 19:39:35 +01:00
Yu Watanabe
a2482eb290
Merge pull request #21839 from yuwata/repart-issue-reproducer-21817
test: add test case for #21817
2021-12-21 02:30:53 +09:00
Daan De Meyer
94c5a83c6e journal: Handle partially read HashItem's when punching holes 2021-12-21 02:29:57 +09:00
Zbigniew Jędrzejewski-Szmek
8ef114c692 nss-resolve: expose various source-disablement settings as variables
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2006761:
> systemd-resolved always (reverse)-resolves the host's IP addresses and FQDN.
> This can be harmful when an application (for instance, a DNS zone manager) is
> installed on the same server instance.  That application would expect
> NXDOMAIN to be returned if the current server's IP does not belong in an
> already managed reverse zone.

This allows clients of nss-resolve to use the same config options that are
available through the dbus api and as command-line options to resolvectl.

The man page text is is mostly copied directly from
c6f20515ab600098b5c2871bae2e9ecab3b41555.
2021-12-21 02:28:52 +09:00
Yu Watanabe
71bb604807 test: add a test case for issue #21817 2021-12-21 00:28:39 +09:00
Yu Watanabe
92ecc87512 test: install losetup by default
Preparation for the next commit.
2021-12-20 23:34:27 +09:00
12 changed files with 116 additions and 21 deletions

9
NEWS
View File

@ -188,10 +188,11 @@ CHANGES WITH 250 in spe:
during build-time. during build-time.
* Path units gained new TriggerLimitBurst= and TriggerLimitIntervalSec= * Path units gained new TriggerLimitBurst= and TriggerLimitIntervalSec=
that default to '200' and '2s' respectively. This ensures that a path settings that default to 200 and 2 s respectively. The ratelimit
unit cannot cause pid1 to busy loop when it is trying to trigger a ensures that a path unit cannot cause PID1 to busy-loop when it is
service that is skipped because of a Condition*= not being satisfied. trying to trigger a service that is skipped because of a Condition*=
This matches the configuration and behaviour of socket units. not being satisfied. This matches the configuration and behaviour of
socket units.
* The TPM2/FIDO2/PKCS11 support in systemd-cryptsetup is now also built * The TPM2/FIDO2/PKCS11 support in systemd-cryptsetup is now also built
as a plug-in for cryptsetup. This means the plain cryptsetup command as a plug-in for cryptsetup. This means the plain cryptsetup command

View File

@ -76,6 +76,55 @@
unreliable.</para></listitem> unreliable.</para></listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<variablelist class='environment-variables'>
<varlistentry>
<term><varname>$SYSTEMD_NSS_RESOLVE_SYNTHESIZE</varname></term>
<listitem><para>Takes a boolean argument. When false, synthetic records, e.g. for the local host
name, will not be returned. See section SYNTHETIC RECORDS in
<citerefentry><refentrytitle>systemd-resolved.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
for more information. This may be useful to query the "public" resource records, independent of the
configuration of the local machine.</para></listitem>
</varlistentry>
</variablelist>
<variablelist class='environment-variables'>
<varlistentry>
<term><varname>$SYSTEMD_NSS_RESOLVE_CACHE</varname></term>
<listitem><para>Takes a boolean argument. When false, the cache of previously queried records will
not be used by <filename>systemd-resolved</filename>.</para></listitem>
</varlistentry>
</variablelist>
<variablelist class='environment-variables'>
<varlistentry>
<term><varname>$SYSTEMD_NSS_RESOLVE_ZONE</varname></term>
<listitem><para>Takes a boolean argument. When false, answers using locally registered public
LLMNR/mDNS resource records will not be returned.</para></listitem>
</varlistentry>
</variablelist>
<variablelist class='environment-variables'>
<varlistentry>
<term><varname>$SYSTEMD_NSS_RESOLVE_TRUST_ANCHOR</varname></term>
<listitem><para>Takes a boolean argument. When false, answers using locally configured trust anchors
will not be used.</para></listitem>
</varlistentry>
</variablelist>
<variablelist class='environment-variables'>
<varlistentry>
<term><varname>$SYSTEMD_NSS_RESOLVE_NETWORK</varname></term>
<listitem><para>Takes a boolean argument. When false, answers will be returned without using the
network, i.e. either from local sources or the cache in <filename>systemd-resolved</filename>.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1> </refsect1>
<refsect1> <refsect1>

View File

@ -81,7 +81,7 @@ static int journald_file_entry_array_punch_hole(JournalFile *f, uint64_t p, uint
static int journald_file_punch_holes(JournalFile *f) { static int journald_file_punch_holes(JournalFile *f) {
HashItem items[PAYLOAD_BUFFER_SIZE / sizeof(HashItem)]; HashItem items[PAYLOAD_BUFFER_SIZE / sizeof(HashItem)];
uint64_t p, sz; uint64_t p, sz;
ssize_t n; ssize_t n = SSIZE_MAX;
int r; int r;
r = journald_file_entry_array_punch_hole( r = journald_file_entry_array_punch_hole(
@ -92,11 +92,14 @@ static int journald_file_punch_holes(JournalFile *f) {
p = le64toh(f->header->data_hash_table_offset); p = le64toh(f->header->data_hash_table_offset);
sz = le64toh(f->header->data_hash_table_size); sz = le64toh(f->header->data_hash_table_size);
for (uint64_t i = p; i < p + sz; i += n) { for (uint64_t i = p; i < p + sz && n > 0; i += n) {
n = pread(f->fd, items, MIN(sizeof(items), p + sz - i), i); n = pread(f->fd, items, MIN(sizeof(items), p + sz - i), i);
if (n < 0) if (n < 0)
return n; return n;
/* Let's ignore any partial hash items by rounding down to the nearest multiple of HashItem. */
n -= n % sizeof(HashItem);
for (size_t j = 0; j < (size_t) n / sizeof(HashItem); j++) { for (size_t j = 0; j < (size_t) n / sizeof(HashItem); j++) {
Object o; Object o;

View File

@ -198,19 +198,29 @@ static const JsonDispatch address_parameters_dispatch_table[] = {
{} {}
}; };
static uint64_t query_flags(void) { static uint64_t query_flag(
uint64_t f = 0; const char *name,
const int value,
uint64_t flag) {
int r; int r;
/* Allow callers to turn off validation, when we resolve via nss-resolve */ r = getenv_bool_secure(name);
if (r >= 0)
return r == value ? flag : 0;
if (r != -ENXIO)
log_debug_errno(r, "Failed to parse $%s, ignoring.", name);
return 0;
}
r = getenv_bool_secure("SYSTEMD_NSS_RESOLVE_VALIDATE"); static uint64_t query_flags(void) {
if (r < 0 && r != -ENXIO) /* Allow callers to turn off validation, synthetization, caching, etc., when we resolve via
log_debug_errno(r, "Failed to parse $SYSTEMD_NSS_RESOLVE_VALIDATE value, ignoring."); * nss-resolve. */
else if (r == 0) return query_flag("SYSTEMD_NSS_RESOLVE_VALIDATE", 0, SD_RESOLVED_NO_VALIDATE) |
f |= SD_RESOLVED_NO_VALIDATE; query_flag("SYSTEMD_NSS_RESOLVE_SYNTHESIZE", 0, SD_RESOLVED_NO_SYNTHESIZE) |
query_flag("SYSTEMD_NSS_RESOLVE_CACHE", 0, SD_RESOLVED_NO_CACHE) |
return f; query_flag("SYSTEMD_NSS_RESOLVE_ZONE", 0, SD_RESOLVED_NO_ZONE) |
query_flag("SYSTEMD_NSS_RESOLVE_TRUST_ANCHOR", 0, SD_RESOLVED_NO_TRUST_ANCHOR) |
query_flag("SYSTEMD_NSS_RESOLVE_NETWORK", 0, SD_RESOLVED_NO_NETWORK);
} }
enum nss_status _nss_resolve_gethostbyname4_r( enum nss_status _nss_resolve_gethostbyname4_r(

View File

@ -7,6 +7,7 @@
#include "af-list.h" #include "af-list.h"
#include "alloc-util.h" #include "alloc-util.h"
#include "dlfcn-util.h" #include "dlfcn-util.h"
#include "env-util.h"
#include "errno-list.h" #include "errno-list.h"
#include "format-util.h" #include "format-util.h"
#include "hexdecoct.h" #include "hexdecoct.h"
@ -135,7 +136,9 @@ static void test_gethostbyname4_r(void *handle, const char *module, const char *
if (STR_IN_SET(module, "resolve", "mymachines") && status == NSS_STATUS_UNAVAIL) if (STR_IN_SET(module, "resolve", "mymachines") && status == NSS_STATUS_UNAVAIL)
return; return;
if (STR_IN_SET(module, "myhostname", "resolve") && streq(name, "localhost")) { if (STR_IN_SET(module, "myhostname", "resolve") &&
streq(name, "localhost") &&
getenv_bool_secure("SYSTEMD_NSS_RESOLVE_SYNTHESIZE") != 0) {
assert_se(status == NSS_STATUS_SUCCESS); assert_se(status == NSS_STATUS_SUCCESS);
assert_se(n == 2); assert_se(n == 2);
} }

View File

@ -742,7 +742,7 @@ static int print_timesync_property(const char *name, const char *expected_value,
printf(" ReceiveTimestamp=%s,", FORMAT_TIMESTAMP(i.recv)); printf(" ReceiveTimestamp=%s,", FORMAT_TIMESTAMP(i.recv));
printf(" TransmitTimestamp=%s,", FORMAT_TIMESTAMP(i.trans)); printf(" TransmitTimestamp=%s,", FORMAT_TIMESTAMP(i.trans));
printf(" DestinationTimestamp=%s,", FORMAT_TIMESTAMP(i.dest)); printf(" DestinationTimestamp=%s,", FORMAT_TIMESTAMP(i.dest));
printf(" Ignored=%s PacketCount=%" PRIu64 ",", printf(" Ignored=%s, PacketCount=%" PRIu64 ",",
yes_no(i.spike), i.packet_count); yes_no(i.spike), i.packet_count);
printf(" Jitter=%s }\n", FORMAT_TIMESPAN(i.jitter, 0)); printf(" Jitter=%s }\n", FORMAT_TIMESPAN(i.jitter, 0));

View File

@ -21,7 +21,6 @@ test_append_files() {
instmods overlay =overlayfs instmods overlay =overlayfs
install_dmevent install_dmevent
generate_module_dependencies generate_module_dependencies
inst_binary losetup
inst_binary mksquashfs inst_binary mksquashfs
inst_binary unsquashfs inst_binary unsquashfs
install_verity_minimal install_verity_minimal

View File

@ -27,7 +27,6 @@ test_append_files() {
instmods overlay =overlayfs instmods overlay =overlayfs
install_dmevent install_dmevent
generate_module_dependencies generate_module_dependencies
inst_binary losetup
inst_binary wc inst_binary wc
if command -v openssl >/dev/null 2>&1; then if command -v openssl >/dev/null 2>&1; then
inst_binary openssl inst_binary openssl

View File

@ -7,4 +7,16 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/17433"
# shellcheck source=test/test-functions # shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions" . "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
(
# Collecting coverage slows this particular test quite a bit, causing
# it to fail with the default settings (20 triggers per 2 secs)
# to trip over the default limit. Let's help it a bit in such case.
if get_bool "$IS_BUILT_WITH_COVERAGE"; then
mkdir -p "${initdir:?}/etc/systemd/system/test63.path.d"
printf "[Path]\nTriggerLimitIntervalSec=10\n" >"${initdir:?}/etc/systemd/system/test63.path.d/coverage-override.conf"
fi
)
}
do_test "$@" do_test "$@"

View File

@ -15,7 +15,6 @@ test_append_files() {(
instmods loop =block instmods loop =block
instmods dm_integrity =md instmods dm_integrity =md
inst_binary losetup
inst_binary integritysetup inst_binary integritysetup
inst_binary blkid inst_binary blkid
install_dmevent install_dmevent

View File

@ -154,6 +154,7 @@ BASICTOOLS=(
ln ln
loadkeys loadkeys
login login
losetup
lz4cat lz4cat
mkfifo mkfifo
mktemp mktemp

View File

@ -116,6 +116,25 @@ grep -qxF '/var/tmp/testsuite-58.3.img3 : start= 3662944, size= 17308536,
rm /var/tmp/testsuite-58.3.img /tmp/testsuite-58.3.dump rm /var/tmp/testsuite-58.3.img /tmp/testsuite-58.3.dump
rm -r /tmp/testsuite-58.3-defs/ rm -r /tmp/testsuite-58.3-defs/
# testcase for #21817
mkdir -p /tmp/testsuite-58-issue-21817-defs/
truncate -s 100m /tmp/testsuite-58-issue-21817.img
LOOP=$(losetup -P --show -f /tmp/testsuite-58-issue-21817.img)
printf 'size=50M,type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709\n,\n' | sfdisk -X gpt /tmp/testsuite-58-issue-21817.img
cat >/tmp/testsuite-58-issue-21817-defs/test.conf <<EOF
[Partition]
Type=root
EOF
systemd-repart --pretty=yes --definitions /tmp/testsuite-58-issue-21817-defs/ "$LOOP"
sfdisk --dump "$LOOP" | tee /tmp/testsuite-58-issue-21817.dump
losetup -d "$LOOP"
grep -qF 'p1 : start= 2048, size= 102400, type=4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709,' /tmp/testsuite-58-issue-21817.dump
grep -qF 'p2 : start= 104448, size= 100319,' /tmp/testsuite-58-issue-21817.dump
rm /tmp/testsuite-58-issue-21817.img /tmp/testsuite-58-issue-21817.dump
rm -r /tmp/testsuite-58-issue-21817-defs/
echo OK >/testok echo OK >/testok
exit 0 exit 0