While trying to mitigate some spammy PAM messages in /var/log/auth.log, following this post, I tried various combinations in /etc/pam.d/sudo. Unfortunately, the last line I tried, completely locked me out of any sudo/su operations.
session [success=1 default=ignore] pam_succeed_if.so quiet_success user = root uid = 0 ruser = pi
The error I get on CLI is:
$ sudo nano sudo
sudo: pam_open_session: Permission denied
sudo: policy plugin failed session initialization
with the corresponding /var/log/auth.log message:
May 11 14:56:29 sudo: pi : TTY=pts/0 ; PWD=/etc/pam.d ; USER=root ; COMMAND=/bin/nano sudo
May 11 14:56:29 sudo: pam_unix(sudo:session): session opened for user root by pi(uid=0)
May 11 14:56:29 sudo: PAM bad jump in stack
May 11 14:56:29 sudo: pi : pam_open_session: Permission denied ; TTY=pts/0 ; PWD=/etc/pam.d ; USER=root ; COMMAND=/bin/nano sudo
Obviously I cannot edit the file back, by using sudo to edit the file.
How can I edit back the file and get out of this horrible situation?
(This is on the latest Debian Stretch on a Raspberry Pi 3B.)