Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libssh implementation #523

Merged
merged 1 commit into from
Nov 5, 2022
Merged

Conversation

markjfisher
Copy link
Contributor

@markjfisher markjfisher commented Nov 5, 2022

Here's my merge of the https://github.com/tnn2/esp-idf-libssh code to implement libssh.

It's mostly a straight copy of src and include dirs.

One issue I had was that libssh uses the include of "config.h", but because of the way the project is setup that includes the libsmb2 generated one, as the include path has:

/path/to/fujinet-platformio/components/libsmb2/include/esp

which means anyone doing

#include "config.h"

gets the file under smb2. sad-panda.

So I manually changed all those to "libssh/config.h"

I've merged the "compat" files that are in the esp-idf-libssh directly into the tree, rather than having it separate. This could be changed, but again is complicated by there being multiple "config.h" files all over the place.
Instead, I merged compat/config.h into libssh/config.h

The only major changes I had to make was by blocking out some code (using LIBSSH_FUJINET define) in options.c, as it is hardwired to require a config dir to try and read some defaults from, and tries to read from "~/.ssh" by default.

There are several files not moved across, because they were not referenced in https://github.com/tnn2/esp-idf-libssh/blob/master/components/libssh/CMakeLists.txt so that build wasn't using them anyway.
Investigating, most are openssl requiring files, but it would be worth getting a second pair of eyes on this.

Note, as in the original SSH.cpp, there is no host validation nor config reading, which leaves the implementation a little fragile to MITM attacks etc.

I did try to enable pthread, but ssh init failed and I couldn't debug it, I was getting weird issues of the unicode sequence for FFFD being spammed to the monitor console whenever I add any debug to init.c, so I stopped trying to get pthread support after an hour of problems.

There are very few changes to the original c files in libssh. I've included a diff file between them below.
This is only for the files I copied into the project.
libssh-diffs.txt
This was generated with the script:

#!/bin/bash

SRC=/home/markf/dev/personal/atari/fujinet/esp-idf-libssh/components/libssh/libssh/src/
TGT=/home/markf/dev/personal/atari/fujinet/fujinet-platformio/lib/libssh/src

find $SRC -name \*.c\* | while read c
do
  JUST_FILE=${c#$SRC}
  TGT_FILE=${TGT}/${JUST_FILE}
  echo "-------------------------------- comparing $JUST_FILE"
  diff -u ${SRC}${JUST_FILE} $TGT_FILE
done

I haven't delete the libssh2 dir, but I have commented out the use of esp32sshclient in modem.h

@markjfisher
Copy link
Contributor Author

markjfisher commented Nov 5, 2022

This is to fix #481

@tschak909 tschak909 merged commit 9f85f4e into FujiNetWIFI:master Nov 5, 2022
@tschak909
Copy link
Collaborator

Thank you so much!

@markjfisher markjfisher deleted the libssh-481 branch November 5, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants