Skip to content

Commit

Permalink
Skip stub grub.cfg files (e.g. used on Debian OS family).
Browse files Browse the repository at this point in the history
Replacing these may break OS update mechanisms which only update
the main file.
  • Loading branch information
olifre committed Aug 4, 2021
1 parent 63c2c4b commit 6ec048b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/puppetx/augeasproviders_grub/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,21 @@ def self.grub2_cfg_paths
]

valid_paths = paths.map do |path|
begin
real_path = nil

if File.readable?(path) && !File.directory?(path)
real_path = File.realpath(path)
real_path if (File.readable?(real_path) && !File.directory?(real_path))
rescue Errno::ENOENT
nil

# Exclude stub files which include main config (e.g. Debian OS family)
File.foreach(real_path) do |line|
if line.match(/^configfile\s/)
real_path = nil
break
end
end
end

real_path
end.compact.uniq

fail(%{No grub configuration found at '#{paths.join("', '")}'}) if valid_paths.empty?
Expand Down

0 comments on commit 6ec048b

Please sign in to comment.