Hello and Happy Holidays.

Does changing 'umask' change the system's default value or does it only apply for the current code and does not affect the system's default value?

Also, what is the result of the 'mkdir' on the directory created if the mode that is specified is different than the default 'umask' if the 'umask' statment is not used in the code?

What I mean is, if e.g.

mkdir("dirname", 0777) or die "could not create dir: $!";
...when the umask default is 0755. Will the new directory, 'dirname' have the permissions of 0755 or 0777?

If the code is...

umask 022; mkdir("dirname", 0777) or die "could not create dir: $!";
...Will the system's default permission be changed from 0755 to 0777 due to these statements? (will subsequent directories created have permissions of 0777 or will the default still be 0755)?

What code do I use if I just want to create a directory with the system's default mode?

I hope this is clear. Most references I read are very vague on the use of 'umask'. I don't want to use it incorrectly and change the system's default. The hosting company may not appreciate it, so I need enough info (risks; proper use; when to use; etc.) before proceeding.

Thanks.
--newbie00


In reply to Does changing 'umask' change the system's default value? by newbie00

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.