Hi
Am currently developing some bash system automation notification scripts and in the process I note a potential bug re command runuser? Please avice if I am dreaming?
Running
$ uname -a
Linux earth 6.8.9-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 18:44:19 UTC 2024 x86_64 GNU/Linux
Note also that clamupdate is in visudo:
clamupdate earth= NOPASSWD: /usr/bin/notify-send, /usr/local/bin/notify-send-all
where for notify-send-all refer to notify-send-all
In adapting the script re send-to where clamupdate(by freshclam process) would send notify-send to display :X of relevant user
So during testing I noted:
[root@earth:]# runuser -u clamupdate β /usr/bin/whoami
clamupdate[root@earth:]# runuser -u clamupdate β /usr/bin/echo $(/usr/bin/whoami)
root
[root@earth:]# runuser -u clamupdate β /usr/bin/echo $(runuser -u clamupdate β /usr/bin/whoami)
clamupdate
While no bash superexpert, It would appear to me that for both cases the answer should be clamupdate or any other -u username?
If the different answer is right, could someone please explain why?