Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix truncation of filenames with suffixes for ISO9660
Include the suffix in the filename truncation so the combined length
remains within the filesystem limit, and truncate from the start of the
string to keep the suffix (the unique bit) to prevent kernel/initrd from
a particularly long filename from colliding.
  • Loading branch information
domcleal committed Jul 29, 2016
1 parent 8e6475f commit 84489ec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/services/foreman_bootdisk/iso_generator.rb
Expand Up @@ -20,8 +20,7 @@ def self.generate_full_host(host, opts = {}, &block)
files.map! do |bootfile_info|
bootfile_info.map do |f|
suffix = f[1].split('/').last
iso_suffix = iso9660_filename(suffix)
iso_f0 = iso9660_filename(f[0].to_s) + '_' + iso_suffix
iso_f0 = iso9660_filename(f[0].to_s + '_' + suffix)
tmpl.gsub!(f[0].to_s + '-' + suffix, iso_f0)
ForemanBootdisk.logger.debug("Boot file #{iso_f0}, source #{f[1]}")
[iso_f0, f[1]]
Expand Down Expand Up @@ -134,7 +133,7 @@ def self.fetch(path, uri)
# isolinux supports up to ISO 9660 level 2 filenames
def self.iso9660_filename(name)
dir = File.dirname(name)
file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_')[0..30]
dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', '_')[0..30], file)
file = File.basename(name).upcase.tr_s('^A-Z0-9_', '_').last(28)
dir == '.' ? file : File.join(dir.upcase.tr_s('^A-Z0-9_', '_').last(28), file)
end
end

0 comments on commit 84489ec

Please sign in to comment.