On Sat, Aug 26, 2023 at 04:45:54PM +0200, DdB wrote:
> Am 26.08.2023 um 16:25 schrieb Tom Browder:
> > Is there a way to distinguish whether 'sudo -i' was used or not?
> >
> Sorry, i am not an expert on this. But ... since years i am using this
> to check for it:
>
> > # if `echo $HOME` is not "/root" or the working dir (pwd) is not "/root", then this was not executed with "sudo -i"
> > assert "echo $HOME" /root "nicht mit sudo -i aufgerufen"
> > assert pwd /root "nicht mit sudo -i aufgerufen"
>
> hope, this will give you a clue ;-)
> DdB
Unless, of course, the shell does "export HOME=/root" at some point
after start. Or one of the other fifty-two ways to achieve that.
That's why I think Roberto is right elsewhere in this thread.
Basically it is not possible to find out, so it makes sense to
think about the question "why do I need this?" to zoom into what
the real problem is. Perhaps that one can be solved :-)
As I think I replied earier, I am now checking the script is in the required directory in order to be executed (by the root user). I am not concerned with any other caveats or use by any unauthorized users for any nefarious purpose.
I consider this thread completed.
Thanks to all who responded--Debian users are the best!
-Tom