From c55080abd52aa03adee48305ae6c6db4dfbe130c Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Wed, 11 Nov 2015 13:11:17 +0100 Subject: audit: respect umask in formula file mode check Closes Homebrew/homebrew#45837. Signed-off-by: Mike McQuaid --- Library/Homebrew/cmd/audit.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Library') 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? -- cgit v1.2.3