Unclear/Missleading error message when using linkahead script with unsufficient permissions
Summary
I got a very unclear Error Traceback when calling linkahead --help
:
vagrant@debian10:/home/bis$ linkahead --help
Traceback (most recent call last):
File "/usr/bin/linkahead", line 2328, in <module>
main()
File "/usr/bin/linkahead", line 2310, in main
global_conf = get_global_config()
File "/usr/bin/linkahead", line 1637, in get_global_config
global_config["default_dir"] = parser["DEFAULT"]["default"]
File "/usr/lib/python3.7/configparser.py", line 1251, in __getitem__
raise KeyError(key)
KeyError: 'default'
It took me some time, but in the end I figured out, that the problem was simply that the user vagrant
didn't have sufficient permissions to read linkahead.conf
.
Expected Behavior
The Error Traceback should not be a KeyError. It should become clear that there simply is a problem with file access/permissions.
Actual Behavior
See above
Steps to Reproduce the Problem
Please describe, step by step, how others can reproduce the problem. Please try these steps for yourself on a clean system.
- Install linkahead with a special user, e.g. a user called "linkahead" on vagrant VM with box debian/buster64
- Connect to the vm as a different user, e.g. "vagrant"
- Open a terminal and execute
linkahead --help
Specifications
- Version: 0.9.1
- Platform: vagrant vm with debian 10 (box: debian/buster64)
Possible fixes
Add:
if not os.access(config_file, os.R_OK):
msg = "Unable to read config file: {}".format(config_file)
raise PermissionError(msg)
before parser.read(config_file)
at line 1635