masneyb / gftp

gFTP is a free multithreaded file transfer client for *NIX based machines. 56 language translations available.
http://www.gftp.org
MIT License
116 stars 21 forks source link

Preserve file permissions broken #142

Open MartinX3 opened 2 years ago

MartinX3 commented 2 years ago

Regardless if I enable or disable the setting, gftp always changes the file permissions. If I send the file from my local computer to the webspace, the file in the webspace now has the same permissions like on my local computer. This breaks the website, since of course on my local computer only the owner and the group can read the file but on the webspace everyone needs to read the file as a visitor.

wdlkmpx commented 2 years ago

I need to perform some tests to see how the file permission stuff works

But I think the preserve_permissions option must be removed

I have a file that has the following permissions

-rwxr-xr-x vivaldi-stable_3.8.2259.42-1_i386.deb

But vsftpd reports (using LIST command):

-rw-r--r-- vivaldi-stable_3.8.2259.42-1_i386.deb

As you can see, (some) FTP servers report wrong permissions

Perhaps FTP servers don't report the true file permissions but the permissions granted to the FTP client (this always seem to be the case with MLSD)

MLSD: permission handling is completely broken, and servers may report permissions that don't map to UNIX permissions, so overall the feature can be considered broken and must be removed.

But I'm not sure that will fix the issue you're seeing, I'll perform tests to get a better picture of the situation ...

MartinX3 commented 2 years ago

Thank you for your response.

In my case the permissions on my site and the server site are correct if I look in my terminal / in SSH. In my case gftp just overrides the server file permission with my local permission each time. But I can correct it with the "edit permission" dialogue of gftp or via SSH.

wdlkmpx commented 2 years ago

Well it shouldn't override default file permissions if the preserve_permissions setting is disabled

It works as expected with the FTP protocol, I just verified that vsFTPd reports the real permissions, I was looking in a different directory. If using MLSD, some servers will report stuff that doesn't map to unix permissions, so it's "partially" broken when it comes to applying permissions after downloading files, depends on the server.

Now I have to see how it works with SFTP, it's probably specifying file permissions when uploading a file or something, and the preserve_permissions setting doesn't change the behavior, I'm speculating https://serverfault.com/questions/283492/how-to-specify-file-permission-when-putting-a-file-using-openssh-sftp-command I have to test

MartinX3 commented 2 years ago

Oh, yes, I use SSH FTP (SFTP)

wdlkmpx commented 2 years ago

Sorry for the long delay. I've been unable to set up a local SSH server, but I did upload a few files to source forge, files with unsuitable permissions and those permissions were not preserved, so SF is setting its default permissions

It's easy for to you determine if gFTP is actually the culprit, upload files with permissions 600, 644, 755, 777 and so on, if all those permissions are preserved then it may be gftp, otherwise the server is applying some defaults

And the log reveals info, when gftp preserves permissions, you'll see that in the log, it explicitly tells you whether it succeeded changing permissions after uploading files, copying and pasting some lines would not be a bad idea

MartinX3 commented 2 years ago

Ah, preserve permission sets the permissions of my local computer file on the ftp storage.

And the other permissions seems to be the server default. Thank you for your help.

In the first place I thought preserving the permissions means that it won't change the file permission of the file on the server, if gFTP overrides an existing file.