dictcli: Avoid running as root if unnecessary

This commit is contained in:
Florian Bruhin 2019-07-25 17:24:53 +02:00
parent 701a183d73
commit c847e67c2a
1 changed files with 14 additions and 0 deletions

View File

@ -256,7 +256,21 @@ def remove_old(languages):
os.remove(os.path.join(spell.dictionary_dir(), old_file))
def check_root():
"""Ask for confirmation if running as root when unnecessary."""
if spell.can_use_data_path() and os.geteuid() == 0:
print("You're running Qt >= 5.10 which means qutebrowser will "
"load dictionaries from a path in your home-directory. "
"Unless you run qutebrowser as root (bad idea!), you "
"most likely want to run this script as your user. ")
answer = input("Do you want to continue anyways? [y/N] ")
if answer not in ['y', 'Y']:
sys.exit(0)
def main():
check_root()
if configdata.DATA is None:
configdata.init()
standarddir.init(None)