Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #261214

Re: Using the bash shell: determine if the root user used 'sudo -i'

From Tom Browder <tom.browder@gmail.com>
Newsgroups linux.debian.user
Subject Re: Using the bash shell: determine if the root user used 'sudo -i'
Date 2023-08-26 21:00 +0200
Message-ID <H76FP-4Ajn-5@gated-at.bofh.it> (permalink)
References <H72sy-4xRT-5@gated-at.bofh.it> <H73HX-4yxc-3@gated-at.bofh.it> <H73HX-4yxc-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sat, Aug 26, 2023 at 10:42 <tomas@tuxteam.de> wrote:

> 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

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 16:30 +0200
  Re: Using the bash shell: determine if the root user used 'sudo -i' Roberto C. Sánchez <roberto@debian.org> - 2023-08-26 16:40 +0200
    Re: Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 18:00 +0200
      Re: Using the bash shell: determine if the root user used 'sudo -i' Greg Wooledge <greg@wooledge.org> - 2023-08-26 18:00 +0200
        Re: Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 18:10 +0200
          Re: Using the bash shell: determine if the root user used 'sudo -i' Nate Bargmann <n0nb@n0nb.us> - 2023-08-26 19:20 +0200
          Re: Using the bash shell: determine if the root user used 'sudo -i' Karl Vogel <vogelke@pobox.com> - 2023-08-27 01:10 +0200
            Re: Using the bash shell: determine if the root user used 'sudo -i' Greg Wooledge <greg@wooledge.org> - 2023-08-27 01:30 +0200
        Re: Using the bash shell: determine if the root user used 'sudo -i' Michael Kjörling <2695bd53d63c@ewoof.net> - 2023-08-26 18:20 +0200
        Re: Using the bash shell: determine if the root user used 'sudo -i' <tomas@tuxteam.de> - 2023-08-26 18:40 +0200
  Re: Using the bash shell: determine if the root user used 'sudo -i' Alain D D Williams <addw@phcomp.co.uk> - 2023-08-26 17:30 +0200
  Re: Using the bash shell: determine if the root user used 'sudo -i' <tomas@tuxteam.de> - 2023-08-26 17:50 +0200
    Re: Using the bash shell: determine if the root user used 'sudo -i' Tom Browder <tom.browder@gmail.com> - 2023-08-26 21:00 +0200
      Re: Using the bash shell: determine if the root user used 'sudo -i' tomas@tuxteam.de - 2023-08-26 21:20 +0200

csiph-web