Re: sudo and shell builtins
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.
--
Thanasis Kinias
Web Developer, Information Technology
Graduate Student, Department of History
Arizona State University
Tempe, Arizona, U.S.A.
Ash nazg durbatul�k, ash nazg gimbatul,
Ash nazg thrakatul�k agh burzum-ishi krimpatul
Reply to: