[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sudo and shell builtins



On Fri, Aug 02, 2002 at 11:13:15PM -0700, Thanasis Kinias wrote:
> scripsit Osamu Aoki:
> > On Fri, Aug 02, 2002 at 03:41:05PM -0700, Thanasis Kinias wrote:
> > > scripsit martin f krafft:
> > > > also sprach Thanasis Kinias <tkinias@optimalco.com> [2002.08.03.0023
> > > > +0200]:
> > > > > In short, is there a way to execute a shell builtin as root using
> > > > > something like sudo, or must I always open a root shell to use 'cd'
> > > > > or similar?
> > > > 
> > > > When sudo finished, permissions will be dropped. what good is a shell
> > > > that might have `pwd` set to a non-permitted resource, but not be able
> > > > to do anything with it since it's administratively prohibited?
> > > 
> > > I can do 'sudo ls', 'sudo tail _file_', etc.
> > 
> > How about sudo sh -c 'cd /root/hidden'
> 
> Neat idea, but when that shell exits, the PWD is back to where you
> started.  The effect is the same as 
> 
> $ su
> $ cd /root/hidden
> $ exit
> 
> I can do this, however:
> 
> sudo sh -c 'cd /root/hidden && ls'
> 
> which gives me a listing of the directory and then exits.  That looks to
> be the only workaround.  This all seems like a lot of effort to go
> through just to avoid doing su . . .
> 
> Thanks for the ideas, Osamu.

I meant allowing sh beat sudo limitation.

Think some one doing

$ sudo sh

Free access to shell.  No limit.  Bad, bad, ...  

So right thing is to make small shell program: /usr/local/bin/listit
from root with root:root 700

---
#!/bin/sh
cd /root/hidden && ls
---

and use sudo top execute /usr/local/bin/listit if listit is executed as

$ sudo listiy

Sorry, I was not clear.  I had little too much bear tonight :)

Good night.
-- 
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ +++++
 Osamu Aoki @ Cupertino CA USA
 See "User's Guide":     http://www.debian.org/doc/manuals/users-guide/
 See "Debian reference": http://www.debian.org/doc/manuals/debian-reference/
 "Debian reference" Project at: http://qref.sf.net

 I welcome your constructive criticisms and corrections.



Reply to: