Compare commits
No commits in common. "c8" and "imports/c8s/systemd-239-73.el8" have entirely different histories.
c8
...
imports/c8
@ -1,38 +0,0 @@
|
||||
From 0491902d0eff9f4480ce873decc5dd29e5e189d7 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Mon, 13 Mar 2023 14:22:28 +0100
|
||||
Subject: [PATCH] journald-server: always create state file in signal handler
|
||||
|
||||
`journalctl --flush` waits on that file, so we must create if even if
|
||||
nothing has really happened.
|
||||
|
||||
RHEL-only
|
||||
|
||||
Resolves: #2176892
|
||||
---
|
||||
src/journal/journald-server.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
|
||||
index 279a32768c..c72cb68095 100644
|
||||
--- a/src/journal/journald-server.c
|
||||
+++ b/src/journal/journald-server.c
|
||||
@@ -1188,6 +1188,7 @@ int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void
|
||||
|
||||
static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
|
||||
Server *s = userdata;
|
||||
+ int r;
|
||||
|
||||
assert(s);
|
||||
|
||||
@@ -1197,6 +1198,10 @@ static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *
|
||||
server_sync(s);
|
||||
server_vacuum(s, false);
|
||||
|
||||
+ r = touch("/run/systemd/journal/flushed");
|
||||
+ if (r < 0)
|
||||
+ log_warning_errno(r, "Failed to touch /run/systemd/journal/flushed, ignoring: %m");
|
||||
+
|
||||
server_space_usage_message(s, NULL);
|
||||
return 0;
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
From 62c8e07498c9dd13aa79371fc169bb51652ef3a9 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Mon, 13 Mar 2023 14:31:38 +0100
|
||||
Subject: [PATCH] journald-server: move relinquish code into function
|
||||
|
||||
No functional change, just refactoring.
|
||||
|
||||
RHEL-only
|
||||
|
||||
Related: #2176892
|
||||
---
|
||||
src/journal/journald-server.c | 23 ++++++++++++++++-------
|
||||
1 file changed, 16 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
|
||||
index c72cb68095..aa70db95cc 100644
|
||||
--- a/src/journal/journald-server.c
|
||||
+++ b/src/journal/journald-server.c
|
||||
@@ -1258,20 +1258,16 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo
|
||||
return 0;
|
||||
}
|
||||
|
||||
-
|
||||
-static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
|
||||
- Server *s = userdata;
|
||||
+static void relinquish_var(Server *s) {
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
||||
if (s->storage == STORAGE_NONE)
|
||||
- return 0;
|
||||
+ return;
|
||||
|
||||
if (s->runtime_journal && !s->system_journal)
|
||||
- return 0;
|
||||
-
|
||||
- log_debug("Received request to relinquish /var from PID " PID_FMT, si->ssi_pid);
|
||||
+ return;
|
||||
|
||||
(void) system_journal_open(s, false, true);
|
||||
|
||||
@@ -1286,6 +1282,19 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
|
||||
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
|
||||
+ Server *s = userdata;
|
||||
+
|
||||
+ assert(s);
|
||||
+ assert(si);
|
||||
+
|
||||
+ log_debug("Received request to relinquish /var from PID " PID_FMT, si->ssi_pid);
|
||||
+
|
||||
+ relinquish_var(s);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
From 05a06e34ac8a38c1cff2a08ba071386141e0b78d Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Mon, 13 Mar 2023 14:32:20 +0100
|
||||
Subject: [PATCH] journald-server: always touch state file in signal handler
|
||||
|
||||
`journalctl --relinquish-var` waits on that file, so we must create if
|
||||
even if nothing has really happened.
|
||||
|
||||
RHEL-only
|
||||
|
||||
Related: #2176892
|
||||
---
|
||||
src/journal/journald-server.c | 12 +++++++-----
|
||||
1 file changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
|
||||
index aa70db95cc..4788ff78bb 100644
|
||||
--- a/src/journal/journald-server.c
|
||||
+++ b/src/journal/journald-server.c
|
||||
@@ -1259,8 +1259,6 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo
|
||||
}
|
||||
|
||||
static void relinquish_var(Server *s) {
|
||||
- int r;
|
||||
-
|
||||
assert(s);
|
||||
|
||||
if (s->storage == STORAGE_NONE)
|
||||
@@ -1278,15 +1276,15 @@ static void relinquish_var(Server *s) {
|
||||
if (unlink("/run/systemd/journal/flushed") < 0 && errno != ENOENT)
|
||||
log_warning_errno(errno, "Failed to unlink /run/systemd/journal/flushed, ignoring: %m") ;
|
||||
|
||||
- r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC));
|
||||
- if (r < 0)
|
||||
- log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
|
||||
+ /* NOTE: We don't create our own state file here, because dispatch_sigrtmin2() has to do it anyway.
|
||||
+ * But if this function is ever called from another place, the creation must be done here too. */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
|
||||
Server *s = userdata;
|
||||
+ int r;
|
||||
|
||||
assert(s);
|
||||
assert(si);
|
||||
@@ -1295,6 +1293,10 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo
|
||||
|
||||
relinquish_var(s);
|
||||
|
||||
+ r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC));
|
||||
+ if (r < 0)
|
||||
+ log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,299 +0,0 @@
|
||||
From 96e69cb655c703d5312c4aa44912e6ce90b4f76f Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <fsumsal@redhat.com>
|
||||
Date: Wed, 29 Mar 2023 22:38:55 +0200
|
||||
Subject: [PATCH] test: make TEST-35-LOGIN stable again
|
||||
|
||||
The expect stuff was anything but expected, so let's just backport
|
||||
the upstream test case and tweak it a bit to account for the missing
|
||||
parts in our downstream testing infrastructure.
|
||||
|
||||
Follow-up to 638c2418e7.
|
||||
Related: #2179309
|
||||
rhel-only
|
||||
---
|
||||
test/TEST-35-LOGIN/testsuite.sh | 225 ++++++++++++++++++++++++--------
|
||||
test/test-functions | 2 +-
|
||||
2 files changed, 175 insertions(+), 52 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-35-LOGIN/testsuite.sh b/test/TEST-35-LOGIN/testsuite.sh
|
||||
index e4d72beb74..149b2354a1 100755
|
||||
--- a/test/TEST-35-LOGIN/testsuite.sh
|
||||
+++ b/test/TEST-35-LOGIN/testsuite.sh
|
||||
@@ -3,6 +3,141 @@
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
+cleanup_test_user() (
|
||||
+ set +ex
|
||||
+
|
||||
+ pkill -u "$(id -u logind-test-user)"
|
||||
+ sleep 1
|
||||
+ pkill -KILL -u "$(id -u logind-test-user)"
|
||||
+ userdel -r logind-test-user
|
||||
+
|
||||
+ return 0
|
||||
+)
|
||||
+
|
||||
+setup_test_user() {
|
||||
+ mkdir -p /var/spool/cron /var/spool/mail /var/run/console
|
||||
+ useradd -m -s /bin/bash logind-test-user
|
||||
+ trap cleanup_test_user EXIT
|
||||
+}
|
||||
+
|
||||
+test_enable_debug() {
|
||||
+ mkdir -p /run/systemd/system/systemd-logind.service.d
|
||||
+ cat >/run/systemd/system/systemd-logind.service.d/debug.conf <<EOF
|
||||
+[Service]
|
||||
+Environment=SYSTEMD_LOG_LEVEL=debug
|
||||
+EOF
|
||||
+ systemctl daemon-reload
|
||||
+ systemctl stop systemd-logind.service
|
||||
+}
|
||||
+
|
||||
+check_session() (
|
||||
+ set +ex
|
||||
+
|
||||
+ local seat session leader_pid
|
||||
+
|
||||
+ if [[ $(loginctl --no-legend | grep -c "logind-test-user") != 1 ]]; then
|
||||
+ echo "no session or multiple sessions for logind-test-user." >&2
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ seat=$(loginctl --no-legend | grep 'logind-test-user *seat' | awk '{ print $4 }')
|
||||
+ if [[ -z "$seat" ]]; then
|
||||
+ echo "no seat found for user logind-test-user" >&2
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ session=$(loginctl --no-legend | awk '$3 == "logind-test-user" { print $1 }')
|
||||
+ if [[ -z "$session" ]]; then
|
||||
+ echo "no session found for user logind-test-user" >&2
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ if ! loginctl session-status "$session" | grep -q "Unit: session-${session}\.scope"; then
|
||||
+ echo "cannot find scope unit for session $session" >&2
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ leader_pid=$(loginctl session-status "$session" | awk '$1 == "Leader:" { print $2 }')
|
||||
+ if [[ -z "$leader_pid" ]]; then
|
||||
+ echo "cannot found leader process for session $session" >&2
|
||||
+ return 1
|
||||
+ fi
|
||||
+
|
||||
+ # cgroup v1: "1:name=systemd:/user.slice/..."; unified hierarchy: "0::/user.slice"
|
||||
+ if ! grep -q -E '(name=systemd|^0:):.*session.*scope' /proc/"$leader_pid"/cgroup; then
|
||||
+ echo "FAIL: process $leader_pid is not in the session cgroup" >&2
|
||||
+ cat /proc/self/cgroup
|
||||
+ return 1
|
||||
+ fi
|
||||
+)
|
||||
+
|
||||
+create_session() {
|
||||
+ # login with the test user to start a session
|
||||
+ mkdir -p /run/systemd/system/getty@tty2.service.d
|
||||
+ cat >/run/systemd/system/getty@tty2.service.d/override.conf <<EOF
|
||||
+[Service]
|
||||
+Type=simple
|
||||
+ExecStart=
|
||||
+ExecStart=-/sbin/agetty --autologin logind-test-user --noclear %I $TERM
|
||||
+Restart=no
|
||||
+EOF
|
||||
+ systemctl daemon-reload
|
||||
+
|
||||
+ systemctl restart getty@tty2.service
|
||||
+
|
||||
+ # check session
|
||||
+ for ((i = 0; i < 30; i++)); do
|
||||
+ (( i != 0 )) && sleep 1
|
||||
+ check_session && break
|
||||
+ done
|
||||
+ check_session
|
||||
+ [[ "$(loginctl --no-legend | awk '$3=="logind-test-user" { print $5 }')" == "tty2" ]]
|
||||
+}
|
||||
+
|
||||
+cleanup_session() (
|
||||
+ set +ex
|
||||
+
|
||||
+ local uid s
|
||||
+
|
||||
+ uid=$(id -u logind-test-user)
|
||||
+
|
||||
+ loginctl disable-linger logind-test-user
|
||||
+
|
||||
+ systemctl stop getty@tty2.service
|
||||
+
|
||||
+ for s in $(loginctl --no-legend list-sessions | awk '$3 == "logind-test-user" { print $1 }'); do
|
||||
+ echo "INFO: stopping session $s"
|
||||
+ loginctl terminate-session "$s"
|
||||
+ done
|
||||
+
|
||||
+ loginctl terminate-user logind-test-user
|
||||
+
|
||||
+ if ! timeout 30 bash -c "while loginctl --no-legend | grep -q logind-test-user; do sleep 1; done"; then
|
||||
+ echo "WARNING: session for logind-test-user still active, ignoring."
|
||||
+ fi
|
||||
+
|
||||
+ pkill -u "$uid"
|
||||
+ sleep 1
|
||||
+ pkill -KILL -u "$uid"
|
||||
+
|
||||
+ if ! timeout 30 bash -c "while systemctl is-active --quiet user@${uid}.service; do sleep 1; done"; then
|
||||
+ echo "WARNING: user@${uid}.service is still active, ignoring."
|
||||
+ fi
|
||||
+
|
||||
+ if ! timeout 30 bash -c "while systemctl is-active --quiet user-runtime-dir@${uid}.service; do sleep 1; done"; then
|
||||
+ echo "WARNING: user-runtime-dir@${uid}.service is still active, ignoring."
|
||||
+ fi
|
||||
+
|
||||
+ if ! timeout 30 bash -c "while systemctl is-active --quiet user-${uid}.slice; do sleep 1; done"; then
|
||||
+ echo "WARNING: user-${uid}.slice is still active, ignoring."
|
||||
+ fi
|
||||
+
|
||||
+ rm -rf /run/systemd/system/getty@tty2.service.d
|
||||
+ systemctl daemon-reload
|
||||
+
|
||||
+ return 0
|
||||
+)
|
||||
+
|
||||
setup_idle_action_lock() {
|
||||
useradd testuser ||:
|
||||
|
||||
@@ -19,83 +154,71 @@ EOF
|
||||
Environment=SYSTEMD_LOG_LEVEL=debug
|
||||
EOF
|
||||
|
||||
+ systemd-analyze cat-config --no-pager systemd/logind.conf
|
||||
systemctl restart systemd-logind.service
|
||||
}
|
||||
|
||||
-teardown_idle_action_lock() {(
|
||||
- set +ex
|
||||
+teardown_lock_idle_action() (
|
||||
+ set +eux
|
||||
+
|
||||
rm -f /run/systemd/logind.conf.d/idle-action-lock.conf
|
||||
- rm -f /run/systemd/systemd-logind.service.d/debug.conf
|
||||
- pkill -9 -u "$(id -u testuser)"
|
||||
- userdel -r testuser
|
||||
systemctl restart systemd-logind.service
|
||||
-)}
|
||||
|
||||
-test_lock_idle_action() {
|
||||
- if ! command -v expect >/dev/null ; then
|
||||
- echo >&2 "expect not installed, skiping test ${FUNCNAME[0]}"
|
||||
- return 0
|
||||
- fi
|
||||
+ cleanup_session
|
||||
|
||||
- setup_idle_action_lock
|
||||
- trap teardown_idle_action_lock RETURN
|
||||
+ return 0
|
||||
+)
|
||||
|
||||
- if loginctl --no-legend | awk '{ print $3; }' | sort -u | grep -q testuser ; then
|
||||
- echo >&2 "Session of the \'testuser\' is already present."
|
||||
- return 1
|
||||
+test_lock_idle_action() {
|
||||
+ local ts
|
||||
+
|
||||
+ if [[ ! -c /dev/tty2 ]]; then
|
||||
+ echo "/dev/tty2 does not exist, skipping test ${FUNCNAME[0]}."
|
||||
+ return
|
||||
fi
|
||||
|
||||
- # IdleActionSec is set 1s but the accuracy of associated timer is 30s so we
|
||||
- # need to sleep in worst case for 31s to make sure timer elapsed. We sleep
|
||||
- # here for 35s to accomodate for any possible scheudling delays.
|
||||
- cat > /tmp/test.exp <<EOF
|
||||
-spawn systemd-run -G -t -p PAMName=login -p User=testuser bash
|
||||
-send "sleep 35\r"
|
||||
-send "echo foobar\r"
|
||||
-send "sleep 35\r"
|
||||
-send "exit\r"
|
||||
-interact
|
||||
-wait
|
||||
-EOF
|
||||
+ if loginctl --no-legend | grep -q logind-test-user; then
|
||||
+ echo >&2 "Session of the \'logind-test-user\' is already present."
|
||||
+ exit 1
|
||||
+ fi
|
||||
|
||||
- ts="$(date '+%H:%M:%S')"
|
||||
- busctl --match "type='signal',sender='org.freedesktop.login1',interface='org.freedesktop.login1.Session',member='Lock'" monitor > dbus.log &
|
||||
+ trap teardown_lock_idle_action RETURN
|
||||
|
||||
- expect /tmp/test.exp &
|
||||
+ create_session
|
||||
|
||||
- # Sleep a bit to give expect time to spawn systemd-run before we check for
|
||||
- # the presence of resulting session.
|
||||
- sleep 2
|
||||
- if [ "$(loginctl --no-legend | awk '{ print $3; }' | sort -u | grep -c testuser)" != 1 ] ; then
|
||||
- echo >&2 "\'testuser\' is expected to have exactly one session running."
|
||||
- return 1
|
||||
- fi
|
||||
+ ts="$(date '+%H:%M:%S')"
|
||||
|
||||
- wait %2
|
||||
- sleep 20
|
||||
- kill %1
|
||||
+ mkdir -p /run/systemd/logind.conf.d
|
||||
+ cat >/run/systemd/logind.conf.d/idle-action-lock.conf <<EOF
|
||||
+[Login]
|
||||
+IdleAction=lock
|
||||
+IdleActionSec=1s
|
||||
+EOF
|
||||
+ systemctl restart systemd-logind.service
|
||||
|
||||
- # We slept for 35s , in that interval all sessions should have become idle
|
||||
+ # Wait for 35s, in that interval all sessions should have become idle
|
||||
# and "Lock" signal should have been sent out. Then we wrote to tty to make
|
||||
# session active again and next we slept for another 35s so sessions have
|
||||
# become idle again. 'Lock' signal is sent out for each session, we have at
|
||||
# least one session, so minimum of 2 "Lock" signals must have been sent.
|
||||
- if [ "$(grep -c Member=Lock dbus.log)" -lt 2 ]; then
|
||||
- echo >&2 "Too few 'Lock' D-Bus signal sent, expected at least 2."
|
||||
- return 1
|
||||
- fi
|
||||
+ timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt 1 ]]; do sleep 1; done"
|
||||
+
|
||||
+ # Wakeup
|
||||
+ touch /dev/tty2
|
||||
+
|
||||
+ # Wait again
|
||||
+ timeout 35 bash -c "while [[ \"\$(journalctl -b -u systemd-logind.service --since=$ts | grep -c 'Sent message type=signal .* member=Lock')\" -lt 2 ]]; do sleep 1; done"
|
||||
|
||||
- journalctl -b -u systemd-logind.service --since="$ts" > logind.log
|
||||
- if [ "$(grep -c 'System idle. Doing lock operation.' logind.log)" -lt 2 ]; then
|
||||
+ if [[ "$(journalctl -b -u systemd-logind.service --since="$ts" | grep -c 'System idle. Doing lock operation.')" -lt 2 ]]; then
|
||||
echo >&2 "System haven't entered idle state at least 2 times."
|
||||
- return 1
|
||||
+ exit 1
|
||||
fi
|
||||
-
|
||||
- rm -f dbus.log logind.log
|
||||
}
|
||||
|
||||
: >/failed
|
||||
|
||||
+setup_test_user
|
||||
+test_enable_debug
|
||||
test_lock_idle_action
|
||||
|
||||
touch /testok
|
||||
diff --git a/test/test-functions b/test/test-functions
|
||||
index 9606a1b085..e5d4d28a5f 100644
|
||||
--- a/test/test-functions
|
||||
+++ b/test/test-functions
|
||||
@@ -23,7 +23,7 @@ fi
|
||||
|
||||
PATH_TO_INIT=$ROOTLIBDIR/systemd
|
||||
|
||||
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel"
|
||||
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout"
|
||||
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
|
||||
|
||||
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
|
@ -1,113 +0,0 @@
|
||||
From c971d99ffc43df89ca4e15cd81f9e44f4139ba91 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 31 Aug 2020 19:37:13 +0200
|
||||
Subject: [PATCH] pager: set $LESSSECURE whenver we invoke a pager
|
||||
|
||||
Some extra safety when invoked via "sudo". With this we address a
|
||||
genuine design flaw of sudo, and we shouldn't need to deal with this.
|
||||
But it's still a good idea to disable this surface given how exotic it
|
||||
is.
|
||||
|
||||
Prompted by #5666
|
||||
|
||||
(cherry picked from commit 612ebf6c913dd0e4197c44909cb3157f5c51a2f0)
|
||||
|
||||
Related: #2175624
|
||||
---
|
||||
man/less-variables.xml | 8 ++++++++
|
||||
man/systemctl.xml | 1 +
|
||||
man/systemd.xml | 2 ++
|
||||
src/basic/pager.c | 23 +++++++++++++++++++++--
|
||||
4 files changed, 32 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/man/less-variables.xml b/man/less-variables.xml
|
||||
index a3faa38997..9dad4247da 100644
|
||||
--- a/man/less-variables.xml
|
||||
+++ b/man/less-variables.xml
|
||||
@@ -36,5 +36,13 @@
|
||||
the invoking terminal is determined to be UTF-8 compatible).</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
+ <varlistentry id='lesssecure'>
|
||||
+ <term><varname>$SYSTEMD_LESSSECURE</varname></term>
|
||||
+
|
||||
+ <listitem><para>Takes a boolean argument. Overrides the <varname>$LESSSECURE</varname> environment
|
||||
+ variable when invoking the pager, which controls the "secure" mode of less (which disables commands
|
||||
+ such as <literal>|</literal> which allow to easily shell out to external command lines). By default
|
||||
+ less secure mode is enabled, with this setting it may be disabled.</para></listitem>
|
||||
+ </varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
diff --git a/man/systemctl.xml b/man/systemctl.xml
|
||||
index a71e6c7c4f..abc386e6fb 100644
|
||||
--- a/man/systemctl.xml
|
||||
+++ b/man/systemctl.xml
|
||||
@@ -2010,6 +2010,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
|
||||
<xi:include href="less-variables.xml" xpointer="pager"/>
|
||||
<xi:include href="less-variables.xml" xpointer="less"/>
|
||||
<xi:include href="less-variables.xml" xpointer="lesscharset"/>
|
||||
+ <xi:include href="less-variables.xml" xpointer="lesssecure"/>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
diff --git a/man/systemd.xml b/man/systemd.xml
|
||||
index 17ab59beb5..66ae4d841d 100644
|
||||
--- a/man/systemd.xml
|
||||
+++ b/man/systemd.xml
|
||||
@@ -862,6 +862,8 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
+ <xi:include href="less-variables.xml" xpointer="lesssecure"/>
|
||||
+
|
||||
<varlistentry>
|
||||
<term><varname>$LISTEN_PID</varname></term>
|
||||
<term><varname>$LISTEN_FDS</varname></term>
|
||||
diff --git a/src/basic/pager.c b/src/basic/pager.c
|
||||
index f241261119..4efb01c483 100644
|
||||
--- a/src/basic/pager.c
|
||||
+++ b/src/basic/pager.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "copy.h"
|
||||
+#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "locale-util.h"
|
||||
#include "log.h"
|
||||
@@ -94,8 +95,7 @@ int pager_open(bool no_pager, bool jump_to_end) {
|
||||
if (setenv("LESS", less_opts, 1) < 0)
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
- /* Initialize a good charset for less. This is
|
||||
- * particularly important if we output UTF-8
|
||||
+ /* Initialize a good charset for less. This is particularly important if we output UTF-8
|
||||
* characters. */
|
||||
less_charset = getenv("SYSTEMD_LESSCHARSET");
|
||||
if (!less_charset && is_locale_utf8())
|
||||
@@ -104,6 +104,25 @@ int pager_open(bool no_pager, bool jump_to_end) {
|
||||
setenv("LESSCHARSET", less_charset, 1) < 0)
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
+ /* People might invoke us from sudo, don't needlessly allow less to be a way to shell out
|
||||
+ * privileged stuff. */
|
||||
+ r = getenv_bool("SYSTEMD_LESSSECURE");
|
||||
+ if (r == 0) { /* Remove env var if off */
|
||||
+ if (unsetenv("LESSSECURE") < 0) {
|
||||
+ log_error_errno(errno, "Failed to uset environment variable LESSSECURE: %m");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* Set env var otherwise */
|
||||
+ if (r < 0)
|
||||
+ log_warning_errno(r, "Unable to parse $SYSTEMD_LESSSECURE, ignoring: %m");
|
||||
+
|
||||
+ if (setenv("LESSSECURE", "1", 1) < 0) {
|
||||
+ log_error_errno(errno, "Failed to set environment variable LESSSECURE: %m");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (pager) {
|
||||
execlp(pager, pager, NULL);
|
||||
execl("/bin/sh", "sh", "-c", pager, NULL);
|
@ -1,264 +0,0 @@
|
||||
From a45636228c7000aef000e45d9853585e51bfb9ef Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Mon, 12 Oct 2020 18:57:32 +0200
|
||||
Subject: [PATCH] test-login: always test sd_pid_get_owner_uid(), modernize
|
||||
|
||||
A long time some function only worked when in a session, and the test
|
||||
didn't execute them when sd_pid_get_session() failed. Let's always call
|
||||
them to increase coverage.
|
||||
|
||||
While at it, let's test for ==0 not >=0 where we don't expect the function
|
||||
to return anything except 0 or error.
|
||||
|
||||
(cherry picked from commit 1b5b507cd2d1d7a2b053151abb548475ad9c5c3b)
|
||||
|
||||
Related: #2175624
|
||||
---
|
||||
src/libsystemd/sd-login/test-login.c | 132 ++++++++++++++-------------
|
||||
1 file changed, 71 insertions(+), 61 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
|
||||
index ccb1905a46..60ef889ec0 100644
|
||||
--- a/src/libsystemd/sd-login/test-login.c
|
||||
+++ b/src/libsystemd/sd-login/test-login.c
|
||||
@@ -8,20 +8,22 @@
|
||||
#include "sd-login.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
+#include "errno-list.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "log.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
-#include "util.h"
|
||||
+#include "time-util.h"
|
||||
+#include "user-util.h"
|
||||
|
||||
static char* format_uids(char **buf, uid_t* uids, int count) {
|
||||
- int pos = 0, k, inc;
|
||||
+ int pos = 0, inc;
|
||||
size_t size = (DECIMAL_STR_MAX(uid_t) + 1) * count + 1;
|
||||
|
||||
assert_se(*buf = malloc(size));
|
||||
|
||||
- for (k = 0; k < count; k++) {
|
||||
+ for (int k = 0; k < count; k++) {
|
||||
sprintf(*buf + pos, "%s"UID_FMT"%n", k > 0 ? " " : "", uids[k], &inc);
|
||||
pos += inc;
|
||||
}
|
||||
@@ -32,6 +34,10 @@ static char* format_uids(char **buf, uid_t* uids, int count) {
|
||||
return *buf;
|
||||
}
|
||||
|
||||
+static const char *e(int r) {
|
||||
+ return r == 0 ? "OK" : errno_to_name(r);
|
||||
+}
|
||||
+
|
||||
static void test_login(void) {
|
||||
_cleanup_close_pair_ int pair[2] = { -1, -1 };
|
||||
_cleanup_free_ char *pp = NULL, *qq = NULL,
|
||||
@@ -41,65 +47,71 @@ static void test_login(void) {
|
||||
*seat = NULL, *session = NULL,
|
||||
*unit = NULL, *user_unit = NULL, *slice = NULL;
|
||||
int r;
|
||||
- uid_t u, u2;
|
||||
- char *t, **seats, **sessions;
|
||||
+ uid_t u, u2 = UID_INVALID;
|
||||
+ char *t, **seats = NULL, **sessions = NULL;
|
||||
|
||||
r = sd_pid_get_unit(0, &unit);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_pid_get_unit(0, …) → \"%s\"", strna(unit));
|
||||
+ log_info("sd_pid_get_unit(0, …) → %s / \"%s\"", e(r), strnull(unit));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
|
||||
r = sd_pid_get_user_unit(0, &user_unit);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_pid_get_user_unit(0, …) → \"%s\"", strna(user_unit));
|
||||
+ log_info("sd_pid_get_user_unit(0, …) → %s / \"%s\"", e(r), strnull(user_unit));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
|
||||
r = sd_pid_get_slice(0, &slice);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_pid_get_slice(0, …) → \"%s\"", strna(slice));
|
||||
+ log_info("sd_pid_get_slice(0, …) → %s / \"%s\"", e(r), strnull(slice));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+
|
||||
+ r = sd_pid_get_owner_uid(0, &u2);
|
||||
+ log_info("sd_pid_get_owner_uid(0, …) → %s / "UID_FMT, e(r), u2);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
|
||||
r = sd_pid_get_session(0, &session);
|
||||
- if (r < 0) {
|
||||
- log_warning_errno(r, "sd_pid_get_session(0, …): %m");
|
||||
- if (r == -ENODATA)
|
||||
- log_info("Seems we are not running in a session, skipping some tests.");
|
||||
- } else {
|
||||
- log_info("sd_pid_get_session(0, …) → \"%s\"", session);
|
||||
-
|
||||
- assert_se(sd_pid_get_owner_uid(0, &u2) == 0);
|
||||
- log_info("sd_pid_get_owner_uid(0, …) → "UID_FMT, u2);
|
||||
-
|
||||
- assert_se(sd_pid_get_cgroup(0, &cgroup) == 0);
|
||||
- log_info("sd_pid_get_cgroup(0, …) → \"%s\"", cgroup);
|
||||
-
|
||||
- r = sd_uid_get_display(u2, &display_session);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_uid_get_display("UID_FMT", …) → \"%s\"",
|
||||
- u2, strnull(display_session));
|
||||
-
|
||||
- assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0);
|
||||
- sd_peer_get_session(pair[0], &pp);
|
||||
- sd_peer_get_session(pair[1], &qq);
|
||||
- assert_se(streq_ptr(pp, qq));
|
||||
-
|
||||
- r = sd_uid_get_sessions(u2, false, &sessions);
|
||||
+ log_info("sd_pid_get_session(0, …) → %s / \"%s\"", e(r), strnull(session));
|
||||
+
|
||||
+ r = sd_pid_get_cgroup(0, &cgroup);
|
||||
+ log_info("sd_pid_get_cgroup(0, …) → %s / \"%s\"", e(r), strnull(cgroup));
|
||||
+ assert_se(r == 0);
|
||||
+
|
||||
+ r = sd_uid_get_display(u2, &display_session);
|
||||
+ log_info("sd_uid_get_display("UID_FMT", …) → %s / \"%s\"", u2, e(r), strnull(display_session));
|
||||
+ if (u2 == UID_INVALID)
|
||||
+ assert_se(r == -EINVAL);
|
||||
+ else
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+
|
||||
+ assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0);
|
||||
+ sd_peer_get_session(pair[0], &pp);
|
||||
+ sd_peer_get_session(pair[1], &qq);
|
||||
+ assert_se(streq_ptr(pp, qq));
|
||||
+
|
||||
+ r = sd_uid_get_sessions(u2, false, &sessions);
|
||||
+ assert_se(t = strv_join(sessions, " "));
|
||||
+ log_info("sd_uid_get_sessions("UID_FMT", …) → %s \"%s\"", u2, e(r), t);
|
||||
+ if (u2 == UID_INVALID)
|
||||
+ assert_se(r == -EINVAL);
|
||||
+ else {
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == (int) strv_length(sessions));
|
||||
- assert_se(t = strv_join(sessions, " "));
|
||||
- strv_free(sessions);
|
||||
- log_info("sd_uid_get_sessions("UID_FMT", …) → [%i] \"%s\"", u2, r, t);
|
||||
- free(t);
|
||||
+ }
|
||||
+ sessions = strv_free(sessions);
|
||||
+ free(t);
|
||||
|
||||
- assert_se(r == sd_uid_get_sessions(u2, false, NULL));
|
||||
+ assert_se(r == sd_uid_get_sessions(u2, false, NULL));
|
||||
|
||||
- r = sd_uid_get_seats(u2, false, &seats);
|
||||
+ r = sd_uid_get_seats(u2, false, &seats);
|
||||
+ assert_se(t = strv_join(seats, " "));
|
||||
+ log_info("sd_uid_get_seats("UID_FMT", …) → %s \"%s\"", u2, e(r), t);
|
||||
+ if (u2 == UID_INVALID)
|
||||
+ assert_se(r == -EINVAL);
|
||||
+ else {
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == (int) strv_length(seats));
|
||||
- assert_se(t = strv_join(seats, " "));
|
||||
- strv_free(seats);
|
||||
- log_info("sd_uid_get_seats("UID_FMT", …) → [%i] \"%s\"", u2, r, t);
|
||||
- free(t);
|
||||
-
|
||||
- assert_se(r == sd_uid_get_seats(u2, false, NULL));
|
||||
}
|
||||
+ seats = strv_free(seats);
|
||||
+ free(t);
|
||||
+
|
||||
+ assert_se(r == sd_uid_get_seats(u2, false, NULL));
|
||||
|
||||
if (session) {
|
||||
r = sd_session_is_active(session);
|
||||
@@ -111,7 +123,7 @@ static void test_login(void) {
|
||||
log_info("sd_session_is_remote(\"%s\") → %s", session, yes_no(r));
|
||||
|
||||
r = sd_session_get_state(session, &state);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(r == 0);
|
||||
log_info("sd_session_get_state(\"%s\") → \"%s\"", session, state);
|
||||
|
||||
assert_se(sd_session_get_uid(session, &u) >= 0);
|
||||
@@ -125,16 +137,16 @@ static void test_login(void) {
|
||||
log_info("sd_session_get_class(\"%s\") → \"%s\"", session, class);
|
||||
|
||||
r = sd_session_get_display(session, &display);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
log_info("sd_session_get_display(\"%s\") → \"%s\"", session, strna(display));
|
||||
|
||||
r = sd_session_get_remote_user(session, &remote_user);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
log_info("sd_session_get_remote_user(\"%s\") → \"%s\"",
|
||||
session, strna(remote_user));
|
||||
|
||||
r = sd_session_get_remote_host(session, &remote_host);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
log_info("sd_session_get_remote_host(\"%s\") → \"%s\"",
|
||||
session, strna(remote_host));
|
||||
|
||||
@@ -160,7 +172,7 @@ static void test_login(void) {
|
||||
assert_se(r == -ENODATA);
|
||||
}
|
||||
|
||||
- assert_se(sd_uid_get_state(u, &state2) >= 0);
|
||||
+ assert_se(sd_uid_get_state(u, &state2) == 0);
|
||||
log_info("sd_uid_get_state("UID_FMT", …) → %s", u, state2);
|
||||
}
|
||||
|
||||
@@ -172,11 +184,11 @@ static void test_login(void) {
|
||||
assert_se(sd_uid_is_on_seat(u, 0, seat) > 0);
|
||||
|
||||
r = sd_seat_get_active(seat, &session2, &u2);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(r == 0);
|
||||
log_info("sd_seat_get_active(\"%s\", …) → \"%s\", "UID_FMT, seat, session2, u2);
|
||||
|
||||
r = sd_uid_is_on_seat(u, 1, seat);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(IN_SET(r, 0, 1));
|
||||
assert_se(!!r == streq(session, session2));
|
||||
|
||||
r = sd_seat_get_sessions(seat, &sessions, &uids, &n);
|
||||
@@ -184,8 +196,8 @@ static void test_login(void) {
|
||||
assert_se(r == (int) strv_length(sessions));
|
||||
assert_se(t = strv_join(sessions, " "));
|
||||
strv_free(sessions);
|
||||
- log_info("sd_seat_get_sessions(\"%s\", …) → %i, \"%s\", [%i] {%s}",
|
||||
- seat, r, t, n, format_uids(&buf, uids, n));
|
||||
+ log_info("sd_seat_get_sessions(\"%s\", …) → %s, \"%s\", [%u] {%s}",
|
||||
+ seat, e(r), t, n, format_uids(&buf, uids, n));
|
||||
free(t);
|
||||
|
||||
assert_se(sd_seat_get_sessions(seat, NULL, NULL, NULL) == r);
|
||||
@@ -203,7 +215,7 @@ static void test_login(void) {
|
||||
|
||||
r = sd_seat_get_active(NULL, &t, NULL);
|
||||
assert_se(IN_SET(r, 0, -ENODATA));
|
||||
- log_info("sd_seat_get_active(NULL, …) (active session on current seat) → %s", strnull(t));
|
||||
+ log_info("sd_seat_get_active(NULL, …) (active session on current seat) → %s / \"%s\"", e(r), strnull(t));
|
||||
free(t);
|
||||
|
||||
r = sd_get_sessions(&sessions);
|
||||
@@ -243,13 +255,11 @@ static void test_login(void) {
|
||||
|
||||
static void test_monitor(void) {
|
||||
sd_login_monitor *m = NULL;
|
||||
- unsigned n;
|
||||
int r;
|
||||
|
||||
- r = sd_login_monitor_new("session", &m);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(sd_login_monitor_new("session", &m) == 0);
|
||||
|
||||
- for (n = 0; n < 5; n++) {
|
||||
+ for (unsigned n = 0; n < 5; n++) {
|
||||
struct pollfd pollfd = {};
|
||||
usec_t timeout, nw;
|
||||
|
@ -1,198 +0,0 @@
|
||||
From 7955f053c498a70616ac6c4d57c0fd47dfa8e5ac Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Wed, 7 Oct 2020 11:15:05 +0200
|
||||
Subject: [PATCH] pager: make pager secure when under euid is changed or
|
||||
explicitly requested
|
||||
|
||||
The variable is renamed to SYSTEMD_PAGERSECURE (because it's not just about
|
||||
less now), and we automatically enable secure mode in certain cases, but not
|
||||
otherwise.
|
||||
|
||||
This approach is more nuanced, but should provide a better experience for
|
||||
users:
|
||||
|
||||
- Previusly we would set LESSSECURE=1 and trust the pager to make use of
|
||||
it. But this has an effect only on less. We need to not start pagers which
|
||||
are insecure when in secure mode. In particular more is like that and is a
|
||||
very popular pager.
|
||||
|
||||
- We don't enable secure mode always, which means that those other pagers can
|
||||
reasonably used.
|
||||
|
||||
- We do the right thing by default, but the user has ultimate control by
|
||||
setting SYSTEMD_PAGERSECURE.
|
||||
|
||||
Fixes #5666.
|
||||
|
||||
v2:
|
||||
- also check $PKEXEC_UID
|
||||
|
||||
v3:
|
||||
- use 'sd_pid_get_owner_uid() != geteuid()' as the condition
|
||||
|
||||
(cherry picked from commit 0a42426d797406b4b01a0d9c13bb759c2629d108)
|
||||
|
||||
Resolves: #2175624
|
||||
---
|
||||
man/less-variables.xml | 28 ++++++++++++++---
|
||||
meson.build | 3 +-
|
||||
src/basic/pager.c | 69 +++++++++++++++++++++++++++---------------
|
||||
3 files changed, 69 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/man/less-variables.xml b/man/less-variables.xml
|
||||
index 9dad4247da..5f3a53c8dd 100644
|
||||
--- a/man/less-variables.xml
|
||||
+++ b/man/less-variables.xml
|
||||
@@ -37,12 +37,30 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='lesssecure'>
|
||||
- <term><varname>$SYSTEMD_LESSSECURE</varname></term>
|
||||
+ <term><varname>$SYSTEMD_PAGERSECURE</varname></term>
|
||||
|
||||
- <listitem><para>Takes a boolean argument. Overrides the <varname>$LESSSECURE</varname> environment
|
||||
- variable when invoking the pager, which controls the "secure" mode of less (which disables commands
|
||||
- such as <literal>|</literal> which allow to easily shell out to external command lines). By default
|
||||
- less secure mode is enabled, with this setting it may be disabled.</para></listitem>
|
||||
+ <listitem><para>Takes a boolean argument. When true, the "secure" mode of the pager is enabled; if
|
||||
+ false, disabled. If <varname>$SYSTEMD_PAGERSECURE</varname> is not set at all, secure mode is enabled
|
||||
+ if the effective UID is not the same as the owner of the login session, see <citerefentry
|
||||
+ project='man-pages'><refentrytitle>geteuid</refentrytitle><manvolnum>2</manvolnum></citerefentry> and
|
||||
+ <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
||||
+ In secure mode, <option>LESSSECURE=1</option> will be set when invoking the pager, and the pager shall
|
||||
+ disable commands that open or create new files or start new subprocesses. When
|
||||
+ <varname>$SYSTEMD_PAGERSECURE</varname> is not set at all, pagers which are not known to implement
|
||||
+ secure mode will not be used. (Currently only
|
||||
+ <citerefentry><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry> implements
|
||||
+ secure mode.)</para>
|
||||
+
|
||||
+ <para>Note: when commands are invoked with elevated privileges, for example under <citerefentry
|
||||
+ project='man-pages'><refentrytitle>sudo</refentrytitle><manvolnum>8</manvolnum></citerefentry> or
|
||||
+ <citerefentry
|
||||
+ project='die-net'><refentrytitle>pkexec</refentrytitle><manvolnum>1</manvolnum></citerefentry>, care
|
||||
+ must be taken to ensure that unintended interactive features are not enabled. "Secure" mode for the
|
||||
+ pager may be enabled automatically as describe above. Setting <varname>SYSTEMD_PAGERSECURE=0</varname>
|
||||
+ or not removing it from the inherited environment allows the user to invoke arbitrary commands. Note
|
||||
+ that if the <varname>$SYSTEMD_PAGER</varname> or <varname>$PAGER</varname> variables are to be
|
||||
+ honoured, <varname>$SYSTEMD_PAGERSECURE</varname> must be set too. It might be reasonable to completly
|
||||
+ disable the pager using <option>--no-pager</option> instead.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
diff --git a/meson.build b/meson.build
|
||||
index 673800a1a7..d986dd24ac 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -1467,7 +1467,8 @@ test_dlopen = executable(
|
||||
'test-dlopen',
|
||||
test_dlopen_c,
|
||||
include_directories : includes,
|
||||
- link_with : [libbasic],
|
||||
+ link_with : [libsystemd_static,
|
||||
+ libbasic],
|
||||
dependencies : [libdl])
|
||||
|
||||
foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
|
||||
diff --git a/src/basic/pager.c b/src/basic/pager.c
|
||||
index 4efb01c483..c7e101235d 100644
|
||||
--- a/src/basic/pager.c
|
||||
+++ b/src/basic/pager.c
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <sys/prctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+#include "sd-login.h"
|
||||
+
|
||||
#include "copy.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
@@ -79,7 +81,7 @@ int pager_open(bool no_pager, bool jump_to_end) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0) {
|
||||
- const char* less_opts, *less_charset;
|
||||
+ const char* less_opts, *less_charset, *exe;
|
||||
|
||||
/* In the child start the pager */
|
||||
|
||||
@@ -105,39 +107,56 @@ int pager_open(bool no_pager, bool jump_to_end) {
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
/* People might invoke us from sudo, don't needlessly allow less to be a way to shell out
|
||||
- * privileged stuff. */
|
||||
- r = getenv_bool("SYSTEMD_LESSSECURE");
|
||||
- if (r == 0) { /* Remove env var if off */
|
||||
- if (unsetenv("LESSSECURE") < 0) {
|
||||
- log_error_errno(errno, "Failed to uset environment variable LESSSECURE: %m");
|
||||
- _exit(EXIT_FAILURE);
|
||||
- }
|
||||
- } else {
|
||||
- /* Set env var otherwise */
|
||||
+ * privileged stuff. If the user set $SYSTEMD_PAGERSECURE, trust their configuration of the
|
||||
+ * pager. If they didn't, use secure mode when under euid is changed. If $SYSTEMD_PAGERSECURE
|
||||
+ * wasn't explicitly set, and we autodetect the need for secure mode, only use the pager we
|
||||
+ * know to be good. */
|
||||
+ int use_secure_mode = getenv_bool("SYSTEMD_PAGERSECURE");
|
||||
+ bool trust_pager = use_secure_mode >= 0;
|
||||
+ if (use_secure_mode == -ENXIO) {
|
||||
+ uid_t uid;
|
||||
+
|
||||
+ r = sd_pid_get_owner_uid(0, &uid);
|
||||
if (r < 0)
|
||||
- log_warning_errno(r, "Unable to parse $SYSTEMD_LESSSECURE, ignoring: %m");
|
||||
+ log_debug_errno(r, "sd_pid_get_owner_uid() failed, enabling pager secure mode: %m");
|
||||
+
|
||||
+ use_secure_mode = r < 0 || uid != geteuid();
|
||||
+
|
||||
+ } else if (use_secure_mode < 0) {
|
||||
+ log_warning_errno(use_secure_mode, "Unable to parse $SYSTEMD_PAGERSECURE, assuming true: %m");
|
||||
+ use_secure_mode = true;
|
||||
+ }
|
||||
|
||||
- if (setenv("LESSSECURE", "1", 1) < 0) {
|
||||
- log_error_errno(errno, "Failed to set environment variable LESSSECURE: %m");
|
||||
- _exit(EXIT_FAILURE);
|
||||
- }
|
||||
+ /* We generally always set variables used by less, even if we end up using a different pager.
|
||||
+ * They shouldn't hurt in any case, and ideally other pagers would look at them too. */
|
||||
+ if (use_secure_mode)
|
||||
+ r = setenv("LESSSECURE", "1", 1);
|
||||
+ else
|
||||
+ r = unsetenv("LESSSECURE");
|
||||
+ if (r < 0) {
|
||||
+ log_error_errno(errno, "Failed to adjust environment variable LESSSECURE: %m");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
- if (pager) {
|
||||
+ if (trust_pager && pager) { /* The pager config might be set globally, and we cannot
|
||||
+ * know if the user adjusted it to be appropriate for the
|
||||
+ * secure mode. Thus, start the pager specified through
|
||||
+ * envvars only when $SYSTEMD_PAGERSECURE was explicitly set
|
||||
+ * as well. */
|
||||
execlp(pager, pager, NULL);
|
||||
execl("/bin/sh", "sh", "-c", pager, NULL);
|
||||
}
|
||||
|
||||
- /* Debian's alternatives command for pagers is
|
||||
- * called 'pager'. Note that we do not call
|
||||
- * sensible-pagers here, since that is just a
|
||||
- * shell script that implements a logic that
|
||||
- * is similar to this one anyway, but is
|
||||
- * Debian-specific. */
|
||||
- execlp("pager", "pager", NULL);
|
||||
+ /* Debian's alternatives command for pagers is called 'pager'. Note that we do not call
|
||||
+ * sensible-pagers here, since that is just a shell script that implements a logic that is
|
||||
+ * similar to this one anyway, but is Debian-specific. */
|
||||
+ FOREACH_STRING(exe, "pager", "less", "more") {
|
||||
+ /* Only less implements secure mode right now. */
|
||||
+ if (use_secure_mode && !streq(exe, "less"))
|
||||
+ continue;
|
||||
|
||||
- execlp("less", "less", NULL);
|
||||
- execlp("more", "more", NULL);
|
||||
+ execlp(exe, exe, NULL);
|
||||
+ }
|
||||
|
||||
pager_fallback();
|
||||
/* not reached */
|
@ -1,49 +0,0 @@
|
||||
From c4c9126b1d64fbe77ef1a74b464646711ced8f83 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Thu, 30 Mar 2023 17:16:44 +0200
|
||||
Subject: [PATCH] ci: trigger differential-shellcheck workflow on push
|
||||
|
||||
Fixes: redhat-plumbers-in-action/differential-shellcheck#215
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/workflows/differential-shellcheck.yml | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/.github/workflows/differential-shellcheck.yml b/.github/workflows/differential-shellcheck.yml
|
||||
index 4399f0bc64..19634c07b3 100644
|
||||
--- a/.github/workflows/differential-shellcheck.yml
|
||||
+++ b/.github/workflows/differential-shellcheck.yml
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
name: Differential ShellCheck
|
||||
on:
|
||||
+ push:
|
||||
+ branches:
|
||||
+ - main
|
||||
+ - rhel-8.*.0
|
||||
pull_request:
|
||||
branches:
|
||||
- - master
|
||||
+ - main
|
||||
- rhel-8.*.0
|
||||
|
||||
permissions:
|
||||
@@ -18,7 +22,6 @@ jobs:
|
||||
|
||||
permissions:
|
||||
security-events: write
|
||||
- pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
@@ -27,6 +30,6 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Differential ShellCheck
|
||||
- uses: redhat-plumbers-in-action/differential-shellcheck@v3
|
||||
+ uses: redhat-plumbers-in-action/differential-shellcheck@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,34 +0,0 @@
|
||||
From 5e5c1425db0982c9d5e5d51e164895aa780f76b2 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Thu, 30 Mar 2023 17:18:17 +0200
|
||||
Subject: [PATCH] ci: codeql `master` -> `main`
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/workflows/codeql.yml | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
|
||||
index c5426d5686..cc4fcf4754 100644
|
||||
--- a/.github/workflows/codeql.yml
|
||||
+++ b/.github/workflows/codeql.yml
|
||||
@@ -7,7 +7,7 @@ name: "CodeQL"
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- - master
|
||||
+ - main
|
||||
- rhel-*
|
||||
paths:
|
||||
- '**/meson.build'
|
||||
@@ -17,7 +17,7 @@ on:
|
||||
- 'tools/**'
|
||||
push:
|
||||
branches:
|
||||
- - master
|
||||
+ - main
|
||||
- rhel-*
|
||||
|
||||
permissions:
|
@ -1,30 +0,0 @@
|
||||
From d9e2735b88513e3b3af9ab468f4d2ba0f6bec64d Mon Sep 17 00:00:00 2001
|
||||
From: Dan Streetman <ddstreet@canonical.com>
|
||||
Date: Fri, 23 Oct 2020 15:50:28 -0400
|
||||
Subject: [PATCH] test: ignore ENOMEDIUM error from sd_pid_get_cgroup()
|
||||
|
||||
Ubuntu builds on the Launchpad infrastructure run inside a chroot that does
|
||||
not have the sysfs cgroup dirs mounted, so this call will return ENOMEDIUM
|
||||
from cg_unified_cached() during the build-time testing, for example when
|
||||
building the package in a Launchpad PPA.
|
||||
|
||||
(cherry picked from commit 352ab9d74049b4ac694fdba1a6e67339f12ded93)
|
||||
|
||||
Resolves: #2175622
|
||||
---
|
||||
src/libsystemd/sd-login/test-login.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
|
||||
index 60ef889ec0..d24a04ccc8 100644
|
||||
--- a/src/libsystemd/sd-login/test-login.c
|
||||
+++ b/src/libsystemd/sd-login/test-login.c
|
||||
@@ -71,7 +71,7 @@ static void test_login(void) {
|
||||
|
||||
r = sd_pid_get_cgroup(0, &cgroup);
|
||||
log_info("sd_pid_get_cgroup(0, …) → %s / \"%s\"", e(r), strnull(cgroup));
|
||||
- assert_se(r == 0);
|
||||
+ assert_se(IN_SET(r, 0, -ENOMEDIUM));
|
||||
|
||||
r = sd_uid_get_display(u2, &display_session);
|
||||
log_info("sd_uid_get_display("UID_FMT", …) → %s / \"%s\"", u2, e(r), strnull(display_session));
|
@ -1,42 +0,0 @@
|
||||
From d0e8ca2dcc1467a9e28c569e0dc608e5426bae79 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 24 Apr 2023 15:25:02 +0200
|
||||
Subject: [PATCH] ci(Mergify): drop requirements on linting workflows
|
||||
|
||||
CodeQL and DifferentialShellCheck workflows aren't run for all PRs on all branches.
|
||||
This results in Mergify incorrectly labeling PRs with `needs-ci` label.
|
||||
Lets drop the requirements on these workflows.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.mergify.yml | 8 --------
|
||||
1 file changed, 8 deletions(-)
|
||||
|
||||
diff --git a/.mergify.yml b/.mergify.yml
|
||||
index a5eed6a82a..624eb7291d 100644
|
||||
--- a/.mergify.yml
|
||||
+++ b/.mergify.yml
|
||||
@@ -11,10 +11,6 @@ pull_request_rules:
|
||||
- -check-success=build (stream8, GCC_ASAN)
|
||||
# CentOS Stream CI
|
||||
- -check-success=CentOS CI (CentOS Stream 8)
|
||||
- # CodeQL
|
||||
- - -check-success=CodeQL
|
||||
- # Other
|
||||
- - -check-success=Differential ShellCheck
|
||||
actions:
|
||||
label:
|
||||
add:
|
||||
@@ -30,10 +26,6 @@ pull_request_rules:
|
||||
- check-success=build (stream8, GCC_ASAN)
|
||||
# CentOS Stream CI
|
||||
- check-success=CentOS CI (CentOS Stream 8)
|
||||
- # CodeQL
|
||||
- - check-success=CodeQL
|
||||
- # Other
|
||||
- - check-success=Differential ShellCheck
|
||||
actions:
|
||||
label:
|
||||
remove:
|
@ -1,51 +0,0 @@
|
||||
From a81ace51e1efa2313fcad18f2ef5c6c6cd167240 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 24 Apr 2023 15:13:08 +0200
|
||||
Subject: [PATCH] ci: workflow for gathering metadata for source-git automation
|
||||
|
||||
Workflow gathers metadata like pull request numbers and information about commits.
|
||||
This metadata is used for commit validation and other actions.
|
||||
This workflow also triggers for rest of the source-git automation workflows.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/workflows/gather-metadata.yml | 28 +++++++++++++++++++++++++++
|
||||
1 file changed, 28 insertions(+)
|
||||
create mode 100644 .github/workflows/gather-metadata.yml
|
||||
|
||||
diff --git a/.github/workflows/gather-metadata.yml b/.github/workflows/gather-metadata.yml
|
||||
new file mode 100644
|
||||
index 0000000000..f432f41811
|
||||
--- /dev/null
|
||||
+++ b/.github/workflows/gather-metadata.yml
|
||||
@@ -0,0 +1,28 @@
|
||||
+name: Gather Pull Request Metadata
|
||||
+on:
|
||||
+ pull_request:
|
||||
+ types: [ opened, reopened, synchronize ]
|
||||
+ branches:
|
||||
+ - main
|
||||
+ - rhel-8.*.0
|
||||
+
|
||||
+permissions:
|
||||
+ contents: read
|
||||
+
|
||||
+jobs:
|
||||
+ gather-metadata:
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ steps:
|
||||
+ - name: Repository checkout
|
||||
+ uses: actions/checkout@v3
|
||||
+
|
||||
+ - id: Metadata
|
||||
+ name: Gather Pull Request Metadata
|
||||
+ uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
|
||||
+
|
||||
+ - name: Upload artifact with gathered metadata
|
||||
+ uses: actions/upload-artifact@v3
|
||||
+ with:
|
||||
+ name: pr-metadata
|
||||
+ path: ${{ steps.Metadata.outputs.metadata-file }}
|
@ -1,103 +0,0 @@
|
||||
From 7e0eb456a99229d19b8e42491c1ddb7b8050903f Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 24 Apr 2023 15:15:00 +0200
|
||||
Subject: [PATCH] ci: first part of the source-git automation - commit linter
|
||||
|
||||
Add a GitHub Workflow that is triggered on `workflow_run` events.
|
||||
It uses metadata provided by `redhat-plumbers-in-action/gather-pull-request-metadata`
|
||||
GitHub Action to get the PR number and the commit metadata.
|
||||
The commit metadata is then used to check if the commit message contains
|
||||
all required information (tracker and upstream reference). GitHub Action
|
||||
responsible for commit verification `redhat-plumbers-in-action/advanced-commit-linter`
|
||||
is configured via the `advanced-commit-linter.yml` file.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/advanced-commit-linter.yml | 23 +++++++++++
|
||||
.github/workflows/source-git-automation.yml | 45 +++++++++++++++++++++
|
||||
2 files changed, 68 insertions(+)
|
||||
create mode 100644 .github/advanced-commit-linter.yml
|
||||
create mode 100644 .github/workflows/source-git-automation.yml
|
||||
|
||||
diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml
|
||||
new file mode 100644
|
||||
index 0000000000..491836abbb
|
||||
--- /dev/null
|
||||
+++ b/.github/advanced-commit-linter.yml
|
||||
@@ -0,0 +1,23 @@
|
||||
+policy:
|
||||
+ cherry-pick:
|
||||
+ upstream:
|
||||
+ - github: systemd/systemd
|
||||
+ - github: systemd/systemd-stable
|
||||
+ exception:
|
||||
+ note:
|
||||
+ - rhel-only
|
||||
+ tracker:
|
||||
+ - keyword:
|
||||
+ - 'Resolves: #?'
|
||||
+ - 'Related: #?'
|
||||
+ - 'Reverts: #?'
|
||||
+ issue-format:
|
||||
+ - '\d+$'
|
||||
+ url: 'https://bugzilla.redhat.com/show_bug.cgi?id='
|
||||
+ - keyword:
|
||||
+ - 'Resolves: '
|
||||
+ - 'Related: '
|
||||
+ - 'Reverts: '
|
||||
+ issue-format:
|
||||
+ - 'RHEL-\d+$'
|
||||
+ url: 'https://issues.redhat.com/browse/'
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
new file mode 100644
|
||||
index 0000000000..140f21b116
|
||||
--- /dev/null
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -0,0 +1,45 @@
|
||||
+name: Source git Automation
|
||||
+on:
|
||||
+ workflow_run:
|
||||
+ workflows: [ Gather Pull Request Metadata ]
|
||||
+ types:
|
||||
+ - completed
|
||||
+
|
||||
+permissions:
|
||||
+ contents: read
|
||||
+
|
||||
+jobs:
|
||||
+ download-metadata:
|
||||
+ if: >
|
||||
+ github.event.workflow_run.event == 'pull_request' &&
|
||||
+ github.event.workflow_run.conclusion == 'success'
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ outputs:
|
||||
+ pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }}
|
||||
+
|
||||
+ steps:
|
||||
+ - id: Artifact
|
||||
+ name: Download Artifact
|
||||
+ uses: redhat-plumbers-in-action/download-artifact@v1
|
||||
+ with:
|
||||
+ name: pr-metadata
|
||||
+
|
||||
+ commit-linter:
|
||||
+ needs: [ download-metadata ]
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ outputs:
|
||||
+ validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
|
||||
+
|
||||
+ permissions:
|
||||
+ statuses: write
|
||||
+ pull-requests: write
|
||||
+
|
||||
+ steps:
|
||||
+ - id: commit-linter
|
||||
+ name: Lint Commits
|
||||
+ uses: redhat-plumbers-in-action/advanced-commit-linter@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,31 +0,0 @@
|
||||
From f86a51500b5aa9288dbb2800e0a1f63ad863bd8f Mon Sep 17 00:00:00 2001
|
||||
From: Michal Sekletar <msekleta@redhat.com>
|
||||
Date: Wed, 26 Apr 2023 20:07:10 +0200
|
||||
Subject: [PATCH] pstore: fix crash and forward dummy arguments instead of NULL
|
||||
|
||||
[msekleta: in our version of systemd "const char path*" argument of
|
||||
path_join() can't be NULL. Here we don't really want any subdirs paths
|
||||
passed into move_file(), but we can't just pass NULL pointers because
|
||||
they will be forwarded to path_join(). Hence, let's just pass "/"
|
||||
instead.]
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2190151
|
||||
---
|
||||
src/pstore/pstore.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
|
||||
index 9f61e8f7f8..5335c9f92d 100644
|
||||
--- a/src/pstore/pstore.c
|
||||
+++ b/src/pstore/pstore.c
|
||||
@@ -366,7 +366,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
/* Move left over files out of pstore */
|
||||
for (size_t n = 0; n < list.n_entries; n++)
|
||||
- (void) move_file(&list.entries[n], NULL, NULL);
|
||||
+ (void) move_file(&list.entries[n], "/", "/");
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
From 6fdc5f71ee28829bdedb159e7d138f7a1b447fb2 Mon Sep 17 00:00:00 2001
|
||||
From: Filipe Brandenburger <filbranden@gmail.com>
|
||||
Date: Wed, 13 Nov 2019 10:46:08 -0800
|
||||
Subject: [PATCH] test: Disable LUKS devices from initramfs in QEMU tests
|
||||
|
||||
We currently use the host's kernel and initramfs in our QEMU tests.
|
||||
|
||||
If the host is running on an encrypted LUKS partition, then the initramfs
|
||||
will have a crypttab setup looking for the particular root disk it needs to
|
||||
encrypt before booting into the system.
|
||||
|
||||
However, this disk obviously doesn't exist in our QEMU VM, so it turns out
|
||||
our tests end up waiting for this device to become available, which will
|
||||
never actually happen, and boot hangs for 90s until that service times out.
|
||||
|
||||
[*** ] A start job is running for /dev/disk/by-uuid/01234567-abcd-1234-abcd-0123456789ab (20s / 1min 30s)
|
||||
|
||||
In order to prevent this issue, let's pass "rd.luks=0" to disable LUKS in
|
||||
the initramfs only as part of our default kernel command-line in our QEMU
|
||||
tests.
|
||||
|
||||
This is enough to disable this behavior and prevent the timeout, while at
|
||||
the same time doesn't conflict with our tests that actually check for LUKS
|
||||
behavior in the systemd running under test (such as TEST-02-CRYPTSETUP).
|
||||
|
||||
Tested: `sudo make -C TEST-02-CRYPTSETUP/ clean setup run`
|
||||
(cherry picked from commit 14e0259b499c188de09040f2e5857a0193094d5a)
|
||||
|
||||
Related: #2190151
|
||||
---
|
||||
test/test-functions | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/test/test-functions b/test/test-functions
|
||||
index e5d4d28a5f..a7b18991f4 100644
|
||||
--- a/test/test-functions
|
||||
+++ b/test/test-functions
|
||||
@@ -154,6 +154,7 @@ fi
|
||||
KERNEL_APPEND="$PARAMS \
|
||||
root=/dev/sda1 \
|
||||
raid=noautodetect \
|
||||
+rd.luks=0 \
|
||||
loglevel=2 \
|
||||
init=$PATH_TO_INIT \
|
||||
console=ttyS0 \
|
@ -1,37 +0,0 @@
|
||||
From 3aefa216bf5e8bcfaf5a628e9e06672e786ce9ea Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
||||
Date: Fri, 28 Apr 2023 11:09:22 +0200
|
||||
Subject: [PATCH] pstore: explicitly set the base when converting record ID
|
||||
|
||||
(cherry picked from commit a95d96a2430db171b40fc2e50589807236f8f746)
|
||||
|
||||
Related: #2190151
|
||||
---
|
||||
src/pstore/pstore.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
|
||||
index 5335c9f92d..073fedb7d2 100644
|
||||
--- a/src/pstore/pstore.c
|
||||
+++ b/src/pstore/pstore.c
|
||||
@@ -207,7 +207,7 @@ static int append_dmesg(PStoreEntry *pe, const char *subdir1, const char *subdir
|
||||
static int process_dmesg_files(PStoreList *list) {
|
||||
/* Move files, reconstruct dmesg.txt */
|
||||
_cleanup_free_ char *erst_subdir = NULL;
|
||||
- uint64_t last_record_id = 0;
|
||||
+ unsigned long long last_record_id = 0;
|
||||
|
||||
/* When dmesg is written into pstore, it is done so in small chunks, whatever the exchange buffer
|
||||
* size is with the underlying pstore backend (ie. EFI may be ~2KiB), which means an example
|
||||
@@ -263,9 +263,9 @@ static int process_dmesg_files(PStoreList *list) {
|
||||
} else if ((p = startswith(pe->dirent.d_name, "dmesg-erst-"))) {
|
||||
/* For the ERST backend, the record is a monotonically increasing number, seeded as
|
||||
* a timestamp. See linux/drivers/acpi/apei/erst.c in erst_writer(). */
|
||||
- uint64_t record_id;
|
||||
+ unsigned long long record_id;
|
||||
|
||||
- if (safe_atou64(p, &record_id) < 0)
|
||||
+ if (safe_atollu_full(p, 10, &record_id) < 0)
|
||||
continue;
|
||||
if (last_record_id - 1 != record_id)
|
||||
/* A discontinuity in the number has been detected, this current record id
|
@ -1,68 +0,0 @@
|
||||
From 7a76b2a073b5df72e9afc39dc6c0cce388e0a733 Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
||||
Date: Fri, 28 Apr 2023 11:50:33 +0200
|
||||
Subject: [PATCH] pstore: avoid opening the dmesg.txt file if not requested
|
||||
|
||||
Even with Storage=journal we would still attempt to open the final
|
||||
dmesg.txt file which causes a lot of noise in the journal:
|
||||
|
||||
```
|
||||
[ 5.764111] H testsuite-82.sh[658]: + systemctl start systemd-pstore
|
||||
[ 5.806385] H systemd[1]: Starting modprobe@efi_pstore.service...
|
||||
[ 5.808656] H systemd[1]: modprobe@efi_pstore.service: Deactivated successfully.
|
||||
[ 5.808971] H systemd[1]: Finished modprobe@efi_pstore.service.
|
||||
[ 5.818845] H kernel: audit: type=1130 audit(1682630623.637:114): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=modprobe@efi_pstore comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? termin>
|
||||
[ 5.818865] H kernel: audit: type=1131 audit(1682630623.637:115): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=modprobe@efi_pstore comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? termin>
|
||||
[ 5.816052] H systemd[1]: Starting systemd-pstore.service...
|
||||
[ 5.840703] H systemd-pstore[806]: PStore dmesg-efi-168263062313014.
|
||||
[ 5.841239] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.841428] H systemd-pstore[806]: PStore dmesg-efi-168263062312014.
|
||||
[ 5.841575] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.841712] H systemd-pstore[806]: PStore dmesg-efi-168263062311014.
|
||||
[ 5.841839] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.841989] H systemd-pstore[806]: PStore dmesg-efi-168263062310014.
|
||||
[ 5.842141] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.842274] H systemd-pstore[806]: PStore dmesg-efi-168263062309014.
|
||||
[ 5.842423] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.842589] H systemd-pstore[806]: PStore dmesg-efi-168263062308014.
|
||||
[ 5.842722] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.842865] H systemd-pstore[806]: PStore dmesg-efi-168263062307014.
|
||||
[ 5.843003] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.843153] H systemd-pstore[806]: PStore dmesg-efi-168263062306014.
|
||||
[ 5.843280] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.843434] H systemd-pstore[806]: PStore dmesg-efi-168263062305014.
|
||||
[ 5.843570] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.843702] H systemd-pstore[806]: PStore dmesg-efi-168263062304014.
|
||||
[ 5.843831] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.843958] H systemd-pstore[806]: PStore dmesg-efi-168263062303014.
|
||||
[ 5.844093] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.844250] H systemd-pstore[806]: PStore dmesg-efi-168263062302014.
|
||||
[ 5.844412] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.844619] H systemd-pstore[806]: PStore dmesg-efi-168263062301014.
|
||||
[ 5.844781] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.844956] H systemd-pstore[806]: PStore dmesg-efi-168263062300014.
|
||||
[ 5.845168] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
|
||||
[ 5.851101] H systemd[1]: Finished systemd-pstore.service.
|
||||
```
|
||||
|
||||
(cherry picked from commit ad5980803adac8dc1cf980447a07cb18962c238b)
|
||||
|
||||
Related: #2190151
|
||||
---
|
||||
src/pstore/pstore.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
|
||||
index 073fedb7d2..9367071833 100644
|
||||
--- a/src/pstore/pstore.c
|
||||
+++ b/src/pstore/pstore.c
|
||||
@@ -181,6 +181,9 @@ static int append_dmesg(PStoreEntry *pe, const char *subdir1, const char *subdir
|
||||
|
||||
assert(pe);
|
||||
|
||||
+ if (arg_storage != PSTORE_STORAGE_EXTERNAL)
|
||||
+ return 0;
|
||||
+
|
||||
if (pe->content_size == 0)
|
||||
return 0;
|
||||
|
@ -1,341 +0,0 @@
|
||||
From 06b0704a8bb41fa9a496f5671e191dc7b6c7ed9b Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <fsumsal@redhat.com>
|
||||
Date: Wed, 3 May 2023 15:25:18 +0200
|
||||
Subject: [PATCH] test: add a couple of tests for systemd-pstore
|
||||
|
||||
Based on:
|
||||
- 6858e32d730fd5574eaa3d7fbf4cb12aacaea336
|
||||
- edea0d6ac57610b7af603b833b19a846327e3638
|
||||
|
||||
Related: #2190151
|
||||
---
|
||||
test/TEST-74-AUX-UTILS/Makefile | 1 +
|
||||
test/TEST-74-AUX-UTILS/test.sh | 48 +++++
|
||||
test/TEST-74-AUX-UTILS/testsuite.pstore.sh | 218 +++++++++++++++++++++
|
||||
test/TEST-74-AUX-UTILS/testsuite.sh | 14 ++
|
||||
test/test-functions | 2 +-
|
||||
5 files changed, 282 insertions(+), 1 deletion(-)
|
||||
create mode 120000 test/TEST-74-AUX-UTILS/Makefile
|
||||
create mode 100755 test/TEST-74-AUX-UTILS/test.sh
|
||||
create mode 100755 test/TEST-74-AUX-UTILS/testsuite.pstore.sh
|
||||
create mode 100755 test/TEST-74-AUX-UTILS/testsuite.sh
|
||||
|
||||
diff --git a/test/TEST-74-AUX-UTILS/Makefile b/test/TEST-74-AUX-UTILS/Makefile
|
||||
new file mode 120000
|
||||
index 0000000000..e9f93b1104
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-74-AUX-UTILS/Makefile
|
||||
@@ -0,0 +1 @@
|
||||
+../TEST-01-BASIC/Makefile
|
||||
\ No newline at end of file
|
||||
diff --git a/test/TEST-74-AUX-UTILS/test.sh b/test/TEST-74-AUX-UTILS/test.sh
|
||||
new file mode 100755
|
||||
index 0000000000..fead257337
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-74-AUX-UTILS/test.sh
|
||||
@@ -0,0 +1,48 @@
|
||||
+#!/usr/bin/env bash
|
||||
+set -e
|
||||
+TEST_DESCRIPTION="Tests for auxiliary utilities"
|
||||
+
|
||||
+. $TEST_BASE_DIR/test-functions
|
||||
+
|
||||
+test_setup() {
|
||||
+ create_empty_image
|
||||
+ mkdir -p $TESTDIR/root
|
||||
+ mount ${LOOPDEV}p1 $TESTDIR/root
|
||||
+
|
||||
+ (
|
||||
+ LOG_LEVEL=5
|
||||
+ eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
||||
+
|
||||
+ setup_basic_environment
|
||||
+
|
||||
+ # mask some services that we do not want to run in these tests
|
||||
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service
|
||||
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service
|
||||
+ 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
|
||||
+ ln -fs /dev/null $initdir/etc/systemd/system/systemd-machined.service
|
||||
+
|
||||
+ # 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
|
||||
+StandardOutput=tty
|
||||
+StandardError=tty
|
||||
+NotifyAccess=all
|
||||
+EOF
|
||||
+ cp testsuite*.sh $initdir/
|
||||
+
|
||||
+ setup_testsuite
|
||||
+ ) || return 1
|
||||
+ setup_nspawn_root
|
||||
+
|
||||
+ ddebug "umount $TESTDIR/root"
|
||||
+ umount $TESTDIR/root
|
||||
+}
|
||||
+
|
||||
+do_test "$@"
|
||||
diff --git a/test/TEST-74-AUX-UTILS/testsuite.pstore.sh b/test/TEST-74-AUX-UTILS/testsuite.pstore.sh
|
||||
new file mode 100755
|
||||
index 0000000000..3a61b8f8f8
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-74-AUX-UTILS/testsuite.pstore.sh
|
||||
@@ -0,0 +1,218 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+set -eux
|
||||
+set -o pipefail
|
||||
+
|
||||
+if systemd-detect-virt -cq; then
|
||||
+ echo "Running in a container, skipping the systemd-pstore test..."
|
||||
+ exit 0
|
||||
+fi
|
||||
+
|
||||
+DUMMY_DMESG_1="$(mktemp)"
|
||||
+cat >"$DUMMY_DMESG_1" <<\EOF
|
||||
+6,17159,5340096332127,-;usb 1-4: USB disconnect, device number 124
|
||||
+6,17160,5340109662397,-;input: WH-1000XM3 (AVRCP) as /devices/virtual/input/input293
|
||||
+6,17161,5343126458360,-;loop0: detected capacity change from 0 to 3145728
|
||||
+6,17162,5343126766065,-; loop0: p1 p2
|
||||
+6,17163,5343126815038,-;EXT4-fs (loop0p1): mounted filesystem with ordered data mode. Quota mode: none.
|
||||
+6,17164,5343158037334,-;EXT4-fs (loop0p1): unmounting filesystem.
|
||||
+6,17165,5343158072598,-;loop0: detected capacity change from 0 to 3145728
|
||||
+6,17166,5343158073563,-; loop0: p1 p2
|
||||
+6,17167,5343158074325,-; loop0: p1 p2
|
||||
+6,17168,5343158140859,-;EXT4-fs (loop0p1): mounted filesystem with ordered data mode. Quota mode: none.
|
||||
+6,17169,5343158182977,-;EXT4-fs (loop0p1): unmounting filesystem.
|
||||
+6,17170,5343158700241,-;loop0: detected capacity change from 0 to 3145728
|
||||
+6,17171,5343158700439,-; loop0: p1 p2
|
||||
+6,17172,5343158701120,-; loop0: p1 p2
|
||||
+EOF
|
||||
+
|
||||
+DUMMY_DMESG_2="$(mktemp)"
|
||||
+cat >"$DUMMY_DMESG_2" <<\EOF
|
||||
+Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a quickstepu.
|
||||
+Příliš žluťoučký kůň úpěl ďábelské ódy.
|
||||
+Zvlášť zákeřný učeň s ďolíčky běží podél zóny úlů.
|
||||
+Vyciď křišťálový nůž, ó učiň úděsné líbivým!
|
||||
+Loď čeří kýlem tůň obzvlášť v Grónské úžině
|
||||
+Ó, náhlý déšť již zvířil prach a čilá laň teď běží s houfcem gazel k úkrytům.
|
||||
+Vypätá dcéra grófa Maxwella s IQ nižším ako kôň núti čeľaď hrýzť hŕbu jabĺk.
|
||||
+Kŕdeľ šťastných ďatľov učí pri ústí Váhu mĺkveho koňa obhrýzať kôru a žrať čerstvé mäso.
|
||||
+Stróż pchnął kość w quiz gędźb vel fax myjń.
|
||||
+Portez ce vieux whisky au juge blond qui fume!
|
||||
+EOF
|
||||
+
|
||||
+file_count() { find "${1:?}" -type f | wc -l; }
|
||||
+file_size() { wc -l <"${1:?}"; }
|
||||
+random_efi_timestamp() { printf "%0.10d" "$((1000000000 + RANDOM))"; }
|
||||
+
|
||||
+# The dmesg- filename contains the backend-type and the Common Platform Error Record, CPER,
|
||||
+# record id, a 64-bit number.
|
||||
+#
|
||||
+# Files are processed in reverse lexigraphical order so as to properly reconstruct original dmesg.
|
||||
+
|
||||
+prepare_efi_logs() {
|
||||
+ local file="${1:?}"
|
||||
+ local timestamp="${2:?}"
|
||||
+ local chunk count filename
|
||||
+
|
||||
+ # For the EFI backend, the 3 least significant digits of record id encodes a
|
||||
+ # "count" number, the next 2 least significant digits for the dmesg part
|
||||
+ # (chunk) number, and the remaining digits as the timestamp. See
|
||||
+ # linux/drivers/firmware/efi/efi-pstore.c in efi_pstore_write().
|
||||
+ count="$(file_size "$file")"
|
||||
+ chunk=0
|
||||
+ # The sed in the process substitution below just reverses the file
|
||||
+ while read -r line; do
|
||||
+ filename="$(printf "dmesg-efi-%0.10d%0.2d%0.3d" "$timestamp" "$chunk" "$count")"
|
||||
+ echo "$line" >"/sys/fs/pstore/$filename"
|
||||
+ chunk=$((chunk + 1))
|
||||
+ done < <(sed '1!G;h;$!d' "$file")
|
||||
+
|
||||
+ if [[ "$chunk" -eq 0 ]]; then
|
||||
+ echo >&2 "No dmesg-efi files were created"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
+prepare_erst_logs() {
|
||||
+ local file="${1:?}"
|
||||
+ local start_id="${2:?}"
|
||||
+ local id filename
|
||||
+
|
||||
+ # For the ERST backend, the record is a monotonically increasing number, seeded as
|
||||
+ # a timestamp. See linux/drivers/acpi/apei/erst.c in erst_writer().
|
||||
+ id="$start_id"
|
||||
+ # The sed in the process substitution below just reverses the file
|
||||
+ while read -r line; do
|
||||
+ filename="$(printf "dmesg-erst-%0.16d" "$id")"
|
||||
+ echo "$line" >"/sys/fs/pstore/$filename"
|
||||
+ id=$((id + 1))
|
||||
+ done < <(sed '1!G;h;$!d' "$file")
|
||||
+
|
||||
+ if [[ "$id" -eq "$start_id" ]]; then
|
||||
+ echo >&2 "No dmesg-erst files were created"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+
|
||||
+ # ID of the last dmesg file will be the ID of the erst subfolder
|
||||
+ echo "$((id - 1))"
|
||||
+}
|
||||
+
|
||||
+prepare_pstore_config() {
|
||||
+ local storage="${1:?}"
|
||||
+ local unlink="${2:?}"
|
||||
+
|
||||
+ systemctl stop systemd-pstore
|
||||
+
|
||||
+ rm -fr /sys/fs/pstore/* /var/lib/systemd/pstore/*
|
||||
+
|
||||
+ mkdir -p /run/systemd/pstore.conf.d
|
||||
+ cat >"/run/systemd/pstore.conf.d/99-test.conf" <<EOF
|
||||
+[PStore]
|
||||
+Storage=$storage
|
||||
+Unlink=$unlink
|
||||
+EOF
|
||||
+
|
||||
+ systemd-analyze cat-config systemd/pstore.conf | grep "$storage"
|
||||
+ systemd-analyze cat-config systemd/pstore.conf | grep "$unlink"
|
||||
+}
|
||||
+
|
||||
+start_pstore() {
|
||||
+ JOURNAL_CURSOR="$(journalctl -q -n 0 --show-cursor | awk '{ print $3 }')"
|
||||
+ systemctl start systemd-pstore
|
||||
+ journalctl --sync
|
||||
+}
|
||||
+
|
||||
+# To avoid having to depend on the VM providing the pstore, let's simulate
|
||||
+# it using a simple bind mount
|
||||
+PSTORE_DIR="$(mktemp -d)"
|
||||
+mount --bind "${PSTORE_DIR:?}" "/sys/fs/pstore"
|
||||
+
|
||||
+# systemd-pstore is a no-op with Storage=none
|
||||
+for unlink in yes no; do
|
||||
+ : "Backend: N/A; Storage: none; Unlink: $unlink"
|
||||
+ timestamp="$(random_efi_timestamp)"
|
||||
+ prepare_pstore_config "none" "$unlink"
|
||||
+ prepare_efi_logs "$DUMMY_DMESG_1" "$timestamp"
|
||||
+ old_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$old_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]]
|
||||
+
|
||||
+ : "Backend: EFI; Storage: external; Unlink: $unlink"
|
||||
+ timestamp="$(random_efi_timestamp)"
|
||||
+ prepare_pstore_config "external" "$unlink"
|
||||
+ prepare_efi_logs "$DUMMY_DMESG_1" "$timestamp"
|
||||
+ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]]
|
||||
+ # We always log to journal
|
||||
+ diff "$DUMMY_DMESG_1" <(journalctl -o json --after-cursor="${JOURNAL_CURSOR:?}" | jq -r 'select(.FILE) | .FILE' | sed '/^$/d')
|
||||
+ filename="$(printf "/var/lib/systemd/pstore/%s/%0.3d/dmesg.txt" "$timestamp" "$(file_size "$DUMMY_DMESG_1")")"
|
||||
+ diff "$DUMMY_DMESG_1" "$filename"
|
||||
+
|
||||
+ : "Backend: EFI; Storage: external; Unlink: $unlink; multiple dmesg files"
|
||||
+ timestamp_1="$(random_efi_timestamp)"
|
||||
+ timestamp_2="$((timestamp_1 + 1))"
|
||||
+ prepare_pstore_config "external" "$unlink"
|
||||
+ prepare_efi_logs "$DUMMY_DMESG_1" "$timestamp_1"
|
||||
+ prepare_efi_logs "$DUMMY_DMESG_2" "$timestamp_2"
|
||||
+ # Add one "random" (non-dmesg) file as well
|
||||
+ echo "hello world" >/sys/fs/pstore/foo.bar
|
||||
+ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]]
|
||||
+ filename_1="$(printf "/var/lib/systemd/pstore/%s/%0.3d/dmesg.txt" "$timestamp_1" "$(file_size "$DUMMY_DMESG_1")")"
|
||||
+ diff "$DUMMY_DMESG_1" "$filename_1"
|
||||
+ filename_2="$(printf "/var/lib/systemd/pstore/%s/%0.3d/dmesg.txt" "$timestamp_2" "$(file_size "$DUMMY_DMESG_2")")"
|
||||
+ diff "$DUMMY_DMESG_2" "$filename_2"
|
||||
+ grep "hello world" "/var/lib/systemd/pstore/foo.bar"
|
||||
+
|
||||
+ : "Backend: EFI; Storage: journal; Unlink: $unlink"
|
||||
+ timestamp="$(random_efi_timestamp)"
|
||||
+ prepare_pstore_config "journal" "$unlink"
|
||||
+ prepare_efi_logs "$DUMMY_DMESG_1" "$timestamp"
|
||||
+ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]]
|
||||
+ diff "$DUMMY_DMESG_1" <(journalctl -o json --after-cursor="${JOURNAL_CURSOR:?}" | jq -r 'select(.FILE) | .FILE' | sed '/^$/d')
|
||||
+
|
||||
+ : "Backend: ERST; Storage: external; Unlink: $unlink"
|
||||
+ prepare_pstore_config "external" "$unlink"
|
||||
+ last_id="$(prepare_erst_logs "$DUMMY_DMESG_1" 0)"
|
||||
+ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]]
|
||||
+ # We always log to journal
|
||||
+ diff "$DUMMY_DMESG_1" <(journalctl -o json --after-cursor="${JOURNAL_CURSOR:?}" | jq -r 'select(.FILE) | .FILE' | sed '/^$/d')
|
||||
+ filename="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id")"
|
||||
+ diff "$DUMMY_DMESG_1" "$filename"
|
||||
+
|
||||
+ : "Backend: ERST; Storage: external; Unlink: $unlink; multiple dmesg files"
|
||||
+ prepare_pstore_config "external" "$unlink"
|
||||
+ last_id_1="$(prepare_erst_logs "$DUMMY_DMESG_1" 0)"
|
||||
+ last_id_2="$(prepare_erst_logs "$DUMMY_DMESG_2" "$((last_id_1 + 10))")"
|
||||
+ # Add one "random" (non-dmesg) file as well
|
||||
+ echo "hello world" >/sys/fs/pstore/foo.bar
|
||||
+ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -ne 0 ]]
|
||||
+ filename_1="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id_1")"
|
||||
+ diff "$DUMMY_DMESG_1" "$filename_1"
|
||||
+ filename_2="$(printf "/var/lib/systemd/pstore/%0.16d/dmesg.txt" "$last_id_2")"
|
||||
+ diff "$DUMMY_DMESG_2" "$filename_2"
|
||||
+ grep "hello world" "/var/lib/systemd/pstore/foo.bar"
|
||||
+
|
||||
+ : "Backend: ERST; Storage: journal; Unlink: $unlink"
|
||||
+ prepare_pstore_config "journal" "$unlink"
|
||||
+ last_id="$(prepare_erst_logs "$DUMMY_DMESG_1" 0)"
|
||||
+ [[ "$unlink" == yes ]] && exp_count=0 || exp_count="$(file_count /sys/fs/pstore/)"
|
||||
+ start_pstore
|
||||
+ [[ "$(file_count /sys/fs/pstore)" -ge "$exp_count" ]]
|
||||
+ [[ "$(file_count /var/lib/systemd/pstore/)" -eq 0 ]]
|
||||
+ diff "$DUMMY_DMESG_1" <(journalctl -o json --after-cursor="${JOURNAL_CURSOR:?}" | jq -r 'select(.FILE) | .FILE' | sed '/^$/d')
|
||||
+done
|
||||
diff --git a/test/TEST-74-AUX-UTILS/testsuite.sh b/test/TEST-74-AUX-UTILS/testsuite.sh
|
||||
new file mode 100755
|
||||
index 0000000000..13c767e490
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-74-AUX-UTILS/testsuite.sh
|
||||
@@ -0,0 +1,14 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+set -eux
|
||||
+set -o pipefail
|
||||
+
|
||||
+: >/failed
|
||||
+
|
||||
+for script in "${0%.sh}".*.sh; do
|
||||
+ echo "Running $script"
|
||||
+ "./$script"
|
||||
+done
|
||||
+
|
||||
+touch /testok
|
||||
+rm /failed
|
||||
diff --git a/test/test-functions b/test/test-functions
|
||||
index a7b18991f4..f0cf6f8575 100644
|
||||
--- a/test/test-functions
|
||||
+++ b/test/test-functions
|
||||
@@ -23,7 +23,7 @@ fi
|
||||
|
||||
PATH_TO_INIT=$ROOTLIBDIR/systemd
|
||||
|
||||
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout"
|
||||
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff"
|
||||
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
|
||||
|
||||
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
|
@ -1,29 +0,0 @@
|
||||
From ab5a221daca2783b73fd286f5410dbec905cabfa Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 19 May 2023 16:42:03 +0200
|
||||
Subject: [PATCH] ci: update permissions for source-git automation workflows
|
||||
|
||||
The new version of `redhat-plumbers-in-action/advanced-commit-linter` requires new permission: `checks: write`.
|
||||
|
||||
https://github.com/redhat-plumbers-in-action/advanced-commit-linter/commit/f1bb35fcdeff83d40eb67b5e7c58baad6be689b2
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/workflows/source-git-automation.yml | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
index 140f21b116..e653e28a7f 100644
|
||||
--- a/.github/workflows/source-git-automation.yml
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
|
||||
|
||||
permissions:
|
||||
- statuses: write
|
||||
+ checks: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
@ -1,130 +0,0 @@
|
||||
From 30cbb55a8d9fedf07d5c9d792849b723b856cd62 Mon Sep 17 00:00:00 2001
|
||||
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
Date: Sun, 12 Feb 2023 12:15:08 +0000
|
||||
Subject: [PATCH] sulogin: fix control lost of the current terminal when
|
||||
default.target is rescue.target
|
||||
|
||||
When default.target is rescue.target, exiting from the single-user shell
|
||||
results in lost of the control of the current terminal. This is because the
|
||||
operation performed to continue to boot is systemctl default but default.target
|
||||
is now rescue.target and it is already active. Hence, no new process that
|
||||
controls the current terminal is created. Users need to make hardware reset to
|
||||
recover the situation.
|
||||
|
||||
This sounds like a bit corner case issue and some might feel configuring
|
||||
default.target as rescue.target is odd because there are several other ways to
|
||||
transition to rescue.mode without configuring default.target to rescue.target
|
||||
such as systemctl rescue or systemd.unit=rescue.target something like
|
||||
that. However, users unfamiliar with systemd operations tend to come up with
|
||||
systemctl set-default rescue.target.
|
||||
|
||||
To fix this issue, let's transition to default.target only when default.target
|
||||
is inactive. Otherwise, invoke the single-user shell again to keep control of
|
||||
the current terminal for users.
|
||||
|
||||
This new logic depends on whether D-Bus working well. Exiting without any check
|
||||
of result of systemctl default could lead to again the control lost of the
|
||||
current terminal. Hence, add checking results of each D-Bus operations
|
||||
including systemctl default and invoke the single-user shell if they fail.
|
||||
|
||||
(cherry picked from commit 937ca8330d11e406b8ef343bead6f4f6244e39c7)
|
||||
|
||||
Resolves: #2169932
|
||||
---
|
||||
src/sulogin-shell/sulogin-shell.c | 60 +++++++++++++++++++++++++------
|
||||
1 file changed, 50 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c
|
||||
index a1ea2333de..8f14ee11bb 100644
|
||||
--- a/src/sulogin-shell/sulogin-shell.c
|
||||
+++ b/src/sulogin-shell/sulogin-shell.c
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "process-util.h"
|
||||
#include "sd-bus.h"
|
||||
#include "signal-util.h"
|
||||
+#include "special.h"
|
||||
+#include "unit-def.h"
|
||||
|
||||
static int reload_manager(sd_bus *bus) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
@@ -43,6 +45,28 @@ static int reload_manager(sd_bus *bus) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int default_target_is_inactive(sd_bus *bus) {
|
||||
+ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
+ _cleanup_free_ char *path = NULL, *state = NULL;
|
||||
+ int r;
|
||||
+
|
||||
+ path = unit_dbus_path_from_name(SPECIAL_DEFAULT_TARGET);
|
||||
+ if (!path)
|
||||
+ return log_oom();
|
||||
+
|
||||
+ r = sd_bus_get_property_string(bus,
|
||||
+ "org.freedesktop.systemd1",
|
||||
+ path,
|
||||
+ "org.freedesktop.systemd1.Unit",
|
||||
+ "ActiveState",
|
||||
+ &error,
|
||||
+ &state);
|
||||
+ if (r < 0)
|
||||
+ return log_error_errno(r, "Failed to retrieve unit state: %s", bus_error_message(&error, r));
|
||||
+
|
||||
+ return streq_ptr(state, "inactive");
|
||||
+}
|
||||
+
|
||||
static int start_default_target(sd_bus *bus) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
int r;
|
||||
@@ -95,7 +119,6 @@ int main(int argc, char *argv[]) {
|
||||
NULL, /* --force */
|
||||
NULL
|
||||
};
|
||||
- _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
int r;
|
||||
|
||||
log_set_target(LOG_TARGET_AUTO);
|
||||
@@ -108,17 +131,34 @@ int main(int argc, char *argv[]) {
|
||||
/* allows passwordless logins if root account is locked. */
|
||||
sulogin_cmdline[1] = "--force";
|
||||
|
||||
- (void) fork_wait(sulogin_cmdline);
|
||||
+ for (;;) {
|
||||
+ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
+
|
||||
+ (void) fork_wait(sulogin_cmdline);
|
||||
+
|
||||
+ r = bus_connect_system_systemd(&bus);
|
||||
+ if (r < 0) {
|
||||
+ log_warning_errno(r, "Failed to get D-Bus connection: %m");
|
||||
+ goto fallback;
|
||||
+ }
|
||||
|
||||
- r = bus_connect_system_systemd(&bus);
|
||||
- if (r < 0) {
|
||||
- log_warning_errno(r, "Failed to get D-Bus connection: %m");
|
||||
- r = 0;
|
||||
- } else {
|
||||
- (void) reload_manager(bus);
|
||||
+ if (reload_manager(bus) < 0)
|
||||
+ goto fallback;
|
||||
|
||||
- r = start_default_target(bus);
|
||||
+ r = default_target_is_inactive(bus);
|
||||
+ if (r < 0)
|
||||
+ goto fallback;
|
||||
+ if (!r) {
|
||||
+ log_warning(SPECIAL_DEFAULT_TARGET" is not inactive. Please review the "SPECIAL_DEFAULT_TARGET" setting.\n");
|
||||
+ goto fallback;
|
||||
+ }
|
||||
+
|
||||
+ if (start_default_target(bus) >= 0)
|
||||
+ break;
|
||||
+
|
||||
+ fallback:
|
||||
+ log_warning("Fallback to the single-user shell.\n");
|
||||
}
|
||||
|
||||
- return r >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
+ return 0;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
From cb99c3e54af1ba7c6cf1cd99d61546f5aa9423cb Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 2 Jul 2018 18:50:25 +0200
|
||||
Subject: [PATCH] parse-util: in parse_permille() check negative earlier
|
||||
|
||||
If 'v' is negative, it's wrong to add the decimal to it, as we'd
|
||||
actually need to subtract it in this case. But given that we don't want
|
||||
to allow negative vaues anyway, simply check earlier whether what we
|
||||
have parsed so far was negative, and react to that before adding the
|
||||
decimal to it.
|
||||
|
||||
(cherry picked from commit 8cbc92d5975b603002c3141364a7709a9c66e23a)
|
||||
|
||||
Related: #2178179
|
||||
---
|
||||
src/basic/parse-util.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
|
||||
index 992ea3605b..2ab8e88451 100644
|
||||
--- a/src/basic/parse-util.c
|
||||
+++ b/src/basic/parse-util.c
|
||||
@@ -728,6 +728,8 @@ int parse_permille_unbounded(const char *p) {
|
||||
r = safe_atoi(n, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
+ if (v < 0)
|
||||
+ return -ERANGE;
|
||||
} else {
|
||||
pc = endswith(p, "%");
|
||||
if (!pc)
|
||||
@@ -748,15 +750,14 @@ int parse_permille_unbounded(const char *p) {
|
||||
r = safe_atoi(n, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
+ if (v < 0)
|
||||
+ return -ERANGE;
|
||||
if (v > (INT_MAX - q) / 10)
|
||||
return -ERANGE;
|
||||
|
||||
v = v * 10 + q;
|
||||
}
|
||||
|
||||
- if (v < 0)
|
||||
- return -ERANGE;
|
||||
-
|
||||
return v;
|
||||
}
|
||||
|
@ -1,165 +0,0 @@
|
||||
From 30343fc0ba66dd7a513de736c7708702ec5400be Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 2 Jul 2018 18:52:42 +0200
|
||||
Subject: [PATCH] tree-wide: increase granularity of percent specifications all
|
||||
over the place to permille
|
||||
|
||||
We so far had various placed we'd parse percentages with
|
||||
parse_percent(). Let's make them use parse_permille() instead, which is
|
||||
downward compatible (as it also parses percent values), and increases
|
||||
the granularity a bit. Given that on the wire we usually normalize
|
||||
relative specifications to something like UINT32_MAX anyway changing
|
||||
from base-100 to base-1000 calculations can be done easily without
|
||||
breaking compat.
|
||||
|
||||
This commit doesn't document this change in the man pages. While
|
||||
allowing more precise specifcations permille is not as commonly
|
||||
understood as perent I guess, hence let's keep this out of the docs for
|
||||
now.
|
||||
|
||||
(cherry picked from commit f806dfd34595dac8632ba777250323a4735568dc)
|
||||
|
||||
Resolves: #2178179
|
||||
---
|
||||
src/core/load-fragment.c | 12 ++++++------
|
||||
src/login/logind-user.c | 6 +++---
|
||||
src/login/pam_systemd.c | 4 ++--
|
||||
src/shared/bus-unit-util.c | 22 ++++++++++++----------
|
||||
4 files changed, 23 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
|
||||
index 53de7ff5e9..f6505cf83c 100644
|
||||
--- a/src/core/load-fragment.c
|
||||
+++ b/src/core/load-fragment.c
|
||||
@@ -2991,13 +2991,13 @@ int config_parse_cpu_quota(
|
||||
return 0;
|
||||
}
|
||||
|
||||
- r = parse_percent_unbounded(rvalue);
|
||||
+ r = parse_permille_unbounded(rvalue);
|
||||
if (r <= 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid CPU quota '%s', ignoring.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
- c->cpu_quota_per_sec_usec = ((usec_t) r * USEC_PER_SEC) / 100U;
|
||||
+ c->cpu_quota_per_sec_usec = ((usec_t) r * USEC_PER_SEC) / 1000U;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3057,7 +3057,7 @@ int config_parse_memory_limit(
|
||||
|
||||
if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
|
||||
|
||||
- r = parse_percent(rvalue);
|
||||
+ r = parse_permille(rvalue);
|
||||
if (r < 0) {
|
||||
r = parse_size(rvalue, 1024, &bytes);
|
||||
if (r < 0) {
|
||||
@@ -3065,7 +3065,7 @@ int config_parse_memory_limit(
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
- bytes = physical_memory_scale(r, 100U);
|
||||
+ bytes = physical_memory_scale(r, 1000U);
|
||||
|
||||
if (bytes >= UINT64_MAX ||
|
||||
(bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
|
||||
@@ -3132,7 +3132,7 @@ int config_parse_tasks_max(
|
||||
return 0;
|
||||
}
|
||||
|
||||
- r = parse_percent(rvalue);
|
||||
+ r = parse_permille(rvalue);
|
||||
if (r < 0) {
|
||||
r = safe_atou64(rvalue, &v);
|
||||
if (r < 0) {
|
||||
@@ -3140,7 +3140,7 @@ int config_parse_tasks_max(
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
- v = system_tasks_max_scale(r, 100U);
|
||||
+ v = system_tasks_max_scale(r, 1000U);
|
||||
|
||||
if (v <= 0 || v >= UINT64_MAX) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Maximum tasks value '%s' out of range, ignoring.", rvalue);
|
||||
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
|
||||
index bba3158d1a..00d25d5876 100644
|
||||
--- a/src/login/logind-user.c
|
||||
+++ b/src/login/logind-user.c
|
||||
@@ -794,9 +794,9 @@ int config_parse_tmpfs_size(
|
||||
assert(data);
|
||||
|
||||
/* First, try to parse as percentage */
|
||||
- r = parse_percent(rvalue);
|
||||
- if (r > 0 && r < 100)
|
||||
- *sz = physical_memory_scale(r, 100U);
|
||||
+ r = parse_permille(rvalue);
|
||||
+ if (r > 0 && r < 1000)
|
||||
+ *sz = physical_memory_scale(r, 1000U);
|
||||
else {
|
||||
uint64_t k;
|
||||
|
||||
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
|
||||
index c87e980b18..7a551a41bb 100644
|
||||
--- a/src/login/pam_systemd.c
|
||||
+++ b/src/login/pam_systemd.c
|
||||
@@ -208,9 +208,9 @@ static int append_session_memory_max(pam_handle_t *handle, sd_bus_message *m, co
|
||||
return r;
|
||||
}
|
||||
} else {
|
||||
- r = parse_percent(limit);
|
||||
+ r = parse_permille(limit);
|
||||
if (r >= 0) {
|
||||
- r = sd_bus_message_append(m, "(sv)", "MemoryMaxScale", "u", (uint32_t) (((uint64_t) UINT32_MAX * r) / 100U));
|
||||
+ r = sd_bus_message_append(m, "(sv)", "MemoryMaxScale", "u", (uint32_t) (((uint64_t) r * UINT32_MAX) / 1000U));
|
||||
if (r < 0) {
|
||||
pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
|
||||
return r;
|
||||
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
|
||||
index c475bbafe0..aa4286ab6e 100644
|
||||
--- a/src/shared/bus-unit-util.c
|
||||
+++ b/src/shared/bus-unit-util.c
|
||||
@@ -440,16 +440,16 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
- r = parse_percent(eq);
|
||||
+ r = parse_permille(eq);
|
||||
if (r >= 0) {
|
||||
char *n;
|
||||
|
||||
- /* When this is a percentage we'll convert this into a relative value in the range
|
||||
- * 0…UINT32_MAX and pass it in the MemoryLowScale property (and related
|
||||
- * ones). This way the physical memory size can be determined server-side */
|
||||
+ /* When this is a percentage we'll convert this into a relative value in the range 0…UINT32_MAX
|
||||
+ * and pass it in the MemoryLowScale property (and related ones). This way the physical memory
|
||||
+ * size can be determined server-side. */
|
||||
|
||||
n = strjoina(field, "Scale");
|
||||
- r = sd_bus_message_append(m, "(sv)", n, "u", (uint32_t) (((uint64_t) UINT32_MAX * r) / 100U));
|
||||
+ r = sd_bus_message_append(m, "(sv)", n, "u", (uint32_t) (((uint64_t) r * UINT32_MAX) / 1000U));
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@@ -467,13 +467,15 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", USEC_INFINITY);
|
||||
else {
|
||||
- r = parse_percent_unbounded(eq);
|
||||
- if (r <= 0) {
|
||||
- log_error_errno(r, "CPU quota '%s' invalid.", eq);
|
||||
- return -EINVAL;
|
||||
+ r = parse_permille_unbounded(eq);
|
||||
+ if (r == 0) {
|
||||
+ log_error("CPU quota too small.");
|
||||
+ return -ERANGE;
|
||||
}
|
||||
+ if (r < 0)
|
||||
+ return log_error_errno(r, "CPU quota '%s' invalid.", eq);
|
||||
|
||||
- r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", (usec_t) r * USEC_PER_SEC / 100U);
|
||||
+ r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", (((uint64_t) r * USEC_PER_SEC) / 1000U));
|
||||
}
|
||||
|
||||
if (r < 0)
|
@ -1,31 +0,0 @@
|
||||
From 5a1d30b9a775a7bbac55752abdc10ed5383d209f Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 30 Nov 2021 03:39:35 +0900
|
||||
Subject: [PATCH] errno-util: introduce ERRNO_IS_TRANSIENT()
|
||||
|
||||
(cherry picked from commit 7aad83580fccee926d903bdb1a2a6af2c40ef0fc)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/basic/util.h | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/src/basic/util.h b/src/basic/util.h
|
||||
index 195f02cf5f..48beb88bac 100644
|
||||
--- a/src/basic/util.h
|
||||
+++ b/src/basic/util.h
|
||||
@@ -180,6 +180,14 @@ static inline int negative_errno(void) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
+
|
||||
+/* For send()/recv() or read()/write(). */
|
||||
+static inline bool ERRNO_IS_TRANSIENT(int r) {
|
||||
+ return IN_SET(abs(r),
|
||||
+ EAGAIN,
|
||||
+ EINTR);
|
||||
+}
|
||||
+
|
||||
/* Two different errors for access problems */
|
||||
static inline bool ERRNO_IS_PRIVILEGE(int r) {
|
||||
return IN_SET(abs(r),
|
@ -1,545 +0,0 @@
|
||||
From da79f303ec02fdb9a1c07e0fe48e0aaf4bd09e1b Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 30 Nov 2021 04:07:24 +0900
|
||||
Subject: [PATCH] tree-wide: use ERRNO_IS_TRANSIENT()
|
||||
|
||||
(cherry picked from commit 8add30a03cb19e4a2722fa5a0fc08c277aaf67fd)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/basic/barrier.c | 7 ++++---
|
||||
src/basic/terminal-util.c | 2 +-
|
||||
src/core/cgroup.c | 2 +-
|
||||
src/core/manager.c | 17 ++++++++---------
|
||||
src/core/path.c | 2 +-
|
||||
src/import/importd.c | 2 +-
|
||||
src/journal/journald-kmsg.c | 2 +-
|
||||
src/journal/journald-server.c | 2 +-
|
||||
src/journal/journald-stream.c | 2 +-
|
||||
src/journal/sd-journal.c | 2 +-
|
||||
src/libsystemd-network/icmp6-util.c | 2 +-
|
||||
src/libsystemd-network/sd-dhcp-client.c | 4 ++--
|
||||
src/libsystemd-network/sd-dhcp-server.c | 2 +-
|
||||
src/libsystemd-network/sd-dhcp6-client.c | 2 +-
|
||||
src/libsystemd-network/sd-ipv4acd.c | 2 +-
|
||||
src/libsystemd-network/sd-lldp.c | 2 +-
|
||||
src/libsystemd/sd-event/sd-event.c | 6 +++---
|
||||
src/libsystemd/sd-netlink/netlink-socket.c | 4 ++--
|
||||
src/libsystemd/sd-network/sd-network.c | 2 +-
|
||||
src/nspawn/nspawn.c | 2 +-
|
||||
src/resolve/resolved-dns-stream.c | 6 +++---
|
||||
src/resolve/resolved-dns-stub.c | 2 +-
|
||||
src/resolve/resolved-manager.c | 2 +-
|
||||
src/shared/ask-password-api.c | 6 +++---
|
||||
src/socket-proxy/socket-proxyd.c | 4 ++--
|
||||
src/time-wait-sync/time-wait-sync.c | 2 +-
|
||||
.../tty-ask-password-agent.c | 2 +-
|
||||
src/udev/udevd.c | 2 +-
|
||||
28 files changed, 47 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/src/basic/barrier.c b/src/basic/barrier.c
|
||||
index 587852aac8..d36c6c6f88 100644
|
||||
--- a/src/basic/barrier.c
|
||||
+++ b/src/basic/barrier.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "barrier.h"
|
||||
#include "fd-util.h"
|
||||
#include "macro.h"
|
||||
+#include "util.h"
|
||||
|
||||
/**
|
||||
* Barriers
|
||||
@@ -181,7 +182,7 @@ static bool barrier_write(Barrier *b, uint64_t buf) {
|
||||
assert(b->me >= 0);
|
||||
do {
|
||||
len = write(b->me, &buf, sizeof(buf));
|
||||
- } while (len < 0 && IN_SET(errno, EAGAIN, EINTR));
|
||||
+ } while (len < 0 && ERRNO_IS_TRANSIENT(errno));
|
||||
|
||||
if (len != sizeof(buf))
|
||||
goto error;
|
||||
@@ -223,7 +224,7 @@ static bool barrier_read(Barrier *b, int64_t comp) {
|
||||
int r;
|
||||
|
||||
r = poll(pfd, 2, -1);
|
||||
- if (r < 0 && IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (r < 0 && ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
else if (r < 0)
|
||||
goto error;
|
||||
@@ -233,7 +234,7 @@ static bool barrier_read(Barrier *b, int64_t comp) {
|
||||
|
||||
/* events on @them signal new data for us */
|
||||
len = read(b->them, &buf, sizeof(buf));
|
||||
- if (len < 0 && IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (len < 0 && ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
if (len != sizeof(buf))
|
||||
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
|
||||
index e2bbe8187d..18176cfe17 100644
|
||||
--- a/src/basic/terminal-util.c
|
||||
+++ b/src/basic/terminal-util.c
|
||||
@@ -460,7 +460,7 @@ int acquire_terminal(
|
||||
|
||||
l = read(notify, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
|
||||
index f89bce3d61..0c8a66edd1 100644
|
||||
--- a/src/core/cgroup.c
|
||||
+++ b/src/core/cgroup.c
|
||||
@@ -2356,7 +2356,7 @@ static int on_cgroup_inotify_event(sd_event_source *s, int fd, uint32_t revents,
|
||||
|
||||
l = read(fd, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_error_errno(errno, "Failed to read control group inotify events: %m");
|
||||
diff --git a/src/core/manager.c b/src/core/manager.c
|
||||
index 4a9f9bfcf9..e09227d5ac 100644
|
||||
--- a/src/core/manager.c
|
||||
+++ b/src/core/manager.c
|
||||
@@ -2331,7 +2331,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
|
||||
|
||||
n = recvmsg(m->notify_fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC|MSG_TRUNC);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(n))
|
||||
return 0; /* Spurious wakeup, try again */
|
||||
|
||||
/* If this is any other, real error, then let's stop processing this socket. This of course means we
|
||||
@@ -2573,19 +2573,18 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
|
||||
}
|
||||
|
||||
n = read(m->signal_fd, &sfsi, sizeof(sfsi));
|
||||
- if (n != sizeof(sfsi)) {
|
||||
- if (n >= 0) {
|
||||
- log_warning("Truncated read from signal fd (%zu bytes), ignoring!", n);
|
||||
- return 0;
|
||||
- }
|
||||
-
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (n < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
/* We return an error here, which will kill this handler,
|
||||
* to avoid a busy loop on read error. */
|
||||
return log_error_errno(errno, "Reading from signal fd failed: %m");
|
||||
}
|
||||
+ if (n != sizeof(sfsi)) {
|
||||
+ log_warning("Truncated read from signal fd (%zu bytes), ignoring!", n);
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
log_received_signal(sfsi.ssi_signo == SIGCHLD ||
|
||||
(sfsi.ssi_signo == SIGTERM && MANAGER_IS_USER(m))
|
||||
@@ -4453,7 +4452,7 @@ int manager_dispatch_user_lookup_fd(sd_event_source *source, int fd, uint32_t re
|
||||
|
||||
l = recv(fd, &buffer, sizeof(buffer), MSG_DONTWAIT);
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_error_errno(errno, "Failed to read from user lookup fd: %m");
|
||||
diff --git a/src/core/path.c b/src/core/path.c
|
||||
index b899bde0de..dfa63d5102 100644
|
||||
--- a/src/core/path.c
|
||||
+++ b/src/core/path.c
|
||||
@@ -152,7 +152,7 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
|
||||
|
||||
l = read(s->inotify_fd, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_error_errno(errno, "Failed to read inotify event: %m");
|
||||
diff --git a/src/import/importd.c b/src/import/importd.c
|
||||
index 04563fb098..5463bd7146 100644
|
||||
--- a/src/import/importd.c
|
||||
+++ b/src/import/importd.c
|
||||
@@ -519,7 +519,7 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
|
||||
|
||||
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(n))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
|
||||
index 726c006ce1..a49cc5c4c5 100644
|
||||
--- a/src/journal/journald-kmsg.c
|
||||
+++ b/src/journal/journald-kmsg.c
|
||||
@@ -321,7 +321,7 @@ static int server_read_dev_kmsg(Server *s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (IN_SET(errno, EAGAIN, EINTR, EPIPE))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno) || errno == EPIPE)
|
||||
return 0;
|
||||
|
||||
return log_error_errno(errno, "Failed to read from kernel: %m");
|
||||
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
|
||||
index 4788ff78bb..1e00e4b4bd 100644
|
||||
--- a/src/journal/journald-server.c
|
||||
+++ b/src/journal/journald-server.c
|
||||
@@ -1131,7 +1131,7 @@ int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void
|
||||
|
||||
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(n))
|
||||
return 0;
|
||||
|
||||
return log_error_errno(errno, "recvmsg() failed: %m");
|
||||
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
|
||||
index 5be5b0939c..470d2e2661 100644
|
||||
--- a/src/journal/journald-stream.c
|
||||
+++ b/src/journal/journald-stream.c
|
||||
@@ -556,7 +556,7 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
|
||||
|
||||
l = recvmsg(s->fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
log_warning_errno(errno, "Failed to read from stream: %m");
|
||||
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
|
||||
index 4c502978de..ca083da161 100644
|
||||
--- a/src/journal/sd-journal.c
|
||||
+++ b/src/journal/sd-journal.c
|
||||
@@ -2563,7 +2563,7 @@ _public_ int sd_journal_process(sd_journal *j) {
|
||||
|
||||
l = read(j->inotify_fd, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return got_something ? determine_change(j) : SD_JOURNAL_NOP;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c
|
||||
index 736df222f0..17d4d1faf2 100644
|
||||
--- a/src/libsystemd-network/icmp6-util.c
|
||||
+++ b/src/libsystemd-network/icmp6-util.c
|
||||
@@ -175,7 +175,7 @@ int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst,
|
||||
|
||||
len = recvmsg(fd, &msg, MSG_DONTWAIT);
|
||||
if (len < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
|
||||
index ff434f8ce7..8a8d806b3f 100644
|
||||
--- a/src/libsystemd-network/sd-dhcp-client.c
|
||||
+++ b/src/libsystemd-network/sd-dhcp-client.c
|
||||
@@ -1720,7 +1720,7 @@ static int client_receive_message_udp(
|
||||
|
||||
len = recv(fd, message, buflen, 0);
|
||||
if (len < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_dhcp_client_errno(client, errno,
|
||||
@@ -1814,7 +1814,7 @@ static int client_receive_message_raw(
|
||||
|
||||
len = recvmsg(fd, &msg, 0);
|
||||
if (len < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_dhcp_client_errno(client, errno,
|
||||
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
|
||||
index 5ca46b3502..c964b73da1 100644
|
||||
--- a/src/libsystemd-network/sd-dhcp-server.c
|
||||
+++ b/src/libsystemd-network/sd-dhcp-server.c
|
||||
@@ -962,7 +962,7 @@ static int server_receive_message(sd_event_source *s, int fd,
|
||||
|
||||
len = recvmsg(fd, &msg, 0);
|
||||
if (len < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(len))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
|
||||
index b3bc259280..67257f2e03 100644
|
||||
--- a/src/libsystemd-network/sd-dhcp6-client.c
|
||||
+++ b/src/libsystemd-network/sd-dhcp6-client.c
|
||||
@@ -1055,7 +1055,7 @@ static int client_receive_message(
|
||||
|
||||
len = recv(fd, message, buflen, 0);
|
||||
if (len < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(len))
|
||||
return 0;
|
||||
|
||||
return log_dhcp6_client_errno(client, errno, "Could not receive message from UDP socket: %m");
|
||||
diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c
|
||||
index a40d40db90..f69810c6f5 100644
|
||||
--- a/src/libsystemd-network/sd-ipv4acd.c
|
||||
+++ b/src/libsystemd-network/sd-ipv4acd.c
|
||||
@@ -336,7 +336,7 @@ static int ipv4acd_on_packet(
|
||||
|
||||
n = recv(fd, &packet, sizeof(struct ether_arp), 0);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
log_ipv4acd_errno(acd, errno, "Failed to read ARP packet: %m");
|
||||
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c
|
||||
index c75d6079e1..bf15029027 100644
|
||||
--- a/src/libsystemd-network/sd-lldp.c
|
||||
+++ b/src/libsystemd-network/sd-lldp.c
|
||||
@@ -200,7 +200,7 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
|
||||
|
||||
length = recv(fd, LLDP_NEIGHBOR_RAW(n), n->raw_size, MSG_DONTWAIT);
|
||||
if (length < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_lldp_errno(errno, "Failed to read LLDP datagram: %m");
|
||||
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||||
index 2c9d331bf2..549103bc6f 100644
|
||||
--- a/src/libsystemd/sd-event/sd-event.c
|
||||
+++ b/src/libsystemd/sd-event/sd-event.c
|
||||
@@ -3007,7 +3007,7 @@ static int flush_timer(sd_event *e, int fd, uint32_t events, usec_t *next) {
|
||||
|
||||
ss = read(fd, &x, sizeof(x));
|
||||
if (ss < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
@@ -3161,7 +3161,7 @@ static int process_signal(sd_event *e, struct signal_data *d, uint32_t events) {
|
||||
|
||||
n = read(d->fd, &si, sizeof(si));
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return read_one;
|
||||
|
||||
return -errno;
|
||||
@@ -3210,7 +3210,7 @@ static int event_inotify_data_read(sd_event *e, struct inotify_data *d, uint32_t
|
||||
|
||||
n = read(d->fd, &d->buffer, sizeof(d->buffer));
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/libsystemd/sd-netlink/netlink-socket.c b/src/libsystemd/sd-netlink/netlink-socket.c
|
||||
index f103cbedea..5fe91450a7 100644
|
||||
--- a/src/libsystemd/sd-netlink/netlink-socket.c
|
||||
+++ b/src/libsystemd/sd-netlink/netlink-socket.c
|
||||
@@ -265,7 +265,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
|
||||
else if (errno == EAGAIN)
|
||||
log_debug("rtnl: no data in socket");
|
||||
|
||||
- return IN_SET(errno, EAGAIN, EINTR) ? 0 : -errno;
|
||||
+ return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
|
||||
}
|
||||
|
||||
if (sender.nl.nl_pid != 0) {
|
||||
@@ -276,7 +276,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
|
||||
/* drop the message */
|
||||
n = recvmsg(fd, &msg, 0);
|
||||
if (n < 0)
|
||||
- return IN_SET(errno, EAGAIN, EINTR) ? 0 : -errno;
|
||||
+ return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
|
||||
}
|
||||
|
||||
return 0;
|
||||
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
|
||||
index 3b8ce935b0..09d3b86e14 100644
|
||||
--- a/src/libsystemd/sd-network/sd-network.c
|
||||
+++ b/src/libsystemd/sd-network/sd-network.c
|
||||
@@ -338,7 +338,7 @@ _public_ int sd_network_monitor_flush(sd_network_monitor *m) {
|
||||
|
||||
l = read(fd, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
|
||||
index 8cb7591f0e..025a513def 100644
|
||||
--- a/src/nspawn/nspawn.c
|
||||
+++ b/src/nspawn/nspawn.c
|
||||
@@ -3252,7 +3252,7 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
||||
|
||||
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(n))
|
||||
return 0;
|
||||
|
||||
return log_warning_errno(errno, "Couldn't read notification socket: %m");
|
||||
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
|
||||
index ca0313d1d7..cebaba4207 100644
|
||||
--- a/src/resolve/resolved-dns-stream.c
|
||||
+++ b/src/resolve/resolved-dns-stream.c
|
||||
@@ -380,7 +380,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
|
||||
|
||||
ss = dns_stream_writev(s, iov, 2, 0);
|
||||
if (ss < 0) {
|
||||
- if (!IN_SET(-ss, EINTR, EAGAIN))
|
||||
+ if (!ERRNO_IS_TRANSIENT(ss))
|
||||
return dns_stream_complete(s, -ss);
|
||||
} else
|
||||
s->n_written += ss;
|
||||
@@ -402,7 +402,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
|
||||
|
||||
ss = dns_stream_read(s, (uint8_t*) &s->read_size + s->n_read, sizeof(s->read_size) - s->n_read);
|
||||
if (ss < 0) {
|
||||
- if (!IN_SET(-ss, EINTR, EAGAIN))
|
||||
+ if (!ERRNO_IS_TRANSIENT(ss))
|
||||
return dns_stream_complete(s, -ss);
|
||||
} else if (ss == 0)
|
||||
return dns_stream_complete(s, ECONNRESET);
|
||||
@@ -452,7 +452,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
|
||||
(uint8_t*) DNS_PACKET_DATA(s->read_packet) + s->n_read - sizeof(s->read_size),
|
||||
sizeof(s->read_size) + be16toh(s->read_size) - s->n_read);
|
||||
if (ss < 0) {
|
||||
- if (!IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (!ERRNO_IS_TRANSIENT(errno))
|
||||
return dns_stream_complete(s, errno);
|
||||
} else if (ss == 0)
|
||||
return dns_stream_complete(s, ECONNRESET);
|
||||
diff --git a/src/resolve/resolved-dns-stub.c b/src/resolve/resolved-dns-stub.c
|
||||
index 5ddf13081e..1b80c42174 100644
|
||||
--- a/src/resolve/resolved-dns-stub.c
|
||||
+++ b/src/resolve/resolved-dns-stub.c
|
||||
@@ -458,7 +458,7 @@ static int on_dns_stub_stream(sd_event_source *s, int fd, uint32_t revents, void
|
||||
|
||||
cfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
|
||||
if (cfd < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
||||
index 01372fc66b..2a23c387a6 100644
|
||||
--- a/src/resolve/resolved-manager.c
|
||||
+++ b/src/resolve/resolved-manager.c
|
||||
@@ -755,7 +755,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||
if (l == 0)
|
||||
return 0;
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
|
||||
index 764ebd08e1..062db31bbd 100644
|
||||
--- a/src/shared/ask-password-api.c
|
||||
+++ b/src/shared/ask-password-api.c
|
||||
@@ -332,7 +332,7 @@ int ask_password_tty(
|
||||
|
||||
n = read(ttyfd >= 0 ? ttyfd : STDIN_FILENO, &c, 1);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
r = -errno;
|
||||
@@ -652,7 +652,7 @@ int ask_password_agent(
|
||||
|
||||
n = recvmsg(socket_fd, &msghdr, 0);
|
||||
if (n < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
r = -errno;
|
||||
@@ -661,7 +661,7 @@ int ask_password_agent(
|
||||
|
||||
cmsg_close_all(&msghdr);
|
||||
|
||||
- if (n <= 0) {
|
||||
+ if (n == 0) {
|
||||
log_debug("Message too short");
|
||||
continue;
|
||||
}
|
||||
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
|
||||
index 3d07483eb4..155631f1e7 100644
|
||||
--- a/src/socket-proxy/socket-proxyd.c
|
||||
+++ b/src/socket-proxy/socket-proxyd.c
|
||||
@@ -144,7 +144,7 @@ static int connection_shovel(
|
||||
} else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {
|
||||
*from_source = sd_event_source_unref(*from_source);
|
||||
*from = safe_close(*from);
|
||||
- } else if (!IN_SET(errno, EAGAIN, EINTR))
|
||||
+ } else if (!ERRNO_IS_TRANSIENT(errno))
|
||||
return log_error_errno(errno, "Failed to splice: %m");
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ static int connection_shovel(
|
||||
} else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {
|
||||
*to_source = sd_event_source_unref(*to_source);
|
||||
*to = safe_close(*to);
|
||||
- } else if (!IN_SET(errno, EAGAIN, EINTR))
|
||||
+ } else if (!ERRNO_IS_TRANSIENT(errno))
|
||||
return log_error_errno(errno, "Failed to splice: %m");
|
||||
}
|
||||
} while (shoveled);
|
||||
diff --git a/src/time-wait-sync/time-wait-sync.c b/src/time-wait-sync/time-wait-sync.c
|
||||
index d268fb0c5a..2071cb2759 100644
|
||||
--- a/src/time-wait-sync/time-wait-sync.c
|
||||
+++ b/src/time-wait-sync/time-wait-sync.c
|
||||
@@ -94,7 +94,7 @@ static int inotify_handler(sd_event_source *s,
|
||||
|
||||
l = read(fd, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return log_warning_errno(errno, "Lost access to inotify: %m");
|
||||
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
|
||||
index 40d594896b..3a20a381c9 100644
|
||||
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
|
||||
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
|
||||
@@ -150,7 +150,7 @@ static int ask_password_plymouth(
|
||||
|
||||
k = read(fd, buffer + p, sizeof(buffer) - p);
|
||||
if (k < 0) {
|
||||
- if (IN_SET(errno, EINTR, EAGAIN))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
r = -errno;
|
||||
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
|
||||
index 34f6a95503..172d21018e 100644
|
||||
--- a/src/udev/udevd.c
|
||||
+++ b/src/udev/udevd.c
|
||||
@@ -1119,7 +1119,7 @@ static int on_inotify(sd_event_source *s, int fd, uint32_t revents, void *userda
|
||||
|
||||
l = read(fd, &buffer, sizeof(buffer));
|
||||
if (l < 0) {
|
||||
- if (IN_SET(errno, EAGAIN, EINTR))
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 1;
|
||||
|
||||
return log_error_errno(errno, "Failed to read inotify fd: %m");
|
@ -1,75 +0,0 @@
|
||||
From 4cbf11180cc6c6792f541a861f3309c34c156f4b Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 30 Nov 2021 03:33:55 +0900
|
||||
Subject: [PATCH] libsystemd: ignore both EINTR and EAGAIN
|
||||
|
||||
(cherry picked from commit b3d06b9226db96fddb6bb45a4708e2e8d413d91d)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/libsystemd/sd-bus/bus-socket.c | 8 ++++----
|
||||
src/libsystemd/sd-resolve/sd-resolve.c | 4 ++--
|
||||
2 files changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
|
||||
index 8813dd5efd..c6e1a1624f 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-socket.c
|
||||
+++ b/src/libsystemd/sd-bus/bus-socket.c
|
||||
@@ -155,7 +155,7 @@ static int bus_socket_write_auth(sd_bus *b) {
|
||||
}
|
||||
|
||||
if (k < 0)
|
||||
- return errno == EAGAIN ? 0 : -errno;
|
||||
+ return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
|
||||
|
||||
iovec_advance(b->auth_iovec, &b->auth_index, (size_t) k);
|
||||
return 1;
|
||||
@@ -573,7 +573,7 @@ static int bus_socket_read_auth(sd_bus *b) {
|
||||
handle_cmsg = true;
|
||||
}
|
||||
if (k < 0)
|
||||
- return errno == EAGAIN ? 0 : -errno;
|
||||
+ return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
|
||||
if (k == 0)
|
||||
return -ECONNRESET;
|
||||
|
||||
@@ -1051,7 +1051,7 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) {
|
||||
}
|
||||
|
||||
if (k < 0)
|
||||
- return errno == EAGAIN ? 0 : -errno;
|
||||
+ return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
|
||||
|
||||
*idx += (size_t) k;
|
||||
return 1;
|
||||
@@ -1205,7 +1205,7 @@ int bus_socket_read_message(sd_bus *bus) {
|
||||
handle_cmsg = true;
|
||||
}
|
||||
if (k < 0)
|
||||
- return errno == EAGAIN ? 0 : -errno;
|
||||
+ return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
|
||||
if (k == 0)
|
||||
return -ECONNRESET;
|
||||
|
||||
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
|
||||
index a189f140f8..99ecb6a467 100644
|
||||
--- a/src/libsystemd/sd-resolve/sd-resolve.c
|
||||
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
|
||||
@@ -402,7 +402,7 @@ static void* thread_worker(void *p) {
|
||||
|
||||
length = recv(resolve->fds[REQUEST_RECV_FD], &buf, sizeof buf, 0);
|
||||
if (length < 0) {
|
||||
- if (errno == EINTR)
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
break;
|
||||
@@ -850,7 +850,7 @@ _public_ int sd_resolve_process(sd_resolve *resolve) {
|
||||
|
||||
l = recv(resolve->fds[RESPONSE_RECV_FD], &buf, sizeof buf, 0);
|
||||
if (l < 0) {
|
||||
- if (errno == EAGAIN)
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
@ -1,90 +0,0 @@
|
||||
From b1075e8b3ecb9e0770dd46331ce8517ea152e1ca Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 21 Nov 2022 17:42:04 +0100
|
||||
Subject: [PATCH] sd-bus: handle -EINTR return from bus_poll()
|
||||
|
||||
In sd_bus_wait(), let's convert EINTR to a return code of 0, thus asking
|
||||
the caller do loop again and enter sd_bus_process() again (which will
|
||||
not find any queued events). This way we'll not return an error on
|
||||
something that isn't really an error. This should typically make sure
|
||||
things are properly handled by the caller, magically, without eating up
|
||||
the event entirely, and still giving the caller time to run some code if
|
||||
they want.
|
||||
|
||||
(cherry picked from commit 3022916b4d2483452c3ddbbac9ee7c4372b1cb46)
|
||||
|
||||
Resolves: #2172846
|
||||
---
|
||||
src/libsystemd/sd-bus/bus-socket.c | 5 ++++-
|
||||
src/libsystemd/sd-bus/sd-bus.c | 18 +++++++++++++++---
|
||||
2 files changed, 19 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
|
||||
index c6e1a1624f..a5c750fc69 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-socket.c
|
||||
+++ b/src/libsystemd/sd-bus/bus-socket.c
|
||||
@@ -1266,8 +1266,11 @@ int bus_socket_process_opening(sd_bus *b) {
|
||||
assert(b->state == BUS_OPENING);
|
||||
|
||||
r = poll(&p, 1, 0);
|
||||
- if (r < 0)
|
||||
+ if (r < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
+ return 0;
|
||||
return -errno;
|
||||
+ }
|
||||
|
||||
if (!(p.revents & (POLLOUT|POLLERR|POLLHUP)))
|
||||
return 0;
|
||||
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
|
||||
index 21e54591f7..5d934cbf73 100644
|
||||
--- a/src/libsystemd/sd-bus/sd-bus.c
|
||||
+++ b/src/libsystemd/sd-bus/sd-bus.c
|
||||
@@ -2209,8 +2209,11 @@ _public_ int sd_bus_call(
|
||||
left = (uint64_t) -1;
|
||||
|
||||
r = bus_poll(bus, true, left);
|
||||
- if (r < 0)
|
||||
+ if (r < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(r))
|
||||
+ continue;
|
||||
goto fail;
|
||||
+ }
|
||||
if (r == 0) {
|
||||
r = -ETIMEDOUT;
|
||||
goto fail;
|
||||
@@ -3069,6 +3072,7 @@ static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
|
||||
}
|
||||
|
||||
_public_ int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec) {
|
||||
+ int r;
|
||||
|
||||
assert_return(bus, -EINVAL);
|
||||
assert_return(bus = bus_resolve(bus), -ENOPKG);
|
||||
@@ -3083,7 +3087,11 @@ _public_ int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec) {
|
||||
if (bus->rqueue_size > 0)
|
||||
return 0;
|
||||
|
||||
- return bus_poll(bus, false, timeout_usec);
|
||||
+ r = bus_poll(bus, false, timeout_usec);
|
||||
+ if (r < 0 && ERRNO_IS_TRANSIENT(r))
|
||||
+ return 1; /* treat EINTR as success, but let's exit, so that the caller will call back into us soon. */
|
||||
+
|
||||
+ return r;
|
||||
}
|
||||
|
||||
_public_ int sd_bus_flush(sd_bus *bus) {
|
||||
@@ -3125,8 +3133,12 @@ _public_ int sd_bus_flush(sd_bus *bus) {
|
||||
return 0;
|
||||
|
||||
r = bus_poll(bus, false, (uint64_t) -1);
|
||||
- if (r < 0)
|
||||
+ if (r < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(r))
|
||||
+ continue;
|
||||
+
|
||||
return r;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
From 9ddb41dd9dc3bac57d6c3e05700485ee98df3e17 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 22 Nov 2022 12:18:07 +0100
|
||||
Subject: [PATCH] stdio-bridge: don't be bothered with EINTR
|
||||
|
||||
We handle signals via signal handlers, hence no need to be concerned
|
||||
about EINTR.
|
||||
|
||||
(cherry picked from commit 7c75f34131772781f690860de797d3e35fd0bed9)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/stdio-bridge/stdio-bridge.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c
|
||||
index 519a92a094..493117ef95 100644
|
||||
--- a/src/stdio-bridge/stdio-bridge.c
|
||||
+++ b/src/stdio-bridge/stdio-bridge.c
|
||||
@@ -276,6 +276,8 @@ int main(int argc, char *argv[]) {
|
||||
r = ppoll(p, ELEMENTSOF(p), ts, NULL);
|
||||
}
|
||||
if (r < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(r)) /* don't be bothered by signals, i.e. EINTR */
|
||||
+ continue;
|
||||
log_error_errno(errno, "ppoll() failed: %m");
|
||||
goto finish;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
From da367d5c87c039f4d1250c12097a5fb16f179a70 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 22 Nov 2022 13:00:48 +0100
|
||||
Subject: [PATCH] sd-netlink: handle EINTR from poll() gracefully, as success
|
||||
|
||||
(cherry picked from commit 69858785335afffc51bc03127beb53332c0fb983)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/libsystemd/sd-netlink/sd-netlink.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
|
||||
index a177f220ab..09900d577b 100644
|
||||
--- a/src/libsystemd/sd-netlink/sd-netlink.c
|
||||
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
|
||||
@@ -488,13 +488,18 @@ static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
|
||||
}
|
||||
|
||||
int sd_netlink_wait(sd_netlink *nl, uint64_t timeout_usec) {
|
||||
+ int r;
|
||||
+
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!rtnl_pid_changed(nl), -ECHILD);
|
||||
|
||||
if (nl->rqueue_size > 0)
|
||||
return 0;
|
||||
|
||||
- return rtnl_poll(nl, false, timeout_usec);
|
||||
+ r = rtnl_poll(nl, false, timeout_usec);
|
||||
+ if (r < 0 && ERRNO_IS_TRANSIENT(r)) /* Convert EINTR to "something happened" and give user a chance to run some code before calling back into us */
|
||||
+ return 1;
|
||||
+ return r;
|
||||
}
|
||||
|
||||
static int timeout_compare(const void *a, const void *b) {
|
@ -1,79 +0,0 @@
|
||||
From 1316ec49f209e31799d42d114bd7f35d5acbe097 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 22 Nov 2022 12:28:19 +0100
|
||||
Subject: [PATCH] resolved: handle -EINTR returned from fd_wait_for_event()
|
||||
better
|
||||
|
||||
We might get signals for various reasons (for example, somebody asking
|
||||
us to reload caches via a signal), hence let's handle this gracefully.
|
||||
|
||||
(cherry picked from commit 6d66a221685c15798e796d9738f73fdb1fdccdb2)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/resolve/resolved-manager.c | 20 ++++++++++++++++----
|
||||
1 file changed, 16 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
||||
index 2a23c387a6..5583d63527 100644
|
||||
--- a/src/resolve/resolved-manager.c
|
||||
+++ b/src/resolve/resolved-manager.c
|
||||
@@ -842,11 +842,14 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||
}
|
||||
|
||||
static int sendmsg_loop(int fd, struct msghdr *mh, int flags) {
|
||||
+ usec_t end;
|
||||
int r;
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(mh);
|
||||
|
||||
+ end = usec_add(now(CLOCK_MONOTONIC), SEND_TIMEOUT_USEC);
|
||||
+
|
||||
for (;;) {
|
||||
if (sendmsg(fd, mh, flags) >= 0)
|
||||
return 0;
|
||||
@@ -857,20 +860,26 @@ static int sendmsg_loop(int fd, struct msghdr *mh, int flags) {
|
||||
if (errno != EAGAIN)
|
||||
return -errno;
|
||||
|
||||
- r = fd_wait_for_event(fd, POLLOUT, SEND_TIMEOUT_USEC);
|
||||
- if (r < 0)
|
||||
+ r = fd_wait_for_event(fd, POLLOUT, LESS_BY(end, now(CLOCK_MONOTONIC)));
|
||||
+ if (r < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(r))
|
||||
+ continue;
|
||||
return r;
|
||||
+ }
|
||||
if (r == 0)
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
}
|
||||
|
||||
static int write_loop(int fd, void *message, size_t length) {
|
||||
+ usec_t end;
|
||||
int r;
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(message);
|
||||
|
||||
+ end = usec_add(now(CLOCK_MONOTONIC), SEND_TIMEOUT_USEC);
|
||||
+
|
||||
for (;;) {
|
||||
if (write(fd, message, length) >= 0)
|
||||
return 0;
|
||||
@@ -881,9 +890,12 @@ static int write_loop(int fd, void *message, size_t length) {
|
||||
if (errno != EAGAIN)
|
||||
return -errno;
|
||||
|
||||
- r = fd_wait_for_event(fd, POLLOUT, SEND_TIMEOUT_USEC);
|
||||
- if (r < 0)
|
||||
+ r = fd_wait_for_event(fd, POLLOUT, LESS_BY(end, now(CLOCK_MONOTONIC)));
|
||||
+ if (r < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(r))
|
||||
+ continue;
|
||||
return r;
|
||||
+ }
|
||||
if (r == 0)
|
||||
return -ETIMEDOUT;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
From c57daab191c6551ac757576fcf7df45fd9790b6b Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 22 Nov 2022 12:56:38 +0100
|
||||
Subject: [PATCH] utmp-wtmp: fix error in case isatty() fails
|
||||
|
||||
(cherry picked from commit 80b780ba178a84b248ecee47eef82358480c9492)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/shared/utmp-wtmp.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c
|
||||
index ef9427fa7b..743b784489 100644
|
||||
--- a/src/shared/utmp-wtmp.c
|
||||
+++ b/src/shared/utmp-wtmp.c
|
||||
@@ -312,8 +312,10 @@ static int write_to_terminal(const char *tty, const char *message) {
|
||||
assert(message);
|
||||
|
||||
fd = open(tty, O_WRONLY|O_NONBLOCK|O_NOCTTY|O_CLOEXEC);
|
||||
- if (fd < 0 || !isatty(fd))
|
||||
+ if (fd < 0)
|
||||
return -errno;
|
||||
+ if (!isatty(fd))
|
||||
+ return -ENOTTY;
|
||||
|
||||
p = message;
|
||||
left = strlen(message);
|
@ -1,52 +0,0 @@
|
||||
From 3590a9c5ce038bc56cdded426156cbd278903c86 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 22 Nov 2022 12:56:55 +0100
|
||||
Subject: [PATCH] utmp-wtmp: handle EINTR gracefully when waiting to write to
|
||||
tty
|
||||
|
||||
(cherry picked from commit 22ecfa83123dbfa2322346ac4e25ad2193a3b10c)
|
||||
|
||||
Related: #2172846
|
||||
---
|
||||
src/shared/utmp-wtmp.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c
|
||||
index 743b784489..7358ece75d 100644
|
||||
--- a/src/shared/utmp-wtmp.c
|
||||
+++ b/src/shared/utmp-wtmp.c
|
||||
@@ -320,7 +320,7 @@ static int write_to_terminal(const char *tty, const char *message) {
|
||||
p = message;
|
||||
left = strlen(message);
|
||||
|
||||
- end = now(CLOCK_MONOTONIC) + TIMEOUT_MSEC*USEC_PER_MSEC;
|
||||
+ end = usec_add(now(CLOCK_MONOTONIC), TIMEOUT_MSEC*USEC_PER_MSEC);
|
||||
|
||||
while (left > 0) {
|
||||
ssize_t n;
|
||||
@@ -332,20 +332,22 @@ static int write_to_terminal(const char *tty, const char *message) {
|
||||
int k;
|
||||
|
||||
t = now(CLOCK_MONOTONIC);
|
||||
-
|
||||
if (t >= end)
|
||||
return -ETIME;
|
||||
|
||||
k = poll(&pollfd, 1, (end - t) / USEC_PER_MSEC);
|
||||
- if (k < 0)
|
||||
+ if (k < 0) {
|
||||
+ if (ERRNO_IS_TRANSIENT(k))
|
||||
+ continue;
|
||||
return -errno;
|
||||
|
||||
+ }
|
||||
if (k == 0)
|
||||
return -ETIME;
|
||||
|
||||
n = write(fd, p, left);
|
||||
if (n < 0) {
|
||||
- if (errno == EAGAIN)
|
||||
+ if (ERRNO_IS_TRANSIENT(errno))
|
||||
continue;
|
||||
|
||||
return -errno;
|
@ -1,90 +0,0 @@
|
||||
From 947296a00d17ef115f4097aa86a8c6f1bfc8bf58 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Wed, 22 Mar 2023 12:36:54 +0100
|
||||
Subject: [PATCH] journal-vacuum: count size of all journal files
|
||||
|
||||
Currently, active journal files are excluded, which means that vacuuming
|
||||
may not remove anything even if *MaxUse= has been exceeded.
|
||||
|
||||
(cherry picked from commit 9ea46af4f2368b41d57705bac09774778126507f)
|
||||
|
||||
Resolves: #2180380
|
||||
---
|
||||
src/journal/journal-vacuum.c | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
|
||||
index 8d3ae71440..dd21f40966 100644
|
||||
--- a/src/journal/journal-vacuum.c
|
||||
+++ b/src/journal/journal-vacuum.c
|
||||
@@ -179,6 +179,8 @@ int journal_directory_vacuum(
|
||||
if (!S_ISREG(st.st_mode))
|
||||
continue;
|
||||
|
||||
+ size = 512UL * (uint64_t) st.st_blocks;
|
||||
+
|
||||
q = strlen(de->d_name);
|
||||
|
||||
if (endswith(de->d_name, ".journal")) {
|
||||
@@ -188,6 +190,7 @@ int journal_directory_vacuum(
|
||||
|
||||
if (q < 1 + 32 + 1 + 16 + 1 + 16 + 8) {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -195,6 +198,7 @@ int journal_directory_vacuum(
|
||||
de->d_name[q-8-16-1-16-1] != '-' ||
|
||||
de->d_name[q-8-16-1-16-1-32-1] != '@') {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -207,11 +211,13 @@ int journal_directory_vacuum(
|
||||
de->d_name[q-8-16-1-16-1] = 0;
|
||||
if (sd_id128_from_string(de->d_name + q-8-16-1-16-1-32, &seqnum_id) < 0) {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sscanf(de->d_name + q-8-16-1-16, "%16llx-%16llx.journal", &seqnum, &realtime) != 2) {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -224,12 +230,14 @@ int journal_directory_vacuum(
|
||||
|
||||
if (q < 1 + 16 + 1 + 16 + 8 + 1) {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (de->d_name[q-1-8-16-1] != '-' ||
|
||||
de->d_name[q-1-8-16-1-16-1] != '@') {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -241,6 +249,7 @@ int journal_directory_vacuum(
|
||||
|
||||
if (sscanf(de->d_name + q-1-8-16-1-16, "%16llx-%16llx.journal~", &realtime, &tmp) != 2) {
|
||||
n_active_files++;
|
||||
+ sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -251,8 +260,6 @@ int journal_directory_vacuum(
|
||||
continue;
|
||||
}
|
||||
|
||||
- size = 512UL * (uint64_t) st.st_blocks;
|
||||
-
|
||||
r = journal_file_empty(dirfd(d), p);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed check if %s is empty, ignoring: %m", p);
|
@ -1,365 +0,0 @@
|
||||
From fc8959efebc662f4050700cc1ed2798750b15b73 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Fri, 6 Nov 2020 13:32:53 +0100
|
||||
Subject: [PATCH] resolved: instead of closing DNS UDP transaction fds
|
||||
right-away, add them to a socket "graveyard"
|
||||
|
||||
The "socket graveyard" shall contain sockets we have sent a question out
|
||||
of, but not received a reply. If we'd close thus sockets immediately
|
||||
when we are not interested anymore, we'd trigger ICMP port unreachable
|
||||
messages once we after all *do* get a reply. Let's avoid that, by
|
||||
leaving the fds open for a bit longer, until a timeout is reached or a
|
||||
reply datagram received.
|
||||
|
||||
Fixes: #17421
|
||||
(cherry picked from commit 80710ade03d971a8877fde8ce9d42eb2b07f4c47)
|
||||
|
||||
Resolves: #2156751
|
||||
---
|
||||
src/resolve/meson.build | 2 +
|
||||
src/resolve/resolved-dns-transaction.c | 44 ++++++--
|
||||
src/resolve/resolved-manager.c | 2 +
|
||||
src/resolve/resolved-manager.h | 5 +
|
||||
src/resolve/resolved-socket-graveyard.c | 133 ++++++++++++++++++++++++
|
||||
src/resolve/resolved-socket-graveyard.h | 18 ++++
|
||||
6 files changed, 194 insertions(+), 10 deletions(-)
|
||||
create mode 100644 src/resolve/resolved-socket-graveyard.c
|
||||
create mode 100644 src/resolve/resolved-socket-graveyard.h
|
||||
|
||||
diff --git a/src/resolve/meson.build b/src/resolve/meson.build
|
||||
index 15f3835d55..a975e58242 100644
|
||||
--- a/src/resolve/meson.build
|
||||
+++ b/src/resolve/meson.build
|
||||
@@ -63,6 +63,8 @@ systemd_resolved_sources = files('''
|
||||
resolved-dns-stub.c
|
||||
resolved-etc-hosts.h
|
||||
resolved-etc-hosts.c
|
||||
+ resolved-socket-graveyard.c
|
||||
+ resolved-socket-graveyard.h
|
||||
'''.split())
|
||||
|
||||
resolvectl_sources = files('''
|
||||
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
|
||||
index c60b8215a6..95aea21134 100644
|
||||
--- a/src/resolve/resolved-dns-transaction.c
|
||||
+++ b/src/resolve/resolved-dns-transaction.c
|
||||
@@ -48,7 +48,14 @@ static void dns_transaction_flush_dnssec_transactions(DnsTransaction *t) {
|
||||
}
|
||||
}
|
||||
|
||||
-static void dns_transaction_close_connection(DnsTransaction *t) {
|
||||
+static void dns_transaction_close_connection(
|
||||
+ DnsTransaction *t,
|
||||
+ bool use_graveyard) { /* Set use_graveyard = false when you know the connection is already
|
||||
+ * dead, for example because you got a connection error back from the
|
||||
+ * kernel. In that case there's no point in keeping the fd around,
|
||||
+ * hence don't. */
|
||||
+ int r;
|
||||
+
|
||||
assert(t);
|
||||
|
||||
if (t->stream) {
|
||||
@@ -62,6 +69,20 @@ static void dns_transaction_close_connection(DnsTransaction *t) {
|
||||
}
|
||||
|
||||
t->dns_udp_event_source = sd_event_source_unref(t->dns_udp_event_source);
|
||||
+
|
||||
+ /* If we have an UDP socket where we sent a packet, but never received one, then add it to the socket
|
||||
+ * graveyard, instead of closing it right away. That way it will stick around for a moment longer,
|
||||
+ * and the reply we might still get from the server will be eaten up instead of resulting in an ICMP
|
||||
+ * port unreachable error message. */
|
||||
+
|
||||
+ if (use_graveyard && t->dns_udp_fd >= 0 && t->sent && !t->received) {
|
||||
+ r = manager_add_socket_to_graveyard(t->scope->manager, t->dns_udp_fd);
|
||||
+ if (r < 0)
|
||||
+ log_debug_errno(r, "Failed to add UDP socket to graveyard, closing immediately: %m");
|
||||
+ else
|
||||
+ TAKE_FD(t->dns_udp_fd);
|
||||
+ }
|
||||
+
|
||||
t->dns_udp_fd = safe_close(t->dns_udp_fd);
|
||||
}
|
||||
|
||||
@@ -81,7 +102,7 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
|
||||
|
||||
log_debug("Freeing transaction %" PRIu16 ".", t->id);
|
||||
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
dns_transaction_stop_timeout(t);
|
||||
|
||||
dns_packet_unref(t->sent);
|
||||
@@ -341,7 +362,7 @@ void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state) {
|
||||
|
||||
t->state = state;
|
||||
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
dns_transaction_stop_timeout(t);
|
||||
|
||||
/* Notify all queries that are interested, but make sure the
|
||||
@@ -455,7 +476,7 @@ static int dns_transaction_maybe_restart(DnsTransaction *t) {
|
||||
static void on_transaction_stream_error(DnsTransaction *t, int error) {
|
||||
assert(t);
|
||||
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
|
||||
if (ERRNO_IS_DISCONNECT(error)) {
|
||||
if (t->scope->protocol == DNS_PROTOCOL_LLMNR) {
|
||||
@@ -478,7 +499,7 @@ static int dns_transaction_on_stream_packet(DnsTransaction *t, DnsPacket *p) {
|
||||
assert(t);
|
||||
assert(p);
|
||||
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
|
||||
if (dns_packet_validate_reply(p) <= 0) {
|
||||
log_debug("Invalid TCP reply packet.");
|
||||
@@ -583,7 +604,7 @@ static int dns_transaction_emit_tcp(DnsTransaction *t) {
|
||||
|
||||
assert(t);
|
||||
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
|
||||
switch (t->scope->protocol) {
|
||||
|
||||
@@ -692,7 +713,7 @@ static int dns_transaction_emit_tcp(DnsTransaction *t) {
|
||||
|
||||
r = dns_stream_write_packet(t->stream, t->sent);
|
||||
if (r < 0) {
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, /* use_graveyard= */ false);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1196,7 +1217,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
|
||||
if (r > 0) {
|
||||
/* There are DNSSEC transactions pending now. Update the state accordingly. */
|
||||
t->state = DNS_TRANSACTION_VALIDATING;
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
dns_transaction_stop_timeout(t);
|
||||
return;
|
||||
}
|
||||
@@ -1277,7 +1298,10 @@ static int dns_transaction_emit_udp(DnsTransaction *t) {
|
||||
if (r > 0 || t->dns_udp_fd < 0) { /* Server changed, or no connection yet. */
|
||||
int fd;
|
||||
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
+
|
||||
+ /* Before we allocate a new UDP socket, let's process the graveyard a bit to free some fds */
|
||||
+ manager_socket_graveyard_process(t->scope->manager);
|
||||
|
||||
fd = dns_scope_socket_udp(t->scope, t->server, 53);
|
||||
if (fd < 0)
|
||||
@@ -1297,7 +1321,7 @@ static int dns_transaction_emit_udp(DnsTransaction *t) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else
|
||||
- dns_transaction_close_connection(t);
|
||||
+ dns_transaction_close_connection(t, true);
|
||||
|
||||
r = dns_scope_emit_udp(t->scope, t->dns_udp_fd, t->sent);
|
||||
if (r < 0)
|
||||
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
||||
index 5583d63527..5feb92a676 100644
|
||||
--- a/src/resolve/resolved-manager.c
|
||||
+++ b/src/resolve/resolved-manager.c
|
||||
@@ -683,6 +683,8 @@ Manager *manager_free(Manager *m) {
|
||||
manager_mdns_stop(m);
|
||||
manager_dns_stub_stop(m);
|
||||
|
||||
+ manager_socket_graveyard_clear(m);
|
||||
+
|
||||
sd_bus_slot_unref(m->prepare_for_sleep_slot);
|
||||
sd_bus_unref(m->bus);
|
||||
|
||||
diff --git a/src/resolve/resolved-manager.h b/src/resolve/resolved-manager.h
|
||||
index d94b2888ab..80119bfcb3 100644
|
||||
--- a/src/resolve/resolved-manager.h
|
||||
+++ b/src/resolve/resolved-manager.h
|
||||
@@ -20,6 +20,7 @@ typedef struct Manager Manager;
|
||||
#include "resolved-dns-stream.h"
|
||||
#include "resolved-dns-trust-anchor.h"
|
||||
#include "resolved-link.h"
|
||||
+#include "resolved-socket-graveyard.h"
|
||||
|
||||
#define MANAGER_SEARCH_DOMAINS_MAX 32
|
||||
#define MANAGER_DNS_SERVERS_MAX 32
|
||||
@@ -130,6 +131,10 @@ struct Manager {
|
||||
sd_event_source *dns_stub_tcp_event_source;
|
||||
|
||||
Hashmap *polkit_registry;
|
||||
+
|
||||
+ LIST_HEAD(SocketGraveyard, socket_graveyard);
|
||||
+ SocketGraveyard *socket_graveyard_oldest;
|
||||
+ size_t n_socket_graveyard;
|
||||
};
|
||||
|
||||
/* Manager */
|
||||
diff --git a/src/resolve/resolved-socket-graveyard.c b/src/resolve/resolved-socket-graveyard.c
|
||||
new file mode 100644
|
||||
index 0000000000..067cb666d4
|
||||
--- /dev/null
|
||||
+++ b/src/resolve/resolved-socket-graveyard.c
|
||||
@@ -0,0 +1,133 @@
|
||||
+/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
+
|
||||
+#include "resolved-socket-graveyard.h"
|
||||
+
|
||||
+#define SOCKET_GRAVEYARD_USEC (5 * USEC_PER_SEC)
|
||||
+#define SOCKET_GRAVEYARD_MAX 100
|
||||
+
|
||||
+/* This implements a socket "graveyard" for UDP sockets. If a socket fd is added to the graveyard it is kept
|
||||
+ * open for a couple of more seconds, expecting one reply. Once the reply is received the fd is closed
|
||||
+ * immediately, or if none is received it is closed after the timeout. Why all this? So that if we contact a
|
||||
+ * DNS server, and it doesn't reply instantly, and we lose interest in the response and thus close the fd, we
|
||||
+ * don't end up sending back an ICMP error once the server responds but we aren't listening anymore. (See
|
||||
+ * https://github.com/systemd/systemd/issues/17421 for further information.)
|
||||
+ *
|
||||
+ * Note that we don't allocate any timer event source to clear up the graveyard once the socket's timeout is
|
||||
+ * reached. Instead we operate lazily: we close old entries when adding a new fd to the graveyard, or
|
||||
+ * whenever any code runs manager_socket_graveyard_process() — which the DNS transaction code does right
|
||||
+ * before allocating a new UDP socket. */
|
||||
+
|
||||
+static SocketGraveyard* socket_graveyard_free(SocketGraveyard *g) {
|
||||
+ if (!g)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (g->manager) {
|
||||
+ assert(g->manager->n_socket_graveyard > 0);
|
||||
+ g->manager->n_socket_graveyard--;
|
||||
+
|
||||
+ if (g->manager->socket_graveyard_oldest == g)
|
||||
+ g->manager->socket_graveyard_oldest = g->graveyard_prev;
|
||||
+
|
||||
+ LIST_REMOVE(graveyard, g->manager->socket_graveyard, g);
|
||||
+
|
||||
+ assert((g->manager->n_socket_graveyard > 0) == !!g->manager->socket_graveyard);
|
||||
+ assert((g->manager->n_socket_graveyard > 0) == !!g->manager->socket_graveyard_oldest);
|
||||
+ }
|
||||
+
|
||||
+ if (g->io_event_source) {
|
||||
+ log_debug("Closing graveyard socket fd %i", sd_event_source_get_io_fd(g->io_event_source));
|
||||
+ sd_event_source_unref(g->io_event_source);
|
||||
+ }
|
||||
+
|
||||
+ return mfree(g);
|
||||
+}
|
||||
+
|
||||
+DEFINE_TRIVIAL_CLEANUP_FUNC(SocketGraveyard*, socket_graveyard_free);
|
||||
+
|
||||
+void manager_socket_graveyard_process(Manager *m) {
|
||||
+ usec_t n = USEC_INFINITY;
|
||||
+
|
||||
+ assert(m);
|
||||
+
|
||||
+ while (m->socket_graveyard_oldest) {
|
||||
+ SocketGraveyard *g = m->socket_graveyard_oldest;
|
||||
+
|
||||
+ if (n == USEC_INFINITY)
|
||||
+ assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &n) >= 0);
|
||||
+
|
||||
+ if (g->deadline > n)
|
||||
+ break;
|
||||
+
|
||||
+ socket_graveyard_free(g);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void manager_socket_graveyard_clear(Manager *m) {
|
||||
+ assert(m);
|
||||
+
|
||||
+ while (m->socket_graveyard)
|
||||
+ socket_graveyard_free(m->socket_graveyard);
|
||||
+}
|
||||
+
|
||||
+static int on_io_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
+ SocketGraveyard *g = userdata;
|
||||
+
|
||||
+ assert(g);
|
||||
+
|
||||
+ /* An IO event happened on the graveyard fd. We don't actually care which event that is, and we don't
|
||||
+ * read any incoming packet off the socket. We just close the fd, that's enough to not trigger the
|
||||
+ * ICMP unreachable port event */
|
||||
+
|
||||
+ socket_graveyard_free(g);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void manager_socket_graveyard_make_room(Manager *m) {
|
||||
+ assert(m);
|
||||
+
|
||||
+ while (m->n_socket_graveyard >= SOCKET_GRAVEYARD_MAX)
|
||||
+ socket_graveyard_free(m->socket_graveyard_oldest);
|
||||
+}
|
||||
+
|
||||
+int manager_add_socket_to_graveyard(Manager *m, int fd) {
|
||||
+ _cleanup_(socket_graveyard_freep) SocketGraveyard *g = NULL;
|
||||
+ int r;
|
||||
+
|
||||
+ assert(m);
|
||||
+ assert(fd >= 0);
|
||||
+
|
||||
+ manager_socket_graveyard_process(m);
|
||||
+ manager_socket_graveyard_make_room(m);
|
||||
+
|
||||
+ g = new(SocketGraveyard, 1);
|
||||
+ if (!g)
|
||||
+ return log_oom();
|
||||
+
|
||||
+ *g = (SocketGraveyard) {
|
||||
+ .manager = m,
|
||||
+ };
|
||||
+
|
||||
+ LIST_PREPEND(graveyard, m->socket_graveyard, g);
|
||||
+ if (!m->socket_graveyard_oldest)
|
||||
+ m->socket_graveyard_oldest = g;
|
||||
+
|
||||
+ m->n_socket_graveyard++;
|
||||
+
|
||||
+ assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &g->deadline) >= 0);
|
||||
+ g->deadline += SOCKET_GRAVEYARD_USEC;
|
||||
+
|
||||
+ r = sd_event_add_io(m->event, &g->io_event_source, fd, EPOLLIN, on_io_event, g);
|
||||
+ if (r < 0)
|
||||
+ return log_error_errno(r, "Failed to create graveyard IO source: %m");
|
||||
+
|
||||
+ r = sd_event_source_set_io_fd_own(g->io_event_source, true);
|
||||
+ if (r < 0)
|
||||
+ return log_error_errno(r, "Failed to enable graveyard IO source fd ownership: %m");
|
||||
+
|
||||
+ (void) sd_event_source_set_description(g->io_event_source, "graveyard");
|
||||
+
|
||||
+ log_debug("Added socket %i to graveyard", fd);
|
||||
+
|
||||
+ TAKE_PTR(g);
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/src/resolve/resolved-socket-graveyard.h b/src/resolve/resolved-socket-graveyard.h
|
||||
new file mode 100644
|
||||
index 0000000000..9b13bb0482
|
||||
--- /dev/null
|
||||
+++ b/src/resolve/resolved-socket-graveyard.h
|
||||
@@ -0,0 +1,18 @@
|
||||
+/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
+#pragma once
|
||||
+
|
||||
+typedef struct SocketGraveyard SocketGraveyard;
|
||||
+
|
||||
+#include "resolved-manager.h"
|
||||
+
|
||||
+struct SocketGraveyard {
|
||||
+ Manager *manager;
|
||||
+ usec_t deadline;
|
||||
+ sd_event_source *io_event_source;
|
||||
+ LIST_FIELDS(SocketGraveyard, graveyard);
|
||||
+};
|
||||
+
|
||||
+void manager_socket_graveyard_process(Manager *m);
|
||||
+void manager_socket_graveyard_clear(Manager *m);
|
||||
+
|
||||
+int manager_add_socket_to_graveyard(Manager *m, int fd);
|
@ -1,26 +0,0 @@
|
||||
From 648fe0097229c7ae46a6b5911521cef27a726cbe Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Fri, 6 Nov 2020 14:31:56 +0100
|
||||
Subject: [PATCH] resolved: close UDP socket when we received a network error
|
||||
on it
|
||||
|
||||
(cherry picked from commit d68dbb37d7408c025e736181f294152e2a515bf1)
|
||||
|
||||
Related: #2156751
|
||||
---
|
||||
src/resolve/resolved-dns-transaction.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
|
||||
index 95aea21134..c975215468 100644
|
||||
--- a/src/resolve/resolved-dns-transaction.c
|
||||
+++ b/src/resolve/resolved-dns-transaction.c
|
||||
@@ -1250,6 +1250,8 @@ static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *use
|
||||
assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &usec) >= 0);
|
||||
dns_server_packet_lost(t->server, IPPROTO_UDP, t->current_feature_level);
|
||||
|
||||
+ dns_transaction_close_connection(t, /* use_graveyard = */ false);
|
||||
+
|
||||
dns_transaction_retry(t, true);
|
||||
return 0;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
From 950cc2c5109f269561d3c0fdd020c6bf7cb561e1 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 10 Jul 2023 12:38:05 +0200
|
||||
Subject: [PATCH] ci: allow RHEL-only labels to mark downstream-only commits
|
||||
|
||||
RHEL-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/advanced-commit-linter.yml | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml
|
||||
index 491836abbb..327af0467a 100644
|
||||
--- a/.github/advanced-commit-linter.yml
|
||||
+++ b/.github/advanced-commit-linter.yml
|
||||
@@ -6,6 +6,7 @@ policy:
|
||||
exception:
|
||||
note:
|
||||
- rhel-only
|
||||
+ - RHEL-only
|
||||
tracker:
|
||||
- keyword:
|
||||
- 'Resolves: #?'
|
@ -1,39 +0,0 @@
|
||||
From e3d4d6b36c111c5273ce5da124116f1c98b10d9d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sat, 29 Feb 2020 09:48:44 +0100
|
||||
Subject: [PATCH] man: tweak markup in systemd-pstore.service(8)
|
||||
|
||||
(cherry picked from commit e3b192626e24cbd3a4dc2c7d5fb9a3b3fd136e24)
|
||||
|
||||
Related: #2217786
|
||||
---
|
||||
man/systemd-pstore.xml | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/man/systemd-pstore.xml b/man/systemd-pstore.xml
|
||||
index dd1aa5e83b..8726071cf0 100644
|
||||
--- a/man/systemd-pstore.xml
|
||||
+++ b/man/systemd-pstore.xml
|
||||
@@ -49,8 +49,8 @@
|
||||
|
||||
<para>The pstore service is independent of the kdump service. In cloud environments
|
||||
specifically, host and guest filesystems are on remote filesystems (eg. iSCSI
|
||||
- or NFS), thus kdump relies [implicitly and/or explicitly] upon proper operation
|
||||
- of networking software *and* hardware *and* infrastructure. Thus it may not be
|
||||
+ or NFS), thus kdump relies (implicitly and/or explicitly) upon proper operation
|
||||
+ of networking software *and* hardware *and* infrastructure. Thus it may not be
|
||||
possible to capture a kernel coredump to a file since writes over the network
|
||||
may not be possible.</para>
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
debugging.</para>
|
||||
|
||||
<para>The <command>systemd-pstore</command> executable does the actual work. Upon starting,
|
||||
- the <filename>pstore.conf</filename> is read to obtain options, then the /sys/fs/pstore
|
||||
+ the <filename>pstore.conf</filename> file is read and the <filename>/sys/fs/pstore</filename>
|
||||
directory contents are processed according to the options. Pstore files are written to the
|
||||
- journal, and optionally saved into /var/lib/systemd/pstore.</para>
|
||||
+ journal, and optionally saved into <filename>/var/lib/systemd/pstore</filename>.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
@ -1,61 +0,0 @@
|
||||
From ff17baae0631f42f59be6e425943c7181c6c5c18 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sat, 29 Feb 2020 09:57:06 +0100
|
||||
Subject: [PATCH] man: add .service suffix to systemd-pstore(8)
|
||||
|
||||
That is the pattern that we always use with executables not in
|
||||
$PATH.
|
||||
|
||||
(cherry picked from commit aa07dc70932837bfeda982affe53f01d36ec6efe)
|
||||
|
||||
Related: #2217786
|
||||
---
|
||||
man/rules/meson.build | 2 +-
|
||||
man/{systemd-pstore.xml => systemd-pstore.service.xml} | 8 ++++----
|
||||
2 files changed, 5 insertions(+), 5 deletions(-)
|
||||
rename man/{systemd-pstore.xml => systemd-pstore.service.xml} (95%)
|
||||
|
||||
diff --git a/man/rules/meson.build b/man/rules/meson.build
|
||||
index 6295330c5e..05eb0a1604 100644
|
||||
--- a/man/rules/meson.build
|
||||
+++ b/man/rules/meson.build
|
||||
@@ -634,7 +634,7 @@ manpages = [
|
||||
['systemd-nspawn', '1', [], ''],
|
||||
['systemd-path', '1', [], ''],
|
||||
['systemd-portabled.service', '8', ['systemd-portabled'], 'ENABLE_PORTABLED'],
|
||||
- ['systemd-pstore', '8', ['systemd-pstore.service'], 'ENABLE_PSTORE'],
|
||||
+ ['systemd-pstore.service', '8', ['systemd-pstore'], 'ENABLE_PSTORE'],
|
||||
['systemd-quotacheck.service',
|
||||
'8',
|
||||
['systemd-quotacheck'],
|
||||
diff --git a/man/systemd-pstore.xml b/man/systemd-pstore.service.xml
|
||||
similarity index 95%
|
||||
rename from man/systemd-pstore.xml
|
||||
rename to man/systemd-pstore.service.xml
|
||||
index 8726071cf0..47916da521 100644
|
||||
--- a/man/systemd-pstore.xml
|
||||
+++ b/man/systemd-pstore.service.xml
|
||||
@@ -7,19 +7,19 @@
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<refentryinfo>
|
||||
- <title>systemd-pstore</title>
|
||||
+ <title>systemd-pstore.service</title>
|
||||
<productname>systemd</productname>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
- <refentrytitle>systemd-pstore</refentrytitle>
|
||||
+ <refentrytitle>systemd-pstore.service</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
- <refname>systemd-pstore</refname>
|
||||
<refname>systemd-pstore.service</refname>
|
||||
- <refpurpose>Tool to archive contents of the persistent storage filesytem</refpurpose>
|
||||
+ <refname>systemd-pstore</refname>
|
||||
+ <refpurpose>A service to archive contents of pstore</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
@ -1,26 +0,0 @@
|
||||
From 36d9a1a50f80322b24ff5756b8fb89a07363dfd7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sat, 29 Feb 2020 10:01:39 +0100
|
||||
Subject: [PATCH] presets: enable systemd-pstore.service by default
|
||||
|
||||
It has no effect is the pstore is not used, and prevents the non-volatile
|
||||
storage from filling up if is used by the kernel.
|
||||
|
||||
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=952767
|
||||
(cherry picked from commit 5926ea0a6860095eaa83403417cbbf345db864f6)
|
||||
|
||||
Resolves: #2217786
|
||||
---
|
||||
presets/90-systemd.preset | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/presets/90-systemd.preset b/presets/90-systemd.preset
|
||||
index 11960e5423..b8edc23d48 100644
|
||||
--- a/presets/90-systemd.preset
|
||||
+++ b/presets/90-systemd.preset
|
||||
@@ -34,3 +34,5 @@ disable syslog.socket
|
||||
disable systemd-journal-gatewayd.*
|
||||
disable systemd-journal-remote.*
|
||||
disable systemd-journal-upload.*
|
||||
+
|
||||
+enable systemd-pstore.service
|
@ -1,54 +0,0 @@
|
||||
From bf5b87db9785b86fadbd2b5e97e4883cbe51797d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Thu, 23 Jun 2022 09:56:33 +0200
|
||||
Subject: [PATCH] logind: simplify code
|
||||
|
||||
Follow-up for 4885d7490b23e08d8444e5a68927ce9ce8727e5a.
|
||||
|
||||
(cherry picked from commit e5c09aad375551b9db499703ab7eb123d408ba16)
|
||||
|
||||
Resolves: #2209328
|
||||
---
|
||||
src/login/logind-session.c | 10 +++-------
|
||||
1 file changed, 3 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
|
||||
index 916202a65a..fabf680b61 100644
|
||||
--- a/src/login/logind-session.c
|
||||
+++ b/src/login/logind-session.c
|
||||
@@ -349,12 +349,11 @@ fail:
|
||||
}
|
||||
|
||||
static int session_load_devices(Session *s, const char *devices) {
|
||||
- const char *p;
|
||||
int r = 0;
|
||||
|
||||
assert(s);
|
||||
|
||||
- for (p = devices;;) {
|
||||
+ for (const char *p = devices;;) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
SessionDevice *sd;
|
||||
dev_t dev;
|
||||
@@ -531,7 +530,7 @@ int session_load(Session *s) {
|
||||
s->class = c;
|
||||
}
|
||||
|
||||
- if (state && streq(state, "closing"))
|
||||
+ if (streq_ptr(state, "closing"))
|
||||
s->stopping = true;
|
||||
|
||||
if (s->fifo_path) {
|
||||
@@ -1073,11 +1072,8 @@ int session_set_display(Session *s, const char *display) {
|
||||
assert(s);
|
||||
assert(display);
|
||||
|
||||
- if (streq(s->display, display))
|
||||
- return 0;
|
||||
-
|
||||
r = free_and_strdup(&s->display, display);
|
||||
- if (r < 0)
|
||||
+ if (r <= 0) /* 0 means the strings were equal */
|
||||
return r;
|
||||
|
||||
session_save(s);
|
@ -1,89 +0,0 @@
|
||||
From 2fb7d36caf560e4ce57265673da7a518d7a5348f Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 16 Jul 2019 00:44:14 +0900
|
||||
Subject: [PATCH] format-table: add TABLE_TIMESTAMP_UTC and _RELATIVE
|
||||
|
||||
(cherry picked from commit c5bbb2b5be079852d92d16ebc0d0840929ed82e1)
|
||||
|
||||
Related: #2156786
|
||||
---
|
||||
src/basic/format-table.c | 25 ++++++++++++++++++-------
|
||||
src/basic/format-table.h | 2 ++
|
||||
2 files changed, 20 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
|
||||
index c541e92b3c..5f2e5e3d73 100644
|
||||
--- a/src/basic/format-table.c
|
||||
+++ b/src/basic/format-table.c
|
||||
@@ -236,6 +236,8 @@ static size_t table_data_size(TableDataType type, const void *data) {
|
||||
return sizeof(bool);
|
||||
|
||||
case TABLE_TIMESTAMP:
|
||||
+ case TABLE_TIMESTAMP_UTC:
|
||||
+ case TABLE_TIMESTAMP_RELATIVE:
|
||||
case TABLE_TIMESPAN:
|
||||
return sizeof(usec_t);
|
||||
|
||||
@@ -700,6 +702,8 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
|
||||
break;
|
||||
|
||||
case TABLE_TIMESTAMP:
|
||||
+ case TABLE_TIMESTAMP_UTC:
|
||||
+ case TABLE_TIMESTAMP_RELATIVE:
|
||||
case TABLE_TIMESPAN:
|
||||
buffer.usec = va_arg(ap, usec_t);
|
||||
data = &buffer.usec;
|
||||
@@ -837,11 +841,9 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
|
||||
return 0;
|
||||
|
||||
case TABLE_TIMESTAMP:
|
||||
- if (a->timestamp < b->timestamp)
|
||||
- return -1;
|
||||
- if (a->timestamp > b->timestamp)
|
||||
- return 1;
|
||||
- return 0;
|
||||
+ case TABLE_TIMESTAMP_UTC:
|
||||
+ case TABLE_TIMESTAMP_RELATIVE:
|
||||
+ return CMP(a->timestamp, b->timestamp);
|
||||
|
||||
case TABLE_TIMESPAN:
|
||||
if (a->timespan < b->timespan)
|
||||
@@ -952,14 +954,23 @@ static const char *table_data_format(TableData *d) {
|
||||
case TABLE_BOOLEAN:
|
||||
return yes_no(d->boolean);
|
||||
|
||||
- case TABLE_TIMESTAMP: {
|
||||
+ case TABLE_TIMESTAMP:
|
||||
+ case TABLE_TIMESTAMP_UTC:
|
||||
+ case TABLE_TIMESTAMP_RELATIVE: {
|
||||
_cleanup_free_ char *p;
|
||||
+ char *ret;
|
||||
|
||||
p = new(char, FORMAT_TIMESTAMP_MAX);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
- if (!format_timestamp(p, FORMAT_TIMESTAMP_MAX, d->timestamp))
|
||||
+ if (d->type == TABLE_TIMESTAMP)
|
||||
+ ret = format_timestamp(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
|
||||
+ else if (d->type == TABLE_TIMESTAMP_UTC)
|
||||
+ ret = format_timestamp_utc(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
|
||||
+ else
|
||||
+ ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
|
||||
+ if (!ret)
|
||||
return "n/a";
|
||||
|
||||
d->formatted = TAKE_PTR(p);
|
||||
diff --git a/src/basic/format-table.h b/src/basic/format-table.h
|
||||
index 5a076b5383..1c8ab5436d 100644
|
||||
--- a/src/basic/format-table.h
|
||||
+++ b/src/basic/format-table.h
|
||||
@@ -12,6 +12,8 @@ typedef enum TableDataType {
|
||||
TABLE_STRING,
|
||||
TABLE_BOOLEAN,
|
||||
TABLE_TIMESTAMP,
|
||||
+ TABLE_TIMESTAMP_UTC,
|
||||
+ TABLE_TIMESTAMP_RELATIVE,
|
||||
TABLE_TIMESPAN,
|
||||
TABLE_SIZE,
|
||||
TABLE_UINT32,
|
@ -1,39 +0,0 @@
|
||||
From c88514d4de20ceeeea2028917087e2710ea419b2 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Tue, 23 May 2023 10:48:15 +0200
|
||||
Subject: [PATCH] loginctl: shorten variable name
|
||||
|
||||
(cherry picked from commit 86f128558d57586bd28c55eb63968eab3dc4b36e)
|
||||
|
||||
Related: #2156786
|
||||
---
|
||||
src/login/loginctl.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
|
||||
index 9b3fed928b..079c0e2b17 100644
|
||||
--- a/src/login/loginctl.c
|
||||
+++ b/src/login/loginctl.c
|
||||
@@ -147,7 +147,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
(void) table_set_align_percent(table, TABLE_HEADER_CELL(1), 100);
|
||||
|
||||
for (;;) {
|
||||
- _cleanup_(sd_bus_error_free) sd_bus_error error_tty = SD_BUS_ERROR_NULL;
|
||||
+ _cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply_tty = NULL;
|
||||
const char *id, *user, *seat, *object, *tty = NULL;
|
||||
uint32_t uid;
|
||||
@@ -164,11 +164,11 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
object,
|
||||
"org.freedesktop.login1.Session",
|
||||
"TTY",
|
||||
- &error_tty,
|
||||
+ &e,
|
||||
&reply_tty,
|
||||
"s");
|
||||
if (r < 0)
|
||||
- log_warning_errno(r, "Failed to get TTY for session %s: %s", id, bus_error_message(&error_tty, r));
|
||||
+ log_warning_errno(r, "Failed to get TTY for session %s: %s", id, bus_error_message(&e, r));
|
||||
else {
|
||||
r = sd_bus_message_read(reply_tty, "s", &tty);
|
||||
if (r < 0)
|
@ -1,137 +0,0 @@
|
||||
From 5d2f49451c5e697d6e3548cfc9087ef3c16aa969 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Fri, 19 May 2023 13:33:58 +0200
|
||||
Subject: [PATCH] loginctl: use bus_map_all_properties
|
||||
|
||||
(cherry picked from commit 5b7d1536d0c2ccf0b7688490f31c92c1e766ea44)
|
||||
|
||||
Related: #2156786
|
||||
---
|
||||
src/login/loginctl.c | 78 ++++++++++++++++++++++----------------------
|
||||
1 file changed, 39 insertions(+), 39 deletions(-)
|
||||
|
||||
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
|
||||
index 079c0e2b17..9e4c710062 100644
|
||||
--- a/src/login/loginctl.c
|
||||
+++ b/src/login/loginctl.c
|
||||
@@ -47,6 +47,27 @@ static bool arg_ask_password = true;
|
||||
static unsigned arg_lines = 10;
|
||||
static OutputMode arg_output = OUTPUT_SHORT;
|
||||
|
||||
+typedef struct SessionStatusInfo {
|
||||
+ const char *id;
|
||||
+ uid_t uid;
|
||||
+ const char *name;
|
||||
+ struct dual_timestamp timestamp;
|
||||
+ unsigned int vtnr;
|
||||
+ const char *seat;
|
||||
+ const char *tty;
|
||||
+ const char *display;
|
||||
+ bool remote;
|
||||
+ const char *remote_host;
|
||||
+ const char *remote_user;
|
||||
+ const char *service;
|
||||
+ pid_t leader;
|
||||
+ const char *type;
|
||||
+ const char *class;
|
||||
+ const char *state;
|
||||
+ const char *scope;
|
||||
+ const char *desktop;
|
||||
+} SessionStatusInfo;
|
||||
+
|
||||
static OutputFlags get_output_flags(void) {
|
||||
|
||||
return
|
||||
@@ -112,6 +133,12 @@ static int show_table(Table *table, const char *word) {
|
||||
}
|
||||
|
||||
static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
+
|
||||
+ static const struct bus_properties_map map[] = {
|
||||
+ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) },
|
||||
+ {},
|
||||
+ };
|
||||
+
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
_cleanup_(table_unrefp) Table *table = NULL;
|
||||
@@ -148,9 +175,10 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
|
||||
for (;;) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
|
||||
- _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply_tty = NULL;
|
||||
- const char *id, *user, *seat, *object, *tty = NULL;
|
||||
+ const char *id, *user, *seat, *object;
|
||||
uint32_t uid;
|
||||
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||
+ SessionStatusInfo i = {};
|
||||
|
||||
r = sd_bus_message_read(reply, "(susso)", &id, &uid, &user, &seat, &object);
|
||||
if (r < 0)
|
||||
@@ -158,21 +186,14 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
- r = sd_bus_get_property(
|
||||
- bus,
|
||||
- "org.freedesktop.login1",
|
||||
- object,
|
||||
- "org.freedesktop.login1.Session",
|
||||
- "TTY",
|
||||
- &e,
|
||||
- &reply_tty,
|
||||
- "s");
|
||||
- if (r < 0)
|
||||
- log_warning_errno(r, "Failed to get TTY for session %s: %s", id, bus_error_message(&e, r));
|
||||
- else {
|
||||
- r = sd_bus_message_read(reply_tty, "s", &tty);
|
||||
- if (r < 0)
|
||||
- return bus_log_parse_error(r);
|
||||
+ r = bus_map_all_properties(bus, "org.freedesktop.login1", object, map, BUS_MAP_BOOLEAN_AS_BOOL, &e, &m, &i);
|
||||
+ if (r < 0) {
|
||||
+ if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT))
|
||||
+ /* The session is already closed when we're querying the property */
|
||||
+ continue;
|
||||
+
|
||||
+ log_warning_errno(r, "Failed to get properties of session %s, ignoring: %s",
|
||||
+ id, bus_error_message(&e, r));
|
||||
}
|
||||
|
||||
r = table_add_many(table,
|
||||
@@ -180,7 +201,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
TABLE_UINT32, uid,
|
||||
TABLE_STRING, user,
|
||||
TABLE_STRING, seat,
|
||||
- TABLE_STRING, strna(tty));
|
||||
+ TABLE_STRING, strna(i.tty));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
}
|
||||
@@ -341,27 +362,6 @@ static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit
|
||||
return 0;
|
||||
}
|
||||
|
||||
-typedef struct SessionStatusInfo {
|
||||
- const char *id;
|
||||
- uid_t uid;
|
||||
- const char *name;
|
||||
- struct dual_timestamp timestamp;
|
||||
- unsigned int vtnr;
|
||||
- const char *seat;
|
||||
- const char *tty;
|
||||
- const char *display;
|
||||
- bool remote;
|
||||
- const char *remote_host;
|
||||
- const char *remote_user;
|
||||
- const char *service;
|
||||
- pid_t leader;
|
||||
- const char *type;
|
||||
- const char *class;
|
||||
- const char *state;
|
||||
- const char *scope;
|
||||
- const char *desktop;
|
||||
-} SessionStatusInfo;
|
||||
-
|
||||
typedef struct UserStatusInfo {
|
||||
uid_t uid;
|
||||
bool linger;
|
@ -1,80 +0,0 @@
|
||||
From 0d1082f3cf9d4028ac69c22e9dad2adb51ee910d Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Fri, 19 May 2023 14:03:09 +0200
|
||||
Subject: [PATCH] loginctl: show session idle status in list-sessions
|
||||
|
||||
(cherry picked from commit 556723e738b96a5c2b2d45a96b87b7b80e0c5664)
|
||||
|
||||
Resolves: #2156786
|
||||
---
|
||||
src/login/loginctl.c | 29 ++++++++++++++++++++---------
|
||||
1 file changed, 20 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
|
||||
index 9e4c710062..65fe182195 100644
|
||||
--- a/src/login/loginctl.c
|
||||
+++ b/src/login/loginctl.c
|
||||
@@ -66,6 +66,8 @@ typedef struct SessionStatusInfo {
|
||||
const char *state;
|
||||
const char *scope;
|
||||
const char *desktop;
|
||||
+ bool idle_hint;
|
||||
+ dual_timestamp idle_hint_timestamp;
|
||||
} SessionStatusInfo;
|
||||
|
||||
static OutputFlags get_output_flags(void) {
|
||||
@@ -135,7 +137,9 @@ static int show_table(Table *table, const char *word) {
|
||||
static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
|
||||
static const struct bus_properties_map map[] = {
|
||||
- { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) },
|
||||
+ { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) },
|
||||
+ { "IdleSinceHintMonotonic", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp.monotonic) },
|
||||
+ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) },
|
||||
{},
|
||||
};
|
||||
|
||||
@@ -165,7 +169,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
- table = table_new("SESSION", "UID", "USER", "SEAT", "TTY");
|
||||
+ table = table_new("SESSION", "UID", "USER", "SEAT", "TTY", "IDLE", "SINCE");
|
||||
if (!table)
|
||||
return log_oom();
|
||||
|
||||
@@ -188,12 +192,11 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
|
||||
r = bus_map_all_properties(bus, "org.freedesktop.login1", object, map, BUS_MAP_BOOLEAN_AS_BOOL, &e, &m, &i);
|
||||
if (r < 0) {
|
||||
- if (sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT))
|
||||
- /* The session is already closed when we're querying the property */
|
||||
- continue;
|
||||
-
|
||||
- log_warning_errno(r, "Failed to get properties of session %s, ignoring: %s",
|
||||
- id, bus_error_message(&e, r));
|
||||
+ log_full_errno(sd_bus_error_has_name(&e, SD_BUS_ERROR_UNKNOWN_OBJECT) ? LOG_DEBUG : LOG_WARNING,
|
||||
+ r,
|
||||
+ "Failed to get properties of session %s, ignoring: %s",
|
||||
+ id, bus_error_message(&e, r));
|
||||
+ continue;
|
||||
}
|
||||
|
||||
r = table_add_many(table,
|
||||
@@ -201,7 +204,15 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
TABLE_UINT32, uid,
|
||||
TABLE_STRING, user,
|
||||
TABLE_STRING, seat,
|
||||
- TABLE_STRING, strna(i.tty));
|
||||
+ TABLE_STRING, strna(i.tty),
|
||||
+ TABLE_BOOLEAN, i.idle_hint);
|
||||
+ if (r < 0)
|
||||
+ return log_error_errno(r, "Failed to add row to table: %m");
|
||||
+
|
||||
+ if (i.idle_hint)
|
||||
+ r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &i.idle_hint_timestamp.monotonic);
|
||||
+ else
|
||||
+ r = table_add_cell(table, NULL, TABLE_EMPTY, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
From ea3d85221a7ba83ff1d9612d29cc8ca3e054f2fa Mon Sep 17 00:00:00 2001
|
||||
From: Mike Yuan <me@yhndnzj.com>
|
||||
Date: Thu, 25 May 2023 01:20:45 +0800
|
||||
Subject: [PATCH] loginctl: list-sessions: fix timestamp for idle hint
|
||||
|
||||
Follow-up for 556723e738b96a5c2b2d45a96b87b7b80e0c5664
|
||||
|
||||
TABLE_TIMESTAMP_RELATIVE takes a realtime timestamp.
|
||||
|
||||
(cherry picked from commit be88af3d9646c8bd1aaea3d4a00520e97ee8674d)
|
||||
|
||||
Related: #2156786
|
||||
---
|
||||
src/login/loginctl.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
|
||||
index 65fe182195..1131267015 100644
|
||||
--- a/src/login/loginctl.c
|
||||
+++ b/src/login/loginctl.c
|
||||
@@ -67,7 +67,7 @@ typedef struct SessionStatusInfo {
|
||||
const char *scope;
|
||||
const char *desktop;
|
||||
bool idle_hint;
|
||||
- dual_timestamp idle_hint_timestamp;
|
||||
+ usec_t idle_hint_timestamp;
|
||||
} SessionStatusInfo;
|
||||
|
||||
static OutputFlags get_output_flags(void) {
|
||||
@@ -136,10 +136,10 @@ static int show_table(Table *table, const char *word) {
|
||||
|
||||
static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
|
||||
- static const struct bus_properties_map map[] = {
|
||||
- { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) },
|
||||
- { "IdleSinceHintMonotonic", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp.monotonic) },
|
||||
- { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) },
|
||||
+ static const struct bus_properties_map map[] = {
|
||||
+ { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) },
|
||||
+ { "IdleSinceHint", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp) },
|
||||
+ { "TTY", "s", NULL, offsetof(SessionStatusInfo, tty) },
|
||||
{},
|
||||
};
|
||||
|
||||
@@ -210,7 +210,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(r, "Failed to add row to table: %m");
|
||||
|
||||
if (i.idle_hint)
|
||||
- r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &i.idle_hint_timestamp.monotonic);
|
||||
+ r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &i.idle_hint_timestamp);
|
||||
else
|
||||
r = table_add_cell(table, NULL, TABLE_EMPTY, NULL);
|
||||
if (r < 0)
|
@ -1,40 +0,0 @@
|
||||
From 0d3f481f791d918380a1b5587529cb8642d3e407 Mon Sep 17 00:00:00 2001
|
||||
From: Mike Yuan <me@yhndnzj.com>
|
||||
Date: Tue, 23 May 2023 18:54:30 +0800
|
||||
Subject: [PATCH] loginctl: also show idle hint in session-status
|
||||
|
||||
(cherry picked from commit 82449055af97cf92466dbe132a89c9d889440c3d)
|
||||
|
||||
Related: #2156786
|
||||
---
|
||||
src/login/loginctl.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
|
||||
index 1131267015..80d0a302d3 100644
|
||||
--- a/src/login/loginctl.c
|
||||
+++ b/src/login/loginctl.c
|
||||
@@ -473,6 +473,8 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
|
||||
{ "Remote", "b", NULL, offsetof(SessionStatusInfo, remote) },
|
||||
{ "Timestamp", "t", NULL, offsetof(SessionStatusInfo, timestamp.realtime) },
|
||||
{ "TimestampMonotonic", "t", NULL, offsetof(SessionStatusInfo, timestamp.monotonic) },
|
||||
+ { "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) },
|
||||
+ { "IdleSinceHint", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp) },
|
||||
{ "User", "(uo)", prop_map_first_of_struct, offsetof(SessionStatusInfo, uid) },
|
||||
{ "Seat", "(so)", prop_map_first_of_struct, offsetof(SessionStatusInfo, seat) },
|
||||
{}
|
||||
@@ -571,6 +573,14 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
|
||||
if (i.state)
|
||||
printf("\t State: %s\n", i.state);
|
||||
|
||||
+ if (i.idle_hint && i.idle_hint_timestamp > 0) {
|
||||
+ s1 = format_timestamp_relative(since1, sizeof(since1), i.idle_hint_timestamp);
|
||||
+ s2 = format_timestamp(since2, sizeof(since2), i.idle_hint_timestamp);
|
||||
+
|
||||
+ printf("\t Idle: %s since %s (%s)\n", yes_no(i.idle_hint), s2, s1);
|
||||
+ } else
|
||||
+ printf("\t Idle: %s\n", yes_no(i.idle_hint));
|
||||
+
|
||||
if (i.scope) {
|
||||
printf("\t Unit: %s\n", i.scope);
|
||||
show_unit_cgroup(bus, "org.freedesktop.systemd1.Scope", i.scope, i.leader);
|
@ -1,46 +0,0 @@
|
||||
From a741d3b8bc23b4be1b83e393ca864983558a730c Mon Sep 17 00:00:00 2001
|
||||
From: Daan De Meyer <daan.j.demeyer@gmail.com>
|
||||
Date: Tue, 23 May 2023 16:24:47 +0200
|
||||
Subject: [PATCH] core/timer: Always use inactive_exit_timestamp if it is set
|
||||
|
||||
If we're doing a daemon-reload, we'll be going from TIMER_DEAD => TIMER_WAITING,
|
||||
so we won't use inactive_exit_timestamp because TIMER_DEAD != UNIT_ACTIVE, even
|
||||
though inactive_exit_timestamp is serialized/deserialized and will be valid after
|
||||
the daemon-reload.
|
||||
|
||||
This issue can lead to timers never firing as we'll always calculate the next
|
||||
elapse based on the current realtime on daemon-reload, so if daemon-reload happens
|
||||
often enough, the elapse interval will be moved into the future every time, which
|
||||
means the timer will never trigger.
|
||||
|
||||
To fix the issue, let's always use inactive_exit_timestamp if it is set, and only
|
||||
fall back to the current realtime if it is not set.
|
||||
|
||||
(cherry picked from commit 6546045fa0bf84737bd8b2e1e8bf7dd3941d8352)
|
||||
|
||||
Resolves: #1719364
|
||||
---
|
||||
src/core/timer.c | 10 ++++------
|
||||
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/core/timer.c b/src/core/timer.c
|
||||
index 990f05fee4..b80f6d714c 100644
|
||||
--- a/src/core/timer.c
|
||||
+++ b/src/core/timer.c
|
||||
@@ -368,12 +368,10 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
||||
|
||||
if (t->last_trigger.realtime > 0)
|
||||
b = t->last_trigger.realtime;
|
||||
- else {
|
||||
- if (state_translation_table[t->state] == UNIT_ACTIVE)
|
||||
- b = UNIT(t)->inactive_exit_timestamp.realtime;
|
||||
- else
|
||||
- b = ts.realtime;
|
||||
- }
|
||||
+ else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
|
||||
+ b = UNIT(t)->inactive_exit_timestamp.realtime;
|
||||
+ else
|
||||
+ b = ts.realtime;
|
||||
|
||||
r = calendar_spec_next_usec(v->calendar_spec, b, &v->next_elapse);
|
||||
if (r < 0)
|
@ -1,25 +0,0 @@
|
||||
From e7c06a10a106068e5bd9f092edbfcc937954a959 Mon Sep 17 00:00:00 2001
|
||||
From: Daan De Meyer <daan.j.demeyer@gmail.com>
|
||||
Date: Wed, 24 May 2023 11:41:37 +0200
|
||||
Subject: [PATCH] timer: Use dual_timestamp_is_set() in one more place
|
||||
|
||||
(cherry picked from commit e21f75afcd95a46261a36a2614712eff6bc119f4)
|
||||
|
||||
Related: #1719364
|
||||
---
|
||||
src/core/timer.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/core/timer.c b/src/core/timer.c
|
||||
index b80f6d714c..81468d4ca6 100644
|
||||
--- a/src/core/timer.c
|
||||
+++ b/src/core/timer.c
|
||||
@@ -366,7 +366,7 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
|
||||
* to that. If we don't, just start from
|
||||
* the activation time. */
|
||||
|
||||
- if (t->last_trigger.realtime > 0)
|
||||
+ if (dual_timestamp_is_set(&t->last_trigger))
|
||||
b = t->last_trigger.realtime;
|
||||
else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
|
||||
b = UNIT(t)->inactive_exit_timestamp.realtime;
|
@ -1,28 +0,0 @@
|
||||
From d55687b7489127b4b6be953c54719f3219e852f6 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Thu, 13 Jul 2023 14:23:51 +0200
|
||||
Subject: [PATCH] ci: drop systemd-stable from advanced-commit-linter config
|
||||
|
||||
It's sufficient enough to check only the `systemd/systemd` repo.
|
||||
|
||||
Related to https://github.com/redhat-plumbers-in-action/advanced-commit-linter/issues/62
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
.github/advanced-commit-linter.yml | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml
|
||||
index 327af0467a..0fb74a9dc8 100644
|
||||
--- a/.github/advanced-commit-linter.yml
|
||||
+++ b/.github/advanced-commit-linter.yml
|
||||
@@ -2,7 +2,6 @@ policy:
|
||||
cherry-pick:
|
||||
upstream:
|
||||
- github: systemd/systemd
|
||||
- - github: systemd/systemd-stable
|
||||
exception:
|
||||
note:
|
||||
- rhel-only
|
@ -1,108 +0,0 @@
|
||||
From 048c335acdaaba173574305c9b03677b3fde999f Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Thu, 11 May 2023 19:21:57 +0900
|
||||
Subject: [PATCH] core/mount: escape invalid UTF8 char in dbus reply
|
||||
|
||||
When What= or Options= may contain invalid UTF8 chars.
|
||||
|
||||
Replaces aaf7b0e41105d7b7cf30912cdac32820f011a219 (#27541).
|
||||
|
||||
(cherry picked from commit 4804da58536ab7ad46178a03f4d2da49fd8e4ba2)
|
||||
|
||||
Resolves: #2158724
|
||||
---
|
||||
src/core/dbus-mount.c | 69 +++++++++++++++++++++++++++++++++++--------
|
||||
1 file changed, 57 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c
|
||||
index 3f98d3ecf0..a089b37e04 100644
|
||||
--- a/src/core/dbus-mount.c
|
||||
+++ b/src/core/dbus-mount.c
|
||||
@@ -9,21 +9,68 @@
|
||||
#include "mount.h"
|
||||
#include "string-util.h"
|
||||
#include "unit.h"
|
||||
+#include "utf8.h"
|
||||
+
|
||||
+static int property_get_what(
|
||||
+ sd_bus *bus,
|
||||
+ const char *path,
|
||||
+ const char *interface,
|
||||
+ const char *property,
|
||||
+ sd_bus_message *reply,
|
||||
+ void *userdata,
|
||||
+ sd_bus_error *error) {
|
||||
+
|
||||
+ _cleanup_free_ char *escaped = NULL;
|
||||
+ Mount *m = userdata;
|
||||
+ const char *s = NULL;
|
||||
+
|
||||
+ assert(bus);
|
||||
+ assert(reply);
|
||||
+ assert(m);
|
||||
|
||||
-static const char *mount_get_what(const Mount *m) {
|
||||
if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what)
|
||||
- return m->parameters_proc_self_mountinfo.what;
|
||||
- if (m->from_fragment && m->parameters_fragment.what)
|
||||
- return m->parameters_fragment.what;
|
||||
- return NULL;
|
||||
+ s = m->parameters_proc_self_mountinfo.what;
|
||||
+ else if (m->from_fragment && m->parameters_fragment.what)
|
||||
+ s = m->parameters_fragment.what;
|
||||
+
|
||||
+ if (s) {
|
||||
+ escaped = utf8_escape_invalid(s);
|
||||
+ if (!escaped)
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ return sd_bus_message_append_basic(reply, 's', escaped);
|
||||
}
|
||||
|
||||
-static const char *mount_get_options(const Mount *m) {
|
||||
+static int property_get_options(
|
||||
+ sd_bus *bus,
|
||||
+ const char *path,
|
||||
+ const char *interface,
|
||||
+ const char *property,
|
||||
+ sd_bus_message *reply,
|
||||
+ void *userdata,
|
||||
+ sd_bus_error *error) {
|
||||
+
|
||||
+ _cleanup_free_ char *escaped = NULL;
|
||||
+ Mount *m = userdata;
|
||||
+ const char *s = NULL;
|
||||
+
|
||||
+ assert(bus);
|
||||
+ assert(reply);
|
||||
+ assert(m);
|
||||
+
|
||||
if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.options)
|
||||
- return m->parameters_proc_self_mountinfo.options;
|
||||
- if (m->from_fragment && m->parameters_fragment.options)
|
||||
- return m->parameters_fragment.options;
|
||||
- return NULL;
|
||||
+ s = m->parameters_proc_self_mountinfo.options;
|
||||
+ else if (m->from_fragment && m->parameters_fragment.options)
|
||||
+ s = m->parameters_fragment.options;
|
||||
+
|
||||
+ if (s) {
|
||||
+ escaped = utf8_escape_invalid(s);
|
||||
+ if (!escaped)
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ return sd_bus_message_append_basic(reply, 's', escaped);
|
||||
}
|
||||
|
||||
static const char *mount_get_fstype(const Mount *m) {
|
||||
@@ -34,8 +81,6 @@ static const char *mount_get_fstype(const Mount *m) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
-static BUS_DEFINE_PROPERTY_GET(property_get_what, "s", Mount, mount_get_what);
|
||||
-static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Mount, mount_get_options);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_type, "s", Mount, mount_get_fstype);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, mount_result, MountResult);
|
||||
|
@ -1,32 +0,0 @@
|
||||
From fd6e63d9c24845c0e9f97d0929d89dbe0c4a4434 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Thu, 14 Feb 2019 10:59:13 +0900
|
||||
Subject: [PATCH] login: add a missing error check for session_set_leader()
|
||||
|
||||
session_set_leader() may fail. If it fails, then manager_start_scope()
|
||||
will trigger assertion.
|
||||
|
||||
This may be related to RHBZ#1663704.
|
||||
|
||||
(cherry picked from commit fe3ab8458b9c0ead4b3e14ac25b342d8c34376fe)
|
||||
|
||||
Related: #2158167
|
||||
---
|
||||
src/login/logind-dbus.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
|
||||
index 81aacb4eed..5edcf4e43f 100644
|
||||
--- a/src/login/logind-dbus.c
|
||||
+++ b/src/login/logind-dbus.c
|
||||
@@ -784,7 +784,9 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
|
||||
goto fail;
|
||||
|
||||
session_set_user(session, user);
|
||||
- session_set_leader(session, leader);
|
||||
+ r = session_set_leader(session, leader);
|
||||
+ if (r < 0)
|
||||
+ goto fail;
|
||||
|
||||
session->type = t;
|
||||
session->class = c;
|
@ -1,77 +0,0 @@
|
||||
From ab53c4f5c39ab8d34a3cca652de67fe31dbb776d Mon Sep 17 00:00:00 2001
|
||||
From: Michal Sekletar <msekleta@redhat.com>
|
||||
Date: Wed, 5 Jul 2023 15:27:38 +0200
|
||||
Subject: [PATCH] logind: reset session leader if we know for a fact that it is
|
||||
gone
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2158167
|
||||
---
|
||||
src/login/logind-dbus.c | 3 +++
|
||||
src/login/logind-session.c | 18 ++++++++++++++++++
|
||||
src/login/logind-session.h | 1 +
|
||||
3 files changed, 22 insertions(+)
|
||||
|
||||
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
|
||||
index 5edcf4e43f..dbac406035 100644
|
||||
--- a/src/login/logind-dbus.c
|
||||
+++ b/src/login/logind-dbus.c
|
||||
@@ -3169,6 +3169,9 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
|
||||
session->scope_job = mfree(session->scope_job);
|
||||
(void) session_jobs_reply(session, unit, result);
|
||||
|
||||
+ /* Scope job is done so leader should be gone as well. */
|
||||
+ session_invalidate_leader(session);
|
||||
+
|
||||
session_save(session);
|
||||
user_save(session->user);
|
||||
}
|
||||
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
|
||||
index fabf680b61..4edc4b9b88 100644
|
||||
--- a/src/login/logind-session.c
|
||||
+++ b/src/login/logind-session.c
|
||||
@@ -179,6 +179,23 @@ int session_set_leader(Session *s, pid_t pid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
+int session_invalidate_leader(Session *s) {
|
||||
+ assert(s);
|
||||
+
|
||||
+ if (s->leader <= 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (pid_is_alive(s->leader))
|
||||
+ return 0;
|
||||
+
|
||||
+ (void) hashmap_remove_value(s->manager->sessions_by_leader, PID_TO_PTR(s->leader), s);
|
||||
+ s->leader = 0;
|
||||
+
|
||||
+ (void) session_save(s);
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
static void session_save_devices(Session *s, FILE *f) {
|
||||
SessionDevice *sd;
|
||||
Iterator i;
|
||||
@@ -1092,6 +1109,7 @@ static int session_dispatch_fifo(sd_event_source *es, int fd, uint32_t revents,
|
||||
/* EOF on the FIFO means the session died abnormally. */
|
||||
|
||||
session_remove_fifo(s);
|
||||
+ session_invalidate_leader(s);
|
||||
session_stop(s, false);
|
||||
|
||||
return 1;
|
||||
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
|
||||
index 6678441bb9..0557696761 100644
|
||||
--- a/src/login/logind-session.h
|
||||
+++ b/src/login/logind-session.h
|
||||
@@ -127,6 +127,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Session *, session_free);
|
||||
|
||||
void session_set_user(Session *s, User *u);
|
||||
int session_set_leader(Session *s, pid_t pid);
|
||||
+int session_invalidate_leader(Session *s);
|
||||
bool session_may_gc(Session *s, bool drop_not_started);
|
||||
void session_add_to_gc_queue(Session *s);
|
||||
int session_activate(Session *s);
|
@ -1,170 +0,0 @@
|
||||
From f80320d15ba6815f0b385e4b8f86f3293fed66ce Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Wed, 16 Dec 2020 15:56:44 +0100
|
||||
Subject: [PATCH] test-login: skip consistency checks when logind is not active
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
There are two ways in swich sd_login_* functions acquire data:
|
||||
some are derived from the cgroup path, but others use the data serialized
|
||||
by logind.
|
||||
|
||||
When the tests are executed under Fedora's mock, without systemd-spawn
|
||||
but instead in a traditional chroot, test-login gets confused:
|
||||
the "outside" cgroup path is visible, so sd_pid_get_unit() and
|
||||
sd_pid_get_session() work, but sd_session_is_active() and other functions
|
||||
that need logind data fail.
|
||||
|
||||
Such a buildroot setup is fairly bad, but it can be encountered in the wild, so
|
||||
let's just skip the tests in that case.
|
||||
|
||||
/* Information printed is from the live system */
|
||||
sd_pid_get_unit(0, …) → "session-237.scope"
|
||||
sd_pid_get_user_unit(0, …) → "n/a"
|
||||
sd_pid_get_slice(0, …) → "user-1000.slice"
|
||||
sd_pid_get_session(0, …) → "237"
|
||||
sd_pid_get_owner_uid(0, …) → 1000
|
||||
sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-237.scope"
|
||||
sd_uid_get_display(1000, …) → "(null)"
|
||||
sd_uid_get_sessions(1000, …) → [0] ""
|
||||
sd_uid_get_seats(1000, …) → [0] ""
|
||||
Assertion 'r >= 0' failed at src/libsystemd/sd-login/test-login.c:104, function test_login(). Aborting.
|
||||
|
||||
(cherry picked from commit ac5644635dba54ce5eb0ff394fc0bc772a984849)
|
||||
|
||||
Resolves: #2223582
|
||||
---
|
||||
src/libsystemd/sd-login/test-login.c | 98 +++++++++++++++-------------
|
||||
1 file changed, 52 insertions(+), 46 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
|
||||
index d24a04ccc8..5a64aef868 100644
|
||||
--- a/src/libsystemd/sd-login/test-login.c
|
||||
+++ b/src/libsystemd/sd-login/test-login.c
|
||||
@@ -115,65 +115,71 @@ static void test_login(void) {
|
||||
|
||||
if (session) {
|
||||
r = sd_session_is_active(session);
|
||||
- assert_se(r >= 0);
|
||||
- log_info("sd_session_is_active(\"%s\") → %s", session, yes_no(r));
|
||||
+ if (r == -ENXIO)
|
||||
+ log_notice("sd_session_is_active() failed with ENXIO, it seems logind is not running.");
|
||||
+ else {
|
||||
+ /* All those tests will fail with ENXIO, so let's skip them. */
|
||||
|
||||
- r = sd_session_is_remote(session);
|
||||
- assert_se(r >= 0);
|
||||
- log_info("sd_session_is_remote(\"%s\") → %s", session, yes_no(r));
|
||||
+ assert_se(r >= 0);
|
||||
+ log_info("sd_session_is_active(\"%s\") → %s", session, yes_no(r));
|
||||
|
||||
- r = sd_session_get_state(session, &state);
|
||||
- assert_se(r == 0);
|
||||
- log_info("sd_session_get_state(\"%s\") → \"%s\"", session, state);
|
||||
+ r = sd_session_is_remote(session);
|
||||
+ assert_se(r >= 0);
|
||||
+ log_info("sd_session_is_remote(\"%s\") → %s", session, yes_no(r));
|
||||
|
||||
- assert_se(sd_session_get_uid(session, &u) >= 0);
|
||||
- log_info("sd_session_get_uid(\"%s\") → "UID_FMT, session, u);
|
||||
- assert_se(u == u2);
|
||||
+ r = sd_session_get_state(session, &state);
|
||||
+ assert_se(r == 0);
|
||||
+ log_info("sd_session_get_state(\"%s\") → \"%s\"", session, state);
|
||||
|
||||
- assert_se(sd_session_get_type(session, &type) >= 0);
|
||||
- log_info("sd_session_get_type(\"%s\") → \"%s\"", session, type);
|
||||
+ assert_se(sd_session_get_uid(session, &u) >= 0);
|
||||
+ log_info("sd_session_get_uid(\"%s\") → "UID_FMT, session, u);
|
||||
+ assert_se(u == u2);
|
||||
|
||||
- assert_se(sd_session_get_class(session, &class) >= 0);
|
||||
- log_info("sd_session_get_class(\"%s\") → \"%s\"", session, class);
|
||||
+ assert_se(sd_session_get_type(session, &type) >= 0);
|
||||
+ log_info("sd_session_get_type(\"%s\") → \"%s\"", session, type);
|
||||
|
||||
- r = sd_session_get_display(session, &display);
|
||||
- assert_se(IN_SET(r, 0, -ENODATA));
|
||||
- log_info("sd_session_get_display(\"%s\") → \"%s\"", session, strna(display));
|
||||
+ assert_se(sd_session_get_class(session, &class) >= 0);
|
||||
+ log_info("sd_session_get_class(\"%s\") → \"%s\"", session, class);
|
||||
|
||||
- r = sd_session_get_remote_user(session, &remote_user);
|
||||
- assert_se(IN_SET(r, 0, -ENODATA));
|
||||
- log_info("sd_session_get_remote_user(\"%s\") → \"%s\"",
|
||||
- session, strna(remote_user));
|
||||
+ r = sd_session_get_display(session, &display);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+ log_info("sd_session_get_display(\"%s\") → \"%s\"", session, strna(display));
|
||||
|
||||
- r = sd_session_get_remote_host(session, &remote_host);
|
||||
- assert_se(IN_SET(r, 0, -ENODATA));
|
||||
- log_info("sd_session_get_remote_host(\"%s\") → \"%s\"",
|
||||
- session, strna(remote_host));
|
||||
+ r = sd_session_get_remote_user(session, &remote_user);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+ log_info("sd_session_get_remote_user(\"%s\") → \"%s\"",
|
||||
+ session, strna(remote_user));
|
||||
|
||||
- r = sd_session_get_seat(session, &seat);
|
||||
- if (r >= 0) {
|
||||
- assert_se(seat);
|
||||
+ r = sd_session_get_remote_host(session, &remote_host);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+ log_info("sd_session_get_remote_host(\"%s\") → \"%s\"",
|
||||
+ session, strna(remote_host));
|
||||
|
||||
- log_info("sd_session_get_seat(\"%s\") → \"%s\"", session, seat);
|
||||
+ r = sd_session_get_seat(session, &seat);
|
||||
+ if (r >= 0) {
|
||||
+ assert_se(seat);
|
||||
|
||||
- r = sd_seat_can_multi_session(seat);
|
||||
- assert_se(r >= 0);
|
||||
- log_info("sd_session_can_multi_seat(\"%s\") → %s", seat, yes_no(r));
|
||||
+ log_info("sd_session_get_seat(\"%s\") → \"%s\"", session, seat);
|
||||
|
||||
- r = sd_seat_can_tty(seat);
|
||||
- assert_se(r >= 0);
|
||||
- log_info("sd_session_can_tty(\"%s\") → %s", seat, yes_no(r));
|
||||
+ r = sd_seat_can_multi_session(seat);
|
||||
+ assert_se(r >= 0);
|
||||
+ log_info("sd_session_can_multi_seat(\"%s\") → %s", seat, yes_no(r));
|
||||
|
||||
- r = sd_seat_can_graphical(seat);
|
||||
- assert_se(r >= 0);
|
||||
- log_info("sd_session_can_graphical(\"%s\") → %s", seat, yes_no(r));
|
||||
- } else {
|
||||
- log_info_errno(r, "sd_session_get_seat(\"%s\"): %m", session);
|
||||
- assert_se(r == -ENODATA);
|
||||
- }
|
||||
+ r = sd_seat_can_tty(seat);
|
||||
+ assert_se(r >= 0);
|
||||
+ log_info("sd_session_can_tty(\"%s\") → %s", seat, yes_no(r));
|
||||
|
||||
- assert_se(sd_uid_get_state(u, &state2) == 0);
|
||||
- log_info("sd_uid_get_state("UID_FMT", …) → %s", u, state2);
|
||||
+ r = sd_seat_can_graphical(seat);
|
||||
+ assert_se(r >= 0);
|
||||
+ log_info("sd_session_can_graphical(\"%s\") → %s", seat, yes_no(r));
|
||||
+ } else {
|
||||
+ log_info_errno(r, "sd_session_get_seat(\"%s\"): %m", session);
|
||||
+ assert_se(r == -ENODATA);
|
||||
+ }
|
||||
+
|
||||
+ assert_se(sd_uid_get_state(u, &state2) == 0);
|
||||
+ log_info("sd_uid_get_state("UID_FMT", …) → %s", u, state2);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (seat) {
|
||||
@@ -214,7 +220,7 @@ static void test_login(void) {
|
||||
assert_se(sd_get_seats(NULL) == r);
|
||||
|
||||
r = sd_seat_get_active(NULL, &t, NULL);
|
||||
- assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA, -ENXIO));
|
||||
log_info("sd_seat_get_active(NULL, …) (active session on current seat) → %s / \"%s\"", e(r), strnull(t));
|
||||
free(t);
|
||||
|
@ -1,91 +0,0 @@
|
||||
From 7bbad13204b3c0870caa80e738d5d5ca39e956c9 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 25 Sep 2018 11:10:12 +0200
|
||||
Subject: [PATCH] sd-event: remove dead code and use _cleanup_
|
||||
|
||||
CID #1393250.
|
||||
|
||||
(cherry picked from commit 8c75fe1765341b538ddded29be6f98e1619f1996)
|
||||
|
||||
Related: #2211358
|
||||
---
|
||||
src/libsystemd/sd-event/sd-event.c | 30 +++++++++---------------------
|
||||
1 file changed, 9 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||||
index 549103bc6f..5e22190366 100644
|
||||
--- a/src/libsystemd/sd-event/sd-event.c
|
||||
+++ b/src/libsystemd/sd-event/sd-event.c
|
||||
@@ -1129,6 +1129,7 @@ static void source_free(sd_event_source *s) {
|
||||
free(s->description);
|
||||
free(s);
|
||||
}
|
||||
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_event_source*, source_free);
|
||||
|
||||
static int source_set_pending(sd_event_source *s, bool b) {
|
||||
int r;
|
||||
@@ -1993,11 +1994,10 @@ _public_ int sd_event_add_inotify(
|
||||
sd_event_inotify_handler_t callback,
|
||||
void *userdata) {
|
||||
|
||||
- bool rm_inotify = false, rm_inode = false;
|
||||
struct inotify_data *inotify_data = NULL;
|
||||
struct inode_data *inode_data = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
- sd_event_source *s;
|
||||
+ _cleanup_(source_freep) sd_event_source *s = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
@@ -2035,13 +2035,13 @@ _public_ int sd_event_add_inotify(
|
||||
/* Allocate an inotify object for this priority, and an inode object within it */
|
||||
r = event_make_inotify_data(e, SD_EVENT_PRIORITY_NORMAL, &inotify_data);
|
||||
if (r < 0)
|
||||
- goto fail;
|
||||
- rm_inotify = r > 0;
|
||||
+ return r;
|
||||
|
||||
r = event_make_inode_data(e, inotify_data, st.st_dev, st.st_ino, &inode_data);
|
||||
- if (r < 0)
|
||||
- goto fail;
|
||||
- rm_inode = r > 0;
|
||||
+ if (r < 0) {
|
||||
+ event_free_inotify_data(e, inotify_data);
|
||||
+ return r;
|
||||
+ }
|
||||
|
||||
/* Keep the O_PATH fd around until the first iteration of the loop, so that we can still change the priority of
|
||||
* the event source, until then, for which we need the original inode. */
|
||||
@@ -2054,30 +2054,18 @@ _public_ int sd_event_add_inotify(
|
||||
LIST_PREPEND(inotify.by_inode_data, inode_data->event_sources, s);
|
||||
s->inotify.inode_data = inode_data;
|
||||
|
||||
- rm_inode = rm_inotify = false;
|
||||
-
|
||||
/* Actually realize the watch now */
|
||||
r = inode_data_realize_watch(e, inode_data);
|
||||
if (r < 0)
|
||||
- goto fail;
|
||||
+ return r;
|
||||
|
||||
(void) sd_event_source_set_description(s, path);
|
||||
|
||||
if (ret)
|
||||
*ret = s;
|
||||
+ TAKE_PTR(s);
|
||||
|
||||
return 0;
|
||||
-
|
||||
-fail:
|
||||
- source_free(s);
|
||||
-
|
||||
- if (rm_inode)
|
||||
- event_free_inode_data(e, inode_data);
|
||||
-
|
||||
- if (rm_inotify)
|
||||
- event_free_inotify_data(e, inotify_data);
|
||||
-
|
||||
- return r;
|
||||
}
|
||||
|
||||
_public_ sd_event_source* sd_event_source_ref(sd_event_source *s) {
|
@ -1,100 +0,0 @@
|
||||
From 4436c767d45c6568cbdb7aa73e5efba6d0f31f1f Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 9 Nov 2021 00:11:38 +0100
|
||||
Subject: [PATCH] sd-event: don't destroy inotify data structures from inotify
|
||||
event handler
|
||||
|
||||
This fixes a bad memory access when we destroy an inotify source handler
|
||||
from the handler itself, and thus destroy the associated inotify_data
|
||||
structures.
|
||||
|
||||
Fixes: #20177
|
||||
(cherry picked from commit 53baf2efa420cab6c4b1904c9a0c46a0c4ec80a1)
|
||||
|
||||
Resolves: #2211358
|
||||
---
|
||||
src/libsystemd/sd-event/sd-event.c | 45 +++++++++++++++++++++++++++---
|
||||
1 file changed, 41 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||||
index 5e22190366..01a97a4801 100644
|
||||
--- a/src/libsystemd/sd-event/sd-event.c
|
||||
+++ b/src/libsystemd/sd-event/sd-event.c
|
||||
@@ -263,6 +263,11 @@ struct inotify_data {
|
||||
* the events locally if they can't be coalesced). */
|
||||
unsigned n_pending;
|
||||
|
||||
+ /* If this counter is non-zero, don't GC the inotify data object even if not used to watch any inode
|
||||
+ * anymore. This is useful to pin the object for a bit longer, after the last event source needing it
|
||||
+ * is gone. */
|
||||
+ unsigned n_busy;
|
||||
+
|
||||
/* A linked list of all inotify objects with data already read, that still need processing. We keep this list
|
||||
* to make it efficient to figure out what inotify objects to process data on next. */
|
||||
LIST_FIELDS(struct inotify_data, buffered);
|
||||
@@ -1845,6 +1850,29 @@ static void event_free_inode_data(
|
||||
free(d);
|
||||
}
|
||||
|
||||
+static void event_gc_inotify_data(
|
||||
+ sd_event *e,
|
||||
+ struct inotify_data *d) {
|
||||
+
|
||||
+ assert(e);
|
||||
+
|
||||
+ /* GCs the inotify data object if we don't need it anymore. That's the case if we don't want to watch
|
||||
+ * any inode with it anymore, which in turn happens if no event source of this priority is interested
|
||||
+ * in any inode any longer. That said, we maintain an extra busy counter: if non-zero we'll delay GC
|
||||
+ * (under the expectation that the GC is called again once the counter is decremented). */
|
||||
+
|
||||
+ if (!d)
|
||||
+ return;
|
||||
+
|
||||
+ if (!hashmap_isempty(d->inodes))
|
||||
+ return;
|
||||
+
|
||||
+ if (d->n_busy > 0)
|
||||
+ return;
|
||||
+
|
||||
+ event_free_inotify_data(e, d);
|
||||
+}
|
||||
+
|
||||
static void event_gc_inode_data(
|
||||
sd_event *e,
|
||||
struct inode_data *d) {
|
||||
@@ -1862,8 +1890,7 @@ static void event_gc_inode_data(
|
||||
inotify_data = d->inotify_data;
|
||||
event_free_inode_data(e, d);
|
||||
|
||||
- if (inotify_data && hashmap_isempty(inotify_data->inodes))
|
||||
- event_free_inotify_data(e, inotify_data);
|
||||
+ event_gc_inotify_data(e, inotify_data);
|
||||
}
|
||||
|
||||
static int event_make_inode_data(
|
||||
@@ -3447,13 +3474,23 @@ static int source_dispatch(sd_event_source *s) {
|
||||
sz = offsetof(struct inotify_event, name) + d->buffer.ev.len;
|
||||
assert(d->buffer_filled >= sz);
|
||||
|
||||
+ /* If the inotify callback destroys the event source then this likely means we don't need to
|
||||
+ * watch the inode anymore, and thus also won't need the inotify object anymore. But if we'd
|
||||
+ * free it immediately, then we couldn't drop the event from the inotify event queue without
|
||||
+ * memory corruption anymore, as below. Hence, let's not free it immediately, but mark it
|
||||
+ * "busy" with a counter (which will ensure it's not GC'ed away prematurely). Let's then
|
||||
+ * explicitly GC it after we are done dropping the inotify event from the buffer. */
|
||||
+ d->n_busy++;
|
||||
r = s->inotify.callback(s, &d->buffer.ev, s->userdata);
|
||||
+ d->n_busy--;
|
||||
|
||||
- /* When no event is pending anymore on this inotify object, then let's drop the event from the
|
||||
- * buffer. */
|
||||
+ /* When no event is pending anymore on this inotify object, then let's drop the event from
|
||||
+ * the inotify event queue buffer. */
|
||||
if (d->n_pending == 0)
|
||||
event_inotify_data_drop(e, d, sz);
|
||||
|
||||
+ /* Now we don't want to access 'd' anymore, it's OK to GC now. */
|
||||
+ event_gc_inotify_data(e, d);
|
||||
break;
|
||||
}
|
||||
|
@ -1,232 +0,0 @@
|
||||
From a78186fbbc05637ef9678b20c630597f2e5d6270 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 9 Nov 2021 00:10:58 +0100
|
||||
Subject: [PATCH] sd-event: add sd_event_add_inotify_fd() call
|
||||
|
||||
sd_event_add_inotify_fd() is like sd_event_add_inotify(), but takes an
|
||||
fd to an inode instead of a path, and is hence a ton nicer.
|
||||
|
||||
(cherry picked from commit e67d738a8771c220a2e1ee81d5499a90589dd15d)
|
||||
|
||||
Related: #2211358
|
||||
---
|
||||
man/rules/meson.build | 4 +-
|
||||
man/sd_event_add_inotify.xml | 16 +++++++
|
||||
src/libsystemd/libsystemd.sym | 1 +
|
||||
src/libsystemd/sd-event/sd-event.c | 76 +++++++++++++++++++++++-------
|
||||
src/systemd/sd-event.h | 1 +
|
||||
5 files changed, 81 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/man/rules/meson.build b/man/rules/meson.build
|
||||
index 05eb0a1604..431a1cf269 100644
|
||||
--- a/man/rules/meson.build
|
||||
+++ b/man/rules/meson.build
|
||||
@@ -272,7 +272,9 @@ manpages = [
|
||||
''],
|
||||
['sd_event_add_inotify',
|
||||
'3',
|
||||
- ['sd_event_inotify_handler_t', 'sd_event_source_get_inotify_mask'],
|
||||
+ ['sd_event_add_inotify_fd',
|
||||
+ 'sd_event_inotify_handler_t',
|
||||
+ 'sd_event_source_get_inotify_mask'],
|
||||
''],
|
||||
['sd_event_add_io',
|
||||
'3',
|
||||
diff --git a/man/sd_event_add_inotify.xml b/man/sd_event_add_inotify.xml
|
||||
index 605863c356..17415bbc17 100644
|
||||
--- a/man/sd_event_add_inotify.xml
|
||||
+++ b/man/sd_event_add_inotify.xml
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
<refnamediv>
|
||||
<refname>sd_event_add_inotify</refname>
|
||||
+ <refname>sd_event_add_inotify_fd</refname>
|
||||
<refname>sd_event_source_get_inotify_mask</refname>
|
||||
<refname>sd_event_inotify_handler_t</refname>
|
||||
|
||||
@@ -47,6 +48,16 @@
|
||||
<paramdef>void *<parameter>userdata</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
+ <funcprototype>
|
||||
+ <funcdef>int <function>sd_event_add_inotify_fd</function></funcdef>
|
||||
+ <paramdef>sd_event *<parameter>event</parameter></paramdef>
|
||||
+ <paramdef>sd_event_source **<parameter>source</parameter></paramdef>
|
||||
+ <paramdef>int <parameter>fd</parameter></paramdef>
|
||||
+ <paramdef>uint32_t <parameter>mask</parameter></paramdef>
|
||||
+ <paramdef>sd_event_inotify_handler_t <parameter>handler</parameter></paramdef>
|
||||
+ <paramdef>void *<parameter>userdata</parameter></paramdef>
|
||||
+ </funcprototype>
|
||||
+
|
||||
<funcprototype>
|
||||
<funcdef>int <function>sd_event_source_get_inotify_mask</function></funcdef>
|
||||
<paramdef>sd_event_source *<parameter>source</parameter></paramdef>
|
||||
@@ -72,6 +83,11 @@
|
||||
<citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
|
||||
further information.</para>
|
||||
|
||||
+ <para><function>sd_event_add_inotify_fd()</function> is identical to
|
||||
+ <function>sd_event_add_inotify()</function>, except that it takes a file descriptor to an inode (possibly
|
||||
+ an <constant>O_PATH</constant> one, but any other will do too) instead of a path in the file
|
||||
+ system.</para>
|
||||
+
|
||||
<para>If multiple event sources are installed for the same inode the backing inotify watch descriptor is
|
||||
automatically shared. The mask parameter may contain any flag defined by the inotify API, with the exception of
|
||||
<constant>IN_MASK_ADD</constant>.</para>
|
||||
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
|
||||
index 449918093c..dc37472b18 100644
|
||||
--- a/src/libsystemd/libsystemd.sym
|
||||
+++ b/src/libsystemd/libsystemd.sym
|
||||
@@ -593,5 +593,6 @@ global:
|
||||
|
||||
LIBSYSTEMD_250 {
|
||||
global:
|
||||
+ sd_event_add_inotify_fd;
|
||||
sd_event_source_set_ratelimit_expire_callback;
|
||||
} LIBSYSTEMD_248;
|
||||
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||||
index 01a97a4801..9247087c41 100644
|
||||
--- a/src/libsystemd/sd-event/sd-event.c
|
||||
+++ b/src/libsystemd/sd-event/sd-event.c
|
||||
@@ -2013,25 +2013,25 @@ static int inode_data_realize_watch(sd_event *e, struct inode_data *d) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
-_public_ int sd_event_add_inotify(
|
||||
+static int event_add_inotify_fd_internal(
|
||||
sd_event *e,
|
||||
sd_event_source **ret,
|
||||
- const char *path,
|
||||
+ int fd,
|
||||
+ bool donate,
|
||||
uint32_t mask,
|
||||
sd_event_inotify_handler_t callback,
|
||||
void *userdata) {
|
||||
|
||||
+ _cleanup_close_ int donated_fd = donate ? fd : -1;
|
||||
+ _cleanup_(source_freep) sd_event_source *s = NULL;
|
||||
struct inotify_data *inotify_data = NULL;
|
||||
struct inode_data *inode_data = NULL;
|
||||
- _cleanup_close_ int fd = -1;
|
||||
- _cleanup_(source_freep) sd_event_source *s = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
assert_return(e, -EINVAL);
|
||||
assert_return(e = event_resolve(e), -ENOPKG);
|
||||
- assert_return(path, -EINVAL);
|
||||
- assert_return(callback, -EINVAL);
|
||||
+ assert_return(fd >= 0, -EBADF);
|
||||
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
|
||||
assert_return(!event_pid_changed(e), -ECHILD);
|
||||
|
||||
@@ -2041,12 +2041,6 @@ _public_ int sd_event_add_inotify(
|
||||
if (mask & IN_MASK_ADD)
|
||||
return -EINVAL;
|
||||
|
||||
- fd = open(path, O_PATH|O_CLOEXEC|
|
||||
- (mask & IN_ONLYDIR ? O_DIRECTORY : 0)|
|
||||
- (mask & IN_DONT_FOLLOW ? O_NOFOLLOW : 0));
|
||||
- if (fd < 0)
|
||||
- return -errno;
|
||||
-
|
||||
if (fstat(fd, &st) < 0)
|
||||
return -errno;
|
||||
|
||||
@@ -2066,14 +2060,24 @@ _public_ int sd_event_add_inotify(
|
||||
|
||||
r = event_make_inode_data(e, inotify_data, st.st_dev, st.st_ino, &inode_data);
|
||||
if (r < 0) {
|
||||
- event_free_inotify_data(e, inotify_data);
|
||||
+ event_gc_inotify_data(e, inotify_data);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Keep the O_PATH fd around until the first iteration of the loop, so that we can still change the priority of
|
||||
* the event source, until then, for which we need the original inode. */
|
||||
if (inode_data->fd < 0) {
|
||||
- inode_data->fd = TAKE_FD(fd);
|
||||
+ if (donated_fd >= 0)
|
||||
+ inode_data->fd = TAKE_FD(donated_fd);
|
||||
+ else {
|
||||
+ inode_data->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
|
||||
+ if (inode_data->fd < 0) {
|
||||
+ r = -errno;
|
||||
+ event_gc_inode_data(e, inode_data);
|
||||
+ return r;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
LIST_PREPEND(to_close, e->inode_data_to_close, inode_data);
|
||||
}
|
||||
|
||||
@@ -2086,8 +2090,6 @@ _public_ int sd_event_add_inotify(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- (void) sd_event_source_set_description(s, path);
|
||||
-
|
||||
if (ret)
|
||||
*ret = s;
|
||||
TAKE_PTR(s);
|
||||
@@ -2095,6 +2097,48 @@ _public_ int sd_event_add_inotify(
|
||||
return 0;
|
||||
}
|
||||
|
||||
+_public_ int sd_event_add_inotify_fd(
|
||||
+ sd_event *e,
|
||||
+ sd_event_source **ret,
|
||||
+ int fd,
|
||||
+ uint32_t mask,
|
||||
+ sd_event_inotify_handler_t callback,
|
||||
+ void *userdata) {
|
||||
+
|
||||
+ return event_add_inotify_fd_internal(e, ret, fd, /* donate= */ false, mask, callback, userdata);
|
||||
+}
|
||||
+
|
||||
+_public_ int sd_event_add_inotify(
|
||||
+ sd_event *e,
|
||||
+ sd_event_source **ret,
|
||||
+ const char *path,
|
||||
+ uint32_t mask,
|
||||
+ sd_event_inotify_handler_t callback,
|
||||
+ void *userdata) {
|
||||
+
|
||||
+ sd_event_source *s;
|
||||
+ int fd, r;
|
||||
+
|
||||
+ assert_return(path, -EINVAL);
|
||||
+
|
||||
+ fd = open(path, O_PATH|O_CLOEXEC|
|
||||
+ (mask & IN_ONLYDIR ? O_DIRECTORY : 0)|
|
||||
+ (mask & IN_DONT_FOLLOW ? O_NOFOLLOW : 0));
|
||||
+ if (fd < 0)
|
||||
+ return -errno;
|
||||
+
|
||||
+ r = event_add_inotify_fd_internal(e, &s, fd, /* donate= */ true, mask, callback, userdata);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+
|
||||
+ (void) sd_event_source_set_description(s, path);
|
||||
+
|
||||
+ if (ret)
|
||||
+ *ret = s;
|
||||
+
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
_public_ sd_event_source* sd_event_source_ref(sd_event_source *s) {
|
||||
|
||||
if (!s)
|
||||
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
|
||||
index 960bea1ac4..48b053c127 100644
|
||||
--- a/src/systemd/sd-event.h
|
||||
+++ b/src/systemd/sd-event.h
|
||||
@@ -91,6 +91,7 @@ int sd_event_add_time_relative(sd_event *e, sd_event_source **s, clockid_t clock
|
||||
int sd_event_add_signal(sd_event *e, sd_event_source **s, int sig, sd_event_signal_handler_t callback, void *userdata);
|
||||
int sd_event_add_child(sd_event *e, sd_event_source **s, pid_t pid, int options, sd_event_child_handler_t callback, void *userdata);
|
||||
int sd_event_add_inotify(sd_event *e, sd_event_source **s, const char *path, uint32_t mask, sd_event_inotify_handler_t callback, void *userdata);
|
||||
+int sd_event_add_inotify_fd(sd_event *e, sd_event_source **s, int fd, uint32_t mask, sd_event_inotify_handler_t callback, void *userdata);
|
||||
int sd_event_add_defer(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
|
||||
int sd_event_add_post(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
|
||||
int sd_event_add_exit(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata);
|
@ -1,65 +0,0 @@
|
||||
From 2fcb71007e5137e1be4a16fb24783ff329313ebf Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 9 Nov 2021 00:15:43 +0100
|
||||
Subject: [PATCH] test: add test case for self-destroy inotify handler
|
||||
|
||||
(cherry picked from commit 035daf73fbfa05e5abf049bd9385fc0994ab5672)
|
||||
|
||||
Related: #2211358
|
||||
---
|
||||
src/libsystemd/sd-event/test-event.c | 36 ++++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
|
||||
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
|
||||
index 9135b22839..df3de1bfb0 100644
|
||||
--- a/src/libsystemd/sd-event/test-event.c
|
||||
+++ b/src/libsystemd/sd-event/test-event.c
|
||||
@@ -588,6 +588,40 @@ static void test_ratelimit(void) {
|
||||
assert_se(expired == 0);
|
||||
}
|
||||
|
||||
+static int inotify_self_destroy_handler(sd_event_source *s, const struct inotify_event *ev, void *userdata) {
|
||||
+ sd_event_source **p = userdata;
|
||||
+
|
||||
+ assert_se(ev);
|
||||
+ assert_se(p);
|
||||
+ assert_se(*p == s);
|
||||
+
|
||||
+ assert_se(FLAGS_SET(ev->mask, IN_ATTRIB));
|
||||
+
|
||||
+ assert_se(sd_event_exit(sd_event_source_get_event(s), 0) >= 0);
|
||||
+
|
||||
+ *p = sd_event_source_unref(*p); /* here's what we actually intend to test: we destroy the event
|
||||
+ * source from inside the event source handler */
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+static void test_inotify_self_destroy(void) {
|
||||
+ _cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL;
|
||||
+ _cleanup_(sd_event_unrefp) sd_event *e = NULL;
|
||||
+ char path[] = "/tmp/inotifyXXXXXX";
|
||||
+ _cleanup_close_ int fd = -1;
|
||||
+
|
||||
+ /* Tests that destroying an inotify event source from its own handler is safe */
|
||||
+
|
||||
+ assert_se(sd_event_default(&e) >= 0);
|
||||
+
|
||||
+ fd = mkostemp_safe(path);
|
||||
+ assert_se(fd >= 0);
|
||||
+ assert_se(sd_event_add_inotify_fd(e, &s, fd, IN_ATTRIB, inotify_self_destroy_handler, &s) >= 0);
|
||||
+ fd = safe_close(fd);
|
||||
+ assert_se(unlink(path) >= 0); /* This will trigger IN_ATTRIB because link count goes to zero */
|
||||
+ assert_se(sd_event_loop(e) >= 0);
|
||||
+}
|
||||
+
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
log_set_max_level(LOG_DEBUG);
|
||||
@@ -602,5 +636,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_ratelimit();
|
||||
|
||||
+ test_inotify_self_destroy();
|
||||
+
|
||||
return 0;
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
From 322ef6cb5fe3c293c6b9a37fe2e58491e9a5100b Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 4 Aug 2023 13:09:46 +0200
|
||||
Subject: [PATCH] doc: add downstream CONTRIBUTING document
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
CONTRIBUTING.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 67 insertions(+)
|
||||
create mode 100644 CONTRIBUTING.md
|
||||
|
||||
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
|
||||
new file mode 100644
|
||||
index 0000000000..361366d899
|
||||
--- /dev/null
|
||||
+++ b/CONTRIBUTING.md
|
||||
@@ -0,0 +1,67 @@
|
||||
+# Contributing
|
||||
+
|
||||
+Welcome to systemd source-git for CentOS Stream and RHEL. When contributing, please follow the guide below.
|
||||
+
|
||||
+## Workflow
|
||||
+
|
||||
+```mermaid
|
||||
+flowchart LR
|
||||
+ A(Issue) --> B{is fixed\nupstream}
|
||||
+ B -->|YES| C(backport\nupstream patch)
|
||||
+ B -->|NO| D(upstream\nsubmit issue or PR)
|
||||
+ D --> E{accepted\nand fixed}
|
||||
+ E -->|YES| C
|
||||
+ E -->|NO| F(rhel-only patch) --> G
|
||||
+ C --> G(submit PR)
|
||||
+```
|
||||
+
|
||||
+## Filing issues
|
||||
+
|
||||
+When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssue!default.jspa) (set Project to **RHEL** and Component to **systemd**).
|
||||
+
|
||||
+GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose).
|
||||
+
|
||||
+## Posting Pull Requests
|
||||
+
|
||||
+Every Pull Request has to comply with the following rules:
|
||||
+
|
||||
+- Each commit has to reference [upstream](https://github.com/systemd/systemd) commit.
|
||||
+- Each commit has to reference the approved issue/tracker.
|
||||
+- Pull requests have to pass mandatory CI validation and testing
|
||||
+- Pull requests have to be approved by at least one systemd downstream maintainer
|
||||
+
|
||||
+### Upstream reference
|
||||
+
|
||||
+When doing a back-port of an upstream commit, always use `cherry-pick -x <sha>`. Consider proposing a change upstream first when an upstream commit doesn't exist.
|
||||
+If the change isn't upstream relevant or accepted by upstream, mark the commit with the `rhel-only` string.
|
||||
+
|
||||
+```md
|
||||
+doc: Fix TYPO
|
||||
+
|
||||
+rhel-only
|
||||
+
|
||||
+Resolves: RHEL-678
|
||||
+```
|
||||
+
|
||||
+### Issue reference
|
||||
+
|
||||
+Each commit has to reference the relevant approved systemd issue (see: [Filling issues section](#filing-issues)). For referencing issues, we use the following keywords:
|
||||
+
|
||||
+- **Resolves** for commits that directly resolve issues described in a referenced tracker
|
||||
+- **Related** for commits related to the referenced issue, but they don't fix it. Usually, tests and documentation.
|
||||
+- **Reverts** for commits that reverts previously merged commit
|
||||
+
|
||||
+When referencing issues, use following structure: `<keyword>: <issue ID>`. See the example below:
|
||||
+
|
||||
+```md
|
||||
+doc: Fix TYPO
|
||||
+
|
||||
+(cherry picked from commit c5afbac31bb33e7b1f4d59b253425af991a630a4)
|
||||
+
|
||||
+Resolves: RHEL-678
|
||||
+```
|
||||
+
|
||||
+### Validation and testing
|
||||
+
|
||||
+Each Pull Request has to pass all enabled tests that are automatically run using GitHub Actions, CentOS Stream CI, and others.
|
||||
+If CI failure is unrelated to the change introduced in Pull Request, the downstream maintainer will set the `ci-waived` label and explain why CI was waived.
|
@ -1,25 +0,0 @@
|
||||
From b50b19af7889a2d44e904fcb327b09130c9c96e7 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Tue, 8 Aug 2023 13:12:03 +0200
|
||||
Subject: [PATCH] doc: use link with prefilled Jira issue
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
CONTRIBUTING.md | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
|
||||
index 361366d899..1de2b88995 100644
|
||||
--- a/CONTRIBUTING.md
|
||||
+++ b/CONTRIBUTING.md
|
||||
@@ -17,7 +17,7 @@ flowchart LR
|
||||
|
||||
## Filing issues
|
||||
|
||||
-When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssue!default.jspa) (set Project to **RHEL** and Component to **systemd**).
|
||||
+When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&issuetype=1&components=12380515).
|
||||
|
||||
GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose).
|
||||
|
@ -1,52 +0,0 @@
|
||||
From 380f7af4fb00d692132b38999813fd9023e14c81 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Thu, 10 Aug 2023 15:25:22 +0200
|
||||
Subject: [PATCH] docs: link downstream CONTRIBUTING in README
|
||||
|
||||
This should increase the visibility of the downstream CONTRIBUTING.
|
||||
|
||||
Also fix some wording and update links.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2179309
|
||||
---
|
||||
CONTRIBUTING.md | 4 ++--
|
||||
README.md | 2 +-
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
|
||||
index 1de2b88995..bd17067be2 100644
|
||||
--- a/CONTRIBUTING.md
|
||||
+++ b/CONTRIBUTING.md
|
||||
@@ -17,7 +17,7 @@ flowchart LR
|
||||
|
||||
## Filing issues
|
||||
|
||||
-When you find an issue with systemd used in CentOS Stream or RHEL, please file an issue in [Jira ticket system](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&issuetype=1&components=12380515).
|
||||
+When you find an issue with systemd used in **CentOS Stream** or **RHEL**, please file an issue in Red Hat [Jira ticket system](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12332745&issuetype=1&components=12380515&priority=10300).
|
||||
|
||||
GitHub Issues are not supported tracking system. If your issue is reproducible using the latest upstream version of systemd, please consider creating [upstream issue](https://github.com/systemd/systemd/issues/new/choose).
|
||||
|
||||
@@ -51,7 +51,7 @@ Each commit has to reference the relevant approved systemd issue (see: [Filling
|
||||
- **Related** for commits related to the referenced issue, but they don't fix it. Usually, tests and documentation.
|
||||
- **Reverts** for commits that reverts previously merged commit
|
||||
|
||||
-When referencing issues, use following structure: `<keyword>: <issue ID>`. See the example below:
|
||||
+When referencing issues, use the following structure: `<keyword>: <issue ID>`. See the example below:
|
||||
|
||||
```md
|
||||
doc: Fix TYPO
|
||||
diff --git a/README.md b/README.md
|
||||
index a57566834c..2e02350299 100644
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -17,7 +17,7 @@ Consult our [NEWS file](../master/NEWS) for information about what's new in the
|
||||
|
||||
Please see the [HACKING file](../master/doc/HACKING) for information how to hack on systemd and test your modifications.
|
||||
|
||||
-Please see our [Contribution Guidelines](../master/.github/CONTRIBUTING.md) for more information about filing GitHub Issues and posting GitHub Pull Requests.
|
||||
+Please see our [Contribution Guidelines](CONTRIBUTING.md) for more information about filing GitHub Issues and posting GitHub Pull Requests.
|
||||
|
||||
When preparing patches for systemd, please follow our [Coding Style Guidelines](../master/doc/CODING_STYLE).
|
||||
|
@ -1,47 +0,0 @@
|
||||
From e257d900b45df7db779fd34f01b251d4054f3685 Mon Sep 17 00:00:00 2001
|
||||
From: "Greg \"GothAck\" Miell" <greg@gothack.ninja>
|
||||
Date: Fri, 27 Dec 2019 14:49:51 +0000
|
||||
Subject: [PATCH] unit drop-in: Fix ordering of special type.d drop-ins
|
||||
|
||||
(cherry picked from commit e6627f2392cde12e21c40a7cfa96578c648c1f33)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
src/shared/dropin.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
|
||||
index 11ed4c7184..927107c508 100644
|
||||
--- a/src/shared/dropin.c
|
||||
+++ b/src/shared/dropin.c
|
||||
@@ -242,6 +242,10 @@ int unit_file_find_dropin_paths(
|
||||
|
||||
assert(ret);
|
||||
|
||||
+ SET_FOREACH(name, names, i)
|
||||
+ STRV_FOREACH(p, lookup_path)
|
||||
+ (void) unit_file_find_dirs(original_root, unit_path_cache, *p, name, dir_suffix, &dirs);
|
||||
+
|
||||
/* All the names in the unit are of the same type so just grab one. */
|
||||
name = (char*) set_first(names);
|
||||
if (name) {
|
||||
@@ -253,7 +257,7 @@ int unit_file_find_dropin_paths(
|
||||
"Failed to to derive unit type from unit name: %s",
|
||||
name);
|
||||
|
||||
- /* Special top level drop in for "<unit type>.<suffix>". Add this first as it's the most generic
|
||||
+ /* Special top level drop in for "<unit type>.<suffix>". Add this last as it's the most generic
|
||||
* and should be able to be overridden by more specific drop-ins. */
|
||||
STRV_FOREACH(p, lookup_path)
|
||||
(void) unit_file_find_dirs(original_root,
|
||||
@@ -264,10 +268,6 @@ int unit_file_find_dropin_paths(
|
||||
&dirs);
|
||||
}
|
||||
|
||||
- SET_FOREACH(name, names, i)
|
||||
- STRV_FOREACH(p, lookup_path)
|
||||
- (void) unit_file_find_dirs(original_root, unit_path_cache, *p, name, dir_suffix, &dirs);
|
||||
-
|
||||
if (strv_isempty(dirs)) {
|
||||
*ret = NULL;
|
||||
return 0;
|
@ -1,57 +0,0 @@
|
||||
From 471f790115b2b0a56328cbf14a6e0f51c1176b62 Mon Sep 17 00:00:00 2001
|
||||
From: "Greg \"GothAck\" Miell" <greg@gothack.ninja>
|
||||
Date: Fri, 27 Dec 2019 14:36:49 +0000
|
||||
Subject: [PATCH] Add failing test to show service.d global drop-in does not
|
||||
get overridden by more specific dropins
|
||||
|
||||
(cherry picked from commit f5dd6e50a781b83bc6b1d8e018783661142aabd0)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 26 ++++++++++++++++++++++++++
|
||||
1 file changed, 26 insertions(+)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index 5419169f7b..a9d1ef0a10 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -118,6 +118,31 @@ EOF
|
||||
clear_services a b c
|
||||
}
|
||||
|
||||
+test_hierarchical_dropins () {
|
||||
+ echo "Testing hierarchical dropins..."
|
||||
+ echo "*** test service.d/ top level drop-in"
|
||||
+ create_services a-b-c
|
||||
+ check_ko a-b-c ExecCondition "/bin/echo service.d"
|
||||
+ check_ko a-b-c ExecCondition "/bin/echo a-.service.d"
|
||||
+ check_ko a-b-c ExecCondition "/bin/echo a-b-.service.d"
|
||||
+ check_ko a-b-c ExecCondition "/bin/echo a-b-c.service.d"
|
||||
+
|
||||
+ for dropin in service.d a-.service.d a-b-.service.d a-b-c.service.d; do
|
||||
+ mkdir -p /usr/lib/systemd/system/$dropin
|
||||
+ echo "
|
||||
+[Service]
|
||||
+ExecCondition=/bin/echo $dropin
|
||||
+ " >/usr/lib/systemd/system/$dropin/override.conf
|
||||
+ systemctl daemon-reload
|
||||
+ check_ok a-b-c ExecCondition "/bin/echo $dropin"
|
||||
+ done
|
||||
+ for dropin in service.d a-.service.d a-b-.service.d a-b-c.service.d; do
|
||||
+ rm -rf /usr/lib/systemd/system/$dropin
|
||||
+ done
|
||||
+
|
||||
+ clear_services a-b-c
|
||||
+}
|
||||
+
|
||||
test_template_dropins () {
|
||||
echo "Testing template dropins..."
|
||||
|
||||
@@ -303,6 +328,7 @@ test_invalid_dropins () {
|
||||
}
|
||||
|
||||
test_basic_dropins
|
||||
+test_hierarchical_dropins
|
||||
test_template_dropins
|
||||
test_alias_dropins
|
||||
test_masked_dropins
|
@ -1,522 +0,0 @@
|
||||
From 3681938e3aa5d3580038011b4579ac39612df23e Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Thu, 13 Apr 2023 14:48:00 +0200
|
||||
Subject: [PATCH] test: set indentation to 4 spaces
|
||||
|
||||
This is what upstream commit cc5549ca12616376a4e4ef04fd4e2fb53d6d098c
|
||||
has done, but just for a single shell file.
|
||||
|
||||
RHEL-only
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 448 ++++++++++++++---------------
|
||||
1 file changed, 224 insertions(+), 224 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index a9d1ef0a10..64d8a98fc7 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -4,103 +4,103 @@ set -e
|
||||
set -x
|
||||
|
||||
_clear_service () {
|
||||
- systemctl stop $1.service 2>/dev/null || :
|
||||
- rm -f /{etc,run,usr/lib}/systemd/system/$1.service
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}
|
||||
+ systemctl stop $1.service 2>/dev/null || :
|
||||
+ rm -f /{etc,run,usr/lib}/systemd/system/$1.service
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}
|
||||
}
|
||||
|
||||
clear_services () {
|
||||
- for u in $*; do
|
||||
- _clear_service $u
|
||||
- done
|
||||
- systemctl daemon-reload
|
||||
+ for u in $*; do
|
||||
+ _clear_service $u
|
||||
+ done
|
||||
+ systemctl daemon-reload
|
||||
}
|
||||
|
||||
create_service () {
|
||||
- clear_services $1
|
||||
+ clear_services $1
|
||||
|
||||
- cat >/etc/systemd/system/$1.service<<EOF
|
||||
+ cat >/etc/systemd/system/$1.service<<EOF
|
||||
[Unit]
|
||||
Description=$1 unit
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sleep 100000
|
||||
EOF
|
||||
- mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
- mkdir -p /etc/systemd/system/$1.service.{wants,requires}
|
||||
- mkdir -p /run/systemd/system/$1.service.{wants,requires}
|
||||
- mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires}
|
||||
+ mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
+ mkdir -p /etc/systemd/system/$1.service.{wants,requires}
|
||||
+ mkdir -p /run/systemd/system/$1.service.{wants,requires}
|
||||
+ mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires}
|
||||
}
|
||||
|
||||
create_services () {
|
||||
- for u in $*; do
|
||||
- create_service $u
|
||||
- done
|
||||
+ for u in $*; do
|
||||
+ create_service $u
|
||||
+ done
|
||||
}
|
||||
|
||||
check_ok () {
|
||||
- [ $# -eq 3 ] || return
|
||||
+ [ $# -eq 3 ] || return
|
||||
|
||||
- x="$(systemctl show --value -p $2 $1)"
|
||||
- case "$x" in
|
||||
- *$3*) return 0 ;;
|
||||
- *) return 1
|
||||
- esac
|
||||
+ x="$(systemctl show --value -p $2 $1)"
|
||||
+ case "$x" in
|
||||
+ *$3*) return 0 ;;
|
||||
+ *) return 1
|
||||
+ esac
|
||||
}
|
||||
|
||||
check_ko () {
|
||||
- ! check_ok "$@"
|
||||
+ ! check_ok "$@"
|
||||
}
|
||||
|
||||
test_basic_dropins () {
|
||||
- echo "Testing basic dropins..."
|
||||
-
|
||||
- echo "*** test a wants b wants c"
|
||||
- create_services a b c
|
||||
- ln -s ../b.service /etc/systemd/system/a.service.wants/
|
||||
- ln -s ../c.service /etc/systemd/system/b.service.wants/
|
||||
- check_ok a Wants b.service
|
||||
- check_ok b Wants c.service
|
||||
-
|
||||
- echo "*** test a wants,requires b"
|
||||
- create_services a b c
|
||||
- ln -s ../b.service /etc/systemd/system/a.service.wants/
|
||||
- ln -s ../b.service /etc/systemd/system/a.service.requires/
|
||||
- check_ok a Wants b.service
|
||||
- check_ok a Requires b.service
|
||||
-
|
||||
- echo "*** test a wants nonexistent"
|
||||
- create_service a
|
||||
- ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/
|
||||
- check_ok a Wants nonexistent.service
|
||||
- systemctl start a
|
||||
- systemctl stop a
|
||||
-
|
||||
- echo "*** test a requires nonexistent"
|
||||
- ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/
|
||||
- systemctl daemon-reload
|
||||
- check_ok a Requires nonexistent.service
|
||||
-
|
||||
- # 'b' is already loaded when 'c' pulls it in via a dropin.
|
||||
- echo "*** test a,c require b"
|
||||
- create_services a b c
|
||||
- ln -sf ../b.service /etc/systemd/system/a.service.requires/
|
||||
- ln -sf ../b.service /etc/systemd/system/c.service.requires/
|
||||
- systemctl start a
|
||||
- check_ok c Requires b.service
|
||||
- systemctl stop a b
|
||||
-
|
||||
- # 'b' is already loaded when 'c' pulls it in via an alias dropin.
|
||||
- echo "*** test a wants alias"
|
||||
- create_services a b c
|
||||
- ln -sf c.service /etc/systemd/system/c1.service
|
||||
- ln -sf ../c.service /etc/systemd/system/a.service.wants/
|
||||
- ln -sf ../c1.service /etc/systemd/system/b.service.wants/
|
||||
- systemctl start a
|
||||
- check_ok a Wants c.service
|
||||
- check_ok b Wants c.service
|
||||
- systemctl stop a c
|
||||
+ echo "Testing basic dropins..."
|
||||
+
|
||||
+ echo "*** test a wants b wants c"
|
||||
+ create_services a b c
|
||||
+ ln -s ../b.service /etc/systemd/system/a.service.wants/
|
||||
+ ln -s ../c.service /etc/systemd/system/b.service.wants/
|
||||
+ check_ok a Wants b.service
|
||||
+ check_ok b Wants c.service
|
||||
+
|
||||
+ echo "*** test a wants,requires b"
|
||||
+ create_services a b c
|
||||
+ ln -s ../b.service /etc/systemd/system/a.service.wants/
|
||||
+ ln -s ../b.service /etc/systemd/system/a.service.requires/
|
||||
+ check_ok a Wants b.service
|
||||
+ check_ok a Requires b.service
|
||||
+
|
||||
+ echo "*** test a wants nonexistent"
|
||||
+ create_service a
|
||||
+ ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/
|
||||
+ check_ok a Wants nonexistent.service
|
||||
+ systemctl start a
|
||||
+ systemctl stop a
|
||||
+
|
||||
+ echo "*** test a requires nonexistent"
|
||||
+ ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/
|
||||
+ systemctl daemon-reload
|
||||
+ check_ok a Requires nonexistent.service
|
||||
+
|
||||
+ # 'b' is already loaded when 'c' pulls it in via a dropin.
|
||||
+ echo "*** test a,c require b"
|
||||
+ create_services a b c
|
||||
+ ln -sf ../b.service /etc/systemd/system/a.service.requires/
|
||||
+ ln -sf ../b.service /etc/systemd/system/c.service.requires/
|
||||
+ systemctl start a
|
||||
+ check_ok c Requires b.service
|
||||
+ systemctl stop a b
|
||||
+
|
||||
+ # 'b' is already loaded when 'c' pulls it in via an alias dropin.
|
||||
+ echo "*** test a wants alias"
|
||||
+ create_services a b c
|
||||
+ ln -sf c.service /etc/systemd/system/c1.service
|
||||
+ ln -sf ../c.service /etc/systemd/system/a.service.wants/
|
||||
+ ln -sf ../c1.service /etc/systemd/system/b.service.wants/
|
||||
+ systemctl start a
|
||||
+ check_ok a Wants c.service
|
||||
+ check_ok b Wants c.service
|
||||
+ systemctl stop a c
|
||||
|
||||
echo "*** test service.d/ top level drop-in"
|
||||
create_services a b
|
||||
@@ -144,174 +144,174 @@ ExecCondition=/bin/echo $dropin
|
||||
}
|
||||
|
||||
test_template_dropins () {
|
||||
- echo "Testing template dropins..."
|
||||
+ echo "Testing template dropins..."
|
||||
|
||||
- create_services foo bar@ yup@
|
||||
+ create_services foo bar@ yup@
|
||||
|
||||
- ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service
|
||||
- check_ok foo Wants bar@1.service
|
||||
+ ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service
|
||||
+ check_ok foo Wants bar@1.service
|
||||
|
||||
- clear_services foo bar@ yup@
|
||||
+ clear_services foo bar@ yup@
|
||||
}
|
||||
|
||||
test_alias_dropins () {
|
||||
- echo "Testing alias dropins..."
|
||||
-
|
||||
- echo "*** test a wants b1 alias of b"
|
||||
- create_services a b
|
||||
- ln -sf b.service /etc/systemd/system/b1.service
|
||||
- ln -sf ../b1.service /etc/systemd/system/a.service.wants/
|
||||
- check_ok a Wants b.service
|
||||
- systemctl start a
|
||||
- systemctl --quiet is-active b
|
||||
- systemctl stop a b
|
||||
- rm /etc/systemd/system/b1.service
|
||||
- clear_services a b
|
||||
-
|
||||
- # A weird behavior: the dependencies for 'a' may vary. It can be
|
||||
- # changed by loading an alias...
|
||||
- #
|
||||
- # [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore
|
||||
- # part of the names set so all its specific dropins are loaded.
|
||||
- #
|
||||
- # [2] 'a' is already loaded. 'a1' is simply only merged into 'a' so
|
||||
- # none of its dropins are loaded ('y' is missing from the deps).
|
||||
- echo "*** test 2"
|
||||
- create_services a x y
|
||||
- mkdir -p /etc/systemd/system/a1.service.wants/
|
||||
- ln -sf a.service /etc/systemd/system/a1.service
|
||||
- ln -sf ../x.service /etc/systemd/system/a.service.wants/
|
||||
- ln -sf ../y.service /etc/systemd/system/a1.service.wants/
|
||||
- check_ok a1 Wants x.service # see [1]
|
||||
- check_ok a1 Wants y.service
|
||||
- systemctl start a
|
||||
- check_ok a1 Wants x.service # see [2]
|
||||
- check_ko a1 Wants y.service
|
||||
- systemctl stop a x y
|
||||
- rm /etc/systemd/system/a1.service
|
||||
-
|
||||
- clear_services a x y
|
||||
+ echo "Testing alias dropins..."
|
||||
+
|
||||
+ echo "*** test a wants b1 alias of b"
|
||||
+ create_services a b
|
||||
+ ln -sf b.service /etc/systemd/system/b1.service
|
||||
+ ln -sf ../b1.service /etc/systemd/system/a.service.wants/
|
||||
+ check_ok a Wants b.service
|
||||
+ systemctl start a
|
||||
+ systemctl --quiet is-active b
|
||||
+ systemctl stop a b
|
||||
+ rm /etc/systemd/system/b1.service
|
||||
+ clear_services a b
|
||||
+
|
||||
+ # A weird behavior: the dependencies for 'a' may vary. It can be
|
||||
+ # changed by loading an alias...
|
||||
+ #
|
||||
+ # [1] 'a1' is loaded and then "renamed" into 'a'. 'a1' is therefore
|
||||
+ # part of the names set so all its specific dropins are loaded.
|
||||
+ #
|
||||
+ # [2] 'a' is already loaded. 'a1' is simply only merged into 'a' so
|
||||
+ # none of its dropins are loaded ('y' is missing from the deps).
|
||||
+ echo "*** test 2"
|
||||
+ create_services a x y
|
||||
+ mkdir -p /etc/systemd/system/a1.service.wants/
|
||||
+ ln -sf a.service /etc/systemd/system/a1.service
|
||||
+ ln -sf ../x.service /etc/systemd/system/a.service.wants/
|
||||
+ ln -sf ../y.service /etc/systemd/system/a1.service.wants/
|
||||
+ check_ok a1 Wants x.service # see [1]
|
||||
+ check_ok a1 Wants y.service
|
||||
+ systemctl start a
|
||||
+ check_ok a1 Wants x.service # see [2]
|
||||
+ check_ko a1 Wants y.service
|
||||
+ systemctl stop a x y
|
||||
+ rm /etc/systemd/system/a1.service
|
||||
+
|
||||
+ clear_services a x y
|
||||
}
|
||||
|
||||
test_masked_dropins () {
|
||||
- echo "Testing masked dropins..."
|
||||
-
|
||||
- create_services a b
|
||||
-
|
||||
- # 'b' is masked for both deps
|
||||
- echo "*** test a wants,requires b is masked"
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
|
||||
- check_ko a Wants b.service
|
||||
- check_ko a Requires b.service
|
||||
-
|
||||
- # 'a' wants 'b' and 'b' is masked at a lower level
|
||||
- echo "*** test a wants b, mask override"
|
||||
- ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service
|
||||
- ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service
|
||||
- check_ok a Wants b.service
|
||||
-
|
||||
- # 'a' wants 'b' and 'b' is masked at a higher level
|
||||
- echo "*** test a wants b, mask"
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
- ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
|
||||
- check_ko a Wants b.service
|
||||
-
|
||||
- # 'a' is masked but has an override config file
|
||||
- echo "*** test a is masked but has an override"
|
||||
- create_services a b
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service
|
||||
- cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF
|
||||
+ echo "Testing masked dropins..."
|
||||
+
|
||||
+ create_services a b
|
||||
+
|
||||
+ # 'b' is masked for both deps
|
||||
+ echo "*** test a wants,requires b is masked"
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
|
||||
+ check_ko a Wants b.service
|
||||
+ check_ko a Requires b.service
|
||||
+
|
||||
+ # 'a' wants 'b' and 'b' is masked at a lower level
|
||||
+ echo "*** test a wants b, mask override"
|
||||
+ ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service
|
||||
+ ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service
|
||||
+ check_ok a Wants b.service
|
||||
+
|
||||
+ # 'a' wants 'b' and 'b' is masked at a higher level
|
||||
+ echo "*** test a wants b, mask"
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
+ ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
|
||||
+ check_ko a Wants b.service
|
||||
+
|
||||
+ # 'a' is masked but has an override config file
|
||||
+ echo "*** test a is masked but has an override"
|
||||
+ create_services a b
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service
|
||||
+ cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF
|
||||
[Unit]
|
||||
After=b.service
|
||||
EOF
|
||||
- check_ok a UnitFileState masked
|
||||
-
|
||||
- # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep
|
||||
- echo "*** test a wants b, b1, and one is masked"
|
||||
- create_services a b
|
||||
- ln -sf b.service /etc/systemd/system/b1.service
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
- ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service
|
||||
- systemctl cat a
|
||||
- systemctl show -p Wants,Requires a
|
||||
- systemctl cat b1
|
||||
- systemctl show -p Wants,Requires b1
|
||||
- check_ok a Wants b.service
|
||||
- check_ko a Wants b1.service # the alias does not show up in the list of units
|
||||
- rm /etc/systemd/system/b1.service
|
||||
-
|
||||
- # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep
|
||||
- echo "*** test a wants b, alias dep is masked"
|
||||
- create_services a b
|
||||
- ln -sf b.service /etc/systemd/system/b1.service
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.wants/b1.service
|
||||
- ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
|
||||
- check_ok a Wants b.service
|
||||
- check_ko a Wants b1.service # the alias does not show up in the list of units
|
||||
- rm /etc/systemd/system/b1.service
|
||||
-
|
||||
- # 'a' has Wants=b.service but also has a masking
|
||||
- # dropin 'b': 'b' should still be pulled in.
|
||||
- echo "*** test a wants b both ways"
|
||||
- create_services a b
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
- cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF
|
||||
+ check_ok a UnitFileState masked
|
||||
+
|
||||
+ # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep
|
||||
+ echo "*** test a wants b, b1, and one is masked"
|
||||
+ create_services a b
|
||||
+ ln -sf b.service /etc/systemd/system/b1.service
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
+ ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service
|
||||
+ systemctl cat a
|
||||
+ systemctl show -p Wants,Requires a
|
||||
+ systemctl cat b1
|
||||
+ systemctl show -p Wants,Requires b1
|
||||
+ check_ok a Wants b.service
|
||||
+ check_ko a Wants b1.service # the alias does not show up in the list of units
|
||||
+ rm /etc/systemd/system/b1.service
|
||||
+
|
||||
+ # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep
|
||||
+ echo "*** test a wants b, alias dep is masked"
|
||||
+ create_services a b
|
||||
+ ln -sf b.service /etc/systemd/system/b1.service
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.wants/b1.service
|
||||
+ ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
|
||||
+ check_ok a Wants b.service
|
||||
+ check_ko a Wants b1.service # the alias does not show up in the list of units
|
||||
+ rm /etc/systemd/system/b1.service
|
||||
+
|
||||
+ # 'a' has Wants=b.service but also has a masking
|
||||
+ # dropin 'b': 'b' should still be pulled in.
|
||||
+ echo "*** test a wants b both ways"
|
||||
+ create_services a b
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
|
||||
+ cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF
|
||||
[Unit]
|
||||
Wants=b.service
|
||||
EOF
|
||||
- check_ok a Wants b.service
|
||||
-
|
||||
- # mask a dropin that points to an nonexistent unit.
|
||||
- echo "*** test a wants nonexistent is masked"
|
||||
- create_services a
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service
|
||||
- ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/
|
||||
- check_ko a Requires nonexistent.service
|
||||
-
|
||||
- # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
|
||||
- # masked at a higher level.
|
||||
- echo "*** test a wants b is masked"
|
||||
- create_services a b c
|
||||
- ln -sf ../b.service /etc/systemd/system/a.service.requires/
|
||||
- ln -sf ../b.service /run/systemd/system/c.service.requires/
|
||||
- ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service
|
||||
- systemctl start a
|
||||
- check_ko c Requires b.service
|
||||
- systemctl stop a b
|
||||
-
|
||||
- # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
|
||||
- # masked at a lower level.
|
||||
- echo "*** test a requires b is masked"
|
||||
- create_services a b c
|
||||
- ln -sf ../b.service /etc/systemd/system/a.service.requires/
|
||||
- ln -sf ../b.service /etc/systemd/system/c.service.requires/
|
||||
- ln -sf /dev/null /run/systemd/system/c.service.requires/b.service
|
||||
- systemctl start a
|
||||
- check_ok c Requires b.service
|
||||
- systemctl stop a b
|
||||
-
|
||||
- # 'a' requires 2 aliases of 'b' and one of them is a mask.
|
||||
- echo "*** test a requires alias of b, other alias masked"
|
||||
- create_services a b
|
||||
- ln -sf b.service /etc/systemd/system/b1.service
|
||||
- ln -sf b.service /etc/systemd/system/b2.service
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.service
|
||||
- ln -sf ../b1.service /run/systemd/system/a.service.requires/
|
||||
- ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
|
||||
- check_ok a Requires b
|
||||
-
|
||||
- # Same as above but now 'b' is masked.
|
||||
- echo "*** test a requires alias of b, b dep masked"
|
||||
- create_services a b
|
||||
- ln -sf b.service /etc/systemd/system/b1.service
|
||||
- ln -sf b.service /etc/systemd/system/b2.service
|
||||
- ln -sf ../b1.service /run/systemd/system/a.service.requires/
|
||||
- ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
|
||||
- ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
|
||||
- check_ok a Requires b
|
||||
-
|
||||
- clear_services a b
|
||||
+ check_ok a Wants b.service
|
||||
+
|
||||
+ # mask a dropin that points to an nonexistent unit.
|
||||
+ echo "*** test a wants nonexistent is masked"
|
||||
+ create_services a
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service
|
||||
+ ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/
|
||||
+ check_ko a Requires nonexistent.service
|
||||
+
|
||||
+ # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
|
||||
+ # masked at a higher level.
|
||||
+ echo "*** test a wants b is masked"
|
||||
+ create_services a b c
|
||||
+ ln -sf ../b.service /etc/systemd/system/a.service.requires/
|
||||
+ ln -sf ../b.service /run/systemd/system/c.service.requires/
|
||||
+ ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service
|
||||
+ systemctl start a
|
||||
+ check_ko c Requires b.service
|
||||
+ systemctl stop a b
|
||||
+
|
||||
+ # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
|
||||
+ # masked at a lower level.
|
||||
+ echo "*** test a requires b is masked"
|
||||
+ create_services a b c
|
||||
+ ln -sf ../b.service /etc/systemd/system/a.service.requires/
|
||||
+ ln -sf ../b.service /etc/systemd/system/c.service.requires/
|
||||
+ ln -sf /dev/null /run/systemd/system/c.service.requires/b.service
|
||||
+ systemctl start a
|
||||
+ check_ok c Requires b.service
|
||||
+ systemctl stop a b
|
||||
+
|
||||
+ # 'a' requires 2 aliases of 'b' and one of them is a mask.
|
||||
+ echo "*** test a requires alias of b, other alias masked"
|
||||
+ create_services a b
|
||||
+ ln -sf b.service /etc/systemd/system/b1.service
|
||||
+ ln -sf b.service /etc/systemd/system/b2.service
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.service
|
||||
+ ln -sf ../b1.service /run/systemd/system/a.service.requires/
|
||||
+ ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
|
||||
+ check_ok a Requires b
|
||||
+
|
||||
+ # Same as above but now 'b' is masked.
|
||||
+ echo "*** test a requires alias of b, b dep masked"
|
||||
+ create_services a b
|
||||
+ ln -sf b.service /etc/systemd/system/b1.service
|
||||
+ ln -sf b.service /etc/systemd/system/b2.service
|
||||
+ ln -sf ../b1.service /run/systemd/system/a.service.requires/
|
||||
+ ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
|
||||
+ ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
|
||||
+ check_ok a Requires b
|
||||
+
|
||||
+ clear_services a b
|
||||
}
|
||||
|
||||
test_invalid_dropins () {
|
@ -1,31 +0,0 @@
|
||||
From eaffd717ec05ced564fc67b880f07640a8d60816 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sat, 21 Mar 2020 16:30:27 +0100
|
||||
Subject: [PATCH] test/TEST-15: remove all created unit files
|
||||
|
||||
We would miss anything created under a template instance.
|
||||
|
||||
(cherry picked from commit 4e2ac45a83e5495a5c1d3ecac62a054e0cef7746)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index 64d8a98fc7..30f1e84954 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -8,6 +8,12 @@ _clear_service () {
|
||||
rm -f /{etc,run,usr/lib}/systemd/system/$1.service
|
||||
rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}
|
||||
+ if [[ $1 == *@ ]]; then
|
||||
+ systemctl stop $1*.service 2>/dev/null || :
|
||||
+ rm -f /{etc,run,usr/lib}/systemd/system/$1*.service
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.d
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.{wants,requires}
|
||||
+ fi
|
||||
}
|
||||
|
||||
clear_services () {
|
@ -1,95 +0,0 @@
|
||||
From 209b8c92f0c44644d0476349b4a65f4b9ad942de Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
||||
Date: Fri, 9 Apr 2021 19:49:32 +0200
|
||||
Subject: [PATCH] test: use quotes where necessary
|
||||
|
||||
to avoid possible word splitting.
|
||||
|
||||
[dtardon: Dropped changes to other files.]
|
||||
|
||||
(cherry picked from commit 38825267983a439f2cf8375463b1edc9ca2d3323)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 44 ++++++++++++++++--------------
|
||||
1 file changed, 23 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index 30f1e84954..a197989f72 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -4,51 +4,53 @@ set -e
|
||||
set -x
|
||||
|
||||
_clear_service () {
|
||||
- systemctl stop $1.service 2>/dev/null || :
|
||||
- rm -f /{etc,run,usr/lib}/systemd/system/$1.service
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires}
|
||||
- if [[ $1 == *@ ]]; then
|
||||
- systemctl stop $1*.service 2>/dev/null || :
|
||||
- rm -f /{etc,run,usr/lib}/systemd/system/$1*.service
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.d
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.{wants,requires}
|
||||
+ local SERVICE_NAME="${1:?_clear_service: missing argument}"
|
||||
+ systemctl stop "$SERVICE_NAME.service" 2>/dev/null || :
|
||||
+ rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.{wants,requires}
|
||||
+ if [[ $SERVICE_NAME == *@ ]]; then
|
||||
+ systemctl stop "$SERVICE_NAME"*.service 2>/dev/null || :
|
||||
+ rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.d
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.{wants,requires}
|
||||
fi
|
||||
}
|
||||
|
||||
clear_services () {
|
||||
- for u in $*; do
|
||||
- _clear_service $u
|
||||
+ for u in "$@"; do
|
||||
+ _clear_service "$u"
|
||||
done
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
create_service () {
|
||||
- clear_services $1
|
||||
+ local SERVICE_NAME="${1:?create_service: missing argument}"
|
||||
+ clear_services "$SERVICE_NAME"
|
||||
|
||||
- cat >/etc/systemd/system/$1.service<<EOF
|
||||
+ cat >/etc/systemd/system/"$SERVICE_NAME".service <<EOF
|
||||
[Unit]
|
||||
-Description=$1 unit
|
||||
+Description=$SERVICE_NAME unit
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sleep 100000
|
||||
EOF
|
||||
- mkdir -p /{etc,run,usr/lib}/systemd/system/$1.service.d
|
||||
- mkdir -p /etc/systemd/system/$1.service.{wants,requires}
|
||||
- mkdir -p /run/systemd/system/$1.service.{wants,requires}
|
||||
- mkdir -p /usr/lib/systemd/system/$1.service.{wants,requires}
|
||||
+ mkdir -p /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d
|
||||
+ mkdir -p /etc/systemd/system/"$SERVICE_NAME".service.{wants,requires}
|
||||
+ mkdir -p /run/systemd/system/"$SERVICE_NAME".service.{wants,requires}
|
||||
+ mkdir -p /usr/lib/systemd/system/"$SERVICE_NAME".service.{wants,requires}
|
||||
}
|
||||
|
||||
create_services () {
|
||||
- for u in $*; do
|
||||
- create_service $u
|
||||
+ for u in "$@"; do
|
||||
+ create_service "$u"
|
||||
done
|
||||
}
|
||||
|
||||
check_ok () {
|
||||
[ $# -eq 3 ] || return
|
||||
|
||||
- x="$(systemctl show --value -p $2 $1)"
|
||||
+ x="$(systemctl show --value -p "$2" "$1")"
|
||||
case "$x" in
|
||||
*$3*) return 0 ;;
|
||||
*) return 1
|
@ -1,43 +0,0 @@
|
||||
From a167aac4c52ad68bc64748bf4f2b63f45b45f25a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Wed, 4 May 2022 08:24:06 +0200
|
||||
Subject: [PATCH] tree-wide: drop manually-crafted message for missing
|
||||
variables
|
||||
|
||||
Bash will generate a very nice message for us:
|
||||
/tmp/ff.sh: line 1: SOMEVAR: parameter null or not set
|
||||
|
||||
Let's save some keystrokes by not replacing this with our own inferior
|
||||
messages.
|
||||
|
||||
[dtardon: Dropped changes to other files.]
|
||||
|
||||
(cherry picked from commit d7ff52403902900b61f644f87b5222822fd4a69b)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index a197989f72..c2c96d9797 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -4,7 +4,7 @@ set -e
|
||||
set -x
|
||||
|
||||
_clear_service () {
|
||||
- local SERVICE_NAME="${1:?_clear_service: missing argument}"
|
||||
+ local SERVICE_NAME="${1:?}"
|
||||
systemctl stop "$SERVICE_NAME.service" 2>/dev/null || :
|
||||
rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service
|
||||
rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d
|
||||
@@ -25,7 +25,7 @@ clear_services () {
|
||||
}
|
||||
|
||||
create_service () {
|
||||
- local SERVICE_NAME="${1:?create_service: missing argument}"
|
||||
+ local SERVICE_NAME="${1:?}"
|
||||
clear_services "$SERVICE_NAME"
|
||||
|
||||
cat >/etc/systemd/system/"$SERVICE_NAME".service <<EOF
|
@ -1,41 +0,0 @@
|
||||
From af4b13c93d55fcbb535c94b0ab2c0aa54a6601d5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Fri, 14 Oct 2022 14:40:24 +0200
|
||||
Subject: [PATCH] manager: reformat boolean expression in unit_is_pristine()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Not not IN_SET(…) is just too much for my poor brain. Let's invert
|
||||
the expression to make it easier to undertand.
|
||||
|
||||
(cherry picked from commit b146a7345b69de16e88347acadb3783ffeeaad9d)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
src/core/unit.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/core/unit.c b/src/core/unit.c
|
||||
index 9be2a0c326..78666e73bf 100644
|
||||
--- a/src/core/unit.c
|
||||
+++ b/src/core/unit.c
|
||||
@@ -4848,12 +4848,12 @@ bool unit_is_pristine(Unit *u) {
|
||||
* are marked UNIT_LOADED even though nothing was actually
|
||||
* loaded, as those unit types don't require a file on disk. */
|
||||
|
||||
- return !(!IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_LOADED) ||
|
||||
- u->fragment_path ||
|
||||
- u->source_path ||
|
||||
- !strv_isempty(u->dropin_paths) ||
|
||||
- u->job ||
|
||||
- u->merged_into);
|
||||
+ return IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_LOADED) &&
|
||||
+ !u->fragment_path &&
|
||||
+ !u->source_path &&
|
||||
+ strv_isempty(u->dropin_paths) &&
|
||||
+ !u->job &&
|
||||
+ !u->merged_into;
|
||||
}
|
||||
|
||||
pid_t unit_control_pid(Unit *u) {
|
@ -1,88 +0,0 @@
|
||||
From fa8ed66b5ff48e0d8e02cfae28e90e65c70e52e3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Fri, 14 Oct 2022 15:02:20 +0200
|
||||
Subject: [PATCH] manager: allow transient units to have drop-ins
|
||||
|
||||
In https://github.com/containers/podman/issues/16107, starting of a transient
|
||||
slice unit fails because there's a "global" drop-in
|
||||
/usr/lib/systemd/user/slice.d/10-oomd-per-slice-defaults.conf (provided by
|
||||
systemd-oomd-defaults package to install some default oomd policy). This means
|
||||
that the unit_is_pristine() check fails and starting of the unit is forbidden.
|
||||
|
||||
It seems pretty clear to me that dropins at any other level then the unit
|
||||
should be ignored in this check: we now have multiple layers of drop-ins
|
||||
(for each level of the cgroup path, and also "global" ones for a specific
|
||||
unit type). If we install a "global" drop-in, we wouldn't be able to start
|
||||
any transient units of that type, which seems undesired.
|
||||
|
||||
In principle we could reject dropins at the unit level, but I don't think that
|
||||
is useful. The whole reason for drop-ins is that they are "add ons", and there
|
||||
isn't any particular reason to disallow them for transient units. It would also
|
||||
make things harder to implement and describe: one place for drop-ins is good,
|
||||
but another is bad. (And as a corner case: for instanciated units, a drop-in
|
||||
in the template would be acceptable, but a instance-specific drop-in bad?)
|
||||
|
||||
Thus, $subject.
|
||||
|
||||
While at it, adjust the message. All the conditions in unit_is_pristine()
|
||||
essentially mean that it wasn't loaded (e.g. it might be in an error state),
|
||||
and that it doesn't have a fragment path (now that drop-ins are acceptable).
|
||||
If there's a job for it, it necessarilly must have been loaded. If it is
|
||||
merged into another unit, it also was loaded and found to be an alias.
|
||||
Based on the discussion in the bugs, it seems that the current message
|
||||
is far from obvious ;)
|
||||
|
||||
Fixes https://github.com/containers/podman/issues/16107,
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=2133792.
|
||||
|
||||
(cherry picked from commit 1f83244641f13a9cb28fdac7e3c17c5446242dfb)
|
||||
|
||||
Resolves: #2156620
|
||||
---
|
||||
src/core/dbus-manager.c | 3 ++-
|
||||
src/core/unit.c | 14 ++++++++------
|
||||
2 files changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
||||
index 8a41eda4a6..ea2f3e7f59 100644
|
||||
--- a/src/core/dbus-manager.c
|
||||
+++ b/src/core/dbus-manager.c
|
||||
@@ -892,7 +892,8 @@ static int transient_unit_from_message(
|
||||
return r;
|
||||
|
||||
if (!unit_is_pristine(u))
|
||||
- return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit %s already exists.", name);
|
||||
+ return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS,
|
||||
+ "Unit %s was already loaded or has a fragment file.", name);
|
||||
|
||||
/* OK, the unit failed to load and is unreferenced, now let's
|
||||
* fill in the transient data instead */
|
||||
diff --git a/src/core/unit.c b/src/core/unit.c
|
||||
index 78666e73bf..76fb9f8075 100644
|
||||
--- a/src/core/unit.c
|
||||
+++ b/src/core/unit.c
|
||||
@@ -4842,16 +4842,18 @@ int unit_fail_if_noncanonical(Unit *u, const char* where) {
|
||||
bool unit_is_pristine(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
- /* Check if the unit already exists or is already around,
|
||||
- * in a number of different ways. Note that to cater for unit
|
||||
- * types such as slice, we are generally fine with units that
|
||||
- * are marked UNIT_LOADED even though nothing was actually
|
||||
- * loaded, as those unit types don't require a file on disk. */
|
||||
+ /* Check if the unit already exists or is already around, in a number of different ways. Note that to
|
||||
+ * cater for unit types such as slice, we are generally fine with units that are marked UNIT_LOADED
|
||||
+ * even though nothing was actually loaded, as those unit types don't require a file on disk.
|
||||
+ *
|
||||
+ * Note that we don't check for drop-ins here, because we allow drop-ins for transient units
|
||||
+ * identically to non-transient units, both unit-specific and hierarchical. E.g. for a-b-c.service:
|
||||
+ * service.d/….conf, a-.service.d/….conf, a-b-.service.d/….conf, a-b-c.service.d/….conf.
|
||||
+ */
|
||||
|
||||
return IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_LOADED) &&
|
||||
!u->fragment_path &&
|
||||
!u->source_path &&
|
||||
- strv_isempty(u->dropin_paths) &&
|
||||
!u->job &&
|
||||
!u->merged_into;
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
From 8a85dd4af8e4948299b4c84df65c789999024d5f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sun, 16 Oct 2022 12:42:35 +0200
|
||||
Subject: [PATCH] TEST-15: allow helper functions to accept other unit types
|
||||
|
||||
clear_services() is renamed to clear_units() and now takes a full
|
||||
unit name including the suffix as an argument.
|
||||
|
||||
_clear_service() is renamed to clear_unit() and changed likewise.
|
||||
create_service() didn't have the same underscore prefix, and I don't think
|
||||
it's useful or needed for a local function, so it is removed.
|
||||
|
||||
No functional change.
|
||||
|
||||
(cherry picked from commit 5731e1378ad6256e34f3da33ee993343f025c075)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 44 ++++++++++++++++--------------
|
||||
1 file changed, 23 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index c2c96d9797..bcd351360d 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -3,30 +3,32 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
-_clear_service () {
|
||||
- local SERVICE_NAME="${1:?}"
|
||||
- systemctl stop "$SERVICE_NAME.service" 2>/dev/null || :
|
||||
- rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.{wants,requires}
|
||||
- if [[ $SERVICE_NAME == *@ ]]; then
|
||||
- systemctl stop "$SERVICE_NAME"*.service 2>/dev/null || :
|
||||
- rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.d
|
||||
- rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.{wants,requires}
|
||||
+clear_unit () {
|
||||
+ local UNIT_NAME="${1:?}"
|
||||
+ systemctl stop "$UNIT_NAME" 2>/dev/null || :
|
||||
+ rm -f /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME"
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME".d
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$UNIT_NAME".{wants,requires}
|
||||
+ if [[ $UNIT_NAME == *@ ]]; then
|
||||
+ local base="${UNIT_NAME%@*}"
|
||||
+ local suffix="${UNIT_NAME##*.}"
|
||||
+ systemctl stop "$base@"*."$suffix" 2>/dev/null || :
|
||||
+ rm -f /{etc,run,usr/lib}/systemd/system/"$base@"*."$suffix"
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$base@"*."$suffix".d
|
||||
+ rm -fr /{etc,run,usr/lib}/systemd/system/"$base@"*."$suffix".{wants,requires}
|
||||
fi
|
||||
}
|
||||
|
||||
-clear_services () {
|
||||
+clear_units () {
|
||||
for u in "$@"; do
|
||||
- _clear_service "$u"
|
||||
+ clear_unit "$u"
|
||||
done
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
create_service () {
|
||||
local SERVICE_NAME="${1:?}"
|
||||
- clear_services "$SERVICE_NAME"
|
||||
+ clear_units "${SERVICE_NAME}".service
|
||||
|
||||
cat >/etc/systemd/system/"$SERVICE_NAME".service <<EOF
|
||||
[Unit]
|
||||
@@ -123,7 +125,7 @@ EOF
|
||||
check_ok b ExecCondition "/bin/echo b"
|
||||
rm -rf /usr/lib/systemd/system/service.d
|
||||
|
||||
- clear_services a b c
|
||||
+ clear_units {a,b,c}.service
|
||||
}
|
||||
|
||||
test_hierarchical_dropins () {
|
||||
@@ -148,7 +150,7 @@ ExecCondition=/bin/echo $dropin
|
||||
rm -rf /usr/lib/systemd/system/$dropin
|
||||
done
|
||||
|
||||
- clear_services a-b-c
|
||||
+ clear_units a-b-c.service
|
||||
}
|
||||
|
||||
test_template_dropins () {
|
||||
@@ -159,7 +161,7 @@ test_template_dropins () {
|
||||
ln -s /etc/systemd/system/bar@.service /etc/systemd/system/foo.service.wants/bar@1.service
|
||||
check_ok foo Wants bar@1.service
|
||||
|
||||
- clear_services foo bar@ yup@
|
||||
+ clear_units {foo,bar@,yup@}.service
|
||||
}
|
||||
|
||||
test_alias_dropins () {
|
||||
@@ -174,7 +176,7 @@ test_alias_dropins () {
|
||||
systemctl --quiet is-active b
|
||||
systemctl stop a b
|
||||
rm /etc/systemd/system/b1.service
|
||||
- clear_services a b
|
||||
+ clear_units {a,b}.service
|
||||
|
||||
# A weird behavior: the dependencies for 'a' may vary. It can be
|
||||
# changed by loading an alias...
|
||||
@@ -198,7 +200,7 @@ test_alias_dropins () {
|
||||
systemctl stop a x y
|
||||
rm /etc/systemd/system/a1.service
|
||||
|
||||
- clear_services a x y
|
||||
+ clear_units {a,x,y}.service
|
||||
}
|
||||
|
||||
test_masked_dropins () {
|
||||
@@ -319,7 +321,7 @@ EOF
|
||||
ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
|
||||
check_ok a Requires b
|
||||
|
||||
- clear_services a b
|
||||
+ clear_units {a,b}.service
|
||||
}
|
||||
|
||||
test_invalid_dropins () {
|
||||
@@ -331,7 +333,7 @@ test_invalid_dropins () {
|
||||
# Assertion failed on earlier versions, command exits unsuccessfully on later versions
|
||||
systemctl cat a@.service || true
|
||||
systemctl stop a
|
||||
- clear_services a
|
||||
+ clear_units a.service
|
||||
return 0
|
||||
}
|
||||
|
@ -1,79 +0,0 @@
|
||||
From 4b10a9b6ba299f804f7c24e9d455e6b6997a9eb4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sun, 16 Oct 2022 12:54:34 +0200
|
||||
Subject: [PATCH] TEST-15: also test hierarchical drop-ins for slices
|
||||
|
||||
Slices are worth testing too, because they don't need a fragment path so they
|
||||
behave slightly differently than service units. I'm making this a separate
|
||||
patch from the actual tests that I wanted to add later because it's complex
|
||||
enough on its own.
|
||||
|
||||
(cherry picked from commit f80c874af376052b6b81f47cbbc43d7fecd98cd6)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 37 +++++++++++++++++++++++++++---
|
||||
1 file changed, 34 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index bcd351360d..d46946fd77 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -128,8 +128,8 @@ EOF
|
||||
clear_units {a,b,c}.service
|
||||
}
|
||||
|
||||
-test_hierarchical_dropins () {
|
||||
- echo "Testing hierarchical dropins..."
|
||||
+test_hierarchical_service_dropins () {
|
||||
+ echo "Testing hierarchical service dropins..."
|
||||
echo "*** test service.d/ top level drop-in"
|
||||
create_services a-b-c
|
||||
check_ko a-b-c ExecCondition "/bin/echo service.d"
|
||||
@@ -153,6 +153,36 @@ ExecCondition=/bin/echo $dropin
|
||||
clear_units a-b-c.service
|
||||
}
|
||||
|
||||
+test_hierarchical_slice_dropins () {
|
||||
+ echo "Testing hierarchical slice dropins..."
|
||||
+ echo "*** test slice.d/ top level drop-in"
|
||||
+ # Slice units don't even need a fragment, so we test the defaults here
|
||||
+ check_ok a-b-c.slice Description "a-b-c.slice"
|
||||
+ check_ok a-b-c.slice MemoryMax "infinity"
|
||||
+
|
||||
+ # Test drop-ins
|
||||
+ for dropin in slice.d a-.slice.d a-b-.slice.d a-b-c.slice.d; do
|
||||
+ mkdir -p /usr/lib/systemd/system/$dropin
|
||||
+ echo "
|
||||
+[Slice]
|
||||
+MemoryMax=1000000000
|
||||
+ " >/usr/lib/systemd/system/$dropin/override.conf
|
||||
+ systemctl daemon-reload
|
||||
+ check_ok a-b-c.slice MemoryMax "1000000000"
|
||||
+ rm /usr/lib/systemd/system/$dropin/override.conf
|
||||
+ done
|
||||
+
|
||||
+ # Test unit with a fragment
|
||||
+ echo "
|
||||
+[Slice]
|
||||
+MemoryMax=1000000001
|
||||
+ " >/usr/lib/systemd/system/a-b-c.slice
|
||||
+ systemctl daemon-reload
|
||||
+ check_ok a-b-c.slice MemoryMax "1000000001"
|
||||
+
|
||||
+ clear_units a-b-c.slice
|
||||
+}
|
||||
+
|
||||
test_template_dropins () {
|
||||
echo "Testing template dropins..."
|
||||
|
||||
@@ -338,7 +368,8 @@ test_invalid_dropins () {
|
||||
}
|
||||
|
||||
test_basic_dropins
|
||||
-test_hierarchical_dropins
|
||||
+test_hierarchical_service_dropins
|
||||
+test_hierarchical_slice_dropins
|
||||
test_template_dropins
|
||||
test_alias_dropins
|
||||
test_masked_dropins
|
@ -1,109 +0,0 @@
|
||||
From c4db01d0c3e1ff05286261971ba39839cc91c21a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sun, 16 Oct 2022 14:02:45 +0200
|
||||
Subject: [PATCH] TEST-15: add test for transient units with drop-ins
|
||||
|
||||
We want to test four things:
|
||||
- that the transient units are successfully started when drop-ins exist
|
||||
- that the transient setings override the defaults
|
||||
- the drop-ins override the transient settings (the same as for a normal unit)
|
||||
- that things are the same before and after a reload
|
||||
|
||||
To make things more fun, we start and stop units in two different ways: via
|
||||
systemctl and via a direct busctl invocation. This gives us a bit more coverage
|
||||
of different code paths.
|
||||
|
||||
(cherry picked from commit 6854434cfb5dda10c07d95835c38b75e5e71c2b5)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 62 +++++++++++++++++++++++++++---
|
||||
1 file changed, 56 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index d46946fd77..5f061d3629 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -132,19 +132,40 @@ test_hierarchical_service_dropins () {
|
||||
echo "Testing hierarchical service dropins..."
|
||||
echo "*** test service.d/ top level drop-in"
|
||||
create_services a-b-c
|
||||
- check_ko a-b-c ExecCondition "/bin/echo service.d"
|
||||
- check_ko a-b-c ExecCondition "/bin/echo a-.service.d"
|
||||
- check_ko a-b-c ExecCondition "/bin/echo a-b-.service.d"
|
||||
- check_ko a-b-c ExecCondition "/bin/echo a-b-c.service.d"
|
||||
+ check_ko a-b-c ExecCondition "echo service.d"
|
||||
+ check_ko a-b-c ExecCondition "echo a-.service.d"
|
||||
+ check_ko a-b-c ExecCondition "echo a-b-.service.d"
|
||||
+ check_ko a-b-c ExecCondition "echo a-b-c.service.d"
|
||||
|
||||
for dropin in service.d a-.service.d a-b-.service.d a-b-c.service.d; do
|
||||
mkdir -p /usr/lib/systemd/system/$dropin
|
||||
echo "
|
||||
[Service]
|
||||
-ExecCondition=/bin/echo $dropin
|
||||
+ExecCondition=echo $dropin
|
||||
" >/usr/lib/systemd/system/$dropin/override.conf
|
||||
systemctl daemon-reload
|
||||
- check_ok a-b-c ExecCondition "/bin/echo $dropin"
|
||||
+ check_ok a-b-c ExecCondition "echo $dropin"
|
||||
+
|
||||
+ # Check that we can start a transient service in presence of the drop-ins
|
||||
+ systemd-run --unit a-b-c2.service -p Description='sleepy' sleep infinity
|
||||
+
|
||||
+ # The transient setting replaces the default
|
||||
+ check_ok a-b-c2.service Description "sleepy"
|
||||
+
|
||||
+ # The override takes precedence for ExecCondition
|
||||
+ # (except the last iteration when it only applies to the other service)
|
||||
+ if [ "$dropin" != "a-b-c.service.d" ]; then
|
||||
+ check_ok a-b-c2.service ExecCondition "echo $dropin"
|
||||
+ fi
|
||||
+
|
||||
+ # Check that things are the same after a reload
|
||||
+ systemctl daemon-reload
|
||||
+ check_ok a-b-c2.service Description "sleepy"
|
||||
+ if [ "$dropin" != "a-b-c.service.d" ]; then
|
||||
+ check_ok a-b-c2.service ExecCondition "echo $dropin"
|
||||
+ fi
|
||||
+
|
||||
+ systemctl stop a-b-c2.service
|
||||
done
|
||||
for dropin in service.d a-.service.d a-b-.service.d a-b-c.service.d; do
|
||||
rm -rf /usr/lib/systemd/system/$dropin
|
||||
@@ -169,6 +190,35 @@ MemoryMax=1000000000
|
||||
" >/usr/lib/systemd/system/$dropin/override.conf
|
||||
systemctl daemon-reload
|
||||
check_ok a-b-c.slice MemoryMax "1000000000"
|
||||
+
|
||||
+ busctl call \
|
||||
+ org.freedesktop.systemd1 \
|
||||
+ /org/freedesktop/systemd1 \
|
||||
+ org.freedesktop.systemd1.Manager \
|
||||
+ StartTransientUnit 'ssa(sv)a(sa(sv))' \
|
||||
+ 'a-b-c.slice' 'replace' \
|
||||
+ 2 \
|
||||
+ 'Description' s 'slice too' \
|
||||
+ 'MemoryMax' t 1000000002 \
|
||||
+ 0
|
||||
+
|
||||
+ # The override takes precedence for MemoryMax
|
||||
+ check_ok a-b-c.slice MemoryMax "1000000000"
|
||||
+ # The transient setting replaces the default
|
||||
+ check_ok a-b-c.slice Description "slice too"
|
||||
+
|
||||
+ # Check that things are the same after a reload
|
||||
+ systemctl daemon-reload
|
||||
+ check_ok a-b-c.slice MemoryMax "1000000000"
|
||||
+ check_ok a-b-c.slice Description "slice too"
|
||||
+
|
||||
+ busctl call \
|
||||
+ org.freedesktop.systemd1 \
|
||||
+ /org/freedesktop/systemd1 \
|
||||
+ org.freedesktop.systemd1.Manager \
|
||||
+ StopUnit 'ss' \
|
||||
+ 'a-b-c.slice' 'replace'
|
||||
+
|
||||
rm /usr/lib/systemd/system/$dropin/override.conf
|
||||
done
|
||||
|
@ -1,66 +0,0 @@
|
||||
From 832ceb778409cac37c3b64294dc64312e86eedc6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sun, 16 Oct 2022 21:52:43 +0200
|
||||
Subject: [PATCH] TEST-15: add one more test for drop-in precedence
|
||||
|
||||
(cherry picked from commit c3fa408dcc03bb6dbd11f180540fb9e684893c39)
|
||||
|
||||
Related: #2156620
|
||||
---
|
||||
test/TEST-15-DROPIN/test-dropin.sh | 36 ++++++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
|
||||
diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
index 5f061d3629..f6b3844630 100755
|
||||
--- a/test/TEST-15-DROPIN/test-dropin.sh
|
||||
+++ b/test/TEST-15-DROPIN/test-dropin.sh
|
||||
@@ -233,6 +233,41 @@ MemoryMax=1000000001
|
||||
clear_units a-b-c.slice
|
||||
}
|
||||
|
||||
+test_transient_service_dropins () {
|
||||
+ echo "Testing dropins for a transient service..."
|
||||
+ echo "*** test transient service drop-ins"
|
||||
+
|
||||
+ mkdir -p /etc/systemd/system/service.d
|
||||
+ mkdir -p /etc/systemd/system/a-.service.d
|
||||
+ mkdir -p /etc/systemd/system/a-b-.service.d
|
||||
+ mkdir -p /etc/systemd/system/a-b-c.service.d
|
||||
+
|
||||
+ echo -e '[Service]\nStandardInputText=aaa' >/etc/systemd/system/service.d/drop1.conf
|
||||
+ echo -e '[Service]\nStandardInputText=bbb' >/etc/systemd/system/a-.service.d/drop2.conf
|
||||
+ echo -e '[Service]\nStandardInputText=ccc' >/etc/systemd/system/a-b-.service.d/drop3.conf
|
||||
+ echo -e '[Service]\nStandardInputText=ddd' >/etc/systemd/system/a-b-c.service.d/drop4.conf
|
||||
+
|
||||
+ # There's no fragment yet, so this fails
|
||||
+ systemctl cat a-b-c.service && exit 1
|
||||
+
|
||||
+ # xxx → eHh4Cg==
|
||||
+ systemd-run --unit a-b-c.service -p StandardInputData=eHh4Cg== sleep infinity
|
||||
+
|
||||
+ data=$(systemctl show --value -p StandardInputData a-b-c.service)
|
||||
+ # xxx\naaa\n\bbb\nccc\nddd\n → eHh4…
|
||||
+ test "$data" = "eHh4CmFhYQpiYmIKY2NjCmRkZAo="
|
||||
+
|
||||
+ # Do a reload and check again
|
||||
+ systemctl daemon-reload
|
||||
+ data=$(systemctl show --value -p StandardInputData a-b-c.service)
|
||||
+ test "$data" = "eHh4CmFhYQpiYmIKY2NjCmRkZAo="
|
||||
+
|
||||
+ clear_units a-b-c.service
|
||||
+ rm /etc/systemd/system/service.d/drop1.conf \
|
||||
+ /etc/systemd/system/a-.service.d/drop2.conf \
|
||||
+ /etc/systemd/system/a-b-.service.d/drop3.conf
|
||||
+}
|
||||
+
|
||||
test_template_dropins () {
|
||||
echo "Testing template dropins..."
|
||||
|
||||
@@ -420,6 +455,7 @@ test_invalid_dropins () {
|
||||
test_basic_dropins
|
||||
test_hierarchical_service_dropins
|
||||
test_hierarchical_slice_dropins
|
||||
+test_transient_service_dropins
|
||||
test_template_dropins
|
||||
test_alias_dropins
|
||||
test_masked_dropins
|
@ -1,50 +0,0 @@
|
||||
From 79e852a6c50ab2eae16761f128c52ef286c2956b Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 14 Aug 2023 15:58:02 +0200
|
||||
Subject: [PATCH] udev/net_id: introduce naming scheme for RHEL-8.9
|
||||
|
||||
rhel-only
|
||||
|
||||
Resolves: #2231846
|
||||
---
|
||||
man/systemd.net-naming-scheme.xml | 6 ++++++
|
||||
src/udev/udev-builtin-net_id.c | 2 ++
|
||||
2 files changed, 8 insertions(+)
|
||||
|
||||
diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml
|
||||
index 3cc7719e99..ddd41646ae 100644
|
||||
--- a/man/systemd.net-naming-scheme.xml
|
||||
+++ b/man/systemd.net-naming-scheme.xml
|
||||
@@ -334,6 +334,12 @@
|
||||
<para>Same as naming scheme <constant>rhel-8.7</constant>.</para>
|
||||
</varlistentry>
|
||||
|
||||
+ <varlistentry>
|
||||
+ <term><constant>rhel-8.9</constant></term>
|
||||
+
|
||||
+ <para>Same as naming scheme <constant>rhel-8.7</constant>.</para>
|
||||
+ </varlistentry>
|
||||
+
|
||||
<para>Note that <constant>latest</constant> may be used to denote the latest scheme known to this
|
||||
particular version of systemd.</para>
|
||||
</variablelist>
|
||||
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
|
||||
index ef2bb1b08e..0f42c1c007 100644
|
||||
--- a/src/udev/udev-builtin-net_id.c
|
||||
+++ b/src/udev/udev-builtin-net_id.c
|
||||
@@ -142,6 +142,7 @@ typedef enum NamingSchemeFlags {
|
||||
NAMING_RHEL_8_6 = NAMING_RHEL_8_4,
|
||||
NAMING_RHEL_8_7 = NAMING_RHEL_8_4|NAMING_SLOT_FUNCTION_ID|NAMING_16BIT_INDEX,
|
||||
NAMING_RHEL_8_8 = NAMING_RHEL_8_7,
|
||||
+ NAMING_RHEL_8_9 = NAMING_RHEL_8_7,
|
||||
|
||||
_NAMING_SCHEME_FLAGS_INVALID = -1,
|
||||
} NamingSchemeFlags;
|
||||
@@ -163,6 +164,7 @@ static const NamingScheme naming_schemes[] = {
|
||||
{ "rhel-8.6", NAMING_RHEL_8_6 },
|
||||
{ "rhel-8.7", NAMING_RHEL_8_7 },
|
||||
{ "rhel-8.8", NAMING_RHEL_8_8 },
|
||||
+ { "rhel-8.9", NAMING_RHEL_8_9 },
|
||||
/* … add more schemes here, as the logic to name devices is updated … */
|
||||
};
|
||||
|
@ -1,27 +0,0 @@
|
||||
From e89c5274a75907bf24689859cdcdf8335df382cd Mon Sep 17 00:00:00 2001
|
||||
From: Luca Boccassi <luca.boccassi@microsoft.com>
|
||||
Date: Wed, 24 Nov 2021 20:23:02 +0000
|
||||
Subject: [PATCH] meson: remove libdw dependency from pstore
|
||||
|
||||
systemd-pstore does not use any symbol from libdw, and never did,
|
||||
but the dependency was listed since the beginning
|
||||
|
||||
(cherry picked from commit 5361f62d6d5b25c6545059f7d2513324be8d7a49)
|
||||
|
||||
Related: #2211416
|
||||
---
|
||||
meson.build | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/meson.build b/meson.build
|
||||
index d986dd24ac..d00d250444 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -2161,7 +2161,6 @@ if conf.get('ENABLE_PSTORE') == 1
|
||||
link_with : [libshared],
|
||||
dependencies : [threads,
|
||||
libacl,
|
||||
- libdw,
|
||||
libxz,
|
||||
liblz4],
|
||||
install_rpath : rootlibexecdir,
|
@ -1,113 +0,0 @@
|
||||
From e7f656192ea399043947640a664bd94129e9549b Mon Sep 17 00:00:00 2001
|
||||
From: Eric DeVolder <eric.devolder@oracle.com>
|
||||
Date: Mon, 13 Apr 2020 16:22:04 -0500
|
||||
Subject: [PATCH] pstore: introduce tmpfiles.d/systemd-pstore.conf
|
||||
|
||||
The systemd pstore service archives the contents of /sys/fs/pstore
|
||||
upon boot so that there is room for a subsequent dump. The issue is
|
||||
that while the service is present, the kernel still needs to be
|
||||
configured to write data into the pstore. The kernel has two
|
||||
parameters, crash_kexec_post_notifiers and printk.always_kmsg_dump,
|
||||
that control writes into pstore.
|
||||
|
||||
The crash_kexec_post_notifiers parameter enables the kernel to write
|
||||
dmesg (including stack trace) into pstore upon a panic, and
|
||||
printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
upon a shutdown (shutdown, reboot, halt).
|
||||
|
||||
As it stands today, these parameters are not managed/manipulated by
|
||||
the systemd pstore service, and are solely reliant upon the user [to
|
||||
have the foresight] to set them on the kernel command line at boot, or
|
||||
post boot via sysfs. Furthermore, the user would need to set these
|
||||
parameters in a persistent fashion so that that they are enabled on
|
||||
subsequent reboots.
|
||||
|
||||
This patch introduces the setting of these two kernel parameters via
|
||||
the systemd tmpfiles technique.
|
||||
|
||||
(cherry picked from commit f00c36641a253f4ea659ec3def5d87ba1336eb3b)
|
||||
|
||||
Resolves: #2211416
|
||||
---
|
||||
man/systemd-pstore.service.xml | 18 ++++++++++++++++++
|
||||
tmpfiles.d/meson.build | 1 +
|
||||
tmpfiles.d/systemd-pstore.conf | 29 +++++++++++++++++++++++++++++
|
||||
3 files changed, 48 insertions(+)
|
||||
create mode 100644 tmpfiles.d/systemd-pstore.conf
|
||||
|
||||
diff --git a/man/systemd-pstore.service.xml b/man/systemd-pstore.service.xml
|
||||
index 47916da521..335a3b3d18 100644
|
||||
--- a/man/systemd-pstore.service.xml
|
||||
+++ b/man/systemd-pstore.service.xml
|
||||
@@ -81,6 +81,24 @@
|
||||
<citerefentry><refentrytitle>pstore.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
</para>
|
||||
</refsect2>
|
||||
+
|
||||
+ <refsect2>
|
||||
+ <title>Controlling kernel parameters</title>
|
||||
+
|
||||
+ <para> The kernel has two parameters,
|
||||
+ <filename>/sys/module/kernel/parameters/crash_kexec_post_notifiers</filename> and
|
||||
+ <filename>/sys/module/printk/parameters/always_kmsg_dump</filename>,
|
||||
+ that control writes into pstore.
|
||||
+ The crash_kexec_post_notifiers parameter enables the kernel to write
|
||||
+ dmesg (including stack trace) into pstore upon a panic or crash, and
|
||||
+ printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
+ upon a normal shutdown (shutdown, reboot, halt). These kernel
|
||||
+ parameters are managed via the
|
||||
+ <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
+ mechanism, specifically the file <filename>/usr/lib/tmpfiles/systemd-pstore.conf</filename>.
|
||||
+ </para>
|
||||
+ </refsect2>
|
||||
+
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
diff --git a/tmpfiles.d/meson.build b/tmpfiles.d/meson.build
|
||||
index 35eea2be5c..5ebb8f432a 100644
|
||||
--- a/tmpfiles.d/meson.build
|
||||
+++ b/tmpfiles.d/meson.build
|
||||
@@ -7,6 +7,7 @@ tmpfiles = [['home.conf', ''],
|
||||
['systemd-nologin.conf', ''],
|
||||
['systemd-nspawn.conf', 'ENABLE_MACHINED'],
|
||||
['portables.conf', 'ENABLE_PORTABLED'],
|
||||
+ ['systemd-pstore.conf', 'ENABLE_PSTORE'],
|
||||
['tmp.conf', ''],
|
||||
['x11.conf', ''],
|
||||
['legacy.conf', 'HAVE_SYSV_COMPAT'],
|
||||
diff --git a/tmpfiles.d/systemd-pstore.conf b/tmpfiles.d/systemd-pstore.conf
|
||||
new file mode 100644
|
||||
index 0000000000..cb600ec1ee
|
||||
--- /dev/null
|
||||
+++ b/tmpfiles.d/systemd-pstore.conf
|
||||
@@ -0,0 +1,29 @@
|
||||
+# SPDX-License-Identifier: LGPL-2.1+
|
||||
+#
|
||||
+# The systemd-pstore.service(1) archives the contents of /sys/fs/pstore
|
||||
+# upon boot so that there is room for a subsequent dump. This service
|
||||
+# is enabled with:
|
||||
+# systemctl enable systemd-pstore
|
||||
+#
|
||||
+# With the service enabled, the kernel still needs to be configured
|
||||
+# to write data into the pstore. The kernel has two parameters,
|
||||
+# crash_kexec_post_notifiers and printk.always_kmsg_dump, that
|
||||
+# control writes into pstore.
|
||||
+#
|
||||
+# The crash_kexec_post_notifiers parameter enables the kernel to write
|
||||
+# dmesg (including stack trace) into pstore upon a panic, and
|
||||
+# printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
+# upon a normal shutdown (shutdown, reboot, halt).
|
||||
+#
|
||||
+# To configure the kernel parameters, uncomment the appropriate
|
||||
+# line(s) below. The value written is either 'Y' to enable the
|
||||
+# kernel parameter, or 'N' to disable the kernel parameter.
|
||||
+#
|
||||
+# After making a change to this file, do:
|
||||
+# systemd-tmpfiles --create path/to/tmpfiles.d/systemd-pstore.conf
|
||||
+#
|
||||
+# These changes are automatically applied on future re-boots.
|
||||
+
|
||||
+d /var/lib/systemd/pstore 0755 root root 14d
|
||||
+#w /sys/module/printk/parameters/always_kmsg_dump - - - - Y
|
||||
+w /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
|
@ -1,25 +0,0 @@
|
||||
From fec31cf3f20aa97b7dc8b381e64f30eea4d4c2d2 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 25 May 2020 16:11:51 +0200
|
||||
Subject: [PATCH] tmpfiles: don't complain if we can't enable pstore in
|
||||
containers
|
||||
|
||||
(cherry picked from commit 203c07c95b91b4ae3b0c1ae3c92accdb71fd5e13)
|
||||
|
||||
Related: #2211416
|
||||
---
|
||||
tmpfiles.d/systemd-pstore.conf | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/tmpfiles.d/systemd-pstore.conf b/tmpfiles.d/systemd-pstore.conf
|
||||
index cb600ec1ee..8b6a1dafc3 100644
|
||||
--- a/tmpfiles.d/systemd-pstore.conf
|
||||
+++ b/tmpfiles.d/systemd-pstore.conf
|
||||
@@ -25,5 +25,5 @@
|
||||
# These changes are automatically applied on future re-boots.
|
||||
|
||||
d /var/lib/systemd/pstore 0755 root root 14d
|
||||
-#w /sys/module/printk/parameters/always_kmsg_dump - - - - Y
|
||||
-w /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
|
||||
+#w- /sys/module/printk/parameters/always_kmsg_dump - - - - Y
|
||||
+w- /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
|
@ -1,66 +0,0 @@
|
||||
From 21e0afbe2764476c98d7809af6634773835723d4 Mon Sep 17 00:00:00 2001
|
||||
From: Kairui Song <kasong@redhat.com>
|
||||
Date: Tue, 4 Aug 2020 17:30:51 +0800
|
||||
Subject: [PATCH] pstore: don't enable crash_kexec_post_notifiers by default
|
||||
|
||||
commit f00c36641a253f4ea659ec3def5d87ba1336eb3b enabled
|
||||
crash_kexec_post_notifiers by default regardless of whether pstore
|
||||
is enabled or not.
|
||||
|
||||
The original intention to enabled this option by default is that
|
||||
it only affects kernel post-panic behavior, so should have no harm.
|
||||
But this is not true if the user wants a reliable kdump.
|
||||
|
||||
crash_kexec_post_notifiers is known to cause problem with kdump,
|
||||
and it's documented in kernel. It's not easy to fix the problem
|
||||
because of how kdump works. Kdump expects the crashed kernel to
|
||||
jump to an pre-loaded crash kernel, so doing any extra job before
|
||||
the jump will increase the risk.
|
||||
|
||||
It depends on the user to choose between having a reliable kdump or
|
||||
some other post-panic debug mechanic.
|
||||
|
||||
So it's better to keep this config untouched by default, or it may put
|
||||
kdump at higher risk of failing silently. User should enable it by
|
||||
uncommenting the config line manually if pstore is always needed.
|
||||
|
||||
Also add a inline comment inform user about the potential issue.
|
||||
|
||||
Thanks to Dave Young for finding out this issue.
|
||||
|
||||
Fixes #16661
|
||||
|
||||
Signed-off-by: Kairui Song <kasong@redhat.com>
|
||||
(cherry picked from commit edb8c98446e7dae54bcda90806bf6c068e1c6385)
|
||||
|
||||
Related: #2211416
|
||||
---
|
||||
tmpfiles.d/systemd-pstore.conf | 11 ++++++++---
|
||||
1 file changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/tmpfiles.d/systemd-pstore.conf b/tmpfiles.d/systemd-pstore.conf
|
||||
index 8b6a1dafc3..e8e9ed48ae 100644
|
||||
--- a/tmpfiles.d/systemd-pstore.conf
|
||||
+++ b/tmpfiles.d/systemd-pstore.conf
|
||||
@@ -11,8 +11,13 @@
|
||||
# control writes into pstore.
|
||||
#
|
||||
# The crash_kexec_post_notifiers parameter enables the kernel to write
|
||||
-# dmesg (including stack trace) into pstore upon a panic, and
|
||||
-# printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
+# dmesg (including stack trace) into pstore upon a panic even if kdump
|
||||
+# is loaded, only needed if you want to use pstore with kdump. Without
|
||||
+# this parameter, kdump could block writing to pstore for stability
|
||||
+# reason. Note this increases the risk of kdump failure even if pstore
|
||||
+# is not available.
|
||||
+#
|
||||
+# The printk.always_kmsg_dump parameter enables the kernel to write dmesg
|
||||
# upon a normal shutdown (shutdown, reboot, halt).
|
||||
#
|
||||
# To configure the kernel parameters, uncomment the appropriate
|
||||
@@ -26,4 +31,4 @@
|
||||
|
||||
d /var/lib/systemd/pstore 0755 root root 14d
|
||||
#w- /sys/module/printk/parameters/always_kmsg_dump - - - - Y
|
||||
-w- /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
|
||||
+#w- /sys/module/kernel/parameters/crash_kexec_post_notifiers - - - - Y
|
@ -1,217 +0,0 @@
|
||||
From 44d19e4beb486969b25c07f7efdee2e8b8bcf986 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Fri, 16 Nov 2018 20:19:07 +0100
|
||||
Subject: [PATCH] core: when Delegate=yes is set for a unit, run ExecStartPre=
|
||||
and friends in a subcgroup of the unit
|
||||
|
||||
Otherwise we might conflict with the "no-processes-in-inner-cgroup" rule
|
||||
of cgroupsv2. Consider nspawn starting up and initializing its cgroup
|
||||
hierarchy with "supervisor/" and "payload/" as subcgroup, with itself
|
||||
moved into the former and the payload into the latter. Now, if an
|
||||
ExecStartPre= is run right after it cannot be placed in the main cgroup,
|
||||
because that is now in inner cgroup with populated children.
|
||||
|
||||
Hence, let's run these helpers in another sub-cgroup .control/ below it.
|
||||
|
||||
This is somewhat ugly since it weakens the clear separation of
|
||||
ownership, but given that this is an explicit contract, and double opt-in should be acceptable.
|
||||
|
||||
Fixes: #10482
|
||||
(cherry picked from commit 78f93209fc7f61f15b12d7a5f74d712bd020b249)
|
||||
|
||||
Resolves: #2215925
|
||||
---
|
||||
src/core/execute.c | 67 +++++++++++++++++++++++++++++++++++++++-------
|
||||
src/core/execute.h | 9 ++++---
|
||||
src/core/service.c | 13 ++++-----
|
||||
3 files changed, 70 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/src/core/execute.c b/src/core/execute.c
|
||||
index b1d8dceb32..7e186c948c 100644
|
||||
--- a/src/core/execute.c
|
||||
+++ b/src/core/execute.c
|
||||
@@ -2834,6 +2834,37 @@ bool exec_context_get_cpu_affinity_from_numa(const ExecContext *c) {
|
||||
return c->cpu_affinity_from_numa;
|
||||
}
|
||||
|
||||
+static int exec_parameters_get_cgroup_path(const ExecParameters *params, char **ret) {
|
||||
+ bool using_subcgroup;
|
||||
+ char *p;
|
||||
+
|
||||
+ assert(params);
|
||||
+ assert(ret);
|
||||
+
|
||||
+ if (!params->cgroup_path)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ /* If we are called for a unit where cgroup delegation is on, and the payload created its own populated
|
||||
+ * subcgroup (which we expect it to do, after all it asked for delegation), then we cannot place the control
|
||||
+ * processes started after the main unit's process in the unit's main cgroup because it is now an inner one,
|
||||
+ * and inner cgroups may not contain processes. Hence, if delegation is on, and this is a control process,
|
||||
+ * let's use ".control" as subcgroup instead. Note that we do so only for ExecStartPost=, ExecReload=,
|
||||
+ * ExecStop=, ExecStopPost=, i.e. for the commands where the main process is already forked. For ExecStartPre=
|
||||
+ * this is not necessary, the cgroup is still empty. We distinguish these cases with the EXEC_CONTROL_CGROUP
|
||||
+ * flag, which is only passed for the former statements, not for the latter. */
|
||||
+
|
||||
+ using_subcgroup = FLAGS_SET(params->flags, EXEC_CONTROL_CGROUP|EXEC_CGROUP_DELEGATE|EXEC_IS_CONTROL);
|
||||
+ if (using_subcgroup)
|
||||
+ p = strjoin(params->cgroup_path, "/.control");
|
||||
+ else
|
||||
+ p = strdup(params->cgroup_path);
|
||||
+ if (!p)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ *ret = p;
|
||||
+ return using_subcgroup;
|
||||
+}
|
||||
+
|
||||
static int exec_child(
|
||||
Unit *unit,
|
||||
const ExecCommand *command,
|
||||
@@ -3055,10 +3086,18 @@ static int exec_child(
|
||||
}
|
||||
|
||||
if (params->cgroup_path) {
|
||||
- r = cg_attach_everywhere(params->cgroup_supported, params->cgroup_path, 0, NULL, NULL);
|
||||
+ _cleanup_free_ char *p = NULL;
|
||||
+
|
||||
+ r = exec_parameters_get_cgroup_path(params, &p);
|
||||
if (r < 0) {
|
||||
*exit_status = EXIT_CGROUP;
|
||||
- return log_unit_error_errno(unit, r, "Failed to attach to cgroup %s: %m", params->cgroup_path);
|
||||
+ return log_unit_error_errno(unit, r, "Failed to acquire cgroup path: %m");
|
||||
+ }
|
||||
+
|
||||
+ r = cg_attach_everywhere(params->cgroup_supported, p, 0, NULL, NULL);
|
||||
+ if (r < 0) {
|
||||
+ *exit_status = EXIT_CGROUP;
|
||||
+ return log_unit_error_errno(unit, r, "Failed to attach to cgroup %s: %m", p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3659,6 +3698,7 @@ int exec_spawn(Unit *unit,
|
||||
DynamicCreds *dcreds,
|
||||
pid_t *ret) {
|
||||
|
||||
+ _cleanup_free_ char *subcgroup_path = NULL;
|
||||
_cleanup_strv_free_ char **files_env = NULL;
|
||||
int *fds = NULL;
|
||||
size_t n_storage_fds = 0, n_socket_fds = 0;
|
||||
@@ -3716,6 +3756,17 @@ int exec_spawn(Unit *unit,
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit));
|
||||
|
||||
+ if (params->cgroup_path) {
|
||||
+ r = exec_parameters_get_cgroup_path(params, &subcgroup_path);
|
||||
+ if (r < 0)
|
||||
+ return log_unit_error_errno(unit, r, "Failed to acquire subcgroup path: %m");
|
||||
+ if (r > 0) { /* We are using a child cgroup */
|
||||
+ r = cg_create(SYSTEMD_CGROUP_CONTROLLER, subcgroup_path);
|
||||
+ if (r < 0)
|
||||
+ return log_unit_error_errno(unit, r, "Failed to create control group '%s': %m", subcgroup_path);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
return log_unit_error_errno(unit, errno, "Failed to fork: %m");
|
||||
@@ -3754,13 +3805,11 @@ int exec_spawn(Unit *unit,
|
||||
|
||||
log_unit_debug(unit, "Forked %s as "PID_FMT, command->path, pid);
|
||||
|
||||
- /* We add the new process to the cgroup both in the child (so
|
||||
- * that we can be sure that no user code is ever executed
|
||||
- * outside of the cgroup) and in the parent (so that we can be
|
||||
- * sure that when we kill the cgroup the process will be
|
||||
- * killed too). */
|
||||
- if (params->cgroup_path)
|
||||
- (void) cg_attach(SYSTEMD_CGROUP_CONTROLLER, params->cgroup_path, pid);
|
||||
+ /* We add the new process to the cgroup both in the child (so that we can be sure that no user code is ever
|
||||
+ * executed outside of the cgroup) and in the parent (so that we can be sure that when we kill the cgroup the
|
||||
+ * process will be killed too). */
|
||||
+ if (subcgroup_path)
|
||||
+ (void) cg_attach(SYSTEMD_CGROUP_CONTROLLER, subcgroup_path, pid);
|
||||
|
||||
exec_status_start(&command->exec_status, pid);
|
||||
|
||||
diff --git a/src/core/execute.h b/src/core/execute.h
|
||||
index 62c6229621..f5bc180ece 100644
|
||||
--- a/src/core/execute.h
|
||||
+++ b/src/core/execute.h
|
||||
@@ -289,12 +289,13 @@ typedef enum ExecFlags {
|
||||
EXEC_CHOWN_DIRECTORIES = 1 << 5, /* chown() the runtime/state/cache/log directories to the user we run as, under all conditions */
|
||||
EXEC_NSS_BYPASS_BUS = 1 << 6, /* Set the SYSTEMD_NSS_BYPASS_BUS environment variable, to disable nss-systemd for dbus */
|
||||
EXEC_CGROUP_DELEGATE = 1 << 7,
|
||||
+ EXEC_IS_CONTROL = 1 << 8,
|
||||
+ EXEC_CONTROL_CGROUP = 1 << 9, /* Place the process not in the indicated cgroup but in a subcgroup '/.control', but only EXEC_CGROUP_DELEGATE and EXEC_IS_CONTROL is set, too */
|
||||
|
||||
/* The following are not used by execute.c, but by consumers internally */
|
||||
- EXEC_PASS_FDS = 1 << 8,
|
||||
- EXEC_IS_CONTROL = 1 << 9,
|
||||
- EXEC_SETENV_RESULT = 1 << 10,
|
||||
- EXEC_SET_WATCHDOG = 1 << 11,
|
||||
+ EXEC_PASS_FDS = 1 << 10,
|
||||
+ EXEC_SETENV_RESULT = 1 << 11,
|
||||
+ EXEC_SET_WATCHDOG = 1 << 12,
|
||||
} ExecFlags;
|
||||
|
||||
struct ExecParameters {
|
||||
diff --git a/src/core/service.c b/src/core/service.c
|
||||
index e05d0e0514..0423f2c73e 100644
|
||||
--- a/src/core/service.c
|
||||
+++ b/src/core/service.c
|
||||
@@ -1429,7 +1429,7 @@ static int service_spawn(
|
||||
assert(c);
|
||||
assert(_pid);
|
||||
|
||||
- r = unit_prepare_exec(UNIT(s));
|
||||
+ r = unit_prepare_exec(UNIT(s)); /* This realizes the cgroup, among other things */
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -1798,7 +1798,7 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
|
||||
r = service_spawn(s,
|
||||
s->control_command,
|
||||
s->timeout_stop_usec,
|
||||
- EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN|EXEC_IS_CONTROL|EXEC_SETENV_RESULT,
|
||||
+ EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN|EXEC_IS_CONTROL|EXEC_SETENV_RESULT|EXEC_CONTROL_CGROUP,
|
||||
&s->control_pid);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
@@ -1913,7 +1913,7 @@ static void service_enter_stop(Service *s, ServiceResult f) {
|
||||
r = service_spawn(s,
|
||||
s->control_command,
|
||||
s->timeout_stop_usec,
|
||||
- EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL|EXEC_SETENV_RESULT,
|
||||
+ EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL|EXEC_SETENV_RESULT|EXEC_CONTROL_CGROUP,
|
||||
&s->control_pid);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
@@ -1991,7 +1991,7 @@ static void service_enter_start_post(Service *s) {
|
||||
r = service_spawn(s,
|
||||
s->control_command,
|
||||
s->timeout_start_usec,
|
||||
- EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL,
|
||||
+ EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL|EXEC_CONTROL_CGROUP,
|
||||
&s->control_pid);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
@@ -2269,7 +2269,7 @@ static void service_enter_reload(Service *s) {
|
||||
r = service_spawn(s,
|
||||
s->control_command,
|
||||
s->timeout_start_usec,
|
||||
- EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL,
|
||||
+ EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL|EXEC_CONTROL_CGROUP,
|
||||
&s->control_pid);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
@@ -2309,7 +2309,8 @@ static void service_run_next_control(Service *s) {
|
||||
timeout,
|
||||
EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_IS_CONTROL|
|
||||
(IN_SET(s->control_command_id, SERVICE_EXEC_CONDITION, SERVICE_EXEC_START_PRE, SERVICE_EXEC_STOP_POST) ? EXEC_APPLY_TTY_STDIN : 0)|
|
||||
- (IN_SET(s->control_command_id, SERVICE_EXEC_STOP, SERVICE_EXEC_STOP_POST) ? EXEC_SETENV_RESULT : 0),
|
||||
+ (IN_SET(s->control_command_id, SERVICE_EXEC_STOP, SERVICE_EXEC_STOP_POST) ? EXEC_SETENV_RESULT : 0)|
|
||||
+ (IN_SET(s->control_command_id, SERVICE_EXEC_START_POST, SERVICE_EXEC_RELOAD, SERVICE_EXEC_STOP, SERVICE_EXEC_STOP_POST) ? EXEC_CONTROL_CGROUP : 0),
|
||||
&s->control_pid);
|
||||
if (r < 0)
|
||||
goto fail;
|
@ -1,26 +0,0 @@
|
||||
From 0c1f96220f2a42c256a1e22e5f16d2ff8f4144df Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Fri, 16 Nov 2018 20:29:02 +0100
|
||||
Subject: [PATCH] man: link Delegate= documentation up with the markdown docs
|
||||
|
||||
(cherry picked from commit 077c40bc5271dfc8d9cee179fbed27a27e741973)
|
||||
|
||||
Related: #2215925
|
||||
---
|
||||
man/systemd.resource-control.xml | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml
|
||||
index d3bff29169..36a622ebf0 100644
|
||||
--- a/man/systemd.resource-control.xml
|
||||
+++ b/man/systemd.resource-control.xml
|
||||
@@ -808,6 +808,9 @@
|
||||
specific to the unified hierarchy while others are specific to the legacy hierarchy. Also note that the
|
||||
kernel might support further controllers, which aren't covered here yet as delegation is either not supported
|
||||
at all for them or not defined cleanly.</para>
|
||||
+
|
||||
+ <para>For further details on the delegation model consult <ulink
|
||||
+ url="https://systemd.io/CGROUP_DELEGATION">Control Group APIs and Delegation</ulink>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -1,196 +0,0 @@
|
||||
From 1628f48a0ecd13db92b79b7689e74b0ed4cb31a0 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Thu, 14 Sep 2023 13:54:12 +0200
|
||||
Subject: [PATCH] ci: Extend source-git-automation
|
||||
|
||||
* on schedule and on demand workflows
|
||||
* Added Tracker validation for Bugzilla and Jira
|
||||
|
||||
rhel-only
|
||||
|
||||
Resolves: RHEL-1087
|
||||
---
|
||||
.github/tracker-validator.yml | 13 +++
|
||||
.../source-git-automation-on-demand.yml | 99 +++++++++++++++++++
|
||||
.github/workflows/source-git-automation.yml | 29 +++++-
|
||||
3 files changed, 139 insertions(+), 2 deletions(-)
|
||||
create mode 100644 .github/tracker-validator.yml
|
||||
create mode 100644 .github/workflows/source-git-automation-on-demand.yml
|
||||
|
||||
diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml
|
||||
new file mode 100644
|
||||
index 0000000000..10ead63eaa
|
||||
--- /dev/null
|
||||
+++ b/.github/tracker-validator.yml
|
||||
@@ -0,0 +1,13 @@
|
||||
+labels:
|
||||
+ missing-tracker: tracker/missing
|
||||
+ invalid-product: tracker/invalid-product
|
||||
+ invalid-component: tracker/invalid-component
|
||||
+ unapproved: tracker/unapproved
|
||||
+products:
|
||||
+ - CentOS Stream 8
|
||||
+ - rhel-8.2.0
|
||||
+ - rhel-8.4.0
|
||||
+ - rhel-8.6.0
|
||||
+ - rhel-8.8.0
|
||||
+ - rhel-8.9.0
|
||||
+ - rhel-8.10.0
|
||||
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
|
||||
new file mode 100644
|
||||
index 0000000000..92a65c8cc7
|
||||
--- /dev/null
|
||||
+++ b/.github/workflows/source-git-automation-on-demand.yml
|
||||
@@ -0,0 +1,99 @@
|
||||
+---
|
||||
+
|
||||
+name: Source git Automation Scheduled/On Demand
|
||||
+on:
|
||||
+ schedule:
|
||||
+ # Workflow runs every 15 minutes
|
||||
+ - cron: '*/15 * * * *'
|
||||
+ workflow_dispatch:
|
||||
+ inputs:
|
||||
+ pr-number:
|
||||
+ description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs'
|
||||
+ required: true
|
||||
+ default: '0'
|
||||
+
|
||||
+permissions:
|
||||
+ contents: read
|
||||
+
|
||||
+jobs:
|
||||
+ # Get all open PRs
|
||||
+ gather-pull-requests:
|
||||
+ if: github.repository == 'redhat-plumbers/systemd-rhel8'
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ outputs:
|
||||
+ pr-numbers: ${{ steps.get-pr-numbers.outputs.result }}
|
||||
+ pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }}
|
||||
+
|
||||
+ steps:
|
||||
+ - id: get-pr-numbers
|
||||
+ if: inputs.pr-number == '0'
|
||||
+ name: Get all open PRs
|
||||
+ uses: actions/github-script@v6
|
||||
+ with:
|
||||
+ # !FIXME: this is not working if there is more than 100 PRs opened
|
||||
+ script: |
|
||||
+ const { data: pullRequests } = await github.rest.pulls.list({
|
||||
+ owner: context.repo.owner,
|
||||
+ repo: context.repo.repo,
|
||||
+ state: 'open',
|
||||
+ per_page: 100
|
||||
+ });
|
||||
+ return pullRequests.map(pr => pr.number);
|
||||
+
|
||||
+ - id: parse-manual-input
|
||||
+ if: inputs.pr-number != '0'
|
||||
+ name: Parse manual input
|
||||
+ run: |
|
||||
+ echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT
|
||||
+ shell: bash
|
||||
+
|
||||
+ validate-pr:
|
||||
+ name: 'Validation of Pull Request #${{ matrix.pr-number }}'
|
||||
+ needs: [ gather-pull-requests ]
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ strategy:
|
||||
+ fail-fast: false
|
||||
+ matrix:
|
||||
+ pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
|
||||
+
|
||||
+ permissions:
|
||||
+ statuses: write
|
||||
+ checks: write
|
||||
+ pull-requests: write
|
||||
+
|
||||
+ steps:
|
||||
+ - name: Repository checkout
|
||||
+ uses: actions/checkout@v3
|
||||
+
|
||||
+ - id: metadata
|
||||
+ name: Gather Pull Request Metadata
|
||||
+ uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
|
||||
+ with:
|
||||
+ pr-number: ${{ matrix.pr-number }}
|
||||
+
|
||||
+ - id: commit-linter
|
||||
+ name: Lint Commits
|
||||
+ uses: redhat-plumbers-in-action/advanced-commit-linter@v2
|
||||
+ with:
|
||||
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
||||
+
|
||||
+ # Validates tracker, changes tracker status, updates PR title
|
||||
+ - id: tracker-validator
|
||||
+ name: Validate Tracker
|
||||
+ uses: redhat-plumbers-in-action/tracker-validator@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
+ component: systemd
|
||||
+ tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
+ tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
+ bugzilla-instance: https://bugzilla.redhat.com
|
||||
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
+ jira-instance: https://issues.redhat.com
|
||||
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
||||
+
|
||||
+ # TODO: merge PR if all checks passed
|
||||
+ # TODO: add comment to Tracker that PR was merged ...
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
index e653e28a7f..16c6f83d77 100644
|
||||
--- a/.github/workflows/source-git-automation.yml
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -12,7 +12,8 @@ jobs:
|
||||
download-metadata:
|
||||
if: >
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
- github.event.workflow_run.conclusion == 'success'
|
||||
+ github.event.workflow_run.conclusion == 'success' &&
|
||||
+ github.repository == 'redhat-plumbers/systemd-rhel8'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
@@ -33,13 +34,37 @@ jobs:
|
||||
validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
|
||||
|
||||
permissions:
|
||||
+ statuses: write
|
||||
checks: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- id: commit-linter
|
||||
name: Lint Commits
|
||||
- uses: redhat-plumbers-in-action/advanced-commit-linter@v1
|
||||
+ uses: redhat-plumbers-in-action/advanced-commit-linter@v2
|
||||
with:
|
||||
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
+
|
||||
+ # Validates tracker, changes tracker status, updates PR title
|
||||
+ tracker-validation:
|
||||
+ needs: [ download-metadata, commit-linter ]
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ permissions:
|
||||
+ checks: write
|
||||
+ pull-requests: write
|
||||
+
|
||||
+ steps:
|
||||
+ - name: Validate Tracker
|
||||
+ uses: redhat-plumbers-in-action/tracker-validator@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
+ component: systemd
|
||||
+ tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
+ tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
+ bugzilla-instance: https://bugzilla.redhat.com
|
||||
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
+ jira-instance: https://issues.redhat.com
|
||||
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,32 +0,0 @@
|
||||
From 21200fc506b1d15be6ed6d5b9ac70f1ec865f9bc Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Tue, 19 Sep 2023 09:53:35 +0200
|
||||
Subject: [PATCH] ci: add missing configuration for commit linter
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.github/advanced-commit-linter.yml | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml
|
||||
index 0fb74a9dc8..86f0e911f2 100644
|
||||
--- a/.github/advanced-commit-linter.yml
|
||||
+++ b/.github/advanced-commit-linter.yml
|
||||
@@ -11,6 +11,7 @@ policy:
|
||||
- 'Resolves: #?'
|
||||
- 'Related: #?'
|
||||
- 'Reverts: #?'
|
||||
+ type: bugzilla
|
||||
issue-format:
|
||||
- '\d+$'
|
||||
url: 'https://bugzilla.redhat.com/show_bug.cgi?id='
|
||||
@@ -18,6 +19,7 @@ policy:
|
||||
- 'Resolves: '
|
||||
- 'Related: '
|
||||
- 'Reverts: '
|
||||
+ type: jira
|
||||
issue-format:
|
||||
- 'RHEL-\d+$'
|
||||
url: 'https://issues.redhat.com/browse/'
|
@ -1,25 +0,0 @@
|
||||
From ffd775b4b96ce0d772bcbb2fe2fbc62ed06bb4a4 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Tue, 19 Sep 2023 15:17:48 +0200
|
||||
Subject: [PATCH] ci: add `Red Hat Enterprise Linux 8` to the list of supported
|
||||
products
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.github/tracker-validator.yml | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml
|
||||
index 10ead63eaa..500dce3d92 100644
|
||||
--- a/.github/tracker-validator.yml
|
||||
+++ b/.github/tracker-validator.yml
|
||||
@@ -4,6 +4,7 @@ labels:
|
||||
invalid-component: tracker/invalid-component
|
||||
unapproved: tracker/unapproved
|
||||
products:
|
||||
+ - Red Hat Enterprise Linux 8
|
||||
- CentOS Stream 8
|
||||
- rhel-8.2.0
|
||||
- rhel-8.4.0
|
@ -1,95 +0,0 @@
|
||||
From bf728def0c6eebdf8d2b8912232ba7806e109293 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 20 Oct 2023 13:32:22 +0200
|
||||
Subject: [PATCH] ci: enable source-git automation to validate reviews and ci
|
||||
results
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.github/pull-request-validator.yml | 4 ++++
|
||||
.../source-git-automation-on-demand.yml | 14 ++++++++++----
|
||||
.github/workflows/source-git-automation.yml | 18 +++++++++++++++++-
|
||||
3 files changed, 31 insertions(+), 5 deletions(-)
|
||||
create mode 100644 .github/pull-request-validator.yml
|
||||
|
||||
diff --git a/.github/pull-request-validator.yml b/.github/pull-request-validator.yml
|
||||
new file mode 100644
|
||||
index 0000000000..4bb5bbec12
|
||||
--- /dev/null
|
||||
+++ b/.github/pull-request-validator.yml
|
||||
@@ -0,0 +1,4 @@
|
||||
+labels:
|
||||
+ missing-review: pr/needs-review
|
||||
+ changes-requested: pr/changes-requested
|
||||
+ missing-failing-ci: pr/needs-ci
|
||||
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
|
||||
index 92a65c8cc7..e70ba4857a 100644
|
||||
--- a/.github/workflows/source-git-automation-on-demand.yml
|
||||
+++ b/.github/workflows/source-git-automation-on-demand.yml
|
||||
@@ -73,7 +73,8 @@ jobs:
|
||||
with:
|
||||
pr-number: ${{ matrix.pr-number }}
|
||||
|
||||
- - id: commit-linter
|
||||
+ - if: ${{ !cancelled() }}
|
||||
+ id: commit-linter
|
||||
name: Lint Commits
|
||||
uses: redhat-plumbers-in-action/advanced-commit-linter@v2
|
||||
with:
|
||||
@@ -81,7 +82,8 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Validates tracker, changes tracker status, updates PR title
|
||||
- - id: tracker-validator
|
||||
+ - if: ${{ !cancelled() }}
|
||||
+ id: tracker-validator
|
||||
name: Validate Tracker
|
||||
uses: redhat-plumbers-in-action/tracker-validator@v1
|
||||
with:
|
||||
@@ -95,5 +97,9 @@ jobs:
|
||||
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- # TODO: merge PR if all checks passed
|
||||
- # TODO: add comment to Tracker that PR was merged ...
|
||||
+ - if: ${{ !cancelled() }}
|
||||
+ name: Pull Request Validator
|
||||
+ uses: redhat-plumbers-in-action/pull-request-validator@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
index 16c6f83d77..9faaaca099 100644
|
||||
--- a/.github/workflows/source-git-automation.yml
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -47,7 +47,8 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Validates tracker, changes tracker status, updates PR title
|
||||
- tracker-validation:
|
||||
+ tracker-validator:
|
||||
+ if: ${{ !cancelled() }}
|
||||
needs: [ download-metadata, commit-linter ]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -68,3 +69,18 @@ jobs:
|
||||
jira-instance: https://issues.redhat.com
|
||||
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
+
|
||||
+ pull-request-validator:
|
||||
+ needs: [ download-metadata ]
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ permissions:
|
||||
+ checks: write
|
||||
+ pull-requests: write
|
||||
+
|
||||
+ steps:
|
||||
+ - name: Pull Request Validator
|
||||
+ uses: redhat-plumbers-in-action/pull-request-validator@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,52 +0,0 @@
|
||||
From 36266d377ee5e57e24cd3c45f6db2a29919798f3 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 20 Oct 2023 13:33:38 +0200
|
||||
Subject: [PATCH] ci: remove Mergify config - replaced by Pull Request
|
||||
Validator
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.mergify.yml | 32 --------------------------------
|
||||
1 file changed, 32 deletions(-)
|
||||
delete mode 100644 .mergify.yml
|
||||
|
||||
diff --git a/.mergify.yml b/.mergify.yml
|
||||
deleted file mode 100644
|
||||
index 624eb7291d..0000000000
|
||||
--- a/.mergify.yml
|
||||
+++ /dev/null
|
||||
@@ -1,32 +0,0 @@
|
||||
-# doc: https://docs.mergify.com
|
||||
----
|
||||
-
|
||||
-pull_request_rules:
|
||||
- - name: Add `needs-ci` label on CI fail
|
||||
- conditions:
|
||||
- - label!=ci-waived
|
||||
- - or:
|
||||
- # Unit tests
|
||||
- - -check-success=build (stream8, GCC)
|
||||
- - -check-success=build (stream8, GCC_ASAN)
|
||||
- # CentOS Stream CI
|
||||
- - -check-success=CentOS CI (CentOS Stream 8)
|
||||
- actions:
|
||||
- label:
|
||||
- add:
|
||||
- - needs-ci
|
||||
-
|
||||
- - name: Remove `needs-ci` label on CI success
|
||||
- conditions:
|
||||
- - or:
|
||||
- - label=ci-waived
|
||||
- - and:
|
||||
- # Unit tests
|
||||
- - check-success=build (stream8, GCC)
|
||||
- - check-success=build (stream8, GCC_ASAN)
|
||||
- # CentOS Stream CI
|
||||
- - check-success=CentOS CI (CentOS Stream 8)
|
||||
- actions:
|
||||
- label:
|
||||
- remove:
|
||||
- - needs-ci
|
@ -1,84 +0,0 @@
|
||||
From 73b327eeeb3e2f17cbc1abd19aa5b87c28fcf509 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 3 Nov 2023 14:07:04 +0100
|
||||
Subject: [PATCH] ci: enable auto-merge GH Action
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.github/auto-merge.yml | 4 ++++
|
||||
.../source-git-automation-on-demand.yml | 14 ++++++++++++
|
||||
.github/workflows/source-git-automation.yml | 22 +++++++++++++++++++
|
||||
3 files changed, 40 insertions(+)
|
||||
create mode 100644 .github/auto-merge.yml
|
||||
|
||||
diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml
|
||||
new file mode 100644
|
||||
index 0000000000..35c2539295
|
||||
--- /dev/null
|
||||
+++ b/.github/auto-merge.yml
|
||||
@@ -0,0 +1,4 @@
|
||||
+labels:
|
||||
+ dont-merge: dont-merge
|
||||
+ manual-merge: pr/needs-manual-merge
|
||||
+target-branch': ['main']
|
||||
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
|
||||
index e70ba4857a..948708916d 100644
|
||||
--- a/.github/workflows/source-git-automation-on-demand.yml
|
||||
+++ b/.github/workflows/source-git-automation-on-demand.yml
|
||||
@@ -59,6 +59,7 @@ jobs:
|
||||
pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
|
||||
|
||||
permissions:
|
||||
+ contents: write
|
||||
statuses: write
|
||||
checks: write
|
||||
pull-requests: write
|
||||
@@ -103,3 +104,16 @@ jobs:
|
||||
with:
|
||||
pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
+
|
||||
+ - id: auto-merge
|
||||
+ name: Auto Merge
|
||||
+ uses: redhat-plumbers-in-action/auto-merge@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
+ tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
+ tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
+ bugzilla-instance: https://bugzilla.redhat.com
|
||||
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
+ jira-instance: https://issues.redhat.com
|
||||
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
index 9faaaca099..95819baa8b 100644
|
||||
--- a/.github/workflows/source-git-automation.yml
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -84,3 +84,25 @@ jobs:
|
||||
with:
|
||||
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
+
|
||||
+ auto-merge:
|
||||
+ needs: [ download-metadata, commit-linter, tracker-validator, pull-request-validator ]
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ permissions:
|
||||
+ contents: write
|
||||
+ checks: write
|
||||
+ pull-requests: write
|
||||
+
|
||||
+ steps:
|
||||
+ - name: Auto Merge
|
||||
+ uses: redhat-plumbers-in-action/auto-merge@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
+ tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
+ tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
+ bugzilla-instance: https://bugzilla.redhat.com
|
||||
+ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
+ jira-instance: https://issues.redhat.com
|
||||
+ jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,179 +0,0 @@
|
||||
From d0f59d4190a9f1e0e6db4b22b5e87bec2db4f7fb Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <fsumsal@redhat.com>
|
||||
Date: Mon, 27 Nov 2023 15:20:47 +0100
|
||||
Subject: [PATCH] fstab-generator: allow overriding /etc/fstab with
|
||||
$SYSTEMD_FSTAB
|
||||
|
||||
Based on: ed4ad4889723a9acdf75ed86f10cee0024bbbcbc
|
||||
Related: RHEL-1087
|
||||
|
||||
rhel-only
|
||||
---
|
||||
src/cryptsetup/cryptsetup.c | 3 ++-
|
||||
src/fstab-generator/fstab-generator.c | 28 ++++++++++++++-------------
|
||||
src/remount-fs/remount-fs.c | 5 +++--
|
||||
src/shared/fstab-util.c | 4 ++--
|
||||
src/shared/fstab-util.h | 4 ++++
|
||||
5 files changed, 26 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
|
||||
index 11162eb722..de4bc9579c 100644
|
||||
--- a/src/cryptsetup/cryptsetup.c
|
||||
+++ b/src/cryptsetup/cryptsetup.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "device-util.h"
|
||||
#include "escape.h"
|
||||
#include "fileio.h"
|
||||
+#include "fstab-util.h"
|
||||
#include "log.h"
|
||||
#include "mount-util.h"
|
||||
#include "parse-util.h"
|
||||
@@ -318,7 +319,7 @@ static char *disk_mount_point(const char *label) {
|
||||
if (asprintf(&device, "/dev/mapper/%s", label) < 0)
|
||||
return NULL;
|
||||
|
||||
- f = setmntent("/etc/fstab", "re");
|
||||
+ f = setmntent(fstab_path(), "re");
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
|
||||
index f24c1d29da..105ddd2fd0 100644
|
||||
--- a/src/fstab-generator/fstab-generator.c
|
||||
+++ b/src/fstab-generator/fstab-generator.c
|
||||
@@ -105,15 +105,17 @@ static int add_swap(
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to generate unit name: %m");
|
||||
|
||||
- r = generator_open_unit_file(arg_dest, "/etc/fstab", name, &f);
|
||||
+ r = generator_open_unit_file(arg_dest, fstab_path(), name, &f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- fputs("# Automatically generated by systemd-fstab-generator\n\n"
|
||||
- "[Unit]\n"
|
||||
- "SourcePath=/etc/fstab\n"
|
||||
- "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
|
||||
- "[Swap]\n", f);
|
||||
+ fprintf(f,
|
||||
+ "# Automatically generated by systemd-fstab-generator\n\n"
|
||||
+ "[Unit]\n"
|
||||
+ "SourcePath=%s\n"
|
||||
+ "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
|
||||
+ "[Swap]\n",
|
||||
+ fstab_path());
|
||||
|
||||
r = write_what(f, what);
|
||||
if (r < 0)
|
||||
@@ -334,7 +336,7 @@ static int add_mount(
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to generate unit name: %m");
|
||||
|
||||
- r = generator_open_unit_file(dest, "/etc/fstab", name, &f);
|
||||
+ r = generator_open_unit_file(dest, fstab_path(), name, &f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -451,7 +453,7 @@ static int add_mount(
|
||||
|
||||
fclose(f);
|
||||
|
||||
- r = generator_open_unit_file(dest, "/etc/fstab", automount_name, &f);
|
||||
+ r = generator_open_unit_file(dest, fstab_path(), automount_name, &f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -503,17 +505,17 @@ static int add_mount(
|
||||
|
||||
static int parse_fstab(bool initrd) {
|
||||
_cleanup_endmntent_ FILE *f = NULL;
|
||||
- const char *fstab_path;
|
||||
+ const char *fstab;
|
||||
struct mntent *me;
|
||||
int r = 0;
|
||||
|
||||
- fstab_path = initrd ? "/sysroot/etc/fstab" : "/etc/fstab";
|
||||
- f = setmntent(fstab_path, "re");
|
||||
+ fstab = initrd ? "/sysroot/etc/fstab" : fstab_path();
|
||||
+ f = setmntent(fstab, "re");
|
||||
if (!f) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
|
||||
- return log_error_errno(errno, "Failed to open %s: %m", fstab_path);
|
||||
+ return log_error_errno(errno, "Failed to open %s: %m", fstab);
|
||||
}
|
||||
|
||||
while ((me = getmntent(f))) {
|
||||
@@ -592,7 +594,7 @@ static int parse_fstab(bool initrd) {
|
||||
me->mnt_passno,
|
||||
makefs*MAKEFS | growfs*GROWFS | noauto*NOAUTO | nofail*NOFAIL | automount*AUTOMOUNT,
|
||||
post,
|
||||
- fstab_path);
|
||||
+ fstab);
|
||||
}
|
||||
|
||||
if (r >= 0 && k < 0)
|
||||
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
|
||||
index 9220a00215..5bcee999cc 100644
|
||||
--- a/src/remount-fs/remount-fs.c
|
||||
+++ b/src/remount-fs/remount-fs.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "exit-status.h"
|
||||
+#include "fstab-util.h"
|
||||
#include "log.h"
|
||||
#include "mount-setup.h"
|
||||
#include "mount-util.h"
|
||||
@@ -39,14 +40,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
umask(0022);
|
||||
|
||||
- f = setmntent("/etc/fstab", "re");
|
||||
+ f = setmntent(fstab_path(), "re");
|
||||
if (!f) {
|
||||
if (errno == ENOENT) {
|
||||
r = 0;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
- r = log_error_errno(errno, "Failed to open /etc/fstab: %m");
|
||||
+ r = log_error_errno(errno, "Failed to open %s: %m", fstab_path());
|
||||
goto finish;
|
||||
}
|
||||
|
||||
diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c
|
||||
index 6fd9866c00..bc0c047509 100644
|
||||
--- a/src/shared/fstab-util.c
|
||||
+++ b/src/shared/fstab-util.c
|
||||
@@ -21,7 +21,7 @@ int fstab_has_fstype(const char *fstype) {
|
||||
_cleanup_endmntent_ FILE *f = NULL;
|
||||
struct mntent *m;
|
||||
|
||||
- f = setmntent("/etc/fstab", "re");
|
||||
+ f = setmntent(fstab_path(), "re");
|
||||
if (!f)
|
||||
return errno == ENOENT ? false : -errno;
|
||||
|
||||
@@ -41,7 +41,7 @@ int fstab_is_mount_point(const char *mount) {
|
||||
_cleanup_endmntent_ FILE *f = NULL;
|
||||
struct mntent *m;
|
||||
|
||||
- f = setmntent("/etc/fstab", "re");
|
||||
+ f = setmntent(fstab_path(), "re");
|
||||
if (!f)
|
||||
return errno == ENOENT ? false : -errno;
|
||||
|
||||
diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h
|
||||
index 9820f78ca8..9ec6db068c 100644
|
||||
--- a/src/shared/fstab-util.h
|
||||
+++ b/src/shared/fstab-util.h
|
||||
@@ -33,3 +33,7 @@ static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no
|
||||
}
|
||||
|
||||
char *fstab_node_to_udev_node(const char *p);
|
||||
+
|
||||
+static inline const char *fstab_path(void) {
|
||||
+ return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab";
|
||||
+}
|
@ -1,37 +0,0 @@
|
||||
From f4a9bdf74c23a55ea96de696155ce9a5dfa43850 Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <fsumsal@redhat.com>
|
||||
Date: Mon, 27 Nov 2023 16:16:40 +0100
|
||||
Subject: [PATCH] fstab-generator: allow overriding path to /sysroot/etc/fstab
|
||||
too
|
||||
|
||||
Based on: 99e3d4767932bce5febb45e8543162d729d17425
|
||||
Related: RHEL-1087
|
||||
|
||||
rhel-only
|
||||
---
|
||||
src/fstab-generator/fstab-generator.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
|
||||
index 105ddd2fd0..02f0bccd2f 100644
|
||||
--- a/src/fstab-generator/fstab-generator.c
|
||||
+++ b/src/fstab-generator/fstab-generator.c
|
||||
@@ -503,13 +503,17 @@ static int add_mount(
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static const char *sysroot_fstab_path(void) {
|
||||
+ return getenv("SYSTEMD_SYSROOT_FSTAB") ?: "/sysroot/etc/fstab";
|
||||
+}
|
||||
+
|
||||
static int parse_fstab(bool initrd) {
|
||||
_cleanup_endmntent_ FILE *f = NULL;
|
||||
const char *fstab;
|
||||
struct mntent *me;
|
||||
int r = 0;
|
||||
|
||||
- fstab = initrd ? "/sysroot/etc/fstab" : fstab_path();
|
||||
+ fstab = initrd ? sysroot_fstab_path() : fstab_path();
|
||||
f = setmntent(fstab, "re");
|
||||
if (!f) {
|
||||
if (errno == ENOENT)
|
@ -1,611 +0,0 @@
|
||||
From 52026032996f021963f5af8d625a5b9653d3f815 Mon Sep 17 00:00:00 2001
|
||||
From: Frantisek Sumsal <fsumsal@redhat.com>
|
||||
Date: Mon, 27 Nov 2023 14:54:15 +0100
|
||||
Subject: [PATCH] test: backport TEST-81-GENERATORS (fstab-generator only)
|
||||
|
||||
Some fstab-generator features are not present on RHEL 8 or they behave
|
||||
differently - in such case there's an inline comment explaining what's
|
||||
different with a reference to an upstream commit that introduced the
|
||||
changed behavior.
|
||||
|
||||
Related: RHEL-1087
|
||||
|
||||
rhel-only
|
||||
---
|
||||
test/TEST-81-GENERATORS/Makefile | 1 +
|
||||
test/TEST-81-GENERATORS/generator-utils.sh | 78 ++++
|
||||
test/TEST-81-GENERATORS/test.sh | 50 +++
|
||||
.../testsuite.fstab-generator.sh | 397 ++++++++++++++++++
|
||||
test/TEST-81-GENERATORS/testsuite.sh | 14 +
|
||||
test/test-functions | 2 +-
|
||||
6 files changed, 541 insertions(+), 1 deletion(-)
|
||||
create mode 120000 test/TEST-81-GENERATORS/Makefile
|
||||
create mode 100755 test/TEST-81-GENERATORS/generator-utils.sh
|
||||
create mode 100755 test/TEST-81-GENERATORS/test.sh
|
||||
create mode 100755 test/TEST-81-GENERATORS/testsuite.fstab-generator.sh
|
||||
create mode 100755 test/TEST-81-GENERATORS/testsuite.sh
|
||||
|
||||
diff --git a/test/TEST-81-GENERATORS/Makefile b/test/TEST-81-GENERATORS/Makefile
|
||||
new file mode 120000
|
||||
index 0000000000..e9f93b1104
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-81-GENERATORS/Makefile
|
||||
@@ -0,0 +1 @@
|
||||
+../TEST-01-BASIC/Makefile
|
||||
\ No newline at end of file
|
||||
diff --git a/test/TEST-81-GENERATORS/generator-utils.sh b/test/TEST-81-GENERATORS/generator-utils.sh
|
||||
new file mode 100755
|
||||
index 0000000000..fb62747fa1
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-81-GENERATORS/generator-utils.sh
|
||||
@@ -0,0 +1,78 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+
|
||||
+link_endswith() {
|
||||
+ [[ -h "${1:?}" && "$(readlink "${1:?}")" =~ ${2:?}$ ]]
|
||||
+}
|
||||
+
|
||||
+link_eq() {
|
||||
+ [[ -h "${1:?}" && "$(readlink "${1:?}")" == "${2:?}" ]]
|
||||
+}
|
||||
+
|
||||
+# Get the value from a 'key=value' assignment
|
||||
+opt_get_arg() {
|
||||
+ local arg
|
||||
+
|
||||
+ IFS="=" read -r _ arg <<< "${1:?}"
|
||||
+ test -n "$arg"
|
||||
+ echo "$arg"
|
||||
+}
|
||||
+
|
||||
+in_initrd() {
|
||||
+ [[ "${SYSTEMD_IN_INITRD:-0}" -ne 0 ]]
|
||||
+}
|
||||
+
|
||||
+# Check if we're parsing host's fstab in initrd
|
||||
+in_initrd_host() {
|
||||
+ in_initrd && [[ "${SYSTEMD_SYSROOT_FSTAB:-/dev/null}" != /dev/null ]]
|
||||
+}
|
||||
+
|
||||
+in_container() {
|
||||
+ systemd-detect-virt -qc
|
||||
+}
|
||||
+
|
||||
+opt_filter() (
|
||||
+ set +x
|
||||
+ local opt split_options filtered_options
|
||||
+
|
||||
+ IFS="," read -ra split_options <<< "${1:?}"
|
||||
+ for opt in "${split_options[@]}"; do
|
||||
+ if [[ "$opt" =~ ${2:?} ]]; then
|
||||
+ continue
|
||||
+ fi
|
||||
+
|
||||
+ filtered_options+=("$opt")
|
||||
+ done
|
||||
+
|
||||
+ IFS=","; printf "%s" "${filtered_options[*]}"
|
||||
+)
|
||||
+
|
||||
+# Run the given generator $1 with target directory $2 - clean the target
|
||||
+# directory beforehand
|
||||
+run_and_list() {
|
||||
+ local generator="${1:?}"
|
||||
+ local out_dir="${2:?}"
|
||||
+ local environ
|
||||
+
|
||||
+ # If $PID1_ENVIRON is set temporarily overmount /proc/1/environ with
|
||||
+ # a temporary file that contains contents of $PID1_ENVIRON. This is
|
||||
+ # necessary in cases where the generator reads the environment through
|
||||
+ # getenv_for_pid(1, ...) or similar like getty-generator does.
|
||||
+ #
|
||||
+ # Note: $PID1_ENVIRON should be a NUL separated list of env assignments
|
||||
+ if [[ -n "${PID1_ENVIRON:-}" ]]; then
|
||||
+ environ="$(mktemp)"
|
||||
+ echo -ne "${PID1_ENVIRON}\0" >"${environ:?}"
|
||||
+ mount -v --bind "$environ" /proc/1/environ
|
||||
+ fi
|
||||
+
|
||||
+ rm -fr "${out_dir:?}"/*
|
||||
+ mkdir -p "$out_dir"/{normal,early,late}
|
||||
+ SYSTEMD_LOG_LEVEL="${SYSTEMD_LOG_LEVEL:-debug}" "$generator" "$out_dir/normal" "$out_dir/early" "$out_dir/late"
|
||||
+ ls -lR "$out_dir"
|
||||
+
|
||||
+ if [[ -n "${environ:-}" ]]; then
|
||||
+ umount /proc/1/environ
|
||||
+ rm -f "$environ"
|
||||
+ fi
|
||||
+}
|
||||
diff --git a/test/TEST-81-GENERATORS/test.sh b/test/TEST-81-GENERATORS/test.sh
|
||||
new file mode 100755
|
||||
index 0000000000..ec9c608c60
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-81-GENERATORS/test.sh
|
||||
@@ -0,0 +1,50 @@
|
||||
+#!/usr/bin/env bash
|
||||
+set -e
|
||||
+TEST_DESCRIPTION="Test systemd generators"
|
||||
+
|
||||
+# shellcheck source=test/test-functions
|
||||
+. "$TEST_BASE_DIR/test-functions"
|
||||
+
|
||||
+test_setup() {
|
||||
+ create_empty_image
|
||||
+ mkdir -p "${TESTDIR:?}/root"
|
||||
+ mount "${LOOPDEV:?}p1" "$TESTDIR/root"
|
||||
+
|
||||
+ (
|
||||
+ LOG_LEVEL=5
|
||||
+ # shellcheck disable=SC2046
|
||||
+ eval $(udevadm info --export --query=env --name="${LOOPDEV}p2")
|
||||
+
|
||||
+ setup_basic_environment
|
||||
+
|
||||
+ # mask some services that we do not want to run in these tests
|
||||
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-hwdb-update.service"
|
||||
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-journal-catalog-update.service"
|
||||
+ 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"
|
||||
+ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-machined.service"
|
||||
+
|
||||
+ # 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
|
||||
+StandardOutput=tty
|
||||
+StandardError=tty
|
||||
+NotifyAccess=all
|
||||
+EOF
|
||||
+ cp generator-utils.sh testsuite*.sh "$initdir/"
|
||||
+
|
||||
+ setup_testsuite
|
||||
+ ) || return 1
|
||||
+ setup_nspawn_root
|
||||
+
|
||||
+ ddebug "umount $TESTDIR/root"
|
||||
+ umount "$TESTDIR/root"
|
||||
+}
|
||||
+
|
||||
+do_test "$@"
|
||||
diff --git a/test/TEST-81-GENERATORS/testsuite.fstab-generator.sh b/test/TEST-81-GENERATORS/testsuite.fstab-generator.sh
|
||||
new file mode 100755
|
||||
index 0000000000..705fd5e5c7
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-81-GENERATORS/testsuite.fstab-generator.sh
|
||||
@@ -0,0 +1,397 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+# shellcheck disable=SC2235,SC2233
|
||||
+set -eux
|
||||
+set -o pipefail
|
||||
+
|
||||
+# shellcheck source=test/TEST-81-GENERATORS/generator-utils.sh
|
||||
+. "$(dirname "$0")/generator-utils.sh"
|
||||
+
|
||||
+GENERATOR_BIN="/usr/lib/systemd/system-generators/systemd-fstab-generator"
|
||||
+NETWORK_FS_RX="^(afs|ceph|cifs|gfs|gfs2|ncp|ncpfs|nfs|nfs4|ocfs2|orangefs|pvfs2|smb3|smbfs|davfs|glusterfs|lustre|sshfs)$"
|
||||
+OUT_DIR="$(mktemp -d /tmp/fstab-generator.XXX)"
|
||||
+FSTAB="$(mktemp)"
|
||||
+
|
||||
+at_exit() {
|
||||
+ rm -fr "${OUT_DIR:?}" "${FSTAB:?}"
|
||||
+}
|
||||
+
|
||||
+trap at_exit EXIT
|
||||
+
|
||||
+test -x "${GENERATOR_BIN:?}"
|
||||
+
|
||||
+FSTAB_GENERAL=(
|
||||
+ # Valid entries
|
||||
+ "/dev/test2 /nofail ext4 nofail 0 0"
|
||||
+ "/dev/test3 /regular btrfs defaults 0 0"
|
||||
+ "/dev/test4 /x-systemd.requires xfs x-systemd.requires=foo.service 0 0"
|
||||
+ "/dev/test5 /x-systemd.before-after xfs x-systemd.before=foo.service,x-systemd.after=bar.mount 0 0"
|
||||
+# Not supported on RHEL 8
|
||||
+# "/dev/test6 /x-systemd.wanted-required-by xfs x-systemd.wanted-by=foo.service,x-systemd.required-by=bar.device 0 0"
|
||||
+ "/dev/test7 /x-systemd.requires-mounts-for xfs x-systemd.requires-mounts-for=/foo/bar/baz 0 0"
|
||||
+ "/dev/test8 /x-systemd.automount-idle-timeout vfat x-systemd.automount,x-systemd.idle-timeout=50s 0 0"
|
||||
+ "/dev/test9 /x-systemd.makefs xfs x-systemd.makefs 0 0"
|
||||
+ "/dev/test10 /x-systemd.growfs xfs x-systemd.growfs 0 0"
|
||||
+ "/dev/test11 /_netdev ext4 defaults,_netdev 0 0"
|
||||
+# Not supported on RHEL 8
|
||||
+# "/dev/test12 /_rwonly ext4 x-systemd.rw-only 0 0"
|
||||
+ "/dev/test13 /chaos1 zfs x-systemd.requires=hello.service,x-systemd.after=my.device 0 0"
|
||||
+ "/dev/test14 /chaos2 zfs x-systemd.growfs,x-systemd.makefs 0 0"
|
||||
+ "/dev/test15 /fstype/auto auto defaults 0 0"
|
||||
+ "/dev/test16 /fsck/me ext4 defaults 0 1"
|
||||
+ "/dev/test17 /also/fsck/me ext4 defaults,x-systemd.requires-mounts-for=/var/lib/foo 0 99"
|
||||
+ "/dev/test18 /swap swap defaults 0 0"
|
||||
+ "/dev/test19 /swap/makefs swap defaults,x-systemd.makefs 0 0"
|
||||
+ "/dev/test20 /var xfs defaults,x-systemd.device-timeout=1h 0 0"
|
||||
+ "/dev/test21 /usr ext4 defaults 0 1"
|
||||
+ "/dev/test22 /initrd/mount ext2 defaults,x-initrd.mount 0 1"
|
||||
+ "/dev/test23 /initrd/mount/nofail ext3 defaults,nofail,x-initrd.mount 0 1"
|
||||
+ "/dev/test24 /initrd/mount/deps ext4 x-initrd.mount,x-systemd.before=early.service,x-systemd.after=late.service 0 1"
|
||||
+
|
||||
+ # Incomplete, but valid entries
|
||||
+ "/dev/incomplete1 /incomplete1"
|
||||
+ "/dev/incomplete2 /incomplete2 ext4"
|
||||
+ "/dev/incomplete3 /incomplete3 ext4 defaults"
|
||||
+ "/dev/incomplete4 /incomplete4 ext4 defaults 0"
|
||||
+
|
||||
+ # Remote filesystems
|
||||
+ "/dev/remote1 /nfs nfs bg 0 0"
|
||||
+ "/dev/remote2 /nfs4 nfs4 bg 0 0"
|
||||
+ "bar.tld:/store /remote/storage nfs ro,x-systemd.after=store.service 0 0"
|
||||
+ "user@host.tld:/remote/dir /remote/top-secret sshfs rw,x-systemd.before=naughty.service 0 0"
|
||||
+ "foo.tld:/hello /hello/world ceph defaults 0 0"
|
||||
+ "//192.168.0.1/storage /cifs-storage cifs automount,nofail 0 0"
|
||||
+)
|
||||
+
|
||||
+FSTAB_GENERAL_ROOT=(
|
||||
+ # rootfs with bunch of options we should ignore and fsck enabled
|
||||
+ "/dev/test1 / ext4 noauto,nofail,x-systemd.automount,x-systemd.wanted-by=foo,x-systemd.required-by=bar 0 1"
|
||||
+ "${FSTAB_GENERAL[@]}"
|
||||
+)
|
||||
+
|
||||
+FSTAB_MINIMAL=(
|
||||
+ "/dev/loop1 /foo/bar ext3 defaults 0 0"
|
||||
+)
|
||||
+
|
||||
+FSTAB_DUPLICATE=(
|
||||
+ "/dev/dup1 / ext4 defaults 0 1"
|
||||
+ "/dev/dup2 / ext4 defaults,x-systemd.requires=foo.mount 0 2"
|
||||
+)
|
||||
+
|
||||
+FSTAB_INVALID=(
|
||||
+ # Ignored entries
|
||||
+ "/dev/ignored1 /sys/fs/cgroup/foo ext4 defaults 0 0"
|
||||
+ "/dev/ignored2 /sys/fs/selinux ext4 defaults 0 0"
|
||||
+ "/dev/ignored3 /dev/console ext4 defaults 0 0"
|
||||
+ "/dev/ignored4 /proc/kmsg ext4 defaults 0 0"
|
||||
+ "/dev/ignored5 /proc/sys ext4 defaults 0 0"
|
||||
+# Not ignored on RHEL 8, see 6f997852c8830ca073c55241b0068ebbf1f94a72
|
||||
+# "/dev/ignored6 /proc/sys/kernel/random/boot_id ext4 defaults 0 0"
|
||||
+# "/dev/ignored7 /run/host ext4 defaults 0 0"
|
||||
+# "/dev/ignored8 /run/host/foo ext4 defaults 0 0"
|
||||
+ "/dev/ignored9 /autofs autofs defaults 0 0"
|
||||
+ "/dev/invalid1 not-a-path ext4 defaults 0 0"
|
||||
+ ""
|
||||
+ "/dev/invalid1"
|
||||
+ " "
|
||||
+ "\\"
|
||||
+ "$"
|
||||
+)
|
||||
+
|
||||
+check_fstab_mount_units() {
|
||||
+ local what where fstype opts passno unit
|
||||
+ local item opt split_options filtered_options supp service device arg
|
||||
+ local array_name="${1:?}"
|
||||
+ local out_dir="${2:?}/normal"
|
||||
+ # Get a reference to the array from its name
|
||||
+ local -n fstab_entries="$array_name"
|
||||
+
|
||||
+ # Running the checks in a container is pretty much useless, since we don't
|
||||
+ # generate any mounts, but don't skip the whole test to test the "skip"
|
||||
+ # paths as well
|
||||
+ in_container && return 0
|
||||
+
|
||||
+ for item in "${fstab_entries[@]}"; do
|
||||
+ # Don't use a pipe here, as it would make the variables out of scope
|
||||
+ read -r what where fstype opts _ passno <<< "$item"
|
||||
+
|
||||
+ # Skip non-initrd mounts in initrd
|
||||
+ if in_initrd_host && ! [[ "$opts" =~ x-initrd.mount ]]; then
|
||||
+ continue
|
||||
+ fi
|
||||
+
|
||||
+ if [[ "$fstype" == swap ]]; then
|
||||
+ unit="$(systemd-escape --suffix=swap --path "${what:?}")"
|
||||
+ cat "$out_dir/$unit"
|
||||
+
|
||||
+ grep -qE "^What=$what$" "$out_dir/$unit"
|
||||
+ if [[ "$opts" != defaults ]]; then
|
||||
+ grep -qE "^Options=$opts$" "$out_dir/$unit"
|
||||
+ fi
|
||||
+
|
||||
+ if [[ "$opts" =~ x-systemd.makefs ]]; then
|
||||
+ service="$(systemd-escape --template=systemd-mkswap@.service --path "$what")"
|
||||
+ test -e "$out_dir/$service"
|
||||
+ fi
|
||||
+
|
||||
+ continue
|
||||
+ fi
|
||||
+
|
||||
+ # If we're parsing host's fstab in initrd, prefix all mount targets
|
||||
+ # with /sysroot
|
||||
+ in_initrd_host && where="/sysroot${where:?}"
|
||||
+ unit="$(systemd-escape --suffix=mount --path "${where:?}")"
|
||||
+ cat "$out_dir/$unit"
|
||||
+
|
||||
+ # Check the general stuff
|
||||
+ grep -qE "^What=$what$" "$out_dir/$unit"
|
||||
+ grep -qE "^Where=$where$" "$out_dir/$unit"
|
||||
+ if [[ -n "$fstype" ]] && [[ "$fstype" != auto ]]; then
|
||||
+ grep -qE "^Type=$fstype$" "$out_dir/$unit"
|
||||
+ fi
|
||||
+ if [[ -n "$opts" ]] && [[ "$opts" != defaults ]]; then
|
||||
+ # Some options are not propagated to the generated unit
|
||||
+ if [[ "$where" == / ]]; then
|
||||
+ filtered_options="$(opt_filter "$opts" "(noauto|nofail|x-systemd.(wanted-by=|required-by=|automount|device-timeout=))")"
|
||||
+ else
|
||||
+ filtered_options="$(opt_filter "$opts" "^x-systemd.device-timeout=")"
|
||||
+ fi
|
||||
+
|
||||
+ if [[ "${filtered_options[*]}" != defaults ]]; then
|
||||
+ grep -qE "^Options=.*$filtered_options.*$" "$out_dir/$unit"
|
||||
+ fi
|
||||
+ fi
|
||||
+
|
||||
+ if ! [[ "$opts" =~ (noauto|x-systemd.(wanted-by=|required-by=|automount)) ]]; then
|
||||
+ # We don't create the Requires=/Wants= symlinks for noauto/automount mounts
|
||||
+ # and for mounts that use x-systemd.wanted-by=/required-by=
|
||||
+ if in_initrd_host; then
|
||||
+ if [[ "$where" == / ]] || ! [[ "$opts" =~ nofail ]]; then
|
||||
+ link_eq "$out_dir/initrd-fs.target.requires/$unit" "../$unit"
|
||||
+ else
|
||||
+ link_eq "$out_dir/initrd-fs.target.wants/$unit" "../$unit"
|
||||
+ fi
|
||||
+ elif [[ "$fstype" =~ $NETWORK_FS_RX || "$opts" =~ _netdev ]]; then
|
||||
+ # Units with network filesystems should have a Requires= dependency
|
||||
+ # on the remote-fs.target, unless they use nofail or are an nfs "bg"
|
||||
+ # mounts, in which case the dependency is downgraded to Wants=
|
||||
+ if [[ "$opts" =~ nofail ]] || [[ "$fstype" =~ ^(nfs|nfs4) && "$opts" =~ bg ]]; then
|
||||
+ link_eq "$out_dir/remote-fs.target.wants/$unit" "../$unit"
|
||||
+ else
|
||||
+ link_eq "$out_dir/remote-fs.target.requires/$unit" "../$unit"
|
||||
+ fi
|
||||
+ else
|
||||
+ # Similarly, local filesystems should have a Requires= dependency on
|
||||
+ # the local-fs.target, unless they use nofail, in which case the
|
||||
+ # dependency is downgraded to Wants=. Rootfs is a special case,
|
||||
+ # since we always ignore nofail there
|
||||
+ if [[ "$where" == / ]] || ! [[ "$opts" =~ nofail ]]; then
|
||||
+ link_eq "$out_dir/local-fs.target.requires/$unit" "../$unit"
|
||||
+ else
|
||||
+ link_eq "$out_dir/local-fs.target.wants/$unit" "../$unit"
|
||||
+ fi
|
||||
+ fi
|
||||
+ fi
|
||||
+
|
||||
+ if [[ "${passno:=0}" -ne 0 ]]; then
|
||||
+ # Generate systemd-fsck@.service dependencies, if applicable
|
||||
+ if in_initrd && [[ "$where" == / || "$where" == /usr ]]; then
|
||||
+ continue
|
||||
+ fi
|
||||
+
|
||||
+ if [[ "$where" == / ]]; then
|
||||
+ link_endswith "$out_dir/local-fs.target.wants/systemd-fsck-root.service" "/lib/systemd/system/systemd-fsck-root.service"
|
||||
+ else
|
||||
+ service="$(systemd-escape --template=systemd-fsck@.service --path "$what")"
|
||||
+ grep -qE "^After=$service$" "$out_dir/$unit"
|
||||
+ # On RHEL 8 this is always a Requires= dependency, even when the target
|
||||
+ # is /usr, see afacf3fc8af0090620383228c6c84345ad63b6f8
|
||||
+ grep -qE "^Requires=$service$" "$out_dir/$unit"
|
||||
+ fi
|
||||
+ fi
|
||||
+
|
||||
+ # Check various x-systemd options
|
||||
+ #
|
||||
+ # First, split them into an array to make splitting them even further
|
||||
+ # easier
|
||||
+ IFS="," read -ra split_options <<< "$opts"
|
||||
+ # and process them one by one.
|
||||
+ #
|
||||
+ # Note: the "machinery" below might (and probably does) miss some
|
||||
+ # combinations of supported options, so tread carefully
|
||||
+ for opt in "${split_options[@]}"; do
|
||||
+ if [[ "$opt" =~ ^x-systemd.requires= ]]; then
|
||||
+ service="$(opt_get_arg "$opt")"
|
||||
+ grep -qE "^Requires=$service$" "$out_dir/$unit"
|
||||
+ grep -qE "^After=$service$" "$out_dir/$unit"
|
||||
+ elif [[ "$opt" =~ ^x-systemd.before= ]]; then
|
||||
+ service="$(opt_get_arg "$opt")"
|
||||
+ grep -qE "^Before=$service$" "$out_dir/$unit"
|
||||
+ elif [[ "$opt" =~ ^x-systemd.after= ]]; then
|
||||
+ service="$(opt_get_arg "$opt")"
|
||||
+ grep -qE "^After=$service$" "$out_dir/$unit"
|
||||
+ elif [[ "$opt" =~ ^x-systemd.wanted-by= ]]; then
|
||||
+ service="$(opt_get_arg "$opt")"
|
||||
+ if [[ "$where" == / ]]; then
|
||||
+ # This option is ignored for rootfs mounts
|
||||
+ (! link_eq "$out_dir/$service.wants/$unit" "../$unit")
|
||||
+ else
|
||||
+ link_eq "$out_dir/$service.wants/$unit" "../$unit"
|
||||
+ fi
|
||||
+ elif [[ "$opt" =~ ^x-systemd.required-by= ]]; then
|
||||
+ service="$(opt_get_arg "$opt")"
|
||||
+ if [[ "$where" == / ]]; then
|
||||
+ # This option is ignored for rootfs mounts
|
||||
+ (! link_eq "$out_dir/$service.requires/$unit" "../$unit")
|
||||
+ else
|
||||
+ link_eq "$out_dir/$service.requires/$unit" "../$unit"
|
||||
+ fi
|
||||
+ elif [[ "$opt" =~ ^x-systemd.requires-mounts-for= ]]; then
|
||||
+ arg="$(opt_get_arg "$opt")"
|
||||
+ grep -qE "^RequiresMountsFor=$arg$" "$out_dir/$unit"
|
||||
+ elif [[ "$opt" == x-systemd.device-bound ]]; then
|
||||
+ # This is implied for fstab mounts
|
||||
+ :
|
||||
+ elif [[ "$opt" == x-systemd.automount ]]; then
|
||||
+ # The $unit should have an accompanying automount unit
|
||||
+ supp="$(systemd-escape --suffix=automount --path "$where")"
|
||||
+ if [[ "$where" == / ]]; then
|
||||
+ # This option is ignored for rootfs mounts
|
||||
+ test ! -e "$out_dir/$supp"
|
||||
+ (! link_eq "$out_dir/local-fs.target.requires/$supp" "../$supp")
|
||||
+ else
|
||||
+ test -e "$out_dir/$supp"
|
||||
+ link_eq "$out_dir/local-fs.target.requires/$supp" "../$supp"
|
||||
+ fi
|
||||
+ elif [[ "$opt" =~ ^x-systemd.idle-timeout= ]]; then
|
||||
+ # The timeout applies to the automount unit, not the original
|
||||
+ # mount one
|
||||
+ arg="$(opt_get_arg "$opt")"
|
||||
+ supp="$(systemd-escape --suffix=automount --path "$where")"
|
||||
+ grep -qE "^TimeoutIdleSec=$arg$" "$out_dir/$supp"
|
||||
+ elif [[ "$opt" =~ ^x-systemd.device-timeout= ]]; then
|
||||
+ arg="$(opt_get_arg "$opt")"
|
||||
+ device="$(systemd-escape --suffix=device --path "$what")"
|
||||
+ grep -qE "^JobRunningTimeoutSec=$arg$" "$out_dir/${device}.d/50-device-timeout.conf"
|
||||
+ elif [[ "$opt" == x-systemd.makefs ]]; then
|
||||
+ # In RHEL8 the unit is called systemd-mkfs@.service, see
|
||||
+ # 804f8e1729e7663c75a88fcf0997539442b891d7
|
||||
+ service="$(systemd-escape --template=systemd-mkfs@.service --path "$what")"
|
||||
+ test -e "$out_dir/$service"
|
||||
+ link_eq "$out_dir/${unit}.requires/$service" "../$service"
|
||||
+ elif [[ "$opt" == x-systemd.rw-only ]]; then
|
||||
+ grep -qE "^ReadWriteOnly=yes$" "$out_dir/$unit"
|
||||
+ elif [[ "$opt" == x-systemd.growfs ]]; then
|
||||
+ service="$(systemd-escape --template=systemd-growfs@.service --path "$where")"
|
||||
+ # Another deviation from upstream, see 50072ccf1bfee8a53563a083a3a52b26f0d5678f
|
||||
+ link_eq "$out_dir/${unit}.wants/$service" "../$service"
|
||||
+ elif [[ "$opt" == bg ]] && [[ "$fstype" =~ ^(nfs|nfs4)$ ]]; then
|
||||
+ # We "convert" nfs bg mounts to fg, so we can do the job-control
|
||||
+ # ourselves
|
||||
+ grep -qE "^Options=.*\bx-systemd.mount-timeout=infinity\b" "$out_dir/$unit"
|
||||
+ grep -qE "^Options=.*\bfg\b.*" "$out_dir/$unit"
|
||||
+ elif [[ "$opt" =~ ^x-systemd\. ]]; then
|
||||
+ echo >&2 "Unhandled mount option: $opt"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ done
|
||||
+ done
|
||||
+}
|
||||
+
|
||||
+: "fstab-generator: regular"
|
||||
+printf "%s\n" "${FSTAB_GENERAL_ROOT[@]}" >"$FSTAB"
|
||||
+cat "$FSTAB"
|
||||
+SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+check_fstab_mount_units FSTAB_GENERAL_ROOT "$OUT_DIR"
|
||||
+
|
||||
+# Skip the rest when running in a container, as it makes little sense to check
|
||||
+# initrd-related stuff there and fstab-generator might have a bit strange
|
||||
+# behavior during certain tests, like https://github.com/systemd/systemd/issues/27156
|
||||
+if in_container; then
|
||||
+ echo "Running in a container, skipping the rest of the fstab-generator tests..."
|
||||
+ exit 0
|
||||
+fi
|
||||
+
|
||||
+# In this mode we treat the entries as "regular" ones
|
||||
+: "fstab-generator: initrd - initrd fstab"
|
||||
+printf "%s\n" "${FSTAB_GENERAL[@]}" >"$FSTAB"
|
||||
+cat "$FSTAB"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_SYSROOT_FSTAB=/dev/null run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_SYSROOT_FSTAB=/dev/null check_fstab_mount_units FSTAB_GENERAL "$OUT_DIR"
|
||||
+
|
||||
+# In this mode we prefix the mount target with /sysroot and ignore all mounts
|
||||
+# that don't have the x-initrd.mount flag
|
||||
+: "fstab-generator: initrd - host fstab"
|
||||
+printf "%s\n" "${FSTAB_GENERAL_ROOT[@]}" >"$FSTAB"
|
||||
+cat "$FSTAB"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_GENERAL_ROOT "$OUT_DIR"
|
||||
+
|
||||
+# Check the default stuff that we (almost) always create in initrd
|
||||
+: "fstab-generator: initrd default"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+test -e "$OUT_DIR/normal/sysroot.mount"
|
||||
+test -e "$OUT_DIR/normal/systemd-fsck-root.service"
|
||||
+link_eq "$OUT_DIR/normal/initrd-root-fs.target.requires/sysroot.mount" "../sysroot.mount"
|
||||
+link_eq "$OUT_DIR/normal/initrd-root-fs.target.requires/sysroot.mount" "../sysroot.mount"
|
||||
+
|
||||
+# systemd-sysroot-fstab-check is not in RHEL 8
|
||||
+
|
||||
+: "fstab-generator: duplicate"
|
||||
+printf "%s\n" "${FSTAB_DUPLICATE[@]}" >"$FSTAB"
|
||||
+cat "$FSTAB"
|
||||
+(! SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR")
|
||||
+
|
||||
+: "fstab-generator: invalid"
|
||||
+printf "%s\n" "${FSTAB_INVALID[@]}" >"$FSTAB"
|
||||
+cat "$FSTAB"
|
||||
+# Don't care about the exit code here
|
||||
+SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR" || :
|
||||
+# No mounts should get created here
|
||||
+[[ "$(find "$OUT_DIR" -name "*.mount" | wc -l)" -eq 0 ]]
|
||||
+
|
||||
+: "fstab-generator: kernel args - fstab=0"
|
||||
+printf "%s\n" "${FSTAB_MINIMAL[@]}" >"$FSTAB"
|
||||
+SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+(! SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR")
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+(! SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR")
|
||||
+
|
||||
+: "fstab-generator: kernel args - rd.fstab=0"
|
||||
+printf "%s\n" "${FSTAB_MINIMAL[@]}" >"$FSTAB"
|
||||
+SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="rd.fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="rd.fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+(! SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR")
|
||||
+
|
||||
+# systemd.swap kernel cmdline arguments is not supported on RHEL 8, see
|
||||
+# 567a5307601728c618546c584f63307283fa8def
|
||||
+
|
||||
+# Possible TODO
|
||||
+# - combine the rootfs & usrfs arguments and mix them with fstab entries
|
||||
+# - systemd.volatile=
|
||||
+: "fstab-generator: kernel args - root= + rootfstype= + rootflags="
|
||||
+# shellcheck disable=SC2034
|
||||
+EXPECTED_FSTAB=(
|
||||
+ "/dev/disk/by-label/rootfs / ext4 noexec,ro 0 1"
|
||||
+)
|
||||
+CMDLINE="root=LABEL=rootfs rootfstype=ext4 rootflags=noexec"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+# The /proc/cmdline here is a dummy value to tell the in_initrd_host() function
|
||||
+# we're parsing host's fstab, but it's all on the kernel cmdline instead
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_SYSROOT_FSTAB=/proc/cmdline check_fstab_mount_units EXPECTED_FSTAB "$OUT_DIR"
|
||||
+
|
||||
+# This is a very basic sanity test that involves manual checks, since adding it
|
||||
+# to the check_fstab_mount_units() function would make it way too complex
|
||||
+# (yet another possible TODO)
|
||||
+: "fstab-generator: kernel args - mount.usr= + mount.usrfstype= + mount.usrflags="
|
||||
+CMDLINE="mount.usr=UUID=be780f43-8803-4a76-9732-02ceda6e9808 mount.usrfstype=ext4 mount.usrflags=noexec,nodev"
|
||||
+SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
||||
+cat "$OUT_DIR/normal/sysroot-usr.mount"
|
||||
+# We don't do the /sysusr/usr/ -> /sysroot/usr/ dance on RHEL 8, see
|
||||
+# 29a24ab28e9790680348b1ffab653a321fa49a67
|
||||
+grep -qE "^What=/dev/disk/by-uuid/be780f43-8803-4a76-9732-02ceda6e9808$" "$OUT_DIR/normal/sysroot-usr.mount"
|
||||
+grep -qE "^Where=/sysroot/usr$" "$OUT_DIR/normal/sysroot-usr.mount"
|
||||
+grep -qE "^Type=ext4$" "$OUT_DIR/normal/sysroot-usr.mount"
|
||||
+grep -qE "^Options=noexec,nodev,ro$" "$OUT_DIR/normal/sysroot-usr.mount"
|
||||
+link_eq "$OUT_DIR/normal/initrd-fs.target.requires/sysroot-usr.mount" "../sysroot-usr.mount"
|
||||
diff --git a/test/TEST-81-GENERATORS/testsuite.sh b/test/TEST-81-GENERATORS/testsuite.sh
|
||||
new file mode 100755
|
||||
index 0000000000..13c767e490
|
||||
--- /dev/null
|
||||
+++ b/test/TEST-81-GENERATORS/testsuite.sh
|
||||
@@ -0,0 +1,14 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+set -eux
|
||||
+set -o pipefail
|
||||
+
|
||||
+: >/failed
|
||||
+
|
||||
+for script in "${0%.sh}".*.sh; do
|
||||
+ echo "Running $script"
|
||||
+ "./$script"
|
||||
+done
|
||||
+
|
||||
+touch /testok
|
||||
+rm /failed
|
||||
diff --git a/test/test-functions b/test/test-functions
|
||||
index f0cf6f8575..2345ab6e8a 100644
|
||||
--- a/test/test-functions
|
||||
+++ b/test/test-functions
|
||||
@@ -23,7 +23,7 @@ fi
|
||||
|
||||
PATH_TO_INIT=$ROOTLIBDIR/systemd
|
||||
|
||||
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff"
|
||||
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff dirname readlink"
|
||||
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
|
||||
|
||||
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
|
@ -1,37 +0,0 @@
|
||||
From c3a86a3ab06713e865db694a80c0c5034ab902af Mon Sep 17 00:00:00 2001
|
||||
From: Michal Sekletar <msekleta@redhat.com>
|
||||
Date: Wed, 20 Dec 2023 16:44:14 +0100
|
||||
Subject: [PATCH] resolved: actually check authenticated flag of SOA
|
||||
transaction
|
||||
|
||||
Fixes #25676
|
||||
|
||||
(cherry picked from commit 3b4cc1437b51fcc0b08da8cc3f5d1175eed25eb1)
|
||||
|
||||
Resolves: RHEL-6213
|
||||
---
|
||||
src/resolve/resolved-dns-transaction.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
|
||||
index c975215468..6f614d7493 100644
|
||||
--- a/src/resolve/resolved-dns-transaction.c
|
||||
+++ b/src/resolve/resolved-dns-transaction.c
|
||||
@@ -2520,7 +2520,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord *
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
- return t->answer_authenticated;
|
||||
+ return dt->answer_authenticated;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2550,7 +2550,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord *
|
||||
* RR for us. This means we are not at a zone cut. In
|
||||
* this case, we require authentication if the SOA
|
||||
* lookup was authenticated too. */
|
||||
- return t->answer_authenticated;
|
||||
+ return dt->answer_authenticated;
|
||||
}
|
||||
|
||||
return true;
|
@ -1,70 +0,0 @@
|
||||
From 1b547e500207a469a533d819db5b7c6c22516ec3 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Thu, 17 Jan 2019 12:23:21 +0100
|
||||
Subject: [PATCH] fd-util: rework how we determine highest possible fd
|
||||
|
||||
(cherry picked from commit 498e265df1c63212ec1a0991c135877a23f1ba4f)
|
||||
|
||||
Related: RHEL-18302
|
||||
---
|
||||
src/basic/fd-util.c | 37 ++++++++++++++++++++++++++-----------
|
||||
1 file changed, 26 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
|
||||
index e085dc23b4..fea93d2039 100644
|
||||
--- a/src/basic/fd-util.c
|
||||
+++ b/src/basic/fd-util.c
|
||||
@@ -188,6 +188,27 @@ _pure_ static bool fd_in_set(int fd, const int fdset[], size_t n_fdset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+static int get_max_fd(void) {
|
||||
+ struct rlimit rl;
|
||||
+ rlim_t m;
|
||||
+
|
||||
+ /* Return the highest possible fd, based RLIMIT_NOFILE, but enforcing FD_SETSIZE-1 as lower boundary
|
||||
+ * and INT_MAX as upper boundary. */
|
||||
+
|
||||
+ if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
|
||||
+ return -errno;
|
||||
+
|
||||
+ m = MAX(rl.rlim_cur, rl.rlim_max);
|
||||
+ if (m < FD_SETSIZE) /* Let's always cover at least 1024 fds */
|
||||
+ return FD_SETSIZE-1;
|
||||
+
|
||||
+ if (m == RLIM_INFINITY || m > INT_MAX) /* Saturate on overflow. After all fds are "int", hence can
|
||||
+ * never be above INT_MAX */
|
||||
+ return INT_MAX;
|
||||
+
|
||||
+ return (int) (m - 1);
|
||||
+}
|
||||
+
|
||||
int close_all_fds(const int except[], size_t n_except) {
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
struct dirent *de;
|
||||
@@ -197,20 +218,14 @@ int close_all_fds(const int except[], size_t n_except) {
|
||||
|
||||
d = opendir("/proc/self/fd");
|
||||
if (!d) {
|
||||
- struct rlimit rl;
|
||||
int fd, max_fd;
|
||||
|
||||
- /* When /proc isn't available (for example in chroots) the fallback is brute forcing through the fd
|
||||
- * table */
|
||||
-
|
||||
- assert_se(getrlimit(RLIMIT_NOFILE, &rl) >= 0);
|
||||
-
|
||||
- if (rl.rlim_max == 0)
|
||||
- return -EINVAL;
|
||||
+ /* When /proc isn't available (for example in chroots) the fallback is brute forcing through
|
||||
+ * the fd table */
|
||||
|
||||
- /* Let's take special care if the resource limit is set to unlimited, or actually larger than the range
|
||||
- * of 'int'. Let's avoid implicit overflows. */
|
||||
- max_fd = (rl.rlim_max == RLIM_INFINITY || rl.rlim_max > INT_MAX) ? INT_MAX : (int) (rl.rlim_max - 1);
|
||||
+ max_fd = get_max_fd();
|
||||
+ if (max_fd < 0)
|
||||
+ return max_fd;
|
||||
|
||||
for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) {
|
||||
int q;
|
@ -1,70 +0,0 @@
|
||||
From 957edb063f3e9751bbdc05bd973bb2190ab0e917 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Fri, 15 Mar 2019 15:13:25 +0100
|
||||
Subject: [PATCH] basic/fd-util: refuse "infinite" loop in close_all_fds()
|
||||
|
||||
I had a test machine with ulimit -n set to 1073741816 through pam
|
||||
("session required pam_limits.so set_all", which copies the limits from PID 1,
|
||||
left over from testing of #10921).
|
||||
|
||||
test-execute would "hang" and then fail with a timeout when running
|
||||
exec-inaccessiblepaths-proc.service. It turns out that the problem was in
|
||||
close_all_fds(), which would go to the fallback path of doing close()
|
||||
1073741813 times. Let's just fail if we hit this case. This only matters
|
||||
for cases where both /proc is inaccessible, and the *soft* limit has been
|
||||
raised.
|
||||
|
||||
(gdb) bt
|
||||
#0 0x00007f7e2e73fdc8 in close () from target:/lib64/libc.so.6
|
||||
#1 0x00007f7e2e42cdfd in close_nointr ()
|
||||
from target:/home/zbyszek/src/systemd-work3/build-rawhide/src/shared/libsystemd-shared-241.so
|
||||
#2 0x00007f7e2e42d525 in close_all_fds ()
|
||||
from target:/home/zbyszek/src/systemd-work3/build-rawhide/src/shared/libsystemd-shared-241.so
|
||||
#3 0x0000000000426e53 in exec_child ()
|
||||
#4 0x0000000000429578 in exec_spawn ()
|
||||
#5 0x00000000004ce1ab in service_spawn ()
|
||||
#6 0x00000000004cff77 in service_enter_start ()
|
||||
#7 0x00000000004d028f in service_enter_start_pre ()
|
||||
#8 0x00000000004d16f2 in service_start ()
|
||||
#9 0x00000000004568f4 in unit_start ()
|
||||
#10 0x0000000000416987 in test ()
|
||||
#11 0x0000000000417632 in test_exec_inaccessiblepaths ()
|
||||
#12 0x0000000000419362 in run_tests ()
|
||||
#13 0x0000000000419632 in main ()
|
||||
|
||||
(cherry picked from commit 6a461d1f59850ff27bd254a3b71fe9ade0523e76)
|
||||
|
||||
Related: RHEL-18302
|
||||
---
|
||||
src/basic/fd-util.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
|
||||
index fea93d2039..5d0df11d7e 100644
|
||||
--- a/src/basic/fd-util.c
|
||||
+++ b/src/basic/fd-util.c
|
||||
@@ -24,6 +24,10 @@
|
||||
#include "stdio-util.h"
|
||||
#include "util.h"
|
||||
|
||||
+/* The maximum number of iterations in the loop to close descriptors in the fallback case
|
||||
+ * when /proc/self/fd/ is inaccessible. */
|
||||
+#define MAX_FD_LOOP_LIMIT (1024*1024)
|
||||
+
|
||||
int close_nointr(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
@@ -227,6 +231,13 @@ int close_all_fds(const int except[], size_t n_except) {
|
||||
if (max_fd < 0)
|
||||
return max_fd;
|
||||
|
||||
+ /* Refuse to do the loop over more too many elements. It's better to fail immediately than to
|
||||
+ * spin the CPU for a long time. */
|
||||
+ if (max_fd > MAX_FD_LOOP_LIMIT)
|
||||
+ return log_debug_errno(EPERM,
|
||||
+ "/proc/self/fd is inaccessible. Refusing to loop over %d potential fds.",
|
||||
+ max_fd);
|
||||
+
|
||||
for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) {
|
||||
int q;
|
||||
|
@ -1,110 +0,0 @@
|
||||
From c2665abd4cae74f262d9a522b94528841ad141d2 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 12 Oct 2021 15:53:27 +0200
|
||||
Subject: [PATCH] fd-util: split out inner fallback loop of close_all_fds() as
|
||||
close_all_fds_without_malloc()
|
||||
|
||||
(cherry picked from commit 11966552a88039869972ca4b450f622664bd1c5e)
|
||||
|
||||
Related: RHEL-18302
|
||||
---
|
||||
src/basic/fd-util.c | 63 +++++++++++++++++++++++++--------------------
|
||||
src/basic/fd-util.h | 1 +
|
||||
2 files changed, 36 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
|
||||
index 5d0df11d7e..7e4611dfda 100644
|
||||
--- a/src/basic/fd-util.c
|
||||
+++ b/src/basic/fd-util.c
|
||||
@@ -213,44 +213,51 @@ static int get_max_fd(void) {
|
||||
return (int) (m - 1);
|
||||
}
|
||||
|
||||
-int close_all_fds(const int except[], size_t n_except) {
|
||||
- _cleanup_closedir_ DIR *d = NULL;
|
||||
- struct dirent *de;
|
||||
- int r = 0;
|
||||
+int close_all_fds_without_malloc(const int except[], size_t n_except) {
|
||||
+ int max_fd, r = 0;
|
||||
|
||||
assert(n_except == 0 || except);
|
||||
|
||||
- d = opendir("/proc/self/fd");
|
||||
- if (!d) {
|
||||
- int fd, max_fd;
|
||||
+ /* This is the inner fallback core of close_all_fds(). This never calls malloc() or opendir() or so
|
||||
+ * and hence is safe to be called in signal handler context. Most users should call close_all_fds(),
|
||||
+ * but when we assume we are called from signal handler context, then use this simpler call
|
||||
+ * instead. */
|
||||
|
||||
- /* When /proc isn't available (for example in chroots) the fallback is brute forcing through
|
||||
- * the fd table */
|
||||
+ max_fd = get_max_fd();
|
||||
+ if (max_fd < 0)
|
||||
+ return max_fd;
|
||||
|
||||
- max_fd = get_max_fd();
|
||||
- if (max_fd < 0)
|
||||
- return max_fd;
|
||||
+ /* Refuse to do the loop over more too many elements. It's better to fail immediately than to
|
||||
+ * spin the CPU for a long time. */
|
||||
+ if (max_fd > MAX_FD_LOOP_LIMIT)
|
||||
+ return log_debug_errno(EPERM,
|
||||
+ "Refusing to loop over %d potential fds.",
|
||||
+ max_fd);
|
||||
|
||||
- /* Refuse to do the loop over more too many elements. It's better to fail immediately than to
|
||||
- * spin the CPU for a long time. */
|
||||
- if (max_fd > MAX_FD_LOOP_LIMIT)
|
||||
- return log_debug_errno(EPERM,
|
||||
- "/proc/self/fd is inaccessible. Refusing to loop over %d potential fds.",
|
||||
- max_fd);
|
||||
+ for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) {
|
||||
+ int q;
|
||||
|
||||
- for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) {
|
||||
- int q;
|
||||
+ if (fd_in_set(fd, except, n_except))
|
||||
+ continue;
|
||||
|
||||
- if (fd_in_set(fd, except, n_except))
|
||||
- continue;
|
||||
+ q = close_nointr(fd);
|
||||
+ if (q < 0 && q != -EBADF && r >= 0)
|
||||
+ r = q;
|
||||
+ }
|
||||
|
||||
- q = close_nointr(fd);
|
||||
- if (q < 0 && q != -EBADF && r >= 0)
|
||||
- r = q;
|
||||
- }
|
||||
+ return r;
|
||||
+}
|
||||
|
||||
- return r;
|
||||
- }
|
||||
+int close_all_fds(const int except[], size_t n_except) {
|
||||
+ _cleanup_closedir_ DIR *d = NULL;
|
||||
+ struct dirent *de;
|
||||
+ int r = 0;
|
||||
+
|
||||
+ assert(n_except == 0 || except);
|
||||
+
|
||||
+ d = opendir("/proc/self/fd");
|
||||
+ if (!d)
|
||||
+ return close_all_fds_without_malloc(except, n_except); /* ultimate fallback if /proc/ is not available */
|
||||
|
||||
FOREACH_DIRENT(de, d, return -errno) {
|
||||
int fd = -1, q;
|
||||
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
|
||||
index 8adc959da8..b2837d3588 100644
|
||||
--- a/src/basic/fd-util.h
|
||||
+++ b/src/basic/fd-util.h
|
||||
@@ -54,6 +54,7 @@ int fd_nonblock(int fd, bool nonblock);
|
||||
int fd_cloexec(int fd, bool cloexec);
|
||||
|
||||
int close_all_fds(const int except[], size_t n_except);
|
||||
+int close_all_fds_without_malloc(const int except[], size_t n_except);
|
||||
|
||||
int same_fd(int a, int b);
|
||||
|
@ -1,29 +0,0 @@
|
||||
From 140e598dcf6b86007b1daba42c31253521964b2e Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Thu, 29 Jul 2021 16:50:44 +0200
|
||||
Subject: [PATCH] exec-util: use close_all_fds_without_malloc() from freeze()
|
||||
|
||||
(cherry picked from commit ab27b2fe56c6c4bd0295b248448adb1c698e9284)
|
||||
|
||||
Resolves: RHEL-18302
|
||||
---
|
||||
src/basic/process-util.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
|
||||
index 6016d83d41..9e2237375d 100644
|
||||
--- a/src/basic/process-util.c
|
||||
+++ b/src/basic/process-util.c
|
||||
@@ -991,8 +991,10 @@ _noreturn_ void freeze(void) {
|
||||
|
||||
log_close();
|
||||
|
||||
- /* Make sure nobody waits for us on a socket anymore */
|
||||
- close_all_fds(NULL, 0);
|
||||
+ /* Make sure nobody waits for us (i.e. on one of our sockets) anymore. Note that we use
|
||||
+ * close_all_fds_without_malloc() instead of plain close_all_fds() here, since we want this function
|
||||
+ * to be compatible with being called from signal handlers. */
|
||||
+ (void) close_all_fds_without_malloc(NULL, 0);
|
||||
|
||||
sync();
|
||||
|
@ -1,185 +0,0 @@
|
||||
From 5d0fc67965b48e05c28d0993368a3982efd03b4b Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 12 Jan 2024 16:01:43 +0100
|
||||
Subject: [PATCH] ci: use source-git-automation composite Action
|
||||
|
||||
This will allow us maintain the source-git automation in separate repo
|
||||
and reduce the duplication of the code and noise in the systemd repo.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.../source-git-automation-on-demand.yml | 55 ++------------
|
||||
.github/workflows/source-git-automation.yml | 72 ++-----------------
|
||||
2 files changed, 9 insertions(+), 118 deletions(-)
|
||||
|
||||
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
|
||||
index 948708916d..0c72f9f210 100644
|
||||
--- a/.github/workflows/source-git-automation-on-demand.yml
|
||||
+++ b/.github/workflows/source-git-automation-on-demand.yml
|
||||
@@ -1,5 +1,3 @@
|
||||
----
|
||||
-
|
||||
name: Source git Automation Scheduled/On Demand
|
||||
on:
|
||||
schedule:
|
||||
@@ -59,61 +57,16 @@ jobs:
|
||||
pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}
|
||||
|
||||
permissions:
|
||||
+ # required for merging PRs
|
||||
contents: write
|
||||
- statuses: write
|
||||
- checks: write
|
||||
+ # required for PR comments and setting labels
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- - name: Repository checkout
|
||||
- uses: actions/checkout@v3
|
||||
-
|
||||
- - id: metadata
|
||||
- name: Gather Pull Request Metadata
|
||||
- uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
|
||||
+ - name: Source-git Automation
|
||||
+ uses: redhat-plumbers-in-action/source-git-automation@v1
|
||||
with:
|
||||
pr-number: ${{ matrix.pr-number }}
|
||||
-
|
||||
- - if: ${{ !cancelled() }}
|
||||
- id: commit-linter
|
||||
- name: Lint Commits
|
||||
- uses: redhat-plumbers-in-action/advanced-commit-linter@v2
|
||||
- with:
|
||||
- pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
- token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
- # Validates tracker, changes tracker status, updates PR title
|
||||
- - if: ${{ !cancelled() }}
|
||||
- id: tracker-validator
|
||||
- name: Validate Tracker
|
||||
- uses: redhat-plumbers-in-action/tracker-validator@v1
|
||||
- with:
|
||||
- pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
- component: systemd
|
||||
- tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
- tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
- bugzilla-instance: https://bugzilla.redhat.com
|
||||
- bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
- jira-instance: https://issues.redhat.com
|
||||
- jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
- token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
- - if: ${{ !cancelled() }}
|
||||
- name: Pull Request Validator
|
||||
- uses: redhat-plumbers-in-action/pull-request-validator@v1
|
||||
- with:
|
||||
- pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
- token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
- - id: auto-merge
|
||||
- name: Auto Merge
|
||||
- uses: redhat-plumbers-in-action/auto-merge@v1
|
||||
- with:
|
||||
- pr-metadata: ${{ steps.metadata.outputs.metadata }}
|
||||
- tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
- tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
- bugzilla-instance: https://bugzilla.redhat.com
|
||||
bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
- jira-instance: https://issues.redhat.com
|
||||
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
index 95819baa8b..b6cefa67b1 100644
|
||||
--- a/.github/workflows/source-git-automation.yml
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -26,83 +26,21 @@ jobs:
|
||||
with:
|
||||
name: pr-metadata
|
||||
|
||||
- commit-linter:
|
||||
+ source-git-automation:
|
||||
needs: [ download-metadata ]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
- outputs:
|
||||
- validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
|
||||
-
|
||||
- permissions:
|
||||
- statuses: write
|
||||
- checks: write
|
||||
- pull-requests: write
|
||||
-
|
||||
- steps:
|
||||
- - id: commit-linter
|
||||
- name: Lint Commits
|
||||
- uses: redhat-plumbers-in-action/advanced-commit-linter@v2
|
||||
- with:
|
||||
- pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
- token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
- # Validates tracker, changes tracker status, updates PR title
|
||||
- tracker-validator:
|
||||
- if: ${{ !cancelled() }}
|
||||
- needs: [ download-metadata, commit-linter ]
|
||||
- runs-on: ubuntu-latest
|
||||
-
|
||||
- permissions:
|
||||
- checks: write
|
||||
- pull-requests: write
|
||||
-
|
||||
- steps:
|
||||
- - name: Validate Tracker
|
||||
- uses: redhat-plumbers-in-action/tracker-validator@v1
|
||||
- with:
|
||||
- pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
- component: systemd
|
||||
- tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
- tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
- bugzilla-instance: https://bugzilla.redhat.com
|
||||
- bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
- jira-instance: https://issues.redhat.com
|
||||
- jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
- token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
- pull-request-validator:
|
||||
- needs: [ download-metadata ]
|
||||
- runs-on: ubuntu-latest
|
||||
-
|
||||
- permissions:
|
||||
- checks: write
|
||||
- pull-requests: write
|
||||
-
|
||||
- steps:
|
||||
- - name: Pull Request Validator
|
||||
- uses: redhat-plumbers-in-action/pull-request-validator@v1
|
||||
- with:
|
||||
- pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
- token: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
- auto-merge:
|
||||
- needs: [ download-metadata, commit-linter, tracker-validator, pull-request-validator ]
|
||||
- runs-on: ubuntu-latest
|
||||
-
|
||||
permissions:
|
||||
+ # required for merging PRs
|
||||
contents: write
|
||||
- checks: write
|
||||
+ # required for PR comments and setting labels
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- - name: Auto Merge
|
||||
- uses: redhat-plumbers-in-action/auto-merge@v1
|
||||
+ - name: Source-git Automation
|
||||
+ uses: redhat-plumbers-in-action/source-git-automation@v1
|
||||
with:
|
||||
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
- tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
|
||||
- tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
|
||||
- bugzilla-instance: https://bugzilla.redhat.com
|
||||
bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }}
|
||||
- jira-instance: https://issues.redhat.com
|
||||
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,29 +0,0 @@
|
||||
From fd21fb2e2e3bbbd937d120197b11c740d608fb19 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 12 Jan 2024 16:03:09 +0100
|
||||
Subject: [PATCH] ci: increase the cron interval to 45 minutes
|
||||
|
||||
This should help us to avoid hitting the rate limit on the GitHub API.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.github/workflows/source-git-automation-on-demand.yml | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml
|
||||
index 0c72f9f210..6aeee51e6d 100644
|
||||
--- a/.github/workflows/source-git-automation-on-demand.yml
|
||||
+++ b/.github/workflows/source-git-automation-on-demand.yml
|
||||
@@ -1,8 +1,8 @@
|
||||
name: Source git Automation Scheduled/On Demand
|
||||
on:
|
||||
schedule:
|
||||
- # Workflow runs every 15 minutes
|
||||
- - cron: '*/15 * * * *'
|
||||
+ # Workflow runs every 45 minutes
|
||||
+ - cron: '*/45 * * * *'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pr-number:
|
@ -1,31 +0,0 @@
|
||||
From 42e3739198e41c65b986f69a53bc6c93f7e112be Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Fri, 12 Jan 2024 16:04:22 +0100
|
||||
Subject: [PATCH] ci: add all Z-Stream versions to array of allowed versions
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: RHEL-1087
|
||||
---
|
||||
.github/tracker-validator.yml | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml
|
||||
index 500dce3d92..b09f702dd9 100644
|
||||
--- a/.github/tracker-validator.yml
|
||||
+++ b/.github/tracker-validator.yml
|
||||
@@ -7,8 +7,14 @@ products:
|
||||
- Red Hat Enterprise Linux 8
|
||||
- CentOS Stream 8
|
||||
- rhel-8.2.0
|
||||
+ - rhel-8.2.0.z
|
||||
- rhel-8.4.0
|
||||
+ - rhel-8.4.0.z
|
||||
- rhel-8.6.0
|
||||
+ - rhel-8.6.0.z
|
||||
- rhel-8.8.0
|
||||
+ - rhel-8.8.0.z
|
||||
- rhel-8.9.0
|
||||
+ - rhel-8.9.0.z
|
||||
- rhel-8.10.0
|
||||
+ - rhel-8.10.0.z
|
@ -1,215 +0,0 @@
|
||||
From dd3c13f364e03e843d838bf925a5fc85513343ed Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 7 Jan 2019 17:48:28 +0100
|
||||
Subject: [PATCH] tree-wide: always declare bitflag enums the same way
|
||||
|
||||
let's always use the 1 << x syntax. No change of behaviour or even of
|
||||
the compiled binary.
|
||||
|
||||
(cherry picked from commit be0b7a1a66fd269b644124c4633088ab2224d1fb)
|
||||
|
||||
Resolves: RHEL-2857
|
||||
---
|
||||
src/basic/btrfs-util.h | 16 ++++++++--------
|
||||
src/basic/cgroup-util.h | 6 +++---
|
||||
src/basic/extract-word.h | 12 ++++++------
|
||||
src/basic/unit-name.h | 10 +++++-----
|
||||
src/libsystemd/sd-bus/bus-dump.h | 4 ++--
|
||||
src/libsystemd/sd-bus/bus-protocol.h | 12 ++++++------
|
||||
src/login/logind-inhibit.h | 18 +++++++++---------
|
||||
src/resolve/resolved-dns-answer.h | 10 +++++-----
|
||||
8 files changed, 44 insertions(+), 44 deletions(-)
|
||||
|
||||
diff --git a/src/basic/btrfs-util.h b/src/basic/btrfs-util.h
|
||||
index a594387b5a..967627991f 100644
|
||||
--- a/src/basic/btrfs-util.h
|
||||
+++ b/src/basic/btrfs-util.h
|
||||
@@ -27,17 +27,17 @@ typedef struct BtrfsQuotaInfo {
|
||||
} BtrfsQuotaInfo;
|
||||
|
||||
typedef enum BtrfsSnapshotFlags {
|
||||
- BTRFS_SNAPSHOT_FALLBACK_COPY = 1, /* If the source isn't a subvolume, reflink everything */
|
||||
- BTRFS_SNAPSHOT_READ_ONLY = 2,
|
||||
- BTRFS_SNAPSHOT_RECURSIVE = 4,
|
||||
- BTRFS_SNAPSHOT_QUOTA = 8,
|
||||
- BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 16, /* If the destination doesn't support subvolumes, reflink/copy instead */
|
||||
- BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 32, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */
|
||||
+ BTRFS_SNAPSHOT_FALLBACK_COPY = 1 << 0, /* If the source isn't a subvolume, reflink everything */
|
||||
+ BTRFS_SNAPSHOT_READ_ONLY = 1 << 1,
|
||||
+ BTRFS_SNAPSHOT_RECURSIVE = 1 << 2,
|
||||
+ BTRFS_SNAPSHOT_QUOTA = 1 << 3,
|
||||
+ BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 1 << 4, /* If the destination doesn't support subvolumes, reflink/copy instead */
|
||||
+ BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 1 << 5, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */
|
||||
} BtrfsSnapshotFlags;
|
||||
|
||||
typedef enum BtrfsRemoveFlags {
|
||||
- BTRFS_REMOVE_RECURSIVE = 1,
|
||||
- BTRFS_REMOVE_QUOTA = 2,
|
||||
+ BTRFS_REMOVE_RECURSIVE = 1 << 0,
|
||||
+ BTRFS_REMOVE_QUOTA = 1 << 1,
|
||||
} BtrfsRemoveFlags;
|
||||
|
||||
int btrfs_is_filesystem(int fd);
|
||||
diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h
|
||||
index 1210b38a83..65d2dbd4b6 100644
|
||||
--- a/src/basic/cgroup-util.h
|
||||
+++ b/src/basic/cgroup-util.h
|
||||
@@ -136,9 +136,9 @@ int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d);
|
||||
int cg_read_subgroup(DIR *d, char **fn);
|
||||
|
||||
typedef enum CGroupFlags {
|
||||
- CGROUP_SIGCONT = 1,
|
||||
- CGROUP_IGNORE_SELF = 2,
|
||||
- CGROUP_REMOVE = 4,
|
||||
+ CGROUP_SIGCONT = 1 << 0,
|
||||
+ CGROUP_IGNORE_SELF = 1 << 1,
|
||||
+ CGROUP_REMOVE = 1 << 2,
|
||||
} CGroupFlags;
|
||||
|
||||
typedef void (*cg_kill_log_func_t)(pid_t pid, int sig, void *userdata);
|
||||
diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h
|
||||
index 8c63b7c306..705ebbe95b 100644
|
||||
--- a/src/basic/extract-word.h
|
||||
+++ b/src/basic/extract-word.h
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "macro.h"
|
||||
|
||||
typedef enum ExtractFlags {
|
||||
- EXTRACT_RELAX = 1,
|
||||
- EXTRACT_CUNESCAPE = 2,
|
||||
- EXTRACT_CUNESCAPE_RELAX = 4,
|
||||
- EXTRACT_QUOTES = 8,
|
||||
- EXTRACT_DONT_COALESCE_SEPARATORS = 16,
|
||||
- EXTRACT_RETAIN_ESCAPE = 32,
|
||||
+ EXTRACT_RELAX = 1 << 0,
|
||||
+ EXTRACT_CUNESCAPE = 1 << 1,
|
||||
+ EXTRACT_CUNESCAPE_RELAX = 1 << 2,
|
||||
+ EXTRACT_QUOTES = 1 << 3,
|
||||
+ EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 4,
|
||||
+ EXTRACT_RETAIN_ESCAPE = 1 << 5,
|
||||
} ExtractFlags;
|
||||
|
||||
int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags);
|
||||
diff --git a/src/basic/unit-name.h b/src/basic/unit-name.h
|
||||
index 602295af8f..7df532bbc8 100644
|
||||
--- a/src/basic/unit-name.h
|
||||
+++ b/src/basic/unit-name.h
|
||||
@@ -9,9 +9,9 @@
|
||||
#define UNIT_NAME_MAX 256
|
||||
|
||||
typedef enum UnitNameFlags {
|
||||
- UNIT_NAME_PLAIN = 1, /* Allow foo.service */
|
||||
- UNIT_NAME_INSTANCE = 2, /* Allow foo@bar.service */
|
||||
- UNIT_NAME_TEMPLATE = 4, /* Allow foo@.service */
|
||||
+ UNIT_NAME_PLAIN = 1 << 0, /* Allow foo.service */
|
||||
+ UNIT_NAME_INSTANCE = 1 << 1, /* Allow foo@bar.service */
|
||||
+ UNIT_NAME_TEMPLATE = 1 << 2, /* Allow foo@.service */
|
||||
UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE,
|
||||
} UnitNameFlags;
|
||||
|
||||
@@ -53,8 +53,8 @@ int unit_name_from_path_instance(const char *prefix, const char *path, const cha
|
||||
int unit_name_to_path(const char *name, char **ret);
|
||||
|
||||
typedef enum UnitNameMangle {
|
||||
- UNIT_NAME_MANGLE_GLOB = 1,
|
||||
- UNIT_NAME_MANGLE_WARN = 2,
|
||||
+ UNIT_NAME_MANGLE_GLOB = 1 << 0,
|
||||
+ UNIT_NAME_MANGLE_WARN = 1 << 1,
|
||||
} UnitNameMangle;
|
||||
|
||||
int unit_name_mangle_with_suffix(const char *name, UnitNameMangle flags, const char *suffix, char **ret);
|
||||
diff --git a/src/libsystemd/sd-bus/bus-dump.h b/src/libsystemd/sd-bus/bus-dump.h
|
||||
index 8e47411a45..7c1f81edec 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-dump.h
|
||||
+++ b/src/libsystemd/sd-bus/bus-dump.h
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "sd-bus.h"
|
||||
|
||||
enum {
|
||||
- BUS_MESSAGE_DUMP_WITH_HEADER = 1,
|
||||
- BUS_MESSAGE_DUMP_SUBTREE_ONLY = 2,
|
||||
+ BUS_MESSAGE_DUMP_WITH_HEADER = 1 << 0,
|
||||
+ BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1,
|
||||
};
|
||||
|
||||
int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags);
|
||||
diff --git a/src/libsystemd/sd-bus/bus-protocol.h b/src/libsystemd/sd-bus/bus-protocol.h
|
||||
index 20d19d4022..f96d4b39aa 100644
|
||||
--- a/src/libsystemd/sd-bus/bus-protocol.h
|
||||
+++ b/src/libsystemd/sd-bus/bus-protocol.h
|
||||
@@ -57,9 +57,9 @@ enum {
|
||||
/* Flags */
|
||||
|
||||
enum {
|
||||
- BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
|
||||
- BUS_MESSAGE_NO_AUTO_START = 2,
|
||||
- BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4,
|
||||
+ BUS_MESSAGE_NO_REPLY_EXPECTED = 1 << 0,
|
||||
+ BUS_MESSAGE_NO_AUTO_START = 1 << 1,
|
||||
+ BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 1 << 2,
|
||||
};
|
||||
|
||||
/* Header fields */
|
||||
@@ -81,9 +81,9 @@ enum {
|
||||
/* RequestName parameters */
|
||||
|
||||
enum {
|
||||
- BUS_NAME_ALLOW_REPLACEMENT = 1,
|
||||
- BUS_NAME_REPLACE_EXISTING = 2,
|
||||
- BUS_NAME_DO_NOT_QUEUE = 4
|
||||
+ BUS_NAME_ALLOW_REPLACEMENT = 1 << 0,
|
||||
+ BUS_NAME_REPLACE_EXISTING = 1 << 1,
|
||||
+ BUS_NAME_DO_NOT_QUEUE = 1 << 2,
|
||||
};
|
||||
|
||||
/* RequestName returns */
|
||||
diff --git a/src/login/logind-inhibit.h b/src/login/logind-inhibit.h
|
||||
index d358a48559..650587106d 100644
|
||||
--- a/src/login/logind-inhibit.h
|
||||
+++ b/src/login/logind-inhibit.h
|
||||
@@ -4,15 +4,15 @@
|
||||
typedef struct Inhibitor Inhibitor;
|
||||
|
||||
typedef enum InhibitWhat {
|
||||
- INHIBIT_SHUTDOWN = 1,
|
||||
- INHIBIT_SLEEP = 2,
|
||||
- INHIBIT_IDLE = 4,
|
||||
- INHIBIT_HANDLE_POWER_KEY = 8,
|
||||
- INHIBIT_HANDLE_SUSPEND_KEY = 16,
|
||||
- INHIBIT_HANDLE_HIBERNATE_KEY = 32,
|
||||
- INHIBIT_HANDLE_LID_SWITCH = 64,
|
||||
- _INHIBIT_WHAT_MAX = 128,
|
||||
- _INHIBIT_WHAT_INVALID = -1
|
||||
+ INHIBIT_SHUTDOWN = 1 << 0,
|
||||
+ INHIBIT_SLEEP = 1 << 1,
|
||||
+ INHIBIT_IDLE = 1 << 2,
|
||||
+ INHIBIT_HANDLE_POWER_KEY = 1 << 3,
|
||||
+ INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4,
|
||||
+ INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5,
|
||||
+ INHIBIT_HANDLE_LID_SWITCH = 1 << 6,
|
||||
+ _INHIBIT_WHAT_MAX = 1 << 7,
|
||||
+ _INHIBIT_WHAT_INVALID = -1
|
||||
} InhibitWhat;
|
||||
|
||||
typedef enum InhibitMode {
|
||||
diff --git a/src/resolve/resolved-dns-answer.h b/src/resolve/resolved-dns-answer.h
|
||||
index aff594a00e..cc90a82529 100644
|
||||
--- a/src/resolve/resolved-dns-answer.h
|
||||
+++ b/src/resolve/resolved-dns-answer.h
|
||||
@@ -15,11 +15,11 @@ typedef struct DnsAnswerItem DnsAnswerItem;
|
||||
* Note that we usually encode the empty DnsAnswer object as a simple NULL. */
|
||||
|
||||
typedef enum DnsAnswerFlags {
|
||||
- DNS_ANSWER_AUTHENTICATED = 1, /* Item has been authenticated */
|
||||
- DNS_ANSWER_CACHEABLE = 2, /* Item is subject to caching */
|
||||
- DNS_ANSWER_SHARED_OWNER = 4, /* For mDNS: RRset may be owner by multiple peers */
|
||||
- DNS_ANSWER_CACHE_FLUSH = 8, /* For mDNS: sets cache-flush bit in the rrclass of response records */
|
||||
- DNS_ANSWER_GOODBYE = 16, /* For mDNS: item is subject to disappear */
|
||||
+ DNS_ANSWER_AUTHENTICATED = 1 << 0, /* Item has been authenticated */
|
||||
+ DNS_ANSWER_CACHEABLE = 1 << 1, /* Item is subject to caching */
|
||||
+ DNS_ANSWER_SHARED_OWNER = 1 << 2, /* For mDNS: RRset may be owner by multiple peers */
|
||||
+ DNS_ANSWER_CACHE_FLUSH = 1 << 3, /* For mDNS: sets cache-flush bit in the rrclass of response records */
|
||||
+ DNS_ANSWER_GOODBYE = 1 << 4, /* For mDNS: item is subject to disappear */
|
||||
} DnsAnswerFlags;
|
||||
|
||||
struct DnsAnswerItem {
|
@ -1,343 +0,0 @@
|
||||
From d3072cec8cec84c6cb6e5771a5084e64f78c7e80 Mon Sep 17 00:00:00 2001
|
||||
From: Robert Marko <robert.marko@sartura.hr>
|
||||
Date: Fri, 14 Aug 2020 13:10:18 +0200
|
||||
Subject: [PATCH] login: Add KEY_RESTART handling
|
||||
|
||||
KEY_RESTART is widely used in Linux to indicate device reboot.
|
||||
So lets handle it in the same fashion as KEY_POWER.
|
||||
|
||||
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
|
||||
(cherry picked from commit adbb2b6afed7858f64f5b940579f6efe79eee997)
|
||||
|
||||
Resolves: RHEL-2857
|
||||
---
|
||||
man/logind.conf.xml | 26 +++++++++++++++----------
|
||||
src/login/logind-button.c | 25 +++++++++++++++++++-----
|
||||
src/login/logind-core.c | 4 ++++
|
||||
src/login/logind-dbus.c | 1 +
|
||||
src/login/logind-gperf.gperf | 2 ++
|
||||
src/login/logind-inhibit.c | 14 ++++++++++++-
|
||||
src/login/logind-inhibit.h | 3 ++-
|
||||
src/login/logind.conf.in | 2 ++
|
||||
src/login/logind.h | 2 ++
|
||||
src/login/org.freedesktop.login1.policy | 11 +++++++++++
|
||||
src/systemd/sd-messages.h | 2 ++
|
||||
11 files changed, 75 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/man/logind.conf.xml b/man/logind.conf.xml
|
||||
index 00b5b1f2e8..56981c1837 100644
|
||||
--- a/man/logind.conf.xml
|
||||
+++ b/man/logind.conf.xml
|
||||
@@ -202,10 +202,11 @@
|
||||
<term><varname>HandleLidSwitch=</varname></term>
|
||||
<term><varname>HandleLidSwitchExternalPower=</varname></term>
|
||||
<term><varname>HandleLidSwitchDocked=</varname></term>
|
||||
+ <term><varname>HandleRebootKey=</varname></term>
|
||||
|
||||
<listitem><para>Controls how logind shall handle the
|
||||
- system power and sleep keys and the lid switch to trigger
|
||||
- actions such as system power-off or suspend. Can be one of
|
||||
+ system power, reboot and sleep keys and the lid switch to trigger
|
||||
+ actions such as system power-off, reboot or suspend. Can be one of
|
||||
<literal>ignore</literal>,
|
||||
<literal>poweroff</literal>,
|
||||
<literal>reboot</literal>,
|
||||
@@ -222,7 +223,8 @@
|
||||
in the respective event. Only input devices with the
|
||||
<literal>power-switch</literal> udev tag will be watched for
|
||||
key/lid switch events. <varname>HandlePowerKey=</varname>
|
||||
- defaults to <literal>poweroff</literal>.
|
||||
+ defaults to <literal>poweroff</literal>, <varname>HandleRebootKey=</varname>
|
||||
+ defaults to <literal>reboot</literal>.
|
||||
<varname>HandleSuspendKey=</varname> and
|
||||
<varname>HandleLidSwitch=</varname> default to
|
||||
<literal>suspend</literal>.
|
||||
@@ -243,7 +245,8 @@
|
||||
<para>A different application may disable logind's handling of system power and
|
||||
sleep keys and the lid switch by taking a low-level inhibitor lock
|
||||
(<literal>handle-power-key</literal>, <literal>handle-suspend-key</literal>,
|
||||
- <literal>handle-hibernate-key</literal>, <literal>handle-lid-switch</literal>).
|
||||
+ <literal>handle-hibernate-key</literal>, <literal>handle-lid-switch</literal>,
|
||||
+ <literal>handle-reboot-switch</literal>).
|
||||
This is most commonly used by graphical desktop environments
|
||||
to take over suspend and hibernation handling, and to use their own configuration
|
||||
mechanisms. If a low-level inhibitor lock is taken, logind will not take any
|
||||
@@ -256,20 +259,23 @@
|
||||
<term><varname>SuspendKeyIgnoreInhibited=</varname></term>
|
||||
<term><varname>HibernateKeyIgnoreInhibited=</varname></term>
|
||||
<term><varname>LidSwitchIgnoreInhibited=</varname></term>
|
||||
+ <term><varname>RebootKeyIgnoreInhibited=</varname></term>
|
||||
|
||||
<listitem><para>Controls whether actions that <command>systemd-logind</command>
|
||||
- takes when the power and sleep keys and the lid switch are triggered are subject
|
||||
- to high-level inhibitor locks ("shutdown", "sleep", "idle"). Low level inhibitor
|
||||
+ takes when the power, reboot and sleep keys and the lid switch are triggered are subject
|
||||
+ to high-level inhibitor locks ("shutdown", "reboot", "sleep", "idle"). Low level inhibitor
|
||||
locks (<literal>handle-power-key</literal>, <literal>handle-suspend-key</literal>,
|
||||
- <literal>handle-hibernate-key</literal>, <literal>handle-lid-switch</literal>),
|
||||
+ <literal>handle-hibernate-key</literal>, <literal>handle-lid-switch</literal>,
|
||||
+ <literal>handle-reboot-key</literal>),
|
||||
are always honored, irrespective of this setting.</para>
|
||||
|
||||
<para>These settings take boolean arguments. If <literal>no</literal>, the
|
||||
inhibitor locks taken by applications are respected. If <literal>yes</literal>,
|
||||
- "shutdown", "sleep", and "idle" inhibitor locks are ignored.
|
||||
+ "shutdown", "reboot" "sleep", and "idle" inhibitor locks are ignored.
|
||||
<varname>PowerKeyIgnoreInhibited=</varname>,
|
||||
- <varname>SuspendKeyIgnoreInhibited=</varname>, and
|
||||
- <varname>HibernateKeyIgnoreInhibited=</varname> default to <literal>no</literal>.
|
||||
+ <varname>SuspendKeyIgnoreInhibited=</varname>,
|
||||
+ <varname>HibernateKeyIgnoreInhibited=</varname> and
|
||||
+ <varname>RebootKeyIgnoreInhibited=</varname> default to <literal>no</literal>.
|
||||
<varname>LidSwitchIgnoreInhibited=</varname> defaults to <literal>yes</literal>.
|
||||
This means that when <command>systemd-logind</command> is handling events by
|
||||
itself (no low level inhibitor locks are taken by another application), the lid
|
||||
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
|
||||
index 9944eb2316..48fc004198 100644
|
||||
--- a/src/login/logind-button.c
|
||||
+++ b/src/login/logind-button.c
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
|
||||
-#define CONST_MAX4(a, b, c, d) CONST_MAX(CONST_MAX(a, b), CONST_MAX(c, d))
|
||||
+#define CONST_MAX5(a, b, c, d, e) CONST_MAX(CONST_MAX(a, b), CONST_MAX(CONST_MAX(c, d), e))
|
||||
|
||||
#define ULONG_BITS (sizeof(unsigned long)*8)
|
||||
|
||||
@@ -159,7 +159,20 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
|
||||
manager_handle_action(b->manager, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true);
|
||||
break;
|
||||
|
||||
- /* The kernel is a bit confused here:
|
||||
+ /* The kernel naming is a bit confusing here:
|
||||
+ KEY_RESTART was probably introduced for media playback purposes, but
|
||||
+ is now being predominantly used to indicate device reboot.
|
||||
+ */
|
||||
+
|
||||
+ case KEY_RESTART:
|
||||
+ log_struct(LOG_INFO,
|
||||
+ LOG_MESSAGE("Reboot key pressed."),
|
||||
+ "MESSAGE_ID=" SD_MESSAGE_REBOOT_KEY_STR);
|
||||
+
|
||||
+ manager_handle_action(b->manager, INHIBIT_HANDLE_REBOOT_KEY, b->manager->handle_reboot_key, b->manager->reboot_key_ignore_inhibited, true);
|
||||
+ break;
|
||||
+
|
||||
+ /* The kernel naming is a bit confusing here:
|
||||
|
||||
KEY_SLEEP = suspend-to-ram, which everybody else calls "suspend"
|
||||
KEY_SUSPEND = suspend-to-disk, which everybody else calls "hibernate"
|
||||
@@ -233,7 +246,7 @@ static int button_suitable(Button *b) {
|
||||
return -errno;
|
||||
|
||||
if (bitset_get(types, EV_KEY)) {
|
||||
- unsigned long keys[CONST_MAX4(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND)/ULONG_BITS+1];
|
||||
+ unsigned long keys[CONST_MAX5(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND, KEY_RESTART)/ULONG_BITS+1];
|
||||
|
||||
if (ioctl(b->fd, EVIOCGBIT(EV_KEY, sizeof(keys)), keys) < 0)
|
||||
return -errno;
|
||||
@@ -241,7 +254,8 @@ static int button_suitable(Button *b) {
|
||||
if (bitset_get(keys, KEY_POWER) ||
|
||||
bitset_get(keys, KEY_POWER2) ||
|
||||
bitset_get(keys, KEY_SLEEP) ||
|
||||
- bitset_get(keys, KEY_SUSPEND))
|
||||
+ bitset_get(keys, KEY_SUSPEND) ||
|
||||
+ bitset_get(keys, KEY_RESTART))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -262,7 +276,7 @@ static int button_suitable(Button *b) {
|
||||
static int button_set_mask(Button *b) {
|
||||
unsigned long
|
||||
types[CONST_MAX(EV_KEY, EV_SW)/ULONG_BITS+1] = {},
|
||||
- keys[CONST_MAX4(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND)/ULONG_BITS+1] = {},
|
||||
+ keys[CONST_MAX5(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND, KEY_RESTART)/ULONG_BITS+1] = {},
|
||||
switches[CONST_MAX(SW_LID, SW_DOCK)/ULONG_BITS+1] = {};
|
||||
struct input_mask mask;
|
||||
|
||||
@@ -287,6 +301,7 @@ static int button_set_mask(Button *b) {
|
||||
bitset_put(keys, KEY_POWER2);
|
||||
bitset_put(keys, KEY_SLEEP);
|
||||
bitset_put(keys, KEY_SUSPEND);
|
||||
+ bitset_put(keys, KEY_RESTART);
|
||||
|
||||
mask = (struct input_mask) {
|
||||
.type = EV_KEY,
|
||||
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
|
||||
index abe6eecffb..81ec4f2653 100644
|
||||
--- a/src/login/logind-core.c
|
||||
+++ b/src/login/logind-core.c
|
||||
@@ -39,10 +39,12 @@ void manager_reset_config(Manager *m) {
|
||||
m->handle_lid_switch = HANDLE_SUSPEND;
|
||||
m->handle_lid_switch_ep = _HANDLE_ACTION_INVALID;
|
||||
m->handle_lid_switch_docked = HANDLE_IGNORE;
|
||||
+ m->handle_reboot_key = HANDLE_REBOOT;
|
||||
m->power_key_ignore_inhibited = false;
|
||||
m->suspend_key_ignore_inhibited = false;
|
||||
m->hibernate_key_ignore_inhibited = false;
|
||||
m->lid_switch_ignore_inhibited = true;
|
||||
+ m->reboot_key_ignore_inhibited = false;
|
||||
|
||||
m->holdoff_timeout_usec = 30 * USEC_PER_SEC;
|
||||
|
||||
@@ -698,6 +700,8 @@ bool manager_all_buttons_ignored(Manager *m) {
|
||||
return false;
|
||||
if (m->handle_lid_switch_docked != HANDLE_IGNORE)
|
||||
return false;
|
||||
+ if (m->handle_reboot_key != HANDLE_IGNORE)
|
||||
+ return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
|
||||
index dbac406035..61fd47999d 100644
|
||||
--- a/src/login/logind-dbus.c
|
||||
+++ b/src/login/logind-dbus.c
|
||||
@@ -2616,6 +2616,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
|
||||
w == INHIBIT_IDLE ? "org.freedesktop.login1.inhibit-block-idle" :
|
||||
w == INHIBIT_HANDLE_POWER_KEY ? "org.freedesktop.login1.inhibit-handle-power-key" :
|
||||
w == INHIBIT_HANDLE_SUSPEND_KEY ? "org.freedesktop.login1.inhibit-handle-suspend-key" :
|
||||
+ w == INHIBIT_HANDLE_REBOOT_KEY ? "org.freedesktop.login1.inhibit-handle-reboot-key" :
|
||||
w == INHIBIT_HANDLE_HIBERNATE_KEY ? "org.freedesktop.login1.inhibit-handle-hibernate-key" :
|
||||
"org.freedesktop.login1.inhibit-handle-lid-switch",
|
||||
NULL,
|
||||
diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf
|
||||
index 214ac5c4a3..c49703698a 100644
|
||||
--- a/src/login/logind-gperf.gperf
|
||||
+++ b/src/login/logind-gperf.gperf
|
||||
@@ -30,10 +30,12 @@ Login.HandleHibernateKey, config_parse_handle_action, 0, offse
|
||||
Login.HandleLidSwitch, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch)
|
||||
Login.HandleLidSwitchExternalPower, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_ep)
|
||||
Login.HandleLidSwitchDocked, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_docked)
|
||||
+Login.HandleRebootKey, config_parse_handle_action, 0, offsetof(Manager, handle_reboot_key)
|
||||
Login.PowerKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, power_key_ignore_inhibited)
|
||||
Login.SuspendKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, suspend_key_ignore_inhibited)
|
||||
Login.HibernateKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, hibernate_key_ignore_inhibited)
|
||||
Login.LidSwitchIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, lid_switch_ignore_inhibited)
|
||||
+Login.RebootKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, reboot_key_ignore_inhibited)
|
||||
Login.HoldoffTimeoutSec, config_parse_sec, 0, offsetof(Manager, holdoff_timeout_usec)
|
||||
Login.IdleAction, config_parse_handle_action, 0, offsetof(Manager, idle_action)
|
||||
Login.IdleActionSec, config_parse_sec, 0, offsetof(Manager, idle_action_usec)
|
||||
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
|
||||
index b1f45baaca..27b862e7c4 100644
|
||||
--- a/src/login/logind-inhibit.c
|
||||
+++ b/src/login/logind-inhibit.c
|
||||
@@ -405,7 +405,15 @@ bool manager_is_inhibited(
|
||||
}
|
||||
|
||||
const char *inhibit_what_to_string(InhibitWhat w) {
|
||||
- static thread_local char buffer[97];
|
||||
+ static thread_local char buffer[STRLEN(
|
||||
+ "shutdown:"
|
||||
+ "sleep:"
|
||||
+ "idle:"
|
||||
+ "handle-power-key:"
|
||||
+ "handle-suspend-key:"
|
||||
+ "handle-hibernate-key:"
|
||||
+ "handle-lid-switch:"
|
||||
+ "handle-reboot-key")+1];
|
||||
char *p;
|
||||
|
||||
if (w < 0 || w >= _INHIBIT_WHAT_MAX)
|
||||
@@ -426,6 +434,8 @@ const char *inhibit_what_to_string(InhibitWhat w) {
|
||||
p = stpcpy(p, "handle-hibernate-key:");
|
||||
if (w & INHIBIT_HANDLE_LID_SWITCH)
|
||||
p = stpcpy(p, "handle-lid-switch:");
|
||||
+ if (w & INHIBIT_HANDLE_REBOOT_KEY)
|
||||
+ p = stpcpy(p, "handle-reboot-key:");
|
||||
|
||||
if (p > buffer)
|
||||
*(p-1) = 0;
|
||||
@@ -455,6 +465,8 @@ InhibitWhat inhibit_what_from_string(const char *s) {
|
||||
what |= INHIBIT_HANDLE_HIBERNATE_KEY;
|
||||
else if (l == 17 && strneq(word, "handle-lid-switch", l))
|
||||
what |= INHIBIT_HANDLE_LID_SWITCH;
|
||||
+ else if (l == 17 && strneq(word, "handle-reboot-key", l))
|
||||
+ what |= INHIBIT_HANDLE_REBOOT_KEY;
|
||||
else
|
||||
return _INHIBIT_WHAT_INVALID;
|
||||
}
|
||||
diff --git a/src/login/logind-inhibit.h b/src/login/logind-inhibit.h
|
||||
index 650587106d..51095a0bde 100644
|
||||
--- a/src/login/logind-inhibit.h
|
||||
+++ b/src/login/logind-inhibit.h
|
||||
@@ -11,7 +11,8 @@ typedef enum InhibitWhat {
|
||||
INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4,
|
||||
INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5,
|
||||
INHIBIT_HANDLE_LID_SWITCH = 1 << 6,
|
||||
- _INHIBIT_WHAT_MAX = 1 << 7,
|
||||
+ INHIBIT_HANDLE_REBOOT_KEY = 1 << 7,
|
||||
+ _INHIBIT_WHAT_MAX = 1 << 8,
|
||||
_INHIBIT_WHAT_INVALID = -1
|
||||
} InhibitWhat;
|
||||
|
||||
diff --git a/src/login/logind.conf.in b/src/login/logind.conf.in
|
||||
index a62c2b0b57..95f2d48d02 100644
|
||||
--- a/src/login/logind.conf.in
|
||||
+++ b/src/login/logind.conf.in
|
||||
@@ -24,10 +24,12 @@
|
||||
#HandleLidSwitch=suspend
|
||||
#HandleLidSwitchExternalPower=suspend
|
||||
#HandleLidSwitchDocked=ignore
|
||||
+#HandleRebootKey=reboot
|
||||
#PowerKeyIgnoreInhibited=no
|
||||
#SuspendKeyIgnoreInhibited=no
|
||||
#HibernateKeyIgnoreInhibited=no
|
||||
#LidSwitchIgnoreInhibited=yes
|
||||
+#RebootKeyIgnoreInhibited=no
|
||||
#HoldoffTimeoutSec=30s
|
||||
#IdleAction=ignore
|
||||
#IdleActionSec=30min
|
||||
diff --git a/src/login/logind.h b/src/login/logind.h
|
||||
index b9b4a5113f..395306ced3 100644
|
||||
--- a/src/login/logind.h
|
||||
+++ b/src/login/logind.h
|
||||
@@ -111,11 +111,13 @@ struct Manager {
|
||||
HandleAction handle_lid_switch;
|
||||
HandleAction handle_lid_switch_ep;
|
||||
HandleAction handle_lid_switch_docked;
|
||||
+ HandleAction handle_reboot_key;
|
||||
|
||||
bool power_key_ignore_inhibited;
|
||||
bool suspend_key_ignore_inhibited;
|
||||
bool hibernate_key_ignore_inhibited;
|
||||
bool lid_switch_ignore_inhibited;
|
||||
+ bool reboot_key_ignore_inhibited;
|
||||
|
||||
bool remove_ipc;
|
||||
|
||||
diff --git a/src/login/org.freedesktop.login1.policy b/src/login/org.freedesktop.login1.policy
|
||||
index 83760e1580..882975849e 100644
|
||||
--- a/src/login/org.freedesktop.login1.policy
|
||||
+++ b/src/login/org.freedesktop.login1.policy
|
||||
@@ -113,6 +113,17 @@
|
||||
</defaults>
|
||||
</action>
|
||||
|
||||
+ <action id="org.freedesktop.login1.inhibit-handle-reboot-key">
|
||||
+ <description gettext-domain="systemd">Allow applications to inhibit system handling of the reboot key</description>
|
||||
+ <message gettext-domain="systemd">Authentication is required for an application to inhibit system handling of the reboot key.</message>
|
||||
+ <defaults>
|
||||
+ <allow_any>no</allow_any>
|
||||
+ <allow_inactive>yes</allow_inactive>
|
||||
+ <allow_active>yes</allow_active>
|
||||
+ </defaults>
|
||||
+ <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.inhibit-handle-suspend-key org.freedesktop.login1.inhibit-handle-hibernate-key org.freedesktop.login1.inhibit-handle-lid-switch</annotate>
|
||||
+ </action>
|
||||
+
|
||||
<action id="org.freedesktop.login1.set-self-linger">
|
||||
<description gettext-domain="systemd">Allow non-logged-in user to run programs</description>
|
||||
<message gettext-domain="systemd">Explicit request is required to run programs as a non-logged-in user.</message>
|
||||
diff --git a/src/systemd/sd-messages.h b/src/systemd/sd-messages.h
|
||||
index 847b698ba4..3e9584c0b2 100644
|
||||
--- a/src/systemd/sd-messages.h
|
||||
+++ b/src/systemd/sd-messages.h
|
||||
@@ -134,6 +134,8 @@ _SD_BEGIN_DECLARATIONS;
|
||||
#define SD_MESSAGE_SYSTEM_UNDOCKED_STR SD_ID128_MAKE_STR(51,e1,71,bd,58,52,48,56,81,10,14,4c,51,7c,ca,53)
|
||||
#define SD_MESSAGE_POWER_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,71)
|
||||
#define SD_MESSAGE_POWER_KEY_STR SD_ID128_MAKE_STR(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,71)
|
||||
+#define SD_MESSAGE_REBOOT_KEY SD_ID128_MAKE(9f,a9,d2,c0,12,13,4e,c3,85,45,1f,fe,31,6f,97,d0)
|
||||
+#define SD_MESSAGE_REBOOT_KEY_STR SD_ID128_MAKE_STR(9f,a9,d2,c0,12,13,4e,c3,85,45,1f,fe,31,6f,97,d0)
|
||||
#define SD_MESSAGE_SUSPEND_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,72)
|
||||
#define SD_MESSAGE_SUSPEND_KEY_STR SD_ID128_MAKE_STR(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,72)
|
||||
#define SD_MESSAGE_HIBERNATE_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,73)
|
@ -1,62 +0,0 @@
|
||||
From dd7a5f4144bde111334582eafbc0f358e63854ea Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Fri, 1 Feb 2019 11:49:24 +0100
|
||||
Subject: [PATCH] analyze security: fix recursive call of
|
||||
syscall_names_in_filter()
|
||||
|
||||
When `syscall_names_in_filter()` is called in itself, it is already
|
||||
examined with `whitelist`. Or, in other words, `syscall_names_in_filter()`
|
||||
returns bad or good in boolean. So, the returned value should not be
|
||||
compared with `whitelist` again.
|
||||
|
||||
This replaces #11302.
|
||||
|
||||
(cherry picked from commit 95832a0f8c2941df83e72dfc9d37eab20da8b1fa)
|
||||
|
||||
Related: RHEL-5991
|
||||
---
|
||||
src/analyze/analyze-security.c | 24 +++++++++++-------------
|
||||
1 file changed, 11 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
|
||||
index 969101c57b..5ef5d52e75 100644
|
||||
--- a/src/analyze/analyze-security.c
|
||||
+++ b/src/analyze/analyze-security.c
|
||||
@@ -480,26 +480,24 @@ static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterS
|
||||
const char *syscall;
|
||||
|
||||
NULSTR_FOREACH(syscall, f->value) {
|
||||
- bool b;
|
||||
+ int id;
|
||||
|
||||
if (syscall[0] == '@') {
|
||||
const SyscallFilterSet *g;
|
||||
- assert_se(g = syscall_filter_set_find(syscall));
|
||||
- b = syscall_names_in_filter(s, whitelist, g);
|
||||
- } else {
|
||||
-#if HAVE_SECCOMP
|
||||
- int id;
|
||||
|
||||
- /* Let's see if the system call actually exists on this platform, before complaining */
|
||||
- id = seccomp_syscall_resolve_name(syscall);
|
||||
- if (id < 0)
|
||||
- continue;
|
||||
-#endif
|
||||
+ assert_se(g = syscall_filter_set_find(syscall));
|
||||
+ if (syscall_names_in_filter(s, whitelist, g))
|
||||
+ return true; /* bad! */
|
||||
|
||||
- b = set_contains(s, syscall);
|
||||
+ continue;
|
||||
}
|
||||
|
||||
- if (whitelist == b) {
|
||||
+ /* Let's see if the system call actually exists on this platform, before complaining */
|
||||
+ id = seccomp_syscall_resolve_name(syscall);
|
||||
+ if (id < 0)
|
||||
+ continue;
|
||||
+
|
||||
+ if (set_contains(s, syscall) == whitelist) {
|
||||
log_debug("Offending syscall filter item: %s", syscall);
|
||||
return true; /* bad! */
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
From c8fe27ea2c560a213c3e3968fa76b5dd84e181f5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sat, 1 Aug 2020 11:28:09 +0200
|
||||
Subject: [PATCH] analyze-security: do not assign badness to filtered-out
|
||||
syscalls
|
||||
|
||||
Fixes #16451, https://bugzilla.redhat.com/show_bug.cgi?id=1856273.
|
||||
|
||||
(cherry picked from commit 01ecb3674ad3650bcbb14155b2dcbd4b9f4ed57e)
|
||||
|
||||
Resolves: RHEL-5991
|
||||
---
|
||||
src/analyze/analyze-security.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
|
||||
index 5ef5d52e75..7c937e3587 100644
|
||||
--- a/src/analyze/analyze-security.c
|
||||
+++ b/src/analyze/analyze-security.c
|
||||
@@ -549,7 +549,7 @@ static int assess_system_call_filter(
|
||||
b = 10;
|
||||
} else {
|
||||
(void) asprintf(&d, "System call blacklist defined for service, and %s is included", f->name);
|
||||
- b = 5;
|
||||
+ b = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
From 7aa12839166b5ae2c67d51946008543d016a7733 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Sat, 1 Aug 2020 11:41:57 +0200
|
||||
Subject: [PATCH] analyze-security: include an actual syscall name in the
|
||||
message
|
||||
|
||||
This information was already available in the debug output, but I think it
|
||||
is good to include it in the message in the table. This makes it easier to wrap
|
||||
one's head around the allowlist/denylist filtering.
|
||||
|
||||
(cherry picked from commit a9134af2e3ab22eba96228ea6ba440e89213cef2)
|
||||
|
||||
Related: RHEL-5991
|
||||
---
|
||||
src/analyze/analyze-security.c | 27 +++++++++++++++++----------
|
||||
1 file changed, 17 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
|
||||
index 7c937e3587..d156aa607a 100644
|
||||
--- a/src/analyze/analyze-security.c
|
||||
+++ b/src/analyze/analyze-security.c
|
||||
@@ -476,7 +476,7 @@ static int assess_system_call_architectures(
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterSet *f) {
|
||||
+static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterSet *f, const char **ret_offending_syscall) {
|
||||
const char *syscall;
|
||||
|
||||
NULSTR_FOREACH(syscall, f->value) {
|
||||
@@ -486,7 +486,7 @@ static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterS
|
||||
const SyscallFilterSet *g;
|
||||
|
||||
assert_se(g = syscall_filter_set_find(syscall));
|
||||
- if (syscall_names_in_filter(s, whitelist, g))
|
||||
+ if (syscall_names_in_filter(s, whitelist, g, ret_offending_syscall))
|
||||
return true; /* bad! */
|
||||
|
||||
continue;
|
||||
@@ -499,10 +499,13 @@ static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterS
|
||||
|
||||
if (set_contains(s, syscall) == whitelist) {
|
||||
log_debug("Offending syscall filter item: %s", syscall);
|
||||
+ if (ret_offending_syscall)
|
||||
+ *ret_offending_syscall = syscall;
|
||||
return true; /* bad! */
|
||||
}
|
||||
}
|
||||
|
||||
+ *ret_offending_syscall = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -513,31 +516,33 @@ static int assess_system_call_filter(
|
||||
uint64_t *ret_badness,
|
||||
char **ret_description) {
|
||||
|
||||
- const SyscallFilterSet *f;
|
||||
- char *d = NULL;
|
||||
- uint64_t b;
|
||||
-
|
||||
assert(a);
|
||||
assert(info);
|
||||
assert(ret_badness);
|
||||
assert(ret_description);
|
||||
|
||||
assert(a->parameter < _SYSCALL_FILTER_SET_MAX);
|
||||
- f = syscall_filter_sets + a->parameter;
|
||||
+ const SyscallFilterSet *f = syscall_filter_sets + a->parameter;
|
||||
+
|
||||
+ char *d = NULL;
|
||||
+ uint64_t b;
|
||||
|
||||
if (!info->system_call_filter_whitelist && set_isempty(info->system_call_filter)) {
|
||||
d = strdup("Service does not filter system calls");
|
||||
b = 10;
|
||||
} else {
|
||||
bool bad;
|
||||
+ const char *offender = NULL;
|
||||
|
||||
log_debug("Analyzing system call filter, checking against: %s", f->name);
|
||||
- bad = syscall_names_in_filter(info->system_call_filter, info->system_call_filter_whitelist, f);
|
||||
+ bad = syscall_names_in_filter(info->system_call_filter, info->system_call_filter_whitelist, f, &offender);
|
||||
log_debug("Result: %s", bad ? "bad" : "good");
|
||||
|
||||
if (info->system_call_filter_whitelist) {
|
||||
if (bad) {
|
||||
- (void) asprintf(&d, "System call whitelist defined for service, and %s is included", f->name);
|
||||
+ (void) asprintf(&d, "System call whitelist defined for service, and %s is included "
|
||||
+ "(e.g. %s is allowed)",
|
||||
+ f->name, offender);
|
||||
b = 9;
|
||||
} else {
|
||||
(void) asprintf(&d, "System call whitelist defined for service, and %s is not included", f->name);
|
||||
@@ -545,7 +550,9 @@ static int assess_system_call_filter(
|
||||
}
|
||||
} else {
|
||||
if (bad) {
|
||||
- (void) asprintf(&d, "System call blacklist defined for service, and %s is not included", f->name);
|
||||
+ (void) asprintf(&d, "System call blacklist defined for service, and %s is not included "
|
||||
+ "(e.g. %s is allowed)",
|
||||
+ f->name, offender);
|
||||
b = 10;
|
||||
} else {
|
||||
(void) asprintf(&d, "System call blacklist defined for service, and %s is included", f->name);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user