def apply
@applied_status = :failed
if File.exist?(@file)
backup_file = "#{@file}.#{@start_time.strftime('%Y%m%dT%H%M%S')}"
debug( "Backing up #{@file} to #{backup_file}" )
FileUtils.cp(@file, backup_file)
group_id = File.stat(@file).gid
File.chown(nil, group_id, backup_file)
end
entries = recommended_value
debug( "Updating #{@file}" )
File.open(@file, 'w') do |file|
file.puts "# You should place any hostnames/domains here that you wish to autosign.\n" +
"# The most security-conscious method is to list each individual hostname:\n" +
"# hosta.your.domain\n" +
"# hostb.your.domain\n" +
"#\n" +
"# Wildcard domains work, but absolutely should NOT be used unless you fully\n" +
"# trust your network.\n" +
"# *.your.domain\n\n"
entries.each do |entry|
file.puts(entry)
end
end
@applied_status = :succeeded
end