executing su under Python

Stuart D. Gathman stuart at bmsi.com
Tue Sep 25 19:01:48 EDT 2001


In article
<Pine.SOL.4.40.0109251312320.10360-100000 at firestorm.OCF.Berkeley.EDU>,
"Brett Cannon" <bac at ocf.berkeley.edu> wrote:

> I am trying to execute this line under Solaris 8: su bac -c "lp
> /tmp/bac.print"
> 
> The trouble I keep running into is when I try to pass in my password. 
> No matter how I try to handle it, either the pipes freeze up under
> popen*, or I get a broken fd message (from the child_process.py file
> uploaded to c.l.p a few days ago), something goes wrong.  I have yet to
> ever get any command that requires a password to the terminal to work
> under Python.

The password system call is specially designed to work only with a tty
interface.  The intent was to foil programs that wish to automatically
try lots of passwords.  Of course, the pty interface gets around this by
providing a tty interface that is under program control,
and by creating a pty pair, you can run programs that require passwords.

A cleaner alternative is to use sudo.

-- 
Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - Mozart background
song for the Microsoft "Where do you want to go from here?" commercial.



More information about the Python-list mailing list