diff options
| author | Martin Afanasjew | 2015-11-11 13:11:17 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2015-11-16 20:07:23 +0000 |
| commit | c55080abd52aa03adee48305ae6c6db4dfbe130c (patch) | |
| tree | 95505381f6985b37b59a9530637cb453ef86ff60 | |
| parent | 14af3e35155c5a8c9035b24773dc5858cca6b01b (diff) | |
| download | brew-c55080abd52aa03adee48305ae6c6db4dfbe130c.tar.bz2 | |
audit: respect umask in formula file mode check
Closes Homebrew/homebrew#45837.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 60bee4722..dc80f6d45 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -144,8 +144,14 @@ class FormulaAuditor end def audit_file - unless formula.path.stat.mode == 0100644 - problem "Incorrect file permissions: chmod 644 #{formula.path}" + # Under normal circumstances (umask 0022), we expect a file mode of 644. If + # the user's umask is more restrictive, respect that by masking out the + # corresponding bits. (The also included 0100000 flag means regular file.) + wanted_mode = 0100644 & ~File.umask + actual_mode = formula.path.stat.mode + unless actual_mode == wanted_mode + problem format("Incorrect file permissions (%03o): chmod %03o %s", + actual_mode & 0777, wanted_mode & 0777, formula.path) end if text.has_DATA? && !text.has_END? |
