saltstack/salt — pull request #9131 by terminalmage (2013-12-09 23:06:13+00:00)
Title: Fix regression in file.managed

Pull request #8818 caused a couple of regressions. Firstly, it assumes
that, if "mode" is not specified (and thus defaults to None), that you
want the permissions to be equal to those dictated by the umask. This
means that a file with perms 640, which already exists, will be chmod'ed
to 644 if the system umask is 022 and no "mode" parameter was specified
in the state. This is not the expected behavior.

Secondly, the calculated perms are passed to file.check_perms as an
integer whose octal representation is the correct value for the file
permissions (i.e. 0o644, which is == 420 in decimal). However,
file.check_perms is designed to be run from the CLI, and thus requires
a value of 644 (decimal) to be passed, in order to set 644 permissions.
file.check_perms can also accept the mode as a string, so this is how
this commit passes the value to file.check_perms when a new file is
created.