Lynx 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 don't actually understand why 'echo' is used.  I would have expected:
cat build-package-name.txt | su
or equivalently:
su <build-package-name.txt


On 29/08/06 00:12:00, Brandon Peirce wrote:
> >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.

Actually, I may be mixing things up there, so let me withdraw that opinion and
stick to the facts....

One _advantage_ of the coreutils version is that is implements a -c switch
which the shadow version doesn't.  (More about -c later.)

However, the shadow version supports PAM which the coreutils version does
not (although I saw a mention of a patch....).

LSB has chosen the shadow version as the standard.  I came across this
the other day:
http://www.freestandards.org/policy/consent.html:
---
1. Util-linux versus Shadow-utils
Where there are conflicts between a command implemented by util-linux
and shadow-utils, the shadow-utils version should be used.
This item moved from Workgroup Policies 16 June 2005. Originally
ratified 01/30/2001.
---

Or do the mean 'removed' instead of 'moved'?  In any case, the debate is
far from settled; a sample of distro's shows no consensus:
http://www.mail-archive.com/bug-coreutils@gnu.org/msg07573.html
http://www.diy-linux.org/pipermail/diy-linux-dev/2005-August/000610.html


It seems I have su from shadow-4.0.14. It gives a usage message with --version. Is it really the shadow-su that accepts this pipe input?

Hmmm, well I was also curious to try this technique, and now I've finally
got round to it.  I have both su-shadow and su-coreutils installed on my
host with su as a symlink to one of them.  Neither of them work as
described.

su-shadow always gives me the "su: must be run from a terminal"
message, no matter which technique I try.  And I've tried from a
linux vc as well as an xterm window.

su-coreutlils will never take the password from anywhere but the
terminal, but thereafter will accept commands from stdin or a file
named with -c:
cat su_script | su
su <su_script
su -c su_script

All 3 above work with su-coreutils (5.2.1) but in a script, it would
still stop and prompt you for a password.

The way I'm working around it is to run my script as root then
that kicks off another script to do the non-root part (as nruser)
with:
su -c nr_script nruser

That works because root can su to any other user without requiring
a password.  BTW, under the same conditions, i.e as root, the piping
technique would work with su-coreutils, as in:
cat nr_script | su nruser
(without the root password as the 1st line of the script!)

I still think the cleaner and correct solution is to use sudo, but I
haven't got around to installing that yet (and one would need it
installed in one's chroot environment too, presumably).


--
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to