mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
fix bug with the GPG password
This commit is contained in:
parent
666a16d306
commit
9ba8cc4936
1 changed files with 8 additions and 6 deletions
14
MPW.rb
14
MPW.rb
|
@ -101,11 +101,11 @@ class MPW
|
|||
@data = ""
|
||||
|
||||
begin
|
||||
if passwd.nil?
|
||||
if passwd.nil? || passwd.empty?
|
||||
passwd = IO.read(@file_pwd)
|
||||
end
|
||||
rescue
|
||||
if not passwd.nil?
|
||||
if !passwd.nil? && !passwd.empty?
|
||||
file_pwd = File.new(@file_pwd, 'w')
|
||||
File.chmod(0600, @file_pwd)
|
||||
file_pwd << passwd
|
||||
|
@ -120,7 +120,7 @@ class MPW
|
|||
end
|
||||
return true
|
||||
rescue
|
||||
if not @file_pwd.nil?
|
||||
if !@file_pwd.nil? && File.exist?(@file_pwd)
|
||||
File.delete(@file_pwd)
|
||||
end
|
||||
|
||||
|
@ -133,12 +133,14 @@ class MPW
|
|||
# Check if a password it saved
|
||||
# @rtrn: true if a password exist in the password file
|
||||
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)
|
||||
return false
|
||||
elsif File.exist?(@file_pwd)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
# Encrypt a file
|
||||
|
|
Loading…
Add table
Reference in a new issue