The spawn function from /usr/bin/expect fails when called from "C" cgi program.

The spawn function from /usr/bin/expect fails when called from "C" cgi program.

Post by L. D. Jame » Sat, 12 Jan 2002 04:49:31



Can someone one advise me what must be added for an expect/send script to work
when called from a "C" cgi program.  I'm writing a program web based password
change program.  I don't know of any other way to invoke yppasswd to accept a
commandline entry for the change, except to run it as root, using expect/send.
I wrote a CGI program using "setuid" to run my /usr/bin/expect script.  It works
when running it from the command line.  However, it fails when running it from
the web page.

I believe I have isolated the problem to the fact that the spawn function fails
when "expect" is run from the C CGI program from the web.

I appreciate any comments on why the /usr/bin/expect won't execute the spawn
function if called by a C program from the WEB but succeeds when run from the
terminal.

Thanks in advance.

-- L. James

---------------------------------------      
Apollo III Communications (One of the World's First ISP's)

http://www.apollo3.com/~ljames

 
 
 

The spawn function from /usr/bin/expect fails when called from "C" cgi program.

Post by Don Libe » Sun, 13 Jan 2002 00:47:59


Why not do this:

spawn /bin/su $login -c "/bin/yppasswd $login"

Then you don't have to write a C program.  Such a script needs no
special permission.

An entire script using this idea is:

http://ats.nist.gov/cgi-bin/cgi.tcl/display.cgi?scriptname=passwd.cgi

The matching front-end script is:

http://ats.nist.gov/cgi-bin/cgi.tcl/passwd-form.cgi

Don


> Can someone one advise me what must be added for an expect/send script to work
> when called from a "C" cgi program.  I'm writing a program web based password
> change program.  I don't know of any other way to invoke yppasswd to accept a
> commandline entry for the change, except to run it as root, using expect/send.
> I wrote a CGI program using "setuid" to run my /usr/bin/expect script.  It works
> when running it from the command line.  However, it fails when running it from
> the web page.

> I believe I have isolated the problem to the fact that the spawn function fails
> when "expect" is run from the C CGI program from the web.

> I appreciate any comments on why the /usr/bin/expect won't execute the spawn
> function if called by a C program from the WEB but succeeds when run from the
> terminal.

> Thanks in advance.

> -- L. James

> ---------------------------------------      
> Apollo III Communications (One of the World's First ISP's)

> http://www.apollo3.com/~ljames


 
 
 

The spawn function from /usr/bin/expect fails when called from "C" cgi program.

Post by Larry Jam » Sun, 13 Jan 2002 17:25:46


.
     Don.  Thanks for the information.  The scripts you gave me will
have me very much with the TLC language.

     I really wanted to know why spawn doesn't work with TLC from a
web page when invoked from a C program, while the same C program works
perfectly when invoked from the keyboard.  I'm sure it has something
to do with a TLC tty input/output setting.

     I used PHP to call the C program.  Now my application works just
like it does from the keyboard.  I needed the setuid because I wrote
my own security and password check.  It turns the default password
security check is too complicated for the users.  If yppasswd is
called from the root account it allows you to set the password to
whatever you want to set it to.

     The scripts on the page you sent is a gold mine.  Thanks again.

                                        -- L. James


> Why not do this:

> spawn /bin/su $login -c "/bin/yppasswd $login"

> Then you don't have to write a C program.  Such a script needs no
> special permission.

> An entire script using this idea is:

> http://ats.nist.gov/cgi-bin/cgi.tcl/display.cgi?scriptname=passwd.cgi

> The matching front-end script is:

> http://ats.nist.gov/cgi-bin/cgi.tcl/passwd-form.cgi

> Don


> > Can someone one advise me what must be added for an expect/send script to work
> > when called from a "C" cgi program.  I'm writing a program web based password
> > change program.  I don't know of any other way to invoke yppasswd to accept a
> > commandline entry for the change, except to run it as root, using expect/send.
> > I wrote a CGI program using "setuid" to run my /usr/bin/expect script.  It works
> > when running it from the command line.  However, it fails when running it from
> > the web page.

> > I believe I have isolated the problem to the fact that the spawn function fails
> > when "expect" is run from the C CGI program from the web.

> > I appreciate any comments on why the /usr/bin/expect won't execute the spawn
> > function if called by a C program from the WEB but succeeds when run from the
> > terminal.

> > Thanks in advance.