alienatedsec / yi-hack-v5

Even newer Custom Firmware for Xiaomi Cameras based on Hi3518ev200 Chipset. It includes free RTSP, ONVIF and other improvements based on the work by roleoroleo
GNU General Public License v3.0
739 stars 87 forks source link

FTP "Create directory tree" issues #337

Closed fraserp closed 2 months ago

fraserp commented 4 months ago

I'm not sure if this is a problem with the FTP server (FileZilla Server, Windows) or the way the FTP Upload works on the camera but when I enable "Create directory tree" on Yi-Hack-V5 (0.4.1e) the video files do not upload. When I turn it off, they do, but of course all to the FTP root directory with unhelpful filenames ({xx}M{yy}S.mp4) to all be in the same folder.

The FileZilla FTP log shows the following:

<Date/Time> Info [Type] Message
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 220-FileZilla Server 1.8.1
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 220 Please visit https://filezilla-project.org/
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Command] USER yi-cam
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 331 Please, specify the password.
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Command] PASS ****
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 230 Login successful.
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Command] TYPE I
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Response] 200 Type set to I
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Command] EPSV
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Response] 229 Entering Extended Passive Mode (|||49989|)
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Command] STOR videos/2024Y02M02D07H/45M00S.mp4
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Response] 550 This function is not supported on this system.
<09/02/2024 13:16:28> FTP Server [Status] Session 47 ended gracefully.

I've also ensure the permissions on the folder ('videos'), which I created by FTPing in via another machine, are set to 777.

Anyone managed to solve this? Am I right in thinking it could be FileZilla Server's interpretation of the STOR commend or possibly some other perm pensions issue?

fraserp commented 4 months ago

I've tried setting up a different FT server with Xlight FTP. Similar errors:

02/11/2024 11:11:39 (not login 192.168.50.205<--192.168.50.11:21) "331 Password required for yi-cam"
02/11/2024 11:11:39 (not login 192.168.50.205-->192.168.50.11:21) "PASS *****"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "230 Login OK"
02/11/2024 11:11:39 (yi-cam 192.168.50.205-->192.168.50.11:21) "TYPE I"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "200 Type set to I."
02/11/2024 11:11:39 (yi-cam 192.168.50.205-->192.168.50.11:21) "EPSV"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "229 Entering Passive Mode (|||54293|)"
02/11/2024 11:11:39 (yi-cam 192.168.50.205-->192.168.50.11:21) "STOR 2024Y02M03D09H/13M30S.mp4"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "451 Cannot create file "13M30S.mp4"."

I have also confirmed that I can write files and directories using FileZilla Client on both the FileZilla Server and the Xlight FTP Server. So I don't think its a permissions issue with the FTP server or Windows.

Again turning off 'Create Directory tree' works just fine:

02/11/2024 11:18:27 (not login 192.168.50.205<--192.168.50.11:21) "220 Xlight FTP Server 3.9 ready..."
02/11/2024 11:18:28 (not login 192.168.50.205-->192.168.50.11:21) "USER yi-cam"
02/11/2024 11:18:28 (not login 192.168.50.205<--192.168.50.11:21) "331 Password required for yi-cam"
02/11/2024 11:18:28 (not login 192.168.50.205-->192.168.50.11:21) "PASS *****"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "230 Login OK"
02/11/2024 11:18:28 (yi-cam 192.168.50.205-->192.168.50.11:21) "TYPE I"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "200 Type set to I."
02/11/2024 11:18:28 (yi-cam 192.168.50.205-->192.168.50.11:21) "EPSV"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "229 Entering Passive Mode (|||54421|)"
02/11/2024 11:18:28 (yi-cam 192.168.50.205-->192.168.50.11:21) "STOR 55M12S.mp4"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "150 Opening BINARY mode data connection for 55M12S.mp4."
02/11/2024 11:18:35 (yi-cam 192.168.50.205<--192.168.50.11:21) "226 Transfer complete (0.000 KB/s)."
02/11/2024 11:18:35 (yi-cam 192.168.50.205-->192.168.50.11:21) "QUIT"
02/11/2024 11:18:35 (yi-cam 192.168.50.205<--192.168.50.11:21) "221 Good-Bye"

Happy to try any suggestions.

alienatedsec commented 4 months ago

Ill try with my QNAP FTP server - I am sure I have done it already when tested but could be wrong.

fraserp commented 4 months ago

My guess is that some FTP clients don't allow STOR to create both the file and the folder, so in this instance its failing to create the file because the folder is missing. No idea what the FTP protocal spec says for this. So perhaps a MKDIR to create the folder first would solve this? (assuming also this would fail or be skipped itself if a folder of that name exists?)

github-actions[bot] commented 3 months ago

This issue has been stale for 30 days - it will be closed within the next 7 days if not updated

fraserp commented 3 months ago

Has anything been changed that I need to test? Or is the auto-close just set to be a bit aggressive about "won't fix" issues?

alienatedsec commented 3 months ago

Apologies @fraserp

The bot option is to get rid of stale issues, so there is some clarify of which issues are still persistent.

While I haven't used the FTP for a while I had to set it up myself. I use QNAP QuFTP service app and this was the outcome with folders created as expected. The modified date is recent as created recently :)

image

The config page looks like this.

image

fraserp commented 3 months ago

My FTP settings are the same... so as I suggested in a previous comment I suspect some FTP clients don't create a folder if not present when the STOR command is sent and instead return an error .. or at leas that's my guess

github-actions[bot] commented 2 months ago

This issue has been stale for 30 days - it will be closed within the next 7 days if not updated

fraserp commented 2 months ago

Gosh, this bot really doesn't like this issue!

alienatedsec commented 2 months ago

I would need your setup with me to recreate and possibly fix it. That is neither efficient nor feasible. I can implement or merge pull requests if you have a fix or point at the code or solution that works.

Otherwise, the bot closed it as it was stale for another 30 days - people always forget about issues they raised even if those are being resolved.