Bug 392682 - Okular ignores umask on save file as
Summary: Okular ignores umask on save file as
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 1.3.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
: 398450 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-04-03 17:42 UTC by Falk Krönert
Modified: 2018-09-10 23:33 UTC (History)
3 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 Falk Krönert 2018-04-03 17:42:46 UTC
If a pdf is saved (changed or unchanged) via "File Save As…". the resulting file has 0600 permissions, regardless of umask settings. Tested on nfs and non-nfs locations (both for the opened and the saved file).

Reproducible: always

How to test:
1. Set umask to anything other than 0077 and run okular from that shell.
2. Open a pdf file.
3. Save as a differently named pdf file.
4. Check the permissions on the original and the saved file.
Comment 1 Albert Astals Cid 2018-04-03 21:46:04 UTC
Seems the QTemporaryFile in Part::saveAs is to blame, i guess we should apply a similar solution to https://git.reviewboard.kde.org/r/122612/diff/2#index_header

Anyone has time for it?
Comment 2 Albert Astals Cid 2018-04-23 21:09:18 UTC
Git commit c5592689874f41df393b44f3ba572acc751c5645 by Albert Astals Cid, on behalf of Chinmoy Ranjan Pradhan.
Committed on 23/04/2018 at 21:07.
Pushed by aacid into branch 'Applications/18.04'.

Obey umask rules when saving new file

Summary:
Okular saves a new file with permissions 0600 completely ignoring the umask value. This is because it
makes use of QTemporaryFile which creates file with the said permissions and which then Okular copies
to the new location.
So to overcome this generate new file permissions using old mask value and change permissions of the
new file.

Test Plan:
Set umask to 0040
Open a pdf file from the same shell and save it under a new name.
Before patch:
file permisions -> 0600
After patch:
file permisions -> 0606

Reviewers: #okular, aacid

Tags: #okular

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

M  +12   -0    part.cpp

https://commits.kde.org/okular/c5592689874f41df393b44f3ba572acc751c5645
Comment 3 Christoph Feck 2018-09-10 23:33:09 UTC
*** Bug 398450 has been marked as a duplicate of this bug. ***