mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-02 22:54:49 +03:00
Password files in same configuration dir in effect #2143
This commit is contained in:
parent
5947e9da36
commit
0302cdcd57
@ -432,13 +432,16 @@ disable=False
|
||||
#server_4_port=61237
|
||||
|
||||
[passwords]
|
||||
# Define the passwords list
|
||||
# Define the passwords list related to the [serverlist] section
|
||||
# Syntax: host=password
|
||||
# Where: host is the hostname
|
||||
# password is the clear password
|
||||
# Additionally (and optionally) a default password could be defined
|
||||
#localhost=abc
|
||||
#default=defaultpassword
|
||||
#
|
||||
# Define the path of the local '.pwd' file (default is system one)
|
||||
#local_password_path=~/.config/glances
|
||||
|
||||
##############################################################################
|
||||
# Exports
|
||||
|
@ -26,12 +26,22 @@ class GlancesPassword(object):
|
||||
|
||||
"""This class contains all the methods relating to password."""
|
||||
|
||||
def __init__(self, username='glances'):
|
||||
def __init__(self, username='glances', config=None):
|
||||
self.username = username
|
||||
self.password_dir = user_config_dir()
|
||||
|
||||
self.config = config
|
||||
self.password_dir = self.local_password_path()
|
||||
self.password_filename = self.username + '.pwd'
|
||||
self.password_file = os.path.join(self.password_dir, self.password_filename)
|
||||
|
||||
def local_password_path(self):
|
||||
"""Return the local password path.
|
||||
Related toissue: Password files in same configuration dir in effect #2143
|
||||
"""
|
||||
return self.config.get_value('passwords',
|
||||
'local_password_path',
|
||||
default=user_config_dir())
|
||||
|
||||
def sha256_hash(self, plain_password):
|
||||
"""Return the SHA-256 of the given password."""
|
||||
return hashlib.sha256(b(plain_password)).hexdigest()
|
||||
|
Loading…
Reference in New Issue
Block a user