PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Sudo question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Sudo question

Réponse
 
LinkBack Outils de la discussion
Vieux 04/09/2007, 00h32   #1
the matt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Sudo question

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

  Réponse avec citation
Vieux 04/09/2007, 09h04   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question

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
  Réponse avec citation
Vieux 04/09/2007, 15h32   #3
the matt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question


> echo $SUDO_USER
>


Unfortunately, not on my system. But it is what I was looking for.

Thanks

Matt

  Réponse avec citation
Vieux 04/09/2007, 16h39   #4
the matt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question

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

  Réponse avec citation
Vieux 04/09/2007, 17h42   #5
Miles
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question

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

  Réponse avec citation
Vieux 04/09/2007, 18h33   #6
the matt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question

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

  Réponse avec citation
Vieux 04/09/2007, 19h04   #7
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question

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"
  Réponse avec citation
Vieux 04/09/2007, 20h40   #8
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sudo question

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h29.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13026 seconds with 16 queries