Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll probably need to show us the code that constitutes:</p> <pre><code>[do some other code here that creates a file] </code></pre> <p>The code you have works fine on my system:</p> <pre><code>import os oldmask = os.umask (022) fh1 = os.open ("qq1.junk", os.O_CREAT, 0777) fh2 = os.open ("qq2.junk", os.O_CREAT, 0022) os.umask (oldmask) os.close (fh1) os.close (fh2) </code></pre> <p>producing files as follows:</p> <pre><code>-rwxr-xr-x 1 pax pax 0 Apr 24 11:11 qq1.junk ---------- 1 pax pax 0 Apr 24 11:11 qq2.junk </code></pre> <p>You should also note the restoration of the old <code>umask</code> value which minimises the impact of changing it to the local operation.</p> <p>As you can see from the results above, you also need to be aware that the <code>umask</code> value is "subtracted" from the mode you're using to create the file and we don't know what that mode is in your particular case.</p> <p>That's evident even in your <code>bash</code> sample since a <code>umask</code> value of <code>022</code> when creating a file of mode <code>777</code> would result in <code>r-xr-xr-x</code>, not <code>rw-r--r--</code> as you have it.</p> <hr> <p>Based on your comments below where you indicate you're using <code>open</code> rather than <code>os.open</code>, a cursory glance of the Python source seems to indicate that this translates to a C <code>fopen</code> call which uses <code>0666</code> as the initial mode. This is supported by the slightly modified code:</p> <pre><code>import os oldmask = os.umask (022) fh3 = open ("qq3.junk", "w") os.umask (0) fh4 = open ("qq4.junk", "w") os.umask (oldmask) fh3.close() fh4.close() </code></pre> <p>which gives us:</p> <pre><code>-rw-r--r-- 1 pax pax 0 Apr 24 11:44 qq3.junk -rw-rw-rw- 1 pax pax 0 Apr 24 11:44 qq4.junk </code></pre> <p>So I'm not entirely certain why you're getting <code>0000</code> permissions in your case.</p> <p>It would be worth seeing what the results are when you run that above program in your environment. If it's the same as I get then the problem may well lie somewhere else.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload