Bug 498888

Summary: New files on SFTP remote folders are created with all permission bits set/enabled
Product: [Frameworks and Libraries] kio-extras Reporter: Kishore Gopalakrishnan <kishore96>
Component: SFTPAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: gaaf, john.kizer
Priority: NOR    
Version First Reported In: 24.12.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Kishore Gopalakrishnan 2025-01-19 15:51:27 UTC
SUMMARY
When creating new files in an SFTP folder, they are created with all permissions enabled (rwx for everyone, setuid, and sticky).

STEPS TO REPRODUCE
1. Open an SFTP folder in Dolphin (in the address bar, type sftp://USERNAME@SERVER:22/PATH_TO_FOLDER)
2. Right-click in the main veiw area > Create New > text file
3. Open the same folder in the terminal (ssh) and run `ls -lh` to see the permissions of the newly created file

OBSERVED RESULT
```
-rwsrwsrwt 1 kishore kishore 0 Jan 19 18:09 test.txt*
```

EXPECTED RESULT
Sane permissions like `rw-r--r--`

SOFTWARE/OS VERSIONS
libssh 0.11.1
libssh2 1.11.1
openssh 9.9p1
sshfs 3.7.3
KDE applications: 24.12.1
Operating System: Arch Linux 
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.9-arch1-1 (64-bit)

ADDITIONAL INFORMATION
The same thing happens if we create a file in an SFTP location by saving a new document in Kate.
Comment 1 John Kizer 2025-01-23 06:14:43 UTC
Hi - thanks for your bug report! I can reproduce this on Fedora KDE 41:

$ stat --format="%a %A" "Downloads/testbugs/Text File.txt" 
7777 -rwsrwsrwt
Comment 2 Alex Hermann 2025-11-14 15:15:39 UTC
I noticed it too and submitted a merge request at: https://invent.kde.org/network/kio-extras/-/merge_requests/479
Comment 3 Méven 2025-12-01 14:08:20 UTC
Git commit edebcef5933836dd9bfc8d2cac9b68bb43d71c41 by Méven Car, on behalf of Alex Hermann.
Committed on 01/12/2025 at 13:43.
Pushed by meven into branch 'master'.

sftp: Fix detection of empty permissions

Commit 04e710b6e5674fe39d314c20c31b956298a918c8 removed the check for
mode < 0, but that is exactly what is fed to ::copy() and ::put() by
their callers.

Re-add the check and make the mode variable an int so a negative
value doesn't get lost.

M  +4    -1    sftp/kio_sftp.cpp

https://invent.kde.org/network/kio-extras/-/commit/edebcef5933836dd9bfc8d2cac9b68bb43d71c41