|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I'm in a position now where we all use sudo to login as a particular user to run our daily batch jobs. The problem is that we all want to set things up slightly differently (Editors, logging dir's, etc). What I'm having a hard time with is identifying who sudo'd in. If I could find this, then I could run some checks in .bashrc to setup our environments correctly. I thought that maybe I could do something with the PID and tie it to the sudo process... but I think that is stretching it a bit. Any thoughts? Thanks Matt |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Mon, 03 Sep 2007 16:32:17 -0700, the matt
<matt@kettlewell.net> wrote: > > > Hello, > > I'm in a position now where we all use sudo to login as a particular > user to run our daily batch jobs. The problem is that we all want to > set things up slightly differently (Editors, logging dir's, etc). > > What I'm having a hard time with is identifying who sudo'd in. If I > could find this, then I could run some checks in .bashrc to setup our > environments correctly. > > I thought that maybe I could do something with the PID and tie it to > the sudo process... but I think that is stretching it a bit. > > Any thoughts? > > Thanks > echo $SUDO_USER -- The water was not fit to drink. To make it palatable, we had to add whiskey. By diligent effort, I learned to like it. -- Winston Churchill |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
> echo $SUDO_USER > Unfortunately, not on my system. But it is what I was looking for. Thanks Matt |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Sep 4, 8:32 am, the matt <m...@kettlewell.net> wrote:
> > echo $SUDO_USER > > Unfortunately, not on my system. But it is what I was looking for. > > Thanks > > Matt I may have found my problem, but I'm not sure of how to solve it. When I sudo, I sudo as another login shell (ie sudo su - jack) So my thought is that the $SUDO_USER is getting set to nothing (or not set at all) and hence i don't get the benefit. So... is there any way to get the value of $SUDO_USER from a login shell? I've tried echo $SUDO_USER from my .profile, and I get unbound variable message, so my guess is that I'm SOL. Any thoughts, comments or jokes? Matt |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Sep 4, 10:39 am, the matt <m...@kettlewell.net> wrote:
> On Sep 4, 8:32 am, the matt <m...@kettlewell.net> wrote: > > > > echo $SUDO_USER > > > Unfortunately, not on my system. But it is what I was looking for. > > > Thanks > > > Matt > > I may have found my problem, but I'm not sure of how to solve it. > When I sudo, I sudo as another login shell (ie sudo su - jack) > > So my thought is that the $SUDO_USER is getting set to nothing (or not > set at all) and hence i don't get the benefit. > > So... is there any way to get the value of $SUDO_USER from a login > shell? I've tried echo $SUDO_USER from my .profile, and I get > unbound variable message, so my guess is that I'm SOL. > > Any thoughts, comments or jokes? > > Matt Try 'who am i' - with the spaces. ms:/u/purdym>sudo /usr/bin/su - sybase sybase@ms:/home/sybase>whoami sybase sybase@ms:/home/sybase>who am i purdym pts/0 Sep 04 07:55 Miles |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Sep 4, 10:42 am, Miles <my_spam_acco...@shaw.ca> wrote:
> On Sep 4, 10:39 am, the matt <m...@kettlewell.net> wrote: > > > > > On Sep 4, 8:32 am, the matt <m...@kettlewell.net> wrote: > > > > > echo $SUDO_USER > > > > Unfortunately, not on my system. But it is what I was looking for. > > > > Thanks > > > > Matt > > > I may have found my problem, but I'm not sure of how to solve it. > > When I sudo, I sudo as another login shell (ie sudo su - jack) > > > So my thought is that the $SUDO_USER is getting set to nothing (or not > > set at all) and hence i don't get the benefit. > > > So... is there any way to get the value of $SUDO_USER from a login > > shell? I've tried echo $SUDO_USER from my .profile, and I get > > unbound variable message, so my guess is that I'm SOL. > > > Any thoughts, comments or jokes? > > > Matt > > Try 'who am i' - with the spaces. > > ms:/u/purdym>sudo /usr/bin/su - sybase > sybase@ms:/home/sybase>whoami > sybase > sybase@ms:/home/sybase>who am i > purdym pts/0 Sep 04 07:55 > > Miles Thank you, Miles. Exactly what I needed. Matt |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Tue, 04 Sep 2007 08:39:12 -0700, the matt
<matt@kettlewell.net> wrote: > > I may have found my problem, but I'm not sure of how to solve it. > When I sudo, I sudo as another login shell (ie sudo su - jack) > > So my thought is that the $SUDO_USER is getting set to nothing (or not > set at all) and hence i don't get the benefit. > > So... is there any way to get the value of $SUDO_USER from a login > shell? I've tried echo $SUDO_USER from my .profile, and I get > unbound variable message, so my guess is that I'm SOL. > > > Any thoughts, comments or jokes? > If you have the power to edit the sudoers file, make it so that you can sudo as jack without "sudo su -". "sudo -i" runs as a login shell. -- The ultimate game show will be the one where somebody gets killed at the end. -- Chuck Barris, creator of "The Gong Show" |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On 2007-09-04, Bill Marcum wrote:
> On Tue, 04 Sep 2007 08:39:12 -0700, the matt > <matt@kettlewell.net> wrote: >> >> I may have found my problem, but I'm not sure of how to solve it. >> When I sudo, I sudo as another login shell (ie sudo su - jack) >> >> So my thought is that the $SUDO_USER is getting set to nothing (or not >> set at all) and hence i don't get the benefit. >> >> So... is there any way to get the value of $SUDO_USER from a login >> shell? I've tried echo $SUDO_USER from my .profile, and I get >> unbound variable message, so my guess is that I'm SOL. >> >> >> Any thoughts, comments or jokes? >> > If you have the power to edit the sudoers file, make it so that you can > sudo as jack without "sudo su -". "sudo -i" runs as a login shell. Not with all versions of sudo. $ sudo -i sudo: Illegal option -i usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-S] [-b] [-p prompt] [-u username/#uid] [-c class] -s | <command> -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
![]() |
| Outils de la discussion | |
|
|