diff --git a/keyring/backends/file.py b/keyring/backends/file.py index f899880..ef6db1d 100644 --- a/keyring/backends/file.py +++ b/keyring/backends/file.py @@ -116,7 +116,7 @@ class BaseKeyring(FileBacked, KeyringBackend): # create the file without group/world permissions with open(self.file_path, 'w'): pass - user_read_write = 0o600 + user_read_write = 0o644 os.chmod(self.file_path, user_read_write) def delete_password(self, service, username): @@ -172,12 +172,19 @@ class Encrypted(object): def _get_new_password(self): while True: - password = getpass.getpass( - "Please set a password for your new keyring: ") - confirm = getpass.getpass('Please confirm the password: ') - if password != confirm: - sys.stderr.write("Error: Your passwords didn't match\n") - continue +#**************************************************************** +# Forging the Keyring password to allow automation and still keep +# the password encoded. TODO to be revisited when Barbican keyring +# Will be used with the complete PKI solution +#**************************************************************** +# password = getpass.getpass( +# "Please set a password for your new keyring: ") +# confirm = getpass.getpass('Please confirm the password: ') +# if password != confirm: +# sys.stderr.write("Error: Your passwords didn't match\n") +# continue + password = "Please set a password for your new keyring: " + if '' == password.strip(): # forbid the blank password sys.stderr.write("Error: blank passwords aren't allowed.\n") @@ -248,8 +255,15 @@ class EncryptedKeyring(Encrypted, BaseKeyring): Unlock this keyring by getting the password for the keyring from the user. """ - self.keyring_key = getpass.getpass( - 'Please enter password for encrypted keyring: ') +#**************************************************************** +# Forging the Keyring password to allow automation and still keep +# the password encoded. TODO to be revisited when Barbican keyring +# Will be used with the complete PKI solution +#**************************************************************** +# self.keyring_key = getpass.getpass( +# 'Please enter password for encrypted keyring: ') + self.keyring_key = "Please set a password for your new keyring: " + try: ref_pw = self.get_password('keyring-setting', 'password reference') assert ref_pw == 'password reference value' diff --git a/keyring/util/platform_.py b/keyring/util/platform_.py index dcdffea..53b9eae 100644 --- a/keyring/util/platform_.py +++ b/keyring/util/platform_.py @@ -19,7 +19,7 @@ def _data_root_Linux(): Use freedesktop.org Base Dir Specfication to determine storage location. """ - fallback = os.path.expanduser('~/.local/share') + fallback = os.path.expanduser('/opt/platform/.keyring/') root = os.environ.get('XDG_DATA_HOME', None) or fallback return os.path.join(root, 'python_keyring')