Bug 395609 - New Text File is created with 600 (-rw-------) permissions
Summary: New Text File is created with 600 (-rw-------) permissions
Status: RESOLVED FIXED
Alias: None
Product: krusader
Classification: Applications
Component: general (show other bugs)
Version: 2.7.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Alex Bikadorov
URL:
Keywords: triaged
: 413389 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-06-19 13:59 UTC by gbophuk_alt
Modified: 2019-10-24 18:21 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gbophuk_alt 2018-06-19 13:59:06 UTC
KDE Frameworks 5.46.0
QT 5.9.4
Krusader 2.7.0


Reproducing:
Open fro menu File -> New Text File

What we get:
New file with 600 permissions 

What we expect:
New File with 644 permissions like in Dolphin
Comment 1 Nikita Melnichenko 2018-06-20 07:36:15 UTC
I confirm on my end. Same for Shift+F4. Permissions should be the same as when you touch the file and depend on umask setting.
Comment 2 Toni Asensi Esteve 2018-06-20 10:52:10 UTC
Confirmed using Kubuntu 18.04; this doesn't happen when creating folders, by the way.
Comment 3 Vera 2019-01-23 12:52:58 UTC
kde5-krusader-2.7.1
Bug is still actual
Comment 4 Alex Bikadorov 2019-02-17 16:30:02 UTC
Heck! I cannot find out why it's not working.
It should done by
krusader/Panel/panelfunc.cpp:522
> KIO::CopyJob *job = KIO::copy(QUrl::fromLocalFile(tempFile->fileName()),
> job->setDefaultPermissions(true);

The same way it is done by KIO for Dolphin
filewidgets/knewfilemenu.cpp:615
> KIO::CopyJob *job = KIO::copyAs(uSrc, dest);
> job->setDefaultPermissions(true);
Comment 5 gbophuk_alt 2019-02-18 13:42:22 UTC
Maybe you should write a test app?
Also I couldn't find what the default permission are in the kio docs.
Comment 6 Nikita Melnichenko 2019-02-18 18:57:12 UTC
Alex, the problem is not with the KIO::copy code. It's QTemporaryFile which is created with the restricted permissions. I think we should refactor the code and possibly remove the QTemporaryFile calls. I'm not yet sure how to deal with remote file systems. Another option is not creating a file and let editor save it. I checked that it saves with proper permissions.
Comment 7 Alex Bikadorov 2019-02-24 15:28:09 UTC
You're right Nikita, I missed that.

But this means that KIO::CopyJob::setDefaultPermissions() is not working. The documentation says it for exactly this use case - having umask applied when copying temporary files.

And AFAIK there is no way to create a file with KIO (KIO::open() seems to be only for opening existing files). All KIO code I have seen also uses the way to copy already existing files to a final destination.
Comment 8 Alex Bikadorov 2019-02-24 16:04:35 UTC
A patch that sets the permissions to 644 until the bug in KIO is fixed:
https://phabricator.kde.org/D19277
Comment 9 Nikita Melnichenko 2019-03-02 07:34:54 UTC
I checked KIO::CopyJob::setDefaultPermissions and follow up code and this piece looks suspicious:

filecopyjob.cpp:
  501     if (d->m_mustChmod) {
  502         // If d->m_permissions == -1, keep the default permissions
  503         if (d->m_permissions != -1) {
  504             d->m_chmodJob = chmod(d->m_dest, d->m_permissions);
  505             addSubjob(d->m_chmodJob);
  506         }
  507         d->m_mustChmod = false;
  508     }

Haven't debugged though since KIO likely requires special debugging environment but according to the code (d->m_permissions == -1) is exactly happens after we call setDefaultPermissions and then chmod is never called.

So far I think the best way is to handle local files differently and create them with QFile to get the default permissions. The downside is that it should be handled carefully given the async nature of that code.

Probably, we should look more into the Dolphin code. They get around it somehow.
Comment 10 Alex Bikadorov 2019-03-08 19:42:29 UTC
Fixed with commit dce5c5057c85a2d42e161f0dbd2dc6cd26c17a32.

Bug 404777 in KIO is still open.
Comment 11 Nikita Melnichenko 2019-07-01 07:19:53 UTC
Git commit 262a96c795c702c7568803b64d3c67df9625364e by Nikita Melnichenko.
Committed on 01/07/2019 at 07:10.
Pushed by melnichenko into branch 'stable'.

Fixed new file permissions

Combined and adapted the following commits from master:
dce5c5057c85a2d42e161f0dbd2dc6cd26c17a32
c6db82bcb2d61e34e1c8bfb87aade25c7fed9093

FIXED: [ 395609 ] New Text File is created with 600 (-rw-------) permissions

Differential Revision: https://phabricator.kde.org/D19277

M  +3    -6    krusader/Panel/listpanel.cpp
M  +1    -1    krusader/Panel/listpanel.h
M  +2    -3    krusader/Panel/listpanelactions.cpp
M  +2    -2    krusader/Panel/listpanelactions.h
M  +2    -11   krusader/Panel/panelcontextmenu.cpp
M  +0    -2    krusader/Panel/panelcontextmenu.h
M  +53   -41   krusader/Panel/panelfunc.cpp
M  +4    -4    krusader/Panel/panelfunc.h

https://commits.kde.org/krusader/262a96c795c702c7568803b64d3c67df9625364e
Comment 12 Alex Bikadorov 2019-10-24 18:21:08 UTC
*** Bug 413389 has been marked as a duplicate of this bug. ***