Read from /proc/mounts instead of the mount command

This commit is contained in:
thecarterb 2018-04-10 23:20:00 -04:00
parent 07b3b576f5
commit 57e243ac49
1 changed files with 10 additions and 2 deletions

View File

@ -247,7 +247,11 @@ module System
# @return [Boolean]
#
def noexec?(mount_path)
cmd_exec("mount | grep --color=never ' #{mount_path} '").to_s.include? 'noexec'
mount = cmd_exec('cat /proc/mounts').to_s
mount.lines.each do |l|
true if l =~ Regexp.new("#{mount_path} (.*)noexec(.*)")
end
false
rescue
raise 'Unable to check for noexec volume'
end
@ -257,7 +261,11 @@ module System
# @return [Boolean]
#
def nosuid?(mount_path)
cmd_exec("mount | grep --color=never ' #{mount_path} '").to_s.include? 'nosuid'
mount = cmd_exec('cat /proc/mounts').to_s
mount.lines.each do |l|
true if l =~ Regexp.new("#{mount_path} (.*)nosuid(.*)")
end
false
rescue
raise 'Unable to check for nosuid volume'
end