Bug 345687 - Dolphin does not respect default umask settings of a SFTP server
Summary: Dolphin does not respect default umask settings of a SFTP server
Status: RESOLVED NOT A BUG
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: SFTP (show other bugs)
Version: 18.04.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Andreas Schneider
URL:
Keywords:
: 471972 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-03-30 10:19 UTC by Ralph Moenchmeyer
Modified: 2023-07-06 11:05 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch for kio-extras (753 bytes, patch)
2015-04-10 08:27 UTC, Andreas Schneider
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Moenchmeyer 2015-03-30 10:19:19 UTC
The SSH configuration for the internal SFTP mechanism on a server allows for umask settings in form of 

ForceCommand internal-sftp -u 0007
Additionally one could set umask in /etc/pam.d/sshd.  

A lot of SFTP clients respect such umask settings on teh server as a default not only for 
* new directories/files freshly and directly created on the server 
* but also for files/directories  transferred - often via a drag and drop mechanism in the GUI.  

Examples for clients who respect the server's umask settings are the Linux CLI sftp command,  Filezilla but also WinSCP for Windows.  In additiion some SFTP clients as WinSCP notably offer a possibility to define the default umask to be used for transferred files/dirs.  

However, neither Dolphin nor Konqueror respect the server's umask settings. E.g. for transferred files the rights for "owner, group, others" are set on the server exactly (!) to what was given on the local machine. The servers default umask is completely ignored. (Probably the transfer for both named clients is handled by the same kio slaves?) 

Why is this a problem and in my opinion a bug ? Of course one could argue that a FTP client should be able to set and change the file rights on the server.  Yes, clearly, but what about a default (!) rights setting if the server explicitly defines one  - and the SFTP client (as dolphin) unfortuantely does not give the user any  possibility to set such a default umask ? So my reasons are:  

Reason 1: 
A direct copy of rights would only be meaningful, if one could assume that the user/group context and respective relations and rights are the same on the server as local. However, this should not be assumed. Especially not in development projects. Whereas locally an umask of 0022 may make sense - on an SFTP server a default setting of 0007 may be more meaningful e.g. in development projects.  
  
Reason 2: As dolphin offers no possibility for the user to set a standard default umask for file transfers the servers default settings should be respected.  

As dolphin works now, one has to prepare the rights locally already to  what we want them to be on the server. Or one has to change the rights manually on the server after the transfer. You could argue: Use ACLs on the server. But on hosted server you do not always have this chance. In addition we have no chance to control the rights settings via ~/.profile or ~/.bashrc settings on the server if a shell login is not allowed and key-authentication is used.        

So, please, correct dolphin to accept SFTP server umask settings. 

If you (in contrast to my personal opinion) think the present behaviour of dolphin as a SFTP client is not a bug - change this to a feature request.      


Reproducible: Always

Steps to Reproduce:
1. Set up a default umask on the SFTP server (ssh sft-internal)  
2. Transfer files with sftp, Filezilla or WinSCP (in standard configuration) and watch the resulting rights on the server. They corespond tio teh sever's umask settings.  
3. Transfer files with Dolphin (or/and Konqueror) and find the file rights on the server to be a copy of the local rights settings  

Actual Results:  
With Dolphin the right settings are copied to the server - i.e. they are set on the server exactly to what was given locally.  

Expected Results:  
The umask settings of the server should be respected - if the user does not define a specific default mask ( which he/she cannot do with dolphin). 

In addition to enable server umask settings make it possible for teh user to define a default umask according to his wishes. (But this is certainly a feature request).
Comment 1 Emmanuel Pescosta 2015-04-02 06:04:46 UTC
Thanks for the detailed bug report! :)

Dolphin uses KIO (in this case the sftp ioslave) for all file operations, so this problem has to be fixed in the ioslave itself. I'll reassign it.
Comment 2 Andreas Schneider 2015-04-10 08:27:27 UTC
Created attachment 91975 [details]
patch for kio-extras

This might fix the issue. But I do not have time to test that right now ...
Comment 3 Harald Sitter 2020-03-05 14:51:52 UTC
What Andreas proposed wouldn't actually change anything. The open() isn't the problem. The process umask does apply when creating a file. The problem is the chmod() when the transfer is complete because chmod is not subject to umasking (otherwise you couldn't ever set more liberal permissions than the umask allows).

The trouble is that we must chmod from an API POV. Permissions are either present or not, and when they are present they ought to be applied unless the file already exists on the remote. 

https://api.kde.org/frameworks/kio/html/classKIO_1_1CopyJob.html#a3bd4dda22a3bd50adf195542d9d009ad
https://api.kde.org/frameworks/kio/html/classKIO_1_1SlaveBase.html#a1f382438285d8f1112e9340f3c0e8bbf

When the client (e.g. dolphin) sets setDefaultPermissions=true the current code would behave exactly as expected and documented. But since the client does not, we ought to obey the API expectation that the permissions given to the sftp slave will be fully applied to the resulting file, hence the chmod. This is also in line with how this works for ftp (which is slightly more core than sftp).

All that said, currently this is not a bug. This may change per bug #418499
Comment 4 Harald Sitter 2023-07-06 11:05:25 UTC
*** Bug 471972 has been marked as a duplicate of this bug. ***