470,863 Members | 1,237 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,863 developers. It's quick & easy.

sftp via proc_open(): where is my prompt ?

Helloooo everyone,
I have a problem with a small solution I made some three or four years ago.
Worked flawless until deployed onto newer machines now and guess what, I
cannot fix it. Maybe some guru here can give this a look and tell a stupid
newbie like me what I miss...

The strategy is to have some kind of a shell-like wrapper and work
interactively with it from my php scripts. So I setup a wrapper object and
can write a command and readout the result until I destruct the object (and
the sftp session). Charming details about that solution:
- works with password authentication OR key based, keys with or without
- I use select(), so no polling or looping
- I can add commands without changing the basic strategy (class)
All in all I am happy and dont really want to reimplement things with the
ssh2-extension since I would have to adapt 20% of my application then...

I start a cli sftp process via proc_open and communicate with 5 sockets with
it. stdin, stdout, stderr, stdin-for-helper & stdout-from-helper. Don't ask
me, it works, took two weeks of my life some three years ago :-)
The stuff usuylla runs under GNU/linux, apache2 and php4 OR php5 as module
OR fastcgi. No difference in result as far as this problem is concerned.

Central turnplace is the methods Connect() & _read_output().
You see the select() call, I read from stdout (clients stdout) until I find
the prompt ("sftp >") in the output.
Now to my problem...
when using the solution on newer systems (GNU/Linux with openSSH
server/client version >= 4.2) *something* has changed. Authentication still
works (according to the server log) but I run into a socket timeout on
stdout when talking with the sftp client. That means I wait for a prompt
("sftp >") that never comes. When writing a single linebreak to stdin first
thing (after authentication) things work, apart from some secondary
stumblers...). So I wonder why the f**k do I have a write e newline first ?
When doing the same session setup from within a bash (manual) as same user,
using the same account, same client and server machine (same einsteinian
universe and so on) everything works fine. I cannot see much difference.
Obviously the client processes environment is different, but there is
nothing relevant as far as I can tell. I cannot find any matching change in
the underlying software packages like php or openssh. I can reproduce this
change in behaviour on multiple older versus newer systems, it is
This is where you can take a look at the class definition.
Do not kill me because of the proprietary license, that is historical in my
company, I can release as open source if someone needs it. Or just use it,
Oh, right, here is the ssh-askpass-helper, has to be callable by the forked
sftp client process...
Hm, feel free to ask, I really need help with this one.
And sorry for the messy description, I really do have headaches after 3 days
of debugging...

Any help on my problem is really welcome,
Aug 18 '08 #1
0 1635

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Christian Hammers | last post: by
3 posts views Thread by Gus M. Creces | last post: by
reply views Thread by Bernhard Günther | last post: by
5 posts views Thread by sakismat | last post: by
4 posts views Thread by sa6113 | last post: by
2 posts views Thread by sivashanmugam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.