I wish to include a count of failed login attempts whenever a user logs in. I've created:/usr/local/bin/dynmotdwhich contains#!/bin/bashFAILLOG=`faillog -u`echo -e $FAILLOGand added /usr/local/bin/dynmotd to /etc/profileThe issue is I get /var/log/faillog: Permission deniedwhenever I login as a regular user. Is there a way to either safely temporarily escalate privileges to run that command on the motd, or temporarily give that user access to faillog to get that response? I don't want to give all user access to faillog permanently.  UPDATETried this:#!/bin/bashCURRENTUSER=`whoami`sudo -u bob setfacl -m u:$CURRENTUSER:rx /var/log/faillogFAILLOG=`sudo -u bob faillog -u $CURRENTUSER`echo -e $FAILLOGAdd added 'bob' to the sudoers with NOPASSWD:, this works fine when I'm logging in as 'bob' but if I try and login as 'bob2' I get asked for the sudoers password.
Faillog - unsuccessful login count in Motd
bash;shell;security;logs;motd