1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-22 10:50:10 +00:00

fix bug with the GPG password

This commit is contained in:
nishiki 2013-07-18 00:17:24 +02:00
parent 666a16d306
commit 9ba8cc4936

14
MPW.rb
View file

@ -101,11 +101,11 @@ class MPW
@data = "" @data = ""
begin begin
if passwd.nil? if passwd.nil? || passwd.empty?
passwd = IO.read(@file_pwd) passwd = IO.read(@file_pwd)
end end
rescue rescue
if not passwd.nil? if !passwd.nil? && !passwd.empty?
file_pwd = File.new(@file_pwd, 'w') file_pwd = File.new(@file_pwd, 'w')
File.chmod(0600, @file_pwd) File.chmod(0600, @file_pwd)
file_pwd << passwd file_pwd << passwd
@ -120,7 +120,7 @@ class MPW
end end
return true return true
rescue rescue
if not @file_pwd.nil? if !@file_pwd.nil? && File.exist?(@file_pwd)
File.delete(@file_pwd) File.delete(@file_pwd)
end end
@ -133,12 +133,14 @@ class MPW
# Check if a password it saved # Check if a password it saved
# @rtrn: true if a password exist in the password file # @rtrn: true if a password exist in the password file
def checkFilePassword() def checkFilePassword()
if !@file_pwd.nil? && File.exist?(@file_pwd) && File.stat(@file_pwd).mtime.to_i + @timeout_pwd < Time.now.to_i if File.exist?(@file_pwd) && File.stat(@file_pwd).mtime.to_i + @timeout_pwd < Time.now.to_i
File.delete(@file_pwd) File.delete(@file_pwd)
return false return false
end elsif File.exist?(@file_pwd)
return true return true
else
return false
end
end end
# Encrypt a file # Encrypt a file