Skip to content

Commit 5724001

Browse files
authored
Merge pull request #4502 from c-po/pam-nologin
T7443: Un-restricting non-root logins after scheduled reboot/shutdown via pam_nologin
2 parents cdffc31 + 9cf35f9 commit 5724001

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

debian/vyos-1x.postinst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ if [[ -e /usr/share/pam-configs/tacplus ]]; then
5050
rm /usr/share/pam-configs/tacplus
5151
fi
5252

53+
# Disable pam_nologin.so behavior for regular users
54+
sed -i '/^auth[[:space:]]\+requisite[[:space:]]\+pam_nologin\.so$/s/^/#/' /etc/pam.d/login
55+
sed -i '/^account[[:space:]]\+required[[:space:]]\+pam_nologin\.so$/s/^/#/' /etc/pam.d/sshd
56+
5357
# Add TACACS system users required for TACACS based system authentication
5458
if ! grep -q '^tacacs' /etc/passwd; then
5559
# Add the tacacs group and all 16 possible tacacs privilege-level users to

smoketest/scripts/cli/test_system_login.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,5 +548,34 @@ def test_delete_current_user(self):
548548
self.cli_commit()
549549
self.cli_discard()
550550

551+
def test_pam_nologin(self):
552+
# Testcase for T7443, test if we can login with a non-privileged user
553+
# when there are only 5 minutes left until the system reboots
554+
username = users[0]
555+
password = f'{username}-pSWd-t3st'
556+
557+
self.cli_set(base_path + ['user', username, 'authentication', 'plaintext-password', password])
558+
self.cli_commit()
559+
560+
# Login with proper credentials
561+
out, err = self.ssh_send_cmd(ssh_test_command, username, password)
562+
# verify login
563+
self.assertFalse(err)
564+
self.assertEqual(out, self.ssh_test_command_result)
565+
566+
# Request system reboot in 5 minutes - this will activate pam_nologin.so
567+
# and prevent any login - but we have this disabled, so we must be able
568+
# to login to the router
569+
self.op_mode(['reboot', 'in', '4'])
570+
571+
# verify login
572+
# Login with proper credentials - after reboot is pending
573+
out, err = self.ssh_send_cmd(ssh_test_command, username, password)
574+
self.assertFalse(err)
575+
self.assertEqual(out, self.ssh_test_command_result)
576+
577+
# Cancel pending reboot - we do wan't to preceed with the remaining tests
578+
self.op_mode(['reboot', 'cancel'])
579+
551580
if __name__ == '__main__':
552581
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)