Switching users in a bash script?

Brandon Peirce brandon_peirce at hotmail.com
Mon Aug 28 15:12:00 PDT 2006


lynx.abraxas wrote:
>On 27/08/06 12:19:38, Scott wrote:
> > On Sat, Aug 26, 2006 at 06:11:43PM -0700, veritosproject at gmail.com 
>wrote:
> > > Here's how you pipe commands.
> > >
> > > Throw an "exit" on the end of that, your root password on the front, 
>giving:
> > > START FILE
> > > 123456
> > > ./configure --prefix=/usr
> > > make
> > > make install
> > > exit
> > > END FILE
> > >
> > > Then simply call:
> > > echo build-package-name.txt | su
> >
> > I tried that before. On my system (Mandrake 10.1) I get:
> >
> >   stdin must be tty
>
>I  have never seen this technique before. But being curious I tried it too 
>and
>am getting:
>
>su: must be run from a terminal
>
>Are there different implementations of su out there? I have an LFS 5.1.1

There is an su command in Coreutils and in Shadow.  The one from coreutils 
sucks.

Ever since I can remember LFS suppresses the coreutils one and installs the 
shadow
one, but maybe the suppression technique has changed.  Also, LFS 5.1.1 is 
probably
from the time before the merge of sh-utils and textutils into coreutils, so 
you
should best go back and look at the relevant chapters of the 5.1.1 book in 
the LFS
museum.  If you skipped the supression command you might have ended up with
the wrong version.

Running 'su --version' might help you to indentify your binary.  Recent 
coreutils
versions will respect that switch and clearly print out that it is from 
coreutils.
Recent shadow versions will complain that it's an unrecognized option and 
print
a usage message.  I also have an older su binary lurking on my box (probably
from the shadow version used in LFS 4.0) which treats the --version arg as
the user name to su to, and will prompt for a password.





More information about the lfs-support mailing list