Created
January 31, 2022 16:27
-
-
Save david-fairbanks42/4375ef0b9f299752ed7edc53744aabce to your computer and use it in GitHub Desktop.
Clean up empty keyring entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux keyring file (login.keyring) contained a lot of dead entries with black passwords | |
# Update the application siganture (chrome-6391234) from an entry | |
# Additional/Alternative search items could be added | |
import keyring | |
keys = keyring.get_keyring() | |
for k in keys.backends: | |
if isinstance(k, keyring.backends.SecretService.Keyring): | |
collection = k.get_preferred_collection() | |
items = collection.search_items({"application": 'chrome-6391234'}) | |
for i in items: | |
k.unlock(i) | |
# print('%s -- %s' % (i.get_attributes().get("origin_url"), i.get_secret().decode('utf-8'))) | |
p = i.get_secret().decode('utf-8') | |
if p == '': | |
i.delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment