Add SSH forwarding snippets (RHEL-65490)
Resolves: RHEL-65490
This commit is contained in:
parent
7c0fbc0587
commit
fe48377606
30
dbus-kill-process-with-session
Normal file
30
dbus-kill-process-with-session
Normal file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# This script ensures the dbus-daemon is killed when the session closes.
|
||||
# It's used by SSH sessions that have X forwarding (since the X display
|
||||
# may outlive the session in those cases)
|
||||
[ $# != 1 ] && exit 1
|
||||
|
||||
exec >& /dev/null
|
||||
|
||||
MONITOR_READY_FILE=$(mktemp dbus-session-monitor.XXXXXX --tmpdir)
|
||||
DBUS_SESSIONS="${XDG_RUNTIME_DIR}/dbus-1/sessions"
|
||||
DBUS_SESSION_ADDRESS_FILE="${DBUS_SESSIONS}/${XDG_SESSION_ID}"
|
||||
|
||||
trap 'rm -f "${MONITOR_READY_FILE}"; rm -f "${DBUS_SESSION_ADDRESS_FILE}"; kill -TERM $1; kill -HUP $(jobs -p)' EXIT
|
||||
|
||||
export GVFS_DISABLE_FUSE=1
|
||||
coproc SESSION_MONITOR (gio monitor -f "/run/systemd/sessions/${XDG_SESSION_ID}" "${MONITOR_READY_FILE}")
|
||||
|
||||
# Poll until the gio monitor command is actively monitoring
|
||||
until
|
||||
touch "${MONITOR_READY_FILE}"
|
||||
read -t 0.5 -u ${SESSION_MONITOR[0]}
|
||||
do
|
||||
continue
|
||||
done
|
||||
|
||||
# Block until the session is closed
|
||||
while grep -q ^State=active <(loginctl show-session $XDG_SESSION_ID)
|
||||
do
|
||||
read -u ${SESSION_MONITOR[0]}
|
||||
done
|
||||
16
dbus.spec
16
dbus.spec
@ -23,7 +23,7 @@
|
||||
Name: dbus
|
||||
Epoch: 1
|
||||
Version: 1.12.20
|
||||
Release: 8%{?dist}
|
||||
Release: 9%{?dist}
|
||||
Summary: D-BUS message bus
|
||||
|
||||
# The effective license of the majority of the package, including the shared
|
||||
@ -42,6 +42,10 @@ Source5: dbus-daemon.service
|
||||
Source6: dbus.user.socket
|
||||
Source7: dbus-daemon.user.service
|
||||
Source8: dbus-systemd-sysusers.conf
|
||||
Source9: ssh-x-forwarding.csh
|
||||
Source10: ssh-x-forwarding.sh
|
||||
Source11: dbus-kill-process-with-session
|
||||
|
||||
Patch0: 0001-tools-Use-Python3-for-GetAllMatchRules.patch
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2133647
|
||||
Patch1: dbus-1.12.20-CVE-2022-42010.patch
|
||||
@ -239,6 +243,11 @@ install -Dp -m644 %{SOURCE6} %{buildroot}%{_userunitdir}/dbus.socket
|
||||
install -Dp -m644 %{SOURCE7} %{buildroot}%{_userunitdir}/dbus-daemon.service
|
||||
install -Dp -m644 %{SOURCE8} %{buildroot}%{_sysusersdir}/dbus.conf
|
||||
|
||||
# SSH forwarding snippets.
|
||||
install -Dp -m644 %{SOURCE9} %{buildroot}%{_sysconfdir}/profile.d/ssh-x-forwarding.csh
|
||||
install -p -m644 %{SOURCE10} %{buildroot}%{_sysconfdir}/profile.d/
|
||||
install -Dp -m755 %{SOURCE11} %{buildroot}%{_libexecdir}/dbus-1/dbus-kill-process-with-session
|
||||
|
||||
# Obsolete, but still widely used, for drop-in configuration snippets.
|
||||
install --directory %{buildroot}%{_sysconfdir}/dbus-1/session.d
|
||||
install --directory %{buildroot}%{_sysconfdir}/dbus-1/system.d
|
||||
@ -431,7 +440,9 @@ systemctl --no-reload --global preset dbus-daemon.service &>/dev/null || :
|
||||
|
||||
%files x11
|
||||
%{_bindir}/dbus-launch
|
||||
%{_libexecdir}/dbus-1/dbus-kill-process-with-session
|
||||
%{_mandir}/man1/dbus-launch.1*
|
||||
%{_sysconfdir}/profile.d/ssh-x-forwarding.*
|
||||
%{_sysconfdir}/X11/xinit/xinitrc.d/00-start-message-bus.sh
|
||||
|
||||
%files doc
|
||||
@ -456,6 +467,9 @@ systemctl --no-reload --global preset dbus-daemon.service &>/dev/null || :
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Apr 13 2026 David King <amigadave@amigadave.com> - 1:1.12.20-9
|
||||
- Add SSH forwarding snippets (RHEL-65490)
|
||||
|
||||
* Mon Jun 12 2023 David King <amigadave@amigadave.com> - 1:1.12.20-8
|
||||
- Fix CVE-2023-34969 (#2213402)
|
||||
|
||||
|
||||
25
ssh-x-forwarding.csh
Normal file
25
ssh-x-forwarding.csh
Normal file
@ -0,0 +1,25 @@
|
||||
# DBus session bus over SSH with X11 forwarding
|
||||
if ( $?SSH_CONNECTION == 0 ) exit
|
||||
if ( $?XDG_SESSION_ID == 0) exit
|
||||
if ( $?DISPLAY == 0 ) exit
|
||||
if ( $DISPLAY =~ :* ) exit
|
||||
if ( $SHLVL > 1 ) exit
|
||||
|
||||
set DBUS_SESSIONS = "${XDG_RUNTIME_DIR}/dbus-1/sessions"
|
||||
set DBUS_SESSION_ADDRESS_FILE = "${DBUS_SESSIONS}/${XDG_SESSION_ID}"
|
||||
|
||||
if ( -e "${DBUS_SESSION_ADDRESS_FILE}" ) then
|
||||
setenv DBUS_SESSION_BUS_ADDRESS "`cat ${DBUS_SESSION_ADDRESS_FILE}`"
|
||||
exit
|
||||
endif
|
||||
|
||||
setenv GDK_BACKEND x11
|
||||
|
||||
eval `dbus-launch --csh-syntax`
|
||||
|
||||
if ( $?DBUS_SESSION_BUS_PID == 0 ) exit
|
||||
|
||||
mkdir -p "${DBUS_SESSIONS}"
|
||||
echo "${DBUS_SESSION_BUS_ADDRESS}" > "${DBUS_SESSION_ADDRESS_FILE}"
|
||||
|
||||
setsid -f /usr/libexec/dbus-1/dbus-kill-process-with-session $DBUS_SESSION_BUS_PID
|
||||
25
ssh-x-forwarding.sh
Normal file
25
ssh-x-forwarding.sh
Normal file
@ -0,0 +1,25 @@
|
||||
# DBus session bus over SSH with X11 forwarding
|
||||
[ -z "$SSH_CONNECTION" ] && return
|
||||
[ -z "$XDG_SESSION_ID" ] && return
|
||||
[ -z "$DISPLAY" ] && return
|
||||
[ "${DISPLAY:0:1}" = ":" ] && return
|
||||
[ "$SHLVL" -ne 1 ] && return
|
||||
|
||||
DBUS_SESSIONS="${XDG_RUNTIME_DIR}/dbus-1/sessions"
|
||||
DBUS_SESSION_ADDRESS_FILE="${DBUS_SESSIONS}/${XDG_SESSION_ID}"
|
||||
|
||||
if [ -e "${DBUS_SESSION_ADDRESS_FILE}" ]; then
|
||||
export DBUS_SESSION_BUS_ADDRESS="$(cat ${DBUS_SESSION_ADDRESS_FILE})"
|
||||
return
|
||||
fi
|
||||
|
||||
export GDK_BACKEND=x11
|
||||
|
||||
eval `dbus-launch --sh-syntax`
|
||||
|
||||
[ -z "$DBUS_SESSION_BUS_PID" ] && return
|
||||
|
||||
mkdir -p "${DBUS_SESSIONS}"
|
||||
echo "${DBUS_SESSION_BUS_ADDRESS}" > "${DBUS_SESSION_ADDRESS_FILE}"
|
||||
|
||||
setsid -f /usr/libexec/dbus-1/dbus-kill-process-with-session "$DBUS_SESSION_BUS_PID"
|
||||
Loading…
Reference in New Issue
Block a user