Skip to content

Commit

Permalink
[rpm] add logic to ensure 0555 permissions on /usr/bin for rhel >= 6
Browse files Browse the repository at this point in the history
We've found that RHEL 5 ships with mode 0755 on /usr/bin, while RHEL 6
and 7 ship with mode 0555. As a result, installing packages built for RHEL 6 or
7 contain files destined for /usr/bin will fail thusly:

```
file /usr/bin from install of sensu-1:0.27.0.beta.2-1.el7.x86_64 conflicts with file from package filesystem-3.2-20.el7.x86_64
```

An solution solution would be to implement an approach which considers the
permissions specified by the system's `filesystem` package at build time (see
chef#666 (comment)). For now, we'll
kick the can down the road a bit.

Signed-off-by: Cameron Johnston <cameron@rootdown.net>
  • Loading branch information
cwjohnston committed Jan 18, 2017
1 parent 26fdb1f commit a372db1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/omnibus/packagers/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,23 @@ def filesystem_directories
@filesystem_directories ||= IO.readlines(resource_path("filesystem_list")).map { |f| f.chomp }
end

#
# Returns true if platform_family matches rhel and major version is 6 or above
#
# @return [TrueClass,FalseClass]
#
def rhel_6_or_newer?
Ohai["platform_family"] == "rhel" && (Gem::Version.new(Ohai["platform_version"]) <= Gem::Version("6"))
end

#
# Mark filesystem directories with ownership and permissions specified in the filesystem package
# https://git.fedorahosted.org/cgit/filesystem.git/plain/filesystem.spec
#
# @return [String]
#
def mark_filesystem_directories(fsdir)
if fsdir.eql?("/") || fsdir.eql?("/usr/lib") || fsdir.eql?("/usr/share/empty")
if fsdir.eql?("/") || fsdir.eql?("/usr/lib") || fsdir.eql?("/usr/share/empty") || (fsdir.eql?("/usr/bin") && rhel_6_or_newer?)
return "%dir %attr(0555,root,root) #{fsdir}"
elsif filesystem_directories.include?(fsdir)
return "%dir %attr(0755,root,root) #{fsdir}"
Expand Down

0 comments on commit a372db1

Please sign in to comment.