tmux sessions don't show up with who, users, ...

Bug #1890406 reported by LTD Admin
30
This bug affects 4 people
Affects Status Importance Assigned to Milestone
tmux (Ubuntu)
Undecided
Unassigned
Focal
Medium
Athos Ribeiro

Bug Description

[Impact]

This is a regression that gets tmux not to record logins through utmp for its sessions (https://github.com/tmux/tmux/issues/2022). The bug was fixed upstream in https://github.com/tmux/tmux/commit/54efe337993b5571728a09b247c7f39d493659a8 by reintroducing the code that calls utempter to register the tmux session in utmp.

This SRU is especially important because it affects unattended-upgrades users. unattended-upgrades uses /usr/bin/users to determine logged-in users, which queries utmp for that purpose. If running tmux sessions are not registered, and unattended-upgrades is configured not to reboot when there are users logged in, then it will misbehave and forcefully kill the running (not recorded) tmux session.

The MP provided solves the issue by introducing the specific upstream fix into Focal's tmux.

[Test Plan]

* Reproducing:
 * Install tmux-3.0a-2ubuntu0.2 in Focal.
 * Start a tmux session (by running tmux) and detach from the session ("ctrl+b", then press "d").
 * Run "who". You should verify that no entries for the running tmux session were recorded.
 * Run "tmux attach" and exit the session.
* Verifying fix:
 * Install tmux-3.0a-2ubuntu0.3 (from MP) in Focal.
 * Start a tmux session (by running tmux) and detach from the session ("ctrl+b", then press "d").
 * Run "who". You should verify that there is an entry for the running tmux session recorded.
 * Run "tmux attach" and exit the session.

[Where problems could occur]

This is a cherry-pick commit from upstream. 113 other code changes (that are not present in this MP) were applied upstream before the patch being proposed was introduced, meaning the code path may deviate from upstream's codepath during execution leading to unexpected behaviour, which could result in tmux terminating abruptly (e.g., segmetation fault) for possible not tested scenarios when starting a tmux session.

In special, there were a small change in an upstream struct (window_pane) is being used in the code introduced by this patch (additional data was added). However, the change does not seem to affect the cherry-picked change AFAICT.

[original message]

Hallo!
I have recently - I am pretty sure it is since the 20.04 upgrade (coming from 18.04) - experienced the problem that (detached) tmux sessions don't show up anymore in the output of commands such as `who -u` or `users`.
Since I have a cron job for shutting down hosts where no users are logged in, I am constantly kicking out people now who have running jobs in detached tmux sessions.
We would be very happy if this could be fixed.
Thanks!

Related branches

Revision history for this message
Paride Legovini (paride) wrote :

Hello and thanks for this bug report. I am able to reproduce the issue, which interestingly is not present in Groovy. I installed tmux 3.1b-1 from Groovy on a Focal system and it *does* set the utmp entries, so something must have changed between tmux 3.0a-2 and 3.1b-1. I had a look at the Ubuntu (= Debian) changelog and at the upstream commit history. Focal tmux (3.0a-2) correctly detected the utempter library [1]:

checking utempter.h usability... yes
checking utempter.h presence... yes
checking for utempter.h... yes
checking for library containing utempter_add_record... -lutempter

so that's not the issue. I'm marking this as Triaged for Focal and Fix Released for Groovy, but in order to push this forward we must identify the root cause of the issue, then we'll be able to evaluate the possibility of a SRU.

Debian doesn't not ship tmux 3.0a-2 anymore, so I don't think it's worth filing a bug in Debian even if tmux is a sync.

[1] https://launchpadlibrarian.net/458624914/buildlog_ubuntu-focal-amd64.tmux_3.0a-2_BUILDING.txt.gz

no longer affects: tmux (Ubuntu Groovy)
Changed in tmux (Ubuntu):
status: New → Fix Released
Changed in tmux (Ubuntu Focal):
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Philipp Wendler (philw85) wrote :

We also experience this bug on Focal. It is a real issue for us because unattended-upgrades relies on the `users` command to determine logged-in users. This means that on Focal, unattended-upgrades reboots forcefully and kills running tmux sessions even if instructed not to with `Unattended-Upgrade::Automatic-Reboot-WithUsers "false";` in the apt config.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the feedback, Philipp.

I was able to further investigate this bug and found that the following upstream commit fixes it:

https://github.com/tmux/tmux/commit/54efe337993b5571728a09b247c7f39d493659a8

Given that this bug is affecting unattended-upgrade users, I'm raising its Importance and also tagging it as server-next.

Changed in tmux (Ubuntu Focal):
importance: Low → Medium
tags: added: bitesize server-next
description: updated
Changed in tmux (Ubuntu Focal):
assignee: nobody → Athos Ribeiro (athos-ribeiro)
Changed in tmux (Ubuntu Focal):
status: Triaged → In Progress
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello LTD, or anyone else affected,

Accepted tmux into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/tmux/3.0a-2ubuntu0.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in tmux (Ubuntu Focal):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-focal
Revision history for this message
Philipp Wendler (philw85) wrote :

Thank you very much!

I downloaded and installed https://launchpad.net/ubuntu/+source/tmux/3.0a-2ubuntu0.3/+build/21444364/+files/tmux_3.0a-2ubuntu0.3_amd64.deb and it works fine. Tmux sessions get shown by `who` as before with `(tmux(3431814).%0)`. `users` also works.

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Test results with Docker. Wrote the following files in an empty directory:

```Dockerfile
FROM ubuntu:focal
COPY proposed.list /etc/apt/sources.list.d/ubuntu-focal-proposed.list
RUN apt update && apt install -y tmux
```

```proposed.list
# Enable Ubuntu proposed archive
deb http://archive.ubuntu.com/ubuntu/ focal-proposed restricted main multiverse universe
```

Then ran:

$ docker build -t test-tmux .
$ docker run -it --rm test-tmux

Inside the container:

$ who
> No output
$ users
> no output

$ tmux
(detach with ctrl+b, then "d")
$ who
> root pts/1 Apr 23 12:14 (tmux(13).%0)
$ users
> root

Which confirms the fix.

tags: added: verification-done verification-done-focal
removed: verification-needed verification-needed-focal
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package tmux - 3.0a-2ubuntu0.3

---------------
tmux (3.0a-2ubuntu0.3) focal; urgency=medium

  * Fix "tmux sessions do not show up with who, users, etc" (LP: #1890406)
    - d/p/add-utempter-code.patch:
      Cherry-pick commit 54efe33 from upstream to add back utempter code to
      avoid users in tmux sessions not being accounted by the system.

 -- Athos Ribeiro <email address hidden> Thu, 22 Apr 2021 16:39:18 -0300

Changed in tmux (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for tmux has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers