Re: umask question

From: Robert Newson (ReapNewsB_at_bullet3.fsnet.oc.ku)
Date: 07/23/05


Date: Fri, 22 Jul 2005 22:32:53 GMT

Shel Sherman wrote:

> Thanks for the reply. You verified my suspicion that the leftmost zero
> implied octal. However, here is the rest of the puzzle. I ran several values
> of umask, created empty files using "touch" called foo1, foo2, etc. and
> looked at the resulting permissions via ls -l for each value of umask. The
> results are tabulated below. Some results were as expected. Others leave me
> scratching my head.
>
> UMASK RESULT OCTAL EQUIVALENT EXPECTED
> 0022 rwxr_xr_x 755 yes
> 0777 --------- 000 yes
> 0321 r__r__rw_ 446 NO
> 0210 r__rw_rw_ 466 NO
> 0111 rw_rw_rw_ 666 yes
> 0123 rw_r__r__ 644 NO
>
> Note that three of the six masks used did not yield the expected results.
> So I remain.....Still confused.

If you check the results that failed to arrive as expected, you should spot
a pattern: the 'x' bit is always masked to be off.

This is probably as a security feature: the eXecute bit is being forced to
be off on a regular file so that you have to explicitly set it - so that
it's less likely that you'll accidently run something you shouldn't, or
attempt to run something that isn't a program.

Note that compilers (eg gcc) will [usually] automatically set the x bits as
per the umask - as the resultant file *is* a program.

Similarly, when you create a directory (with mkdir), it will use the full
umask - which means if you've disabled the x bit (eXecute = search for
directories) you won't be able to access any file within that directory
(including creating any even if you've got Write perms on the directory).



Relevant Pages

  • Re: default permissions when scping files
    ... >> username take on specific permissions, or barring that, ... I read it to mean that the umask does not affect the execute bit of files ... as the source file has. ...
    (comp.unix.shell)
  • Re: umask
    ... No. umask 077 means "remove any group read, write, execute or other read, write, ... execute permissions" on created files. ... Because these files are executed by various login procedures, ...
    (comp.unix.questions)
  • Re: umask
    ... I am trying to understand 'umask. ... What I understand is that umask is used to specify the initial permissions ... When you specify a umask of 0022, you tell the system that /if/ the creat ... Group read, write, execute ...
    (comp.unix.programmer)
  • Re: Multiple users read/write to same directory in Linux via Samba
    ... > Can you explain what the umask is? ... It defines the default permissions that are given to a newly created file. ... need to be root in order to execute the command. ...
    (comp.os.linux.security)
  • Re: File Sharing (again - sorry, Pd)
    ... InTerminal, type umask. ... Back in the good old days, Mac OS X user accounts ... The reason that the file permissions are "resetting" each time the ... that folder inherit the ACLs from the folder. ...
    (uk.comp.sys.mac)