Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
When a ssh connection is made with X11 forwarding, there is a background task (dbus-kill-process-with-session) which is started and it will kill the dbus-daemon when the ssh connection is over.
This background task while check if the session where the ssh connection was started still exit. If not, it will kill the associated dbus-daemon.
It's working fine up to the usage of the ssh option ControlMaster.
With it, all the ssh connections will share the same session.
That means a new dbus-daemon is created each time a ssh connection is made and it will not be necessary killed when the ssh connection exit.
The dbus-daemon(s) will be killed only when exiting the *last* ssh connection, and therefore terminating the session.
The typical issue is when a client start/close many ssh connections against a server, therefore there are 'zombie dbus daemons' which are still running up the moment when the client close *all* its ssh connections.
Version-Release number of selected component (if applicable):
The backgroup task /usr/libexec/dbus-1/dbus-kill-process-with-session is provided by :
dbus-x11.x86_64 1:1.12.8-23.el8_7.1
How reproducible:
Always
Steps to Reproduce:
1. Install RHEL8.7
[root@bml-el8 ~]# uname -r
4.18.0-425.13.1.el8_7.x86_64
2. Install some "X11 related" packages
[root@bml-el8 ~]# yum install -y gnome-terminal xorg-x11-xauth
...
3. From a client machine with the following ssh option, connect a first time to the server
client-pts1> ssh root@bml-el8 -G | egrep -i 'ForwardX11|ControlMaster'
controlmaster auto
forwardx11 yes
forwardx11trusted yes
forwardx11timeout 1200
4. From the same client, connect to the server with a second term to the server and exit
client-pts2> ssh root@bml-el8 ':'
Actual results:
[root@bml-el8 ~]# who
root pts/0 Apr 24 12:30 (<IP>)
[root@bml-el8 ~]# loginctl session-status
7 - root (0)
Since: Mon 2023-04-24 12:30:38 CEST; 23s ago
Leader: 15664 (sshd)
TTY: pts/0
Remote: <IP>
Service: sshd; type tty; class user
State: active
Unit: session-7.scope
├─15664 sshd: root [priv]
├─15667 sshd: root@pts/0
├─15668 -bash
├─15693 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session
├─15696 /bin/bash /usr/libexec/dbus-1/dbus-kill-process-with-session 15693
├─15701 gio monitor -f /run/systemd/sessions/7 /tmp/dbus-session-monitor.sTnGKW
├─15730 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session
├─15733 /bin/bash /usr/libexec/dbus-1/dbus-kill-process-with-session 15730
├─15738 gio monitor -f /run/systemd/sessions/7 /tmp/dbus-session-monitor.Xrrn2w
├─15748 loginctl session-status
└─15749 less
Expected results:
[root@bml-el8 ~]# who
root pts/0 Apr 24 12:30 (<IP>)
[root@bml-el8 ~]# loginctl session-status
7 - root (0)
Since: Mon 2023-04-24 12:30:38 CEST; 23s ago
Leader: 15664 (sshd)
TTY: pts/0
Remote: <IP>
Service: sshd; type tty; class user
State: active
Unit: session-7.scope
├─15664 sshd: root [priv]
├─15667 sshd: root@pts/0
├─15668 -bash
├─15693 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session
├─15696 /bin/bash /usr/libexec/dbus-1/dbus-kill-process-with-session 15693
├─15701 gio monitor -f /run/systemd/sessions/7 /tmp/dbus-session-monitor.sTnGKW
├─15748 loginctl session-status
└─15749 less
It's not a real expected result but it's just for showing that only one dbus-daemon is running while using one ssh connection.
Additional info:
It was implemented in https://bugzilla.redhat.com/show_bug.cgi?id=2089362 where it was assumed that 1 ssh connection = 1 session.
Comment 2Ray Strode [halfline]
2023-04-24 15:26:34 UTC
Ah, right. Since, the two commands are sharing the same connection and DISPLAY, they should really be sharing the same dbus-daemon as well.
The easiest fix is to just check if there's already a dbus connection set up and not start a new one, if so. Maybe something like this:
diff --git a/ssh-x-forwarding.csh b/ssh-x-forwarding.csh
index 10d87ed..0364caf 100644
--- a/ssh-x-forwarding.csh
+++ b/ssh-x-forwarding.csh
@@ -2,4 +2,10 @@
if ( $?SSH_CONNECTION == 0 ) exit
+if ( $?XDG_SESSION_ID == 0) exit
if ( $?DISPLAY == 0 ) exit
if ( $SHLVL > 1 ) exit
+
+set SESSION_PROCESSES = `systemd-cgls --unit session-${XDG_SESSION_ID}.scope`
+echo "${SESSION_PROCESSES}" | grep -q '/usr/libexec/dbus-1/dbus-kill-process-with-session'
+if ($status == 0) exit
+
setenv GDK_BACKEND x11
diff --git a/ssh-x-forwarding.sh b/ssh-x-forwarding.sh
index 37c48f4..3b5fe37 100644
--- a/ssh-x-forwarding.sh
+++ b/ssh-x-forwarding.sh
@@ -2,2 +2,3 @@
[ -z "$SSH_CONNECTION" ] && return
+[ -z "$XDG_SESSION_ID" ] && return
[ -z "$DISPLAY" ] && return
@@ -6,2 +7,5 @@
+SESSION_PROCESSES=$(systemd-cgls --unit session-${XDG_SESSION_ID}.scope)
+echo "${SESSION_PROCESSES}" | grep -q '/usr/libexec/dbus-1/dbus-kill-process-with-session' && return
+
export GDK_BACKEND=x11
Comment 3Ray Strode [halfline]
2023-04-24 15:28:28 UTC
oh except, DBUS_SESSION_BUS_ADDRESS won't get set, so the new shell won't see the old dbus-daemon instance
Comment 4Ray Strode [halfline]
2023-04-24 15:57:28 UTC
Created attachment 1959590[details]
ensure only one dbus-daemon is spawned for all shells sharing a connection
This patch adds some bookkeeping code to track which dbus-daemons are already spawned for a user and avoids creating more than one for the same logind session.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (dbus bug fix and enhancement update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2023:7129
Description of problem: When a ssh connection is made with X11 forwarding, there is a background task (dbus-kill-process-with-session) which is started and it will kill the dbus-daemon when the ssh connection is over. This background task while check if the session where the ssh connection was started still exit. If not, it will kill the associated dbus-daemon. It's working fine up to the usage of the ssh option ControlMaster. With it, all the ssh connections will share the same session. That means a new dbus-daemon is created each time a ssh connection is made and it will not be necessary killed when the ssh connection exit. The dbus-daemon(s) will be killed only when exiting the *last* ssh connection, and therefore terminating the session. The typical issue is when a client start/close many ssh connections against a server, therefore there are 'zombie dbus daemons' which are still running up the moment when the client close *all* its ssh connections. Version-Release number of selected component (if applicable): The backgroup task /usr/libexec/dbus-1/dbus-kill-process-with-session is provided by : dbus-x11.x86_64 1:1.12.8-23.el8_7.1 How reproducible: Always Steps to Reproduce: 1. Install RHEL8.7 [root@bml-el8 ~]# uname -r 4.18.0-425.13.1.el8_7.x86_64 2. Install some "X11 related" packages [root@bml-el8 ~]# yum install -y gnome-terminal xorg-x11-xauth ... 3. From a client machine with the following ssh option, connect a first time to the server client-pts1> ssh root@bml-el8 -G | egrep -i 'ForwardX11|ControlMaster' controlmaster auto forwardx11 yes forwardx11trusted yes forwardx11timeout 1200 4. From the same client, connect to the server with a second term to the server and exit client-pts2> ssh root@bml-el8 ':' Actual results: [root@bml-el8 ~]# who root pts/0 Apr 24 12:30 (<IP>) [root@bml-el8 ~]# loginctl session-status 7 - root (0) Since: Mon 2023-04-24 12:30:38 CEST; 23s ago Leader: 15664 (sshd) TTY: pts/0 Remote: <IP> Service: sshd; type tty; class user State: active Unit: session-7.scope ├─15664 sshd: root [priv] ├─15667 sshd: root@pts/0 ├─15668 -bash ├─15693 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session ├─15696 /bin/bash /usr/libexec/dbus-1/dbus-kill-process-with-session 15693 ├─15701 gio monitor -f /run/systemd/sessions/7 /tmp/dbus-session-monitor.sTnGKW ├─15730 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session ├─15733 /bin/bash /usr/libexec/dbus-1/dbus-kill-process-with-session 15730 ├─15738 gio monitor -f /run/systemd/sessions/7 /tmp/dbus-session-monitor.Xrrn2w ├─15748 loginctl session-status └─15749 less Expected results: [root@bml-el8 ~]# who root pts/0 Apr 24 12:30 (<IP>) [root@bml-el8 ~]# loginctl session-status 7 - root (0) Since: Mon 2023-04-24 12:30:38 CEST; 23s ago Leader: 15664 (sshd) TTY: pts/0 Remote: <IP> Service: sshd; type tty; class user State: active Unit: session-7.scope ├─15664 sshd: root [priv] ├─15667 sshd: root@pts/0 ├─15668 -bash ├─15693 /usr/bin/dbus-daemon --syslog --fork --print-pid 7 --print-address 9 --session ├─15696 /bin/bash /usr/libexec/dbus-1/dbus-kill-process-with-session 15693 ├─15701 gio monitor -f /run/systemd/sessions/7 /tmp/dbus-session-monitor.sTnGKW ├─15748 loginctl session-status └─15749 less It's not a real expected result but it's just for showing that only one dbus-daemon is running while using one ssh connection. Additional info: It was implemented in https://bugzilla.redhat.com/show_bug.cgi?id=2089362 where it was assumed that 1 ssh connection = 1 session.