Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Anton Graham

Submitted 24-Jun-00 by Jasper Spit:

> This doesn't work for me. I just don't understand why su doesn't load
> the user's profile. What's the point of the -c option if it doesn't load
> the profile with the correct PATH settings, etc. ?!?

The point of -c is to set the euid of the process, that is all :)
Anything that is dependent on a particular user's base environment
should be specified as opposed to expecting that environment.

For example, root's path does not include /usr/local/bin or ~user/bin.
If I want to run a program from one of those locations as a user via
su in a script, I use su -c "~user/bin/program"

You *shouldn't* require access to a specific user's environment for
administrative functions, which is all the root account is meant for.
Set those environment variables you need within the script.  This will
prevent them from being exported into root's master environment.

-- 
   _
 _|_|_
  ( )   *Anton Graham
  /v\  / <[EMAIL PROTECTED]>
/(   )X
 (m_m)   GPG ID: 18F78541
Penguin Powered!




Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Anton Graham

Submitted 24-Jun-00 by Jasper Spit:
> Hi,
> 
> On Mandrake 7.0 when you do a su -  -c "command" from the root
> account, 's profile is not loaded. When you just do a su -
> , it works OK.

This is correct behavior.  su -  is a login shell, which is the
only time 's profile is loaded.  su -c only executes a command
as if it were that user.

> This is very annoying, I need to create a script that runs as root
> and executes some commands as another user. I can't get this to work
> right now.
> Even su -  -c ". .profile; echo $ORACLE_HOME" doesn't work.

Those are conflicting options. A shell cannot be both a login shell
and only be passed the single command.  Also you're attemting to
source .profile from $PWD.  if $PWD is not 's $HOME then you
aren't sourcing the correct file.

> How can I get this fixed ? I can't remember having this problem on
> Red Hat or SuSE. I upgraded to the newest sh-utils, but that didn't
> help either.

How about su -c ". ~user/.profile;echo $ORACLE_HOME"

-- 
   _
 _|_|_
  ( )   *Anton Graham
  /v\  / <[EMAIL PROTECTED]>
/(   )X
 (m_m)   GPG ID: 18F78541
Penguin Powered!




Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Charles Curley

On Sat, Jun 24, 2000 at 08:01:34PM +0200, Jasper Spit wrote:
-> Hi,
-> 
-> On Sat, 24 Jun 2000, Charles Curley wrote:
-> 
-> > I suspect you want to take out the initial hyphen. Here is what I use to
-> > start up the distributed net daemon:
-> >
-> > # dnetc 2000 06 21 16:19:34
-> > pushd /home/dnetc/bin
-> > su dnetc -c \"./dnetc\" -s /bin/bash
-> > popd
-> >
-> > Your initial hyphen tells su to run the login sequence, e.g. run the
-> > .bash_profile, etc.
-> 
-> This doesn't work for me. I just don't understand why su doesn't load
-> the user's profile. What's the point of the -c option if it doesn't load
-> the profile with the correct PATH settings, etc. ?!?

OK, then try escaping the quotes and the semicolon and any other shell
special characters in the original.

The point of the -c with or without the user profile, etc., depends on
what you are trying to do. You may not want the user profile for some
things. You may want some other profile, like that of the user you are
suing from. Not being a Microsoft product, Linux is not going to prohibit
you from doing something just because the developers can't think of a
reason why you would want to do it.

The sample I showed above does not load the profile, and works just
fine. I didn't load the profile in that one because I didn't need it.

-- 

-- C^2

No windows were crashed in the making of this email.

Looking for fine software and/or web pages?
http://w3.trib.com/~ccurley
 PGP signature


Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Bug Hunter


  true.  However, please note that the sudoers file ships with
ALL=(ALL):NOPASSWD

  as an example.  ALL does not mean "all the programs I have defined
to be run by people I have given access to."  Instead, ALL means "every
program on the machine."

 This can bite you, as it is a silent permission.

bug

On Sat, 24 Jun 2000, Anton Graham wrote:

> Submitted 24-Jun-00 by Lars Nordin:
> > Try downloading "sudo"  that was the old Linux "su" package
> > - it should still be out there.
> > 
> 
> Actually sudo is far more powerdul in limiting access than su is
> because you can define who can use what commands and never give out a
> superuser password :)




Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Anton Graham

Submitted 24-Jun-00 by Lars Nordin:
> Try downloading "sudo"  that was the old Linux "su" package
> - it should still be out there.
> 

Actually sudo is far more powerdul in limiting access than su is
because you can define who can use what commands and never give out a
superuser password :)

-- 
   _
 _|_|_
  ( )   *Anton Graham
  /v\  / <[EMAIL PROTECTED]>
/(   )X
 (m_m)   GPG ID: 18F78541
Penguin Powered!




Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Lars Nordin

Try downloading "sudo"  that was the old Linux "su" package
- it should still be out there.

On Sat, 24 Jun 2000, Jasper Spit wrote:
> On Mandrake 7.0 when you do a su -  -c "command" from the root
> account, 's profile is not loaded. When you just do a su - ,
>  it works OK. 
> How can I get this fixed ? I can't remember having this problem on Red Hat
> or SuSE.  I upgraded to the newest sh-utils, but that didn't help either.
> 
> Also, su doesn't return the correct errorcode if you use the -c flag, it
> always returns 0.
> This works fine on e.g. HP/UX and Sun Solaris.
> 
> Jasper
-- 
Lars Nordin
Noble Systems Corporation
www.noblesys.com




Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Jasper Spit

Hi,

On Sat, 24 Jun 2000, Charles Curley wrote:

> I suspect you want to take out the initial hyphen. Here is what I use to
> start up the distributed net daemon:
>
> # dnetc 2000 06 21 16:19:34
> pushd /home/dnetc/bin
> su dnetc -c \"./dnetc\" -s /bin/bash
> popd
>
> Your initial hyphen tells su to run the login sequence, e.g. run the
> .bash_profile, etc.

This doesn't work for me. I just don't understand why su doesn't load
the user's profile. What's the point of the -c option if it doesn't load
the profile with the correct PATH settings, etc. ?!?

Thanks,

Jasper




Re: [expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Charles Curley

On Sat, Jun 24, 2000 at 01:41:26PM +0200, Jasper Spit wrote:
-> Hi,
-> 
-> On Mandrake 7.0 when you do a su -  -c "command" from the root
-> account,
-> 's profile is not loaded. When you just do a su - , it works OK.
-> 
-> This is very annoying, I need to create a script that runs as root and
-> executes some
-> commands as another user. I can't get this to work right now.
-> Even su -  -c ". .profile; echo $ORACLE_HOME" doesn't work.
-> 
-> How can I get this fixed ? I can't remember having this problem on Red Hat
-> or SuSE.
-> I upgraded to the newest sh-utils, but that didn't help either.
-> 
-> Also, su doesn't return the correct errorcode if you use the -c flag, it
-> always returns 0.
-> This works fine on e.g. HP/UX and Sun Solaris.

I suspect you want to take out the initial hyphen. Here is what I use to
start up the distributed net daemon:


# dnetc 2000 06 21 16:19:34
pushd /home/dnetc/bin
su dnetc -c \"./dnetc\" -s /bin/bash
popd

Your initial hyphen tells su to run the login sequence, e.g. run the
.bash_profile, etc.


-- 

-- C^2

No windows were crashed in the making of this email.

Looking for fine software and/or web pages?
http://w3.trib.com/~ccurley
 PGP signature


[expert] su - user -c "command" doesn't load profile

2000-06-24 Thread Jasper Spit

Hi,

On Mandrake 7.0 when you do a su -  -c "command" from the root
account,
's profile is not loaded. When you just do a su - , it works OK.

This is very annoying, I need to create a script that runs as root and
executes some
commands as another user. I can't get this to work right now.
Even su -  -c ". .profile; echo $ORACLE_HOME" doesn't work.

How can I get this fixed ? I can't remember having this problem on Red Hat
or SuSE.
I upgraded to the newest sh-utils, but that didn't help either.

Also, su doesn't return the correct errorcode if you use the -c flag, it
always returns 0.
This works fine on e.g. HP/UX and Sun Solaris.

Thanks for the help,

Jasper