Skip to content

Conversation

@jdarwood007
Copy link
Member

This introduces a file system handler for package manager, bringing in FTPS and SFTP support to our package manager operations.

FTPS is handled with PHP ftp library and SFTP is handled with Phpseclib (MIT License). This simplifies and centralizes the logic for determining how to perform file system operations by using the root as a substitution for the boarddir.

The test page has been changed from xml supported to json and most of the logic moved into admin.js.

The settings page now operates as config vars. Not sure why it wasn't ever this way.

The legacy FtpConnection was moved to basically be a wrapper for the new file system caller. I didn't want to remove it as it needs to remain backwards compatible.

The code for Maintenance was updated, but since none of our tools yet use it, the logic is only in theory based on matching changes.

Additionally, I had no luck getting FTP stuff to work before hand. I made changes until things started to operate. I also tried to support using ssl:// like we did before, but this never worked for me, so I forced the use of the dedicated FTPS logic. If anyone is able to get it to work, we can better identify the file system handlings.

Finally, I know there is leagues's file system (MIT License) handler that does FTP(s), SFTP, Webdav and a few others. I thought about using it, but the only additional library I see useful for SMF to support would be webdav. If we want to redirect to using it, then we can.

Fixes #5316

This introduces a file system handler for package manager, bringing in FTPS and SFTP support to our package manager operations.

FTPS is handled with PHP ftp library and SFTP is handled with Phpseclib (MIT License).
This simplifies and centralizes the logic for determining how to perform file system operations by using the root as a substitution for the boarddir.

The test page has been changed from xml supported to json and most of the logic moved into admin.js.

The settings page now operates as config vars.  Not sure why it wasn't ever this way.

The legacy FtpConnection was moved to basically be a wrapper for the new file system caller.  I didn't want to remove it as it needs to remain backwards compatible.

The code for Maintenance was updated, but since none of our tools yet use it, the logic is only in theory based on matching changes.

Additionally, I had no luck getting FTP stuff to work before hand.  I made changes until things started to operate.  I also tried to support using ssl:// like we did before, but this never worked for me, so I forced the use of the dedicated FTPS logic.  If anyone is able to get it to work, we can better identify the file system handlings.

Finally, I know there is leagues's file system (MIT License) handler that does FTP(s), SFTP, Webdav and a few others.  I thought about using it, but the only additional library I see useful for SMF to support would be webdav.  If we want to redirect to using it, then we can.

// Hold on, do we have a 'ssl://' or 'ftps://' in the server name?
if (str_starts_with(Config::$modSettings['package_server'], 'ssl://') || str_starts_with(Config::$modSettings['package_server'], 'ftps://')) {
$server_addr = preg_replace('~^((ft|htt)ps?|ssl)?://~i', '', Config::$modSettings['package_server']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex also matches ://. Is this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't intended, but I am also now wondering, would it be harmful? Ideally, we strip out any schema from the provided server address.

* @param string $ftp_file The file to CHMOD
* @return bool Whether or not the operation was successful
*/
public function changePermissions(string $filename, string $chmod): bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docblock mismatch

jdarwood007 and others added 2 commits July 25, 2025 14:25
Remove debug code.
# Conflicts:
#	Sources/Maintenance/Tools/ToolsBase.php
#	Sources/PackageManager/FtpConnection.php
#	Sources/PackageManager/PackageUtils.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FTPS/SFTP support

3 participants