Skip to content

Fix user KeyError if user dir doesn't exist

Adrian Byszuk requested to merge adbyszuk/cheby:fix_user_unknown into master

This MR fixes an issue when trying to run Cheby in a setup where user home directory doesn't exist.
This may include following scenarios:

  • Docker image run with --user switch (necessary for AFS access)
  • using sudo with UID not present in the system
  • SystemD dynamic users

This MR is especially useful for Dockerized environments.

Details: In cases mentioned above getpass.getuser() will fail with KeyError exception.
Problem was fixed in posixpath.expanduser() (see here and here) but wasn't propagated to getpass module.
Source code suggest this is intended behaviour.

Merge request reports