lib/dbus/auth.rb in ruby-dbus-0.16.0 vs lib/dbus/auth.rb in ruby-dbus-0.17.0
- old
+ new
@@ -71,11 +71,11 @@
c_challenge = 1.upto(s_challenge.bytesize / 2).map { rand(255).to_s }.join
# Search cookie file for id
path = File.join(ENV["HOME"], ".dbus-keyrings", context)
DBus.logger.debug "path: #{path.inspect}"
File.foreach(path) do |line|
- if line.index(id).zero?
+ if line.start_with?(id)
# Right line of file, read cookie
cookie = line.split(" ")[2].chomp
DBus.logger.debug "cookie: #{cookie.inspect}"
# Concatenate and encrypt
to_encrypt = [s_challenge, c_challenge, cookie].join(":")
@@ -85,17 +85,17 @@
# Return response
response = [:AuthOk, hex_response]
return response
end
end
+ return if @retries <= 0
+
# a little rescue magic
- unless @retries <= 0
- puts "ERROR: Could not auth, will now exit."
- puts "ERROR: Unable to locate cookie, retry in 1 second."
- @retries -= 1
- sleep 1
- data(hexdata)
- end
+ puts "ERROR: Could not auth, will now exit."
+ puts "ERROR: Unable to locate cookie, retry in 1 second."
+ @retries -= 1
+ sleep 1
+ data(hexdata)
end
# encode plain to hex
def hex_encode(plain)
return nil if plain.nil?