Skip to content

Commit 730d7d8

Browse files
committed
.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.
1 parent 31a9d32 commit 730d7d8

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

.github/workflows/CICD.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,13 @@ jobs:
718718
sudo apt-get -y update
719719
sudo apt-get -y install libselinux1-dev
720720
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
721-
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
722-
# To work around this for pinky tests, we create a fake login entry for the GH runner account...
723-
FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
724-
# ... by dumping the login records, adding our fake line, then reverse dumping ...
725-
(utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp
721+
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing.
722+
# The account also has empty gecos fields.
723+
# To work around these issues for pinky (and who) tests, we create a fake utmp file with a
724+
# system boot entry and a login entry for the GH runner account.
725+
FAKE_UTMP_2='[2] [00000] [~~ ] [reboot] [~ ] [6.0.0-test] [0.0.0.0] [2022-02-22T22:11:22,222222+00:00]'
726+
FAKE_UTMP_7='[7] [999999] [tty2] [runner] [tty2] [ ] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
727+
(echo "$FAKE_UTMP_2" ; echo "$FAKE_UTMP_7") | sudo utmpdump -r -o /var/run/utmp
726728
# ... and add a full name to each account with a gecos field but no full name.
727729
sudo sed -i 's/:,/:runner name,/' /etc/passwd
728730
# We also create a couple optional files pinky looks for
@@ -1090,11 +1092,13 @@ jobs:
10901092
ubuntu-latest)
10911093
sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
10921094
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
1093-
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
1094-
# To work around this for pinky tests, we create a fake login entry for the GH runner account...
1095-
FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
1096-
# ... by dumping the login records, adding our fake line, then reverse dumping ...
1097-
(utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp
1095+
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing.
1096+
# The account also has empty gecos fields.
1097+
# To work around these issues for pinky (and who) tests, we create a fake utmp file with a
1098+
# system boot entry and a login entry for the GH runner account.
1099+
FAKE_UTMP_2='[2] [00000] [~~ ] [reboot] [~ ] [6.0.0-test] [0.0.0.0] [2022-02-22T22:11:22,222222+00:00]'
1100+
FAKE_UTMP_7='[7] [999999] [tty2] [runner] [tty2] [ ] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
1101+
(echo "$FAKE_UTMP_2" ; echo "$FAKE_UTMP_7") | sudo utmpdump -r -o /var/run/utmp
10981102
# ... and add a full name to each account with a gecos field but no full name.
10991103
sudo sed -i 's/:,/:runner name,/' /etc/passwd
11001104
# We also create a couple optional files pinky looks for

0 commit comments

Comments
 (0)