def session(user, password)
fname = File.join(ENV['HOME'], '.ruby-bugzilla-cookie.yml')
if File.exist?(fname) && File.lstat(fname).mode & 0600 == 0600 then
conf = YAML.load(File.open(fname).read)
host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)
cookie = conf[host]
unless cookie.nil? then
@iface.cookie = cookie
print "Using cookie\n"
yield
conf[host] = @iface.cookie
File.open(fname, 'w') {|f| f.chmod(0600); f.write(conf.to_yaml)}
return
end
end
if user.nil? || password.nil? then
yield
else
login({'login'=>user, 'password'=>password, 'remember'=>true})
yield
logout
end
end