sudo ignores -H

This is a discussion on sudo ignores -H within the Linux Security forums, part of the System Security and Security Related category; I can't get sudo to change directories to the home dir of the target user, whether or not I ...


Go Back   Usenet Forums > System Security and Security Related > Linux Security

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-05-2005
frwarner
 
Posts: n/a
Default sudo ignores -H

I can't get sudo to change directories to the home dir of the target
user, whether or not I pass the -H option on the command line. Any
ideas?

Also wanted to try "always_set_home" in /etc/sudoers, but I don't know
where to put it (man page doesn't say).

SUSE 9.3

Reply With Quote
  #2 (permalink)  
Old 11-08-2005
Jeremiah DeWitt Weiner
 
Posts: n/a
Default Re: sudo ignores -H

frwarner <frankwarner4499@yahoo.com> wrote:
> I can't get sudo to change directories to the home dir of the target
> user, whether or not I pass the -H option on the command line. Any
> ideas?


Because that's not what -H does. It sets the $HOME variable; it
does not change your current directory. I assume you are running a
shell with sudo, which is why you say "I can't get sudo to change
directories". If you want it to change to the target user's home
directory, use 'sudo su - targetuser' or 'sudo -i'. From the man page:

-i The -i (simulate initial login) option runs the shell
specified in the passwd(5) entry of the user that the
command is being run as. The command name argument
given to the shell begins with a - to tell the shell
to run as a login shell. sudo attempts to change to
that user's home directory before running the shell.


--
Oh to have a lodge in some vast wilderness. Where rumors of oppression
and deceit, of unsuccessful and successful wars may never reach me
anymore.
-- William Cowper
Reply With Quote
  #3 (permalink)  
Old 11-09-2005
frwarner
 
Posts: n/a
Default Re: sudo ignores -H


Jeremiah DeWitt Weiner wrote:
> frwarner <frankwarner4499@yahoo.com> wrote:
> > I can't get sudo to change directories to the home dir of the target
> > user, whether or not I pass the -H option on the command line. Any
> > ideas?

>
> Because that's not what -H does. It sets the $HOME variable; it
> does not change your current directory. I assume you are running a
> shell with sudo, which is why you say "I can't get sudo to change
> directories". If you want it to change to the target user's home
> directory, use 'sudo su - targetuser' or 'sudo -i'. From the man page:
>
> -i The -i (simulate initial login) option runs the shell
> specified in the passwd(5) entry of the user that the
> command is being run as. The command name argument
> given to the shell begins with a - to tell the shell
> to run as a login shell. sudo attempts to change to
> that user's home directory before running the shell.


Ah, I understand, thanks!

I wanted to be logged in as "frank" and run a command, say
"martys_script" as user "marty". The command is stored in $HOME/bin/,
where $HOME is marty's. How do I do that?

I tried:
sudo su - marty martys_script
(even with path), but then I get asked for a password (sudo didn't, but
su did, I think).
Also when I try something like
sudo -i -u marty ls
I get the reply
ls: command not found

What am I doing wrong?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:54 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0