class CORINEUS
Public Instance Methods
add()
click to toggle source
# File lib/corineus.rb, line 36 def add() update 'add' end
delete()
click to toggle source
# File lib/corineus.rb, line 55 def delete() update 'delete' end
update(action='add')
click to toggle source
# File lib/corineus.rb, line 60 def update(action='add') k_conf = <<-KRBCONF.unindent [realms] #{options[:realm]} = { kdc = #{options[:kdc]} default_domain = #{options[:realm]} } KRBCONF ns_input = <<-NSINPUT.unindent server #{options[:server]} update #{action} #{options[:name]} #{options[:ttl]} #{options[:type]} #{options[:data]} send quit NSINPUT pad_length = 50 k_file = Tempfile.new('krb5') k_file.write(k_conf) k_file.rewind commands = { "Kerberos" => { :desc => 'Get Kerberos ticket', :command => "env KRB5_CONFIG=#{k_file.path} kinit #{options[:user]}@#{options[:realm]}", :input => "#{options[:password]}", :exit => 1, :clue => 'Do you have the kinit command installed and in your PATH?' }, "nsupdate" => { :desc => "#{action.capitalize} DNS record", :command => "env KRB5_CONFIG=#{k_file.path} nsupdate -g", :input => ns_input, :exit => 2, :clue => 'Do you have the nsupdate command installed and in your PATH?' } } commands.each do |task, details| outputs = '' errors = '' print "#{details[:desc]}...".ljust(pad_length, padstr='.') if options[:verbose] command_status = POpen4::popen4(details[:command]) do |stdout, stderr, stdin| stdin.puts details[:input] stdout.each do |line| outputs << "#{line.strip}\n" end stderr.each do |line| errors << "#{line.strip}\n" end end if command_status.exitstatus == 0 print "Success.\n".green if options[:verbose] else if options[:verbose] print "Failure:\n".red print "#{outputs.strip}\n".red print "#{errors.strip}\n".red print "#{details[:clue]}\n".light_blue end exit details[:exit] end end k_file.close k_file.unlink end