StreamWrapper for SFTP (PHPSecLib)

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Sat Jan 12, 2013 1:26 pm

Hello,

I'm currently working in the integration of this great library, PHPSecLib, in the AjaxPlorer project, a WebFTP (http://ajaxplorer.info/)

I would like to rebuild the "plugin" that manage SFTP (http://ajaxplorer.info/plugins/access/sftp/) in order to have the SFTP protocol available without the requirement of having the ugly libssh2 extension installed.

Since ajaxplorer core use Streams and Wrappers, I have to build a stream wrapper that implements SFTP using PHPSecLib.

I would like to know if the work I have done is correct and is well done, your point of view, a kind of validation for production usage.
Please, do not hesitate to rebuild some parts of the code and tell me your advice.

Here is some documentation:

http://php.net/manual/fr/wrappers.ssh2.php // Original ssh2.sftp (libssh2)
http://php.net/manual/en/class.streamwrapper.php // streamWrapper to implement SSH2.SFTP protocol
http://php.net/manual/en/stream.streamw ... mple-1.php // Example
http://php.net/manual/en/function.parse-url.php

SecLib is included before this class.

Here is my code:
EDIT: https://github.com/warhawk3407/StreamWrappers_PHPSecLib

Best Regards,
warhawk3407
Last edited by brightgamepanel on Wed Mar 13, 2013 11:15 am, edited 5 times in total.
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby TerraFrost » Sat Jan 12, 2013 6:40 pm

That looks pretty cool! A full review will take some time - I'll try to do so in the next few days.

Thanks!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Sat Jan 12, 2013 8:54 pm

Thank you TerraFrost :)

Take your time to test and feel free to improve it, you can also implement missing functions, when it is possible.

I like when the things are well done, even if it takes a lot of time :8

It is my contribution to this great project :) When this class will be ready, I think it will be a new key feature for the library :D

Regards
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Wed Jan 16, 2013 11:11 am

Hello,

I'm enquiring some news about your progress on our Stream Wrapper :8

Best regards
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby TerraFrost » Thu Jan 17, 2013 5:54 am

Mind if I take a look this weekend? This has thus far been a busy week for me :(
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Fri Jan 18, 2013 4:10 pm

Yeah no problem :)
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby TerraFrost » Mon Jan 21, 2013 4:38 am

I'll try to take a look at this next week maybe...

To be quite perfectly honest I'm feeling a little burned out with phpseclib atm. Take a look at this:

https://www.ohloh.net/p/phpseclib/commits/summary

This month there have been 71 commits already, more than any month in the past, and there's still a week and a half left to go in this month.

Granted, not all of those commits are mine, but every commit that isn't mine generally takes just as much time as it would if I did it because I vet the commits. And unlike code I contribute at my own leisure code contributed by other people needs feedback within a few day window, I figure, lest the original developer lose interest all together. Plus, I'm grateful for any and all contributions and want to honor them accordingly. And I don't do that by just letting them pile up.

Problem with this is... it screws with my own plans. Like every weekend, so far, this year, I'm like "I'm gonna work on this cool facebook app idea of mine!" But nope... never happens, because someone makes a commit I don't expect that requires vetting, hijaking whatever plans I may have had.

So anyway, this'll happen when it happens meh. Sorry :(
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Sun Feb 10, 2013 8:29 pm

Hello TerraFrost,

I would like to re open this thread :D

After your massive wave of commits in January, I would like to know if you think you may check my "Wrapper". Even if it late, but I need your help, you know more than everyone how phpseclib works ^_^ ( If it is not you, who may help me in the creation of this "extension" ? )

I have my self my own software to maintain and I know how hard it is, between commits, forums and social life... :lol

More seriously, could you re-consider StreamWrapper ?

Best Regards,
warhawk3407
Last edited by brightgamepanel on Sun Mar 10, 2013 6:27 pm, edited 1 time in total.
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby TerraFrost » Mon Feb 11, 2013 6:08 am

I'll try to take a look as time permits.

That said, my expectation is that this'll take more time than you expect. I've not created stream wrappers so I'll want to thoroughly examine how those works. And if portions of Net/SFTP.php could benefit from rewriting to better accommodate them I'll probably do that.

Like last time I did a big sorta "adaptation" of phpseclib was for the Wordpress SSH SFTP Plugin and for that one I wound up making chmod recursive along with the delete functions. They were good changes that made phpseclib a better project but it did make it more of a project for me than it would have been for someone else. ie. someone else could have just been like "oh, they're not recursive? Guess I'll have to work with what I got even if I don't like it" whereas me? If I don't like it I'll change it.

Anyway, just FYI...
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Mon Feb 11, 2013 6:40 pm

Hi,

No problem, I will wait necessary time :)

You don't start from scratch, I tried to give you a good starting point and useful links, in order to save you some time. Thank you Terra :D

I would like to add that you have done a very good work with this library, and everyone on this forum should say you : "Thanks" :)

Best Regards,
warhawk
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby TerraFrost » Sat Feb 16, 2013 7:50 pm

So as an update... my latest two commits are working towards this.

https://github.com/phpseclib/phpseclib/ ... f011898c7f

With streams you can fseek() and fwrite() in the middle of a file. With phpseclib 0.3.1 however you can't. This commit remedies that deficiency.

Also...

https://github.com/phpseclib/phpseclib/ ... 0d6b04dd37

That's for touch, over streams, which itself calls streamWrapper::stream_metadata in PHP 5.4+. Still need to do chown and chgrp. That's a bit tricky however as SFTP doesn't let you set one or the other but rather both or none. If you want to change the owner phpseclib could do a stat to get the original group and then change the owner to the new owner and the group to the old group but that wouldn't be that efficient if done recursively. I sent an email out to the IETF SFTP working group to see how others dealt with this problem.
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Mon Feb 18, 2013 7:50 pm

Great ! I will check this carefully this week !

Have you tested my class that implements the protocol as a stream wrapper ?
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby TerraFrost » Thu Feb 21, 2013 4:48 am

It's going slowly. Reason for this is two fold - I'm aiming for comprehensiveness. Hence my implementing touch / chown / chgrp (which btw have been implemented now) in Net_SFTP. Also, at the end of the day, it's probably going to be me who has to support it so I need to understand it pretty thoroughly. Well not just it but just the streamwrapper interface. To wit I've filed two bug reports on php.net:

https://bugs.php.net/bug.php?id=64238
https://bugs.php.net/bug.php?id=64246

That said, I was recently inspired by this article and am playing around with using SplFixedArray in Math_BigInteger instead of arrays, which is itself taking a while. And I've been spending a good amount of time this week providing phpseclib support via email and fixing an issue with the Wordpress adaptation of phpseclib:

http://wordpress.org/support/topic/inst ... ?replies=9

Anyway it'll be done when it's done. I appreciate your enthusiasm but asking me for status updates once a week or whoever often... well it reminds me of my employer in an unpleasant way. At work I can't give unrealistic ETA's because my boss will likely know. But at the same time the ETAs I do give don't give me time to pursue tangential topics. Like "ooh - that's interesting - let me play around with that for the time being!".

That said, phpseclib is, at the end of the day, a pet project. Something I'm doing for fun. And if pursuing a tangential project I want to be able to do so without having to justify myself to anyone - without having to provide a breakdown of how I've allocated the time that I've been allotted etc. That I'm playing around with SplFixedArray and fixed a few issues with the Wordpress plugin is entirely my business and is not something that I feel is anyone's business but my own. At least for the time being.

Anyway just FYI. I appreciate your patience and understanding. Thanks.
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Thu Feb 21, 2013 4:38 pm

Hello TerraFrost,

It's going slowly. Reason for this is two fold - I'm aiming for comprehensiveness. Hence my implementing touch / chown / chgrp (which btw have been implemented now) in Net_SFTP. Also, at the end of the day, it's probably going to be me who has to support it so I need to understand it pretty thoroughly. Well not just it but just the streamwrapper interface.


There is no problem about time :) I'm like you, I like to understand what I'm doing : view the whole aspect of the problem, what it affects, what it implies ... Finally thinking the thing, not only pressing my keyboard keys in order to "produce code" , even if it takes a lot of time :D Only other developers can understand how it may be long to develop / implement new functions or extensions to a software :)
Your addition to phpseclib with this commit is very useful, we will have a powerful alternative solution to the current PHP SSH2 extension :8

Anyway it'll be done when it's done


Okay :8 I don't want to stress you about that in no way, take your time :)

I appreciate your enthusiasm but asking me for status updates once a week or whoever often... well it reminds me of my employer in an unpleasant way. At work I can't give unrealistic ETA's because my boss will likely know. But at the same time the ETAs I do give don't give me time to pursue tangential topics.

[...]

That said, phpseclib is, at the end of the day, a pet project. Something I'm doing for fun. And if pursuing a tangential project I want to be able to do so without having to justify myself to anyone - without having to provide a breakdown of how I've allocated the time that I've been allotted etc.


I apologize for this, this not what I expected by doing this. I'm also working on what you call a "pet project" during my spare time. I'm also doing this for fun and I don't want to oppress you with my request.
We are working on different part of code with several developers and in order to plan our future works, we have to know when "it may be ready" in order to continue extending our software.
I would like also add that in software development, communication is very important. That's why I'm trying to keep in touch with you because I'm very interested in this beautiful project.
I will watch phpseclib/phpseclib repo on GitHub and I will check commits, like that I will be noticed when you push an update about the wrapper and you will be freed of my ETAs requests :D

So please, do not assimilate me to your boss anymore :lol

Finally, I will answer this thread if I have some news about the SFTP driver (if I find something interesting for us) or if you have got any questions to submit me (do not hesitate to ask me your questions).

Best Regards,
Warhawk3407
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Re: Pseudo-StreamWrapper for SFTP (PHPSecLib)

Postby brightgamepanel » Tue Feb 26, 2013 5:34 pm

Hello TerraFrost,

I have created a repository on GitHub concerning this class / stream_wrapper: https://github.com/warhawk3407/StreamWrappers_PHPSecLib

I have applied some updates to the original piece of code I gave you.

Best Regards
warhawk
Last edited by brightgamepanel on Wed Mar 13, 2013 11:15 am, edited 1 time in total.
brightgamepanel
Traveler
 
Posts: 48
Joined: Sun Jan 06, 2013 9:33 pm

Next

Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 0 guests

cron