KIO-SFTP backport #279

Merged
blu.256 merged 3 commits from feat/kio-sftp-backport into master 2 years ago
Collaborator

This PR is a backport of a version of the SFTP ioslave based on libssh.

This was based on the KDE2 port I mentioned in issue #276 and the actual KDE5 version of kio-sftp.

Basic testing suggests it mostly works, but there are some issues. This list is not exhaustive:

What works

  • Browsing directories
  • Opening most files via TDEParts
  • File previews
  • Moving/renaming files
  • Creating directories
  • Copying files (local & remote)
  • Symlinks

What does not work

  • Opening symlinks fixed.
  • Putting files, either by copying a local file or by creating one (results in a crash) fixed.
  • URLs with no usernames (hangs?)

Needs testing

  • Public key authentication

Other issues

  • Random hangs probably fixed.
  • The password dialog pops up too many times. fixed.
This PR is a backport of a version of the SFTP ioslave based on libssh. This was based on the KDE2 port I mentioned in issue #276 and the actual KDE5 version of `kio-sftp`. ~~Basic testing suggests it mostly works, but there are some issues. This list is not exhaustive:~~ ## What works * Browsing directories * Opening most files via TDEParts * File previews * Moving/renaming files * Creating directories * Copying files (local & remote) * Symlinks ## What does not work * ~~Opening symlinks~~ **fixed.** * ~~Putting files, either by copying a local file or by creating one (results in a crash)~~ **fixed.** * URLs with no usernames (hangs?) ## Needs testing * Public key authentication ## Other issues * ~~Random hangs~~ **probably fixed.** * ~~The password dialog pops up too many times.~~ **fixed.**
blu.256 added the PR/wip label 2 years ago
Owner

Great, good work. I was planning to work on this myself at some point, but you have been quicker :-)
If you work on solving the remaining issues, then I will have a look. Unless you prefer I first take a look at the existing code.

Great, good work. I was planning to work on this myself at some point, but you have been quicker :-) If you work on solving the remaining issues, then I will have a look. Unless you prefer I first take a look at the existing code.
Owner

Btw, good to mentioned in the commit where we copy the backported code from and that it is available under GPL2 license.

Btw, good to mentioned in the commit where we copy the backported code from and that it is available under GPL2 license.
blu.256 force-pushed feat/kio-sftp-backport from 5228777376 to e506638fda 2 years ago
Poster
Collaborator

I'll finish with the remaining issues probably tomorrow.

I'll finish with the remaining issues probably tomorrow.
Owner

no worries, ping me when this is ready for review and I will do so.

no worries, ping me when this is ready for review and I will do so.
Poster
Collaborator

@MicheleC Looks like I finished much earlier than I expected. The issues were trivial after all.

@MicheleC Looks like I finished much earlier than I expected. The issues were trivial after all.
blu.256 requested review from MicheleC 2 years ago
Poster
Collaborator

I can say that the IOSlave seems fully functional at this point with the features I tested.

Special attention in testing should be paid to public key authentication (it's the first that the code tries anyway) because I'm not sure whether it works. I tried to imitate the code of the latest (KDE5) version for this auth method so it could work fine. Password authentication works normally.

I can say that the IOSlave seems fully functional at this point with the features I tested. Special attention in testing should be paid to public key authentication ([it's the first that the code tries anyway](https://mirror.git.trinitydesktop.org/gitea/TDE/tdebase/src/commit/f68d8c58879266e687a6217ca5e2faef7b463235/tdeioslave/sftp/tdeio_sftp.cpp#L740)) because I'm not sure whether it works. I tried to imitate the code of the latest (KDE5) version for this auth method so it *could* work fine. Password authentication works normally.
blu.256 force-pushed feat/kio-sftp-backport from f68d8c5887 to c360b08b7e 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from d21debe5af to 36965d7e5f 2 years ago
Poster
Collaborator

Upd.: nevermind the TDEParts issue, I must have missed Slavek's TDEIO patch.

Upd.: nevermind the TDEParts issue, I must have missed Slavek's TDEIO patch.
MicheleC requested changes 2 years ago
MicheleC left a comment
Owner

Please amend as per comment

Please amend as per comment
extern "C"
{
int KDE_EXPORT kdemain( int argc, char **argv )
int kdemain( int argc, char **argv )
Owner

KDE_EXPORT is required to make sure the symbol is visible when building with hidden visibility enabled. Otherwise the tdeio slave can't be found and can't be loaded.
int KDE_EXPORT kdemain(

KDE_EXPORT is required to make sure the symbol is visible when building with hidden visibility enabled. Otherwise the tdeio slave can't be found and can't be loaded. ```int KDE_EXPORT kdemain(```
blu.256 marked this conversation as resolved
Owner

Seems to work fine, I could connect to a server on another computer on a local network and use the remote files with ease.

URLs with no usernames (hangs)

Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed.

Good job!

Seems to work fine, I could connect to a server on another computer on a local network and use the remote files with ease. > URLs with no usernames (hangs) Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed. Good job!
Poster
Collaborator

Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed.

Might be a distribution issue then.

> Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed. Might be a distribution issue then.
Owner

I use a static IP as url (like sftp://aaa.bbb.ccc.ddd), not sure if this makes any difference.
I suggest we merge it and ask those users who had problem to test out the new package. If the username-less URL becomes a problem, we will fix it as a separate issue. In any case existing sftp does not work in recent distro apparently, so no much to lose in it.

I use a static IP as url (like sftp://aaa.bbb.ccc.ddd), not sure if this makes any difference. I suggest we merge it and ask those users who had problem to test out the new package. If the username-less URL becomes a problem, we will fix it as a separate issue. In any case existing sftp does not work in recent distro apparently, so no much to lose in it.
Poster
Collaborator

I agree. Anything to do before I squash and merge?

I plan to squash it all to one commit:
Replaced tdeio-sftp with backported version

I agree. Anything to do before I squash and merge? I plan to squash it all to one commit: `Replaced tdeio-sftp with backported version`
Owner

Before you merge, one more thing.
I will comment in the code.

Before you merge, one more thing. I will comment in the code.
Poster
Collaborator

Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed.

Actually the dialog just showed up, but it took a minute or two for it to open, while with username in URL it connects immendately.

> Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed. Actually the dialog just showed up, but it took a minute or two for it to open, while with username in URL it connects immendately.
Owner

Before you merge, one more thing.
I will comment in the code.

Sorry, ignore previous comment. I was confused about something, but it is fine.

Squash into one commit sounds good. Make sure the message retains a link to the original source that we imported, again to state that it is GPL2 licensed.

> Before you merge, one more thing. > I will comment in the code. Sorry, ignore previous comment. I was confused about something, but it is fine. Squash into one commit sounds good. Make sure the message retains a link to the original source that we imported, again to state that it is GPL2 licensed.
blu.256 removed the PR/wip label 2 years ago
Owner

Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed.

Actually the dialog just showed up, but it took a minute or two for it to open, while with username in URL it connects immendately.

Interesting. I noticed a 2-3 secs delay here, on local network.... maybe something you can try debugging, see if you can understand while it takes longer without specifying the user (unless it is the server side being slow...)

> > Seems to work fine here. The urls I tried did not have a username: a dialog opened asking for user/password and that is all that was needed. > > Actually the dialog just showed up, but it took a minute or two for it to open, while with username in URL it connects immendately. Interesting. I noticed a 2-3 secs delay here, on local network.... maybe something you can try debugging, see if you can understand while it takes longer without specifying the user (unless it is the server side being slow...)
blu.256 force-pushed feat/kio-sftp-backport from 6a56948b41 to c1e434f1c6 2 years ago
Poster
Collaborator

Squashed commit ready. Please have a look at the commit message.

Squashed commit ready. Please have a look at the commit message.
Poster
Collaborator

Interesting. I noticed a 2-3 secs delay here, on local network.... maybe something you can try debugging

I think I'll look into it after the merge.

Also, should this be backported or is it only for R14.1.0?

> Interesting. I noticed a 2-3 secs delay here, on local network.... maybe something you can try debugging I think I'll look into it after the merge. Also, should this be backported or is it only for R14.1.0?
Owner

Interesting. I noticed a 2-3 secs delay here, on local network.... maybe something you can try debugging
I think I'll look into it after the merge.

for reference, trying to connect here (sftp://itcsubmit.wustl.edu) shows the dialog in a couple of seconds.

Also, should this be backported or is it only for R14.1.0?

That is a good question. The code is quite different, so in theory it should go into R14.1.0 only. But given that tdeio_sftp does not work in R14.0.12 with recent distros, IMO it makes sense to backport this to R14.0.x too. @SlavekB what do you think?

>> Interesting. I noticed a 2-3 secs delay here, on local network.... maybe something you can try debugging > I think I'll look into it after the merge. for reference, trying to connect here (sftp://itcsubmit.wustl.edu) shows the dialog in a couple of seconds. > Also, should this be backported or is it only for R14.1.0? That is a good question. The code is quite different, so in theory it should go into R14.1.0 only. But given that tdeio_sftp does not work in R14.0.12 with recent distros, IMO it makes sense to backport this to R14.0.x too. @SlavekB what do you think?
MicheleC approved these changes 2 years ago
MicheleC left a comment
Owner

Looks good

Looks good
Poster
Collaborator

for reference, trying to connect here (sftp://itcsubmit.wustl.edu) shows the dialog in a couple of seconds.

Indeed, so it might be dependent on the SSH/SFTP server after all.

> for reference, trying to connect here (sftp://itcsubmit.wustl.edu) shows the dialog in a couple of seconds. Indeed, so it might be dependent on the SSH/SFTP server after all.
Owner

Also, should this be backported or is it only for R14.1.0?

That is a good question. The code is quite different, so in theory it should go into R14.1.0 only. But given that tdeio_sftp does not work in R14.0.12 with recent distros, IMO it makes sense to backport this to R14.0.x too. @SlavekB what do you think?

It does not make any change API/ABI, so there nothing that would fundamentally block the backport to R14.0.x. It is clear that it is definitely solving the problem, so it seems to be a good idea to do backport.

Regarding squash into single commit: There could be useful to leave the initial backport as one commit and subsequent fixes and improvements as another commit. But I have no objection if you want to leave it as one commit.

> > Also, should this be backported or is it only for R14.1.0? > > That is a good question. The code is quite different, so in theory it should go into R14.1.0 only. But given that tdeio_sftp does not work in R14.0.12 with recent distros, IMO it makes sense to backport this to R14.0.x too. @SlavekB what do you think? > It does not make any change API/ABI, so there nothing that would fundamentally block the backport to R14.0.x. It is clear that it is definitely solving the problem, so it seems to be a good idea to do backport. Regarding squash into single commit: There could be useful to leave the initial backport as one commit and subsequent fixes and improvements as another commit. But I have no objection if you want to leave it as one commit.
SlavekB requested changes 2 years ago
SlavekB left a comment
Owner

I did not test functionality, but there are some unexpected changes that relate to translations. It seems that something should be done with it.

I did not test functionality, but there are some unexpected changes that relate to translations. It seems that something should be done with it.
##### create translation templates ##############
tde_l10n_create_template( "tdeio_sftp" )
Owner

Why is the generation of translation templates removed? Obviously, in the source code some texts are suitable for translation – there are calls i18n().

Why is the generation of translation templates removed? Obviously, in the source code some texts are suitable for translation – there are calls `i18n()`.
blu.256 marked this conversation as resolved
SOURCE sftp.protocol
DESTINATION ${SERVICES_INSTALL_DIR}
PO_DIR tdeioslave-desktops
#PO_DIR tdeioslave-desktops
Owner

Why is the use of translations for the tdeioslave-desktops template removed here?

Why is the use of translations for the `tdeioslave-desktops` template removed here?
blu.256 marked this conversation as resolved
moving=true
Icon=ftp
Description=A tdeioslave for sftp
Description=A new tdeioslave for sftp
Owner

It looks like an unnecessary change of description.

It looks like an unnecessary change of description.
blu.256 marked this conversation as resolved
Owner

It does not make any change API/ABI, so there nothing that would fundamentally block the backport to R14.0.x. It is clear that it is definitely solving the problem, so it seems to be a good idea to do backport.

Sounds good 👍

> It does not make any change API/ABI, so there nothing that would fundamentally block the backport to R14.0.x. It is clear that it is definitely solving the problem, so it seems to be a good idea to do backport. Sounds good 👍
blu.256 referenced this issue from a commit 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from c1e434f1c6 to 376c445647 2 years ago
blu.256 referenced this issue from a commit 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from 376c445647 to 61a15f23e3 2 years ago
blu.256 referenced this issue from a commit 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from 61a15f23e3 to eec5c5e764 2 years ago
blu.256 requested review from SlavekB 2 years ago
Poster
Collaborator

@SlavekB Translations and ioslave description should be OK now. I split it all into two commits too.

@MicheleC Identation on line 73 fixed ;-)

@SlavekB Translations and ioslave description should be OK now. I split it all into two commits too. @MicheleC Identation on line 73 fixed ;-)
blu.256 added this to the R14.0.13 release milestone 2 years ago
blu.256 changed title from WIP: KIO-SFTP backport to KIO-SFTP backport 2 years ago
blu.256 referenced this issue from a commit 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from eec5c5e764 to c58023a394 2 years ago
Owner

I have now looked at the versions of libssh in older Debian and it seems that 0.7.x does not contain CMake files => there will probably be better to detect library using pkg-config instead of find_package.

I have now looked at the versions of `libssh` in older Debian and it seems that 0.7.x does not contain CMake files => there will probably be better to detect library using `pkg-config` instead of `find_package`.
blu.256 referenced this issue from a commit 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from c58023a394 to f6385f2b50 2 years ago
Poster
Collaborator

I have now looked at the versions of libssh in older Debian and it seems that 0.7.x does not contain CMake files => there will probably be better to detect library using pkg-config instead of find_package.

Like this?

  pkg_search_module( LIBSSH libssh )
  if( NOT LIBSSH_FOUND )
    tde_message_fatal( "LibSSH is required, but was not found on your system" )
  endif( )
> I have now looked at the versions of libssh in older Debian and it seems that 0.7.x does not contain CMake files => there will probably be better to detect library using pkg-config instead of find_package. Like this? ``` pkg_search_module( LIBSSH libssh ) if( NOT LIBSSH_FOUND ) tde_message_fatal( "LibSSH is required, but was not found on your system" ) endif( ) ```
Owner

Changing the way of detection libssh is good. Unfortunately, it turned out that there would be necessary other modifications to ensure compatibility with libssh on all supported distributions (Xenial - 0.6.3, Stretch - 0.7.3).

Changing the way of detection libssh is good. Unfortunately, it turned out that there would be necessary other modifications to ensure compatibility with libssh on all supported distributions (Xenial - 0.6.3, Stretch - 0.7.3).
Owner

I think about two options:

  1. Pay efforts to solve compatibility with libssh < 0.8.x – ie to 0.6.x to allow use of libssh from older distributions. As a sample there can be sftp from kio-extras 15.12.3 from Ubuntu Xenial.
  2. For Stretch require libssh 0.8.x from Stretch-backports and for Xenial to do our own backport. Both we would add to our build-dependencies.

What is your opinion?

I think about two options: 1. Pay efforts to solve compatibility with libssh < 0.8.x – ie to 0.6.x to allow use of libssh from older distributions. As a sample there can be sftp from kio-extras 15.12.3 from Ubuntu Xenial. 2. For Stretch require libssh 0.8.x from Stretch-backports and for Xenial to do our own backport. Both we would add to our build-dependencies. What is your opinion?
Owner

If it does not require too much effort, I think option 1 would be preferable.

If it does not require too much effort, I think option 1 would be preferable.
Poster
Collaborator

Will do.

Will do.
blu.256 force-pushed feat/kio-sftp-backport from 8f091690b1 to 0bbb1684a0 2 years ago
Poster
Collaborator

@SlavekB can you please test the latest changes?

@SlavekB can you please test the latest changes?
blu.256 force-pushed feat/kio-sftp-backport from 0bbb1684a0 to b3f53c3910 2 years ago
SlavekB requested changes 2 years ago
SlavekB left a comment
Owner

There seems to be the last two calls that need to treat for the libssh API < 0.7.90. See comments below.

There seems to be the last two calls that need to treat for the libssh API < 0.7.90. See comments below.
/* get the hash */
ssh_key serverKey;
#if LIBSSH_VERSION_INT < SSH_VERSION_INT(0, 7, 0)
if (ssh_get_publickey(mSession, &serverKey) < 0) {
Owner

It seems that this change in the API (ssh_get_server_publickey) actually occurred with 0.7.90 (like 0.8.0~pre), while in 0.7.x the branch remains valid original call ssh_get_publickey.

It seems that this change in the API (`ssh_get_server_publickey`) actually occurred with 0.7.90 (like 0.8.0~pre), while in 0.7.x the branch remains valid original call `ssh_get_publickey`.
SlavekB marked this conversation as resolved
<< mHost << "? " << mConnected << endl;
/* write the known_hosts file */
kdDebug(TDEIO_SFTP_DB) << "Adding server to known_hosts file." << endl;
if (ssh_session_update_known_hosts(mSession) != SSH_OK) {
Owner

For libssh API older than 0.7.90 you need to use ssh_write_knownhost instead of ssh_session_update_known_hosts.

For libssh API older than 0.7.90 you need to use `ssh_write_knownhost` instead of `ssh_session_update_known_hosts`.
SlavekB marked this conversation as resolved
SlavekB force-pushed feat/kio-sftp-backport from b3f53c3910 to 462db8b954 2 years ago
Owner

To move forward, I have made changes related to compatibility for older versions of libssh, which I mentioned in the previous revise. Therefore, it is now ready to do rebase and we can go to merging.

To move forward, I have made changes related to compatibility for older versions of libssh, which I mentioned in the previous revise. Therefore, it is now ready to do rebase and we can go to merging.
SlavekB approved these changes 2 years ago
SlavekB left a comment
Owner

Tested builds with older and also with current libssh and everything looks ready for merge.

Tested builds with older and also with current libssh and everything looks ready for merge.
blu.256 referenced this issue from a commit 2 years ago
blu.256 force-pushed feat/kio-sftp-backport from 462db8b954 to d6db1a583c 2 years ago
blu.256 merged commit d6db1a583c into master 2 years ago
blu.256 deleted branch feat/kio-sftp-backport 2 years ago
blu.256 referenced this issue from a commit 2 years ago
Poster
Collaborator

Merged and backported for R14.0.13.

Merged and backported for R14.0.13.
Owner

Great, well done @blu.256!

Great, well done @blu.256!

Reviewers

MicheleC approved these changes 2 years ago
SlavekB approved these changes 2 years ago
The pull request has been merged as d6db1a583c.
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Reference: TDE/tdebase#279
Loading…
There is no content yet.