From 730d7d8c7a6b66ee2df0eaa5a8b75aa51a8ad454 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sat, 9 Aug 2025 21:27:49 +0800 Subject: [PATCH] .github/workflows/CICD.yml: Create a fully fake utmp Looks like the "system boot" entry is not present in /var/lib/utmp on recent ubuntu-latest images. Not totally clear why it disappeared, but let's just create a fake one instead. --- .github/workflows/CICD.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index e5aefffe2..8e5fac0c0 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -718,11 +718,13 @@ jobs: sudo apt-get -y update sudo apt-get -y install libselinux1-dev # pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd. - # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields. - # To work around this for pinky tests, we create a fake login entry for the GH runner account... - FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]' - # ... by dumping the login records, adding our fake line, then reverse dumping ... - (utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp + # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing. + # The account also has empty gecos fields. + # To work around these issues for pinky (and who) tests, we create a fake utmp file with a + # system boot entry and a login entry for the GH runner account. + FAKE_UTMP_2='[2] [00000] [~~ ] [reboot] [~ ] [6.0.0-test] [0.0.0.0] [2022-02-22T22:11:22,222222+00:00]' + FAKE_UTMP_7='[7] [999999] [tty2] [runner] [tty2] [ ] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]' + (echo "$FAKE_UTMP_2" ; echo "$FAKE_UTMP_7") | sudo utmpdump -r -o /var/run/utmp # ... and add a full name to each account with a gecos field but no full name. sudo sed -i 's/:,/:runner name,/' /etc/passwd # We also create a couple optional files pinky looks for @@ -1090,11 +1092,13 @@ jobs: ubuntu-latest) sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev # pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd. - # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields. - # To work around this for pinky tests, we create a fake login entry for the GH runner account... - FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]' - # ... by dumping the login records, adding our fake line, then reverse dumping ... - (utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp + # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing. + # The account also has empty gecos fields. + # To work around these issues for pinky (and who) tests, we create a fake utmp file with a + # system boot entry and a login entry for the GH runner account. + FAKE_UTMP_2='[2] [00000] [~~ ] [reboot] [~ ] [6.0.0-test] [0.0.0.0] [2022-02-22T22:11:22,222222+00:00]' + FAKE_UTMP_7='[7] [999999] [tty2] [runner] [tty2] [ ] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]' + (echo "$FAKE_UTMP_2" ; echo "$FAKE_UTMP_7") | sudo utmpdump -r -o /var/run/utmp # ... and add a full name to each account with a gecos field but no full name. sudo sed -i 's/:,/:runner name,/' /etc/passwd # We also create a couple optional files pinky looks for