diff options
author | Robbie Harwood <rharwood@redhat.com> | 2023-03-09 18:23:30 -0500 |
---|---|---|
committer | Robbie Harwood <rharwood@redhat.com> | 2023-03-13 09:47:35 -0400 |
commit | a8fd46bb50fdfa30d4dabf634dcc26749c9864a8 (patch) | |
tree | 02402ceab093a5c76802d8ec483755eecc1e3f63 /extract_token_from_browser.py | |
parent | 39ff696e6ad2c3c6381b2556786394adb06bf935 (diff) | |
download | wee-slack-a8fd46bb50fdfa30d4dabf634dcc26749c9864a8.tar.gz |
extract_token_from_browser: read default from profiles.ini
Firefox's default profile can have several different name suffixes,
including ".default-release", the legacy ".default", and others for
different release channels. Rather than guessing, just parse
profiles.ini to determine the default path. Suggested by Trygve
Aaberge.
Link: https://support.mozilla.org/gl/questions/1264072
Link: https://support.mozilla.org/en-US/kb/understanding-depth-profile-installation
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Diffstat (limited to 'extract_token_from_browser.py')
-rwxr-xr-x | extract_token_from_browser.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/extract_token_from_browser.py b/extract_token_from_browser.py index 5798ba0..d42bd5b 100755 --- a/extract_token_from_browser.py +++ b/extract_token_from_browser.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +from configparser import ConfigParser import json from pathlib import Path import sqlite3 @@ -26,9 +27,21 @@ else: print("Currently only Linux and macOS is supported by this script", file=sys.stderr) sys.exit(1) -try: - default_profile_path = next(firefox_path.glob("*.default-release")) -except StopIteration: +profile_path = firefox_path.joinpath("profiles.ini") +profile_data = ConfigParser() +profile_data.read(profile_path) + +default_profile_path = None +for key in profile_data.sections(): + if not key.startswith("Install"): + continue + + value = profile_data[key] + if "Default" in value: + default_profile_path = firefox_path.joinpath(value["Default"]) + break + +if default_profile_path is None: print("Couldn't find the default profile for Firefox", file=sys.stderr) sys.exit(1) |