<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>445801</bug_id>
          
          <creation_ts>2021-11-20 11:50:44 +0000</creation_ts>
          <short_desc>Doesn&apos;t honor the system umask for newly-created files</short_desc>
          <delta_ts>2023-09-18 20:23:24 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>plasmashell</product>
          <component>general</component>
          <version>5.23.4</version>
          <rep_platform>Arch Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DOWNSTREAM</resolution>
          
          <see_also>https://bugs.kde.org/show_bug.cgi?id=404777</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.0</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="0BADC0DE">vincenzo.romano</reporter>
          <assigned_to name="David Edmundson">kde</assigned_to>
          <cc>a.samirh78</cc>
    
    <cc>arojas</cc>
    
    <cc>kde</cc>
    
    <cc>kde</cc>
    
    <cc>kdelibs-bugs-null</cc>
    
    <cc>nate</cc>
    
    <cc>plasma-bugs-null</cc>
    
    <cc>vincent.minder</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2079014</commentid>
    <comment_count>0</comment_count>
    <who name="0BADC0DE">vincenzo.romano</who>
    <bug_when>2021-11-20 11:50:44 +0000</bug_when>
    <thetext>SUMMARY
***
Screenshots are saved with 0644 permissions no matter what umask says***


STEPS TO REPRODUCE
1.  Setup user-level umask to, say, 0077 (no permissions for G and O)
2. Take a screenshot and save it
3. Use konsole+cd+ls to check the screenshot file permissions.

OBSERVED RESULT
File has permissions 0644

EXPECTED RESULT
File should obey umask (in the example should have permissions 0600)

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080175</commentid>
    <comment_count>1</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2021-11-23 23:28:34 +0000</bug_when>
    <thetext>Does this also happen in Dolphin with Create New &gt; File?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080289</commentid>
    <comment_count>2</comment_count>
    <who name="0BADC0DE">vincenzo.romano</who>
    <bug_when>2021-11-24 08:39:44 +0000</bug_when>
    <thetext>Yes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080493</commentid>
    <comment_count>3</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2021-11-24 20:20:30 +0000</bug_when>
    <thetext>Moving to KIO, then. What version of KIO or KDE frameworks do you have? I ask because this was supposed to have been fixed with Bug 404777 in Frameworks 5.87. So are you using 5.87 or 5.88, or an older version?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080526</commentid>
    <comment_count>4</comment_count>
    <who name="0BADC0DE">vincenzo.romano</who>
    <bug_when>2021-11-24 21:27:45 +0000</bug_when>
    <thetext>5.88</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080528</commentid>
    <comment_count>5</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2021-11-24 21:39:52 +0000</bug_when>
    <thetext>Looks like there&apos;s still a use case that needs to be fixed, then. Perhaps only copying got fixed, and file creation still suffers from the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080533</commentid>
    <comment_count>6</comment_count>
    <who name="0BADC0DE">vincenzo.romano</who>
    <bug_when>2021-11-24 22:10:56 +0000</bug_when>
    <thetext>Maybe i am wrong, but when you copy a file you first create an empty one. Then you fill it in with the original content.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2081214</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Samir">a.samirh78</who>
    <bug_when>2021-11-28 14:33:49 +0000</bug_when>
    <thetext>$ umask
0022
$ umask 0077
$ dolphin

then creating a new file with dolphin, checking the permissions I get `-rw-------`  which is correct.

Starting spectacle from the same terminal, I took a screenshot, clicked &quot;Save&quot;, and the resulting .png file has the expected permissions.

So I think it&apos;s not an issue with KIO per se, rather the environment from where the screenshot app is launched doesn&apos;t have the correct umask? not sure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2081324</commentid>
    <comment_count>8</comment_count>
    <who name="0BADC0DE">vincenzo.romano</who>
    <bug_when>2021-11-29 06:17:20 +0000</bug_when>
    <thetext>I don&apos;t start apps from command line but rather from menu.
My bash has umask set to 0077.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2081335</commentid>
    <comment_count>9</comment_count>
    <who name="Ahmad Samir">a.samirh78</who>
    <bug_when>2021-11-29 08:15:22 +0000</bug_when>
    <thetext>To clarify, I meant that when you press e.g. the PrintScreen button, KGlobalAccel (?) starts Spectacle to take the screenshot, the way KGlobalAccel starts the app could be where the umask wasn&apos;t carried over.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2081336</commentid>
    <comment_count>10</comment_count>
    <who name="0BADC0DE">vincenzo.romano</who>
    <bug_when>2021-11-29 08:21:37 +0000</bug_when>
    <thetext>I somehow would expect that stuff like umask is setup globally for any KDE/Plasma application.
If all of them use KIO to write files, then I would say KIO is the right place to fix it.
But I don&apos;t know enough about the overall architecture.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088018</commentid>
    <comment_count>11</comment_count>
    <who name="Vincent Minder">vincent.minder</who>
    <bug_when>2021-12-24 21:46:56 +0000</bug_when>
    <thetext>Confirmed under Fedora 35 with KDE Frameworks 5.89, though not sure KIO is the best place for this.
The issue is that KDE just doesn&apos;t seem to know about the user-defined umask at all. Not only KDE apps, any app launched through the Kickoff menu, like LibreOffice, will fail to honor the umask when creating a file. These same apps will behave as expected when launched from a shell, because the shell knows... The umask is usually set in the user profile or in the global profile. I hear that it should preferably be set in /etc/pam.d/login nowadays. I tried but it did not work any better.
We&apos;ve been there before, long ago, and probably several times since then:
https://bugs.kde.org/show_bug.cgi?id=43172
An easy workaround then was to boot into non-graphical mode and type &quot;startkde&quot; by hand. Everything would work as expected, but if you went through the display manager, user-defined umask would be ignored.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088047</commentid>
    <comment_count>12</comment_count>
    <who name="Ahmad Samir">a.samirh78</who>
    <bug_when>2021-12-25 08:19:35 +0000</bug_when>
    <thetext>Hmm, that might have to do with systemd, which Plasma has been using for a while, not sure though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088048</commentid>
    <comment_count>13</comment_count>
    <who name="Ahmad Samir">a.samirh78</who>
    <bug_when>2021-12-25 08:40:27 +0000</bug_when>
    <thetext>FWIW, I found:
https://github.com/systemd/systemd/issues/6077
https://github.com/systemd/systemd/pull/15318

so it &quot;should&quot; work, but I am not a systemd expert.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088380</commentid>
    <comment_count>14</comment_count>
    <who name="Vincent Minder">vincent.minder</who>
    <bug_when>2021-12-27 12:46:01 +0000</bug_when>
    <thetext>Thanks for the links. So for systemd the proper way to set umask would be inside /etc/login.defs (always globally)?
I edited this file, but it didn&apos;t solve the issue on my Fedora system.
Even if it did, doesn&apos;t KDE need to remain compatible with non-systemd systems? Maybe it shouldn&apos;t depend on systemd to be made aware of the umask? There are so many different ways to set it... I wonder if KDE shouldn&apos;t just query for it by attempting to issue a &quot;umask&quot; command as early as possible. Not sure how it would allow our Kickoff menu to have all apps (including non-KDE apps) inherit this umask at launch though... Or shouldn&apos;t the display manager provide it? (In my case, SDDM.) That&apos;d be even earlier.
It&apos;d be nice if someone with deeper technical knowledge than us users could step in.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088570</commentid>
    <comment_count>15</comment_count>
    <who name="Ahmad Samir">a.samirh78</who>
    <bug_when>2021-12-28 11:21:29 +0000</bug_when>
    <thetext>If am reading this correctly, the issue is supposedly fixed by using pam_umask.so, which is probably what ArchLinux is already doing (but I don&apos;t know for sure).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088577</commentid>
    <comment_count>16</comment_count>
    <who name="Antonio Rojas">arojas</who>
    <bug_when>2021-12-28 11:46:15 +0000</bug_when>
    <thetext>(In reply to Ahmad Samir from comment #15)
&gt; If am reading this correctly, the issue is supposedly fixed by using
&gt; pam_umask.so, which is probably what ArchLinux is already doing (but I don&apos;t
&gt; know for sure).

No, we&apos;re not. I will comment on the relevant downstream report.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088579</commentid>
    <comment_count>17</comment_count>
    <who name="Ahmad Samir">a.samirh78</who>
    <bug_when>2021-12-28 11:52:40 +0000</bug_when>
    <thetext>OK, thanks. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2253826</commentid>
    <comment_count>18</comment_count>
    <who name="Antonio Rojas">arojas</who>
    <bug_when>2023-09-18 20:23:24 +0000</bug_when>
    <thetext>This is now implemented downstream</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>