473,767 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
passphrases.
- 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
reproduceable.
This is where you can take a look at the class definition.
http://mybib.imageware.de/~reiner/sftp.inc.pdf
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,
whatever.
Oh, right, here is the ssh-askpass-helper, has to be callable by the forked
sftp client process...
http://mybib.imageware.de/~reiner/mybib_ssh_askpass.pdf
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,
arkascha
Aug 18 '08 #1
0 1887

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2293
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems to be the right thing to use but I have the problem that the called program gives >8kb data on both stdout/stderr back which causes my PHP script to simply hang in the fread call. To be precise the first 4096 "O" characters are read and displayed. ...
4
3154
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the drama) I've been trying to think of good ways to get Perl code to run inline in a PHP script. Here are a few of my ideas. If anyone has any further ideas, resources, or knows of someone else who's solved this already, please do tell... 1.) The...
3
4162
by: Gus M. Creces | last post by:
Hi... I'm looking for some information, technical, white paper - whatever - on how SFTP works. I need to add SFTP capabilities into an app's present FTP capabilities. I'm not really looking for a 3rd party solution, like a plug in. Would prefer to write the code in C++ or C#. Just haven't found much technical information on the topic. Thanks in advance for any suggestions, leads in the right direction.
0
4690
by: Bernhard Günther | last post by:
Hello friends of php, PhP-Version is 4 on a FreeBSD-System using apache. Got a problem using ssh2.sftp. Installed correctly (libssh2, ssh2.so-module). Connecting with publickey works, sftp subsystem-connect works too:
7
15416
by: RadhakrishnanR | last post by:
How i can implement SFTP in VB. Scenario is I want to take file from SFTP server, then after some process with the file , file will be moved to database.. Our requirement is very clear that how to use SFTP in VB, currently we are using the OS-native FTP functionality, for SFTP there is no OS-native functionality. And we are not using any third party tool. In VB is it possible to accomplish this job.? If not could u give the reason. ...
12
15677
by: jcor | last post by:
Hi, I'm using Ubuntu 7.04. I'm writing a sript that sends files via ftp for several destinations. So far I used Net::FTP and it worked fine. My problem is that I need to send files via SFTP (SSH2). I've been trying to install Net::SFTP with 'sudo perl -MCPAN -e "install NET::SFTP' but I can't. It stops in the middle of the installation: Crypt-DH-0.06/t/ Crypt-DH-0.06/t/00-compile.t
5
3105
by: sakismat | last post by:
please help how can I get stderr from processes ($proc) in my screen without waiting the other processes to end #!/usr/bin/php <?php $con = mysql_connect("localhost", "user"); if (!$con)
4
4714
by: sa6113 | last post by:
I want to use sftp from paramiko to copy a file from a windows machine to a Linux in the network, I use this code : host = "LinuxComputerName" (or its Ip) port = 22 transport = paramiko.Transport((host, port)) password = "LinuxComputerPassword" username = "LinuxComputerUserName" transport.connect(username = username, password = password)
2
3828
by: sivashanmugam | last post by:
Hi Friends, I tried to send some zips from local to remote location but the transfer is not sucess i can transfer the zips partially can some one assist me how to make it as sucess i had used the below code #!/bin/sh /usr/local/bin/expect <<EOF
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10009
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8835
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.