trek10inc / awsume

A utility for easily assuming AWS IAM roles from the command line.
https://awsu.me
MIT License
485 stars 90 forks source link

Logging output directory does not follow XDG standard and sometimes lead to errors #250

Closed sriesenberg-reply closed 3 months ago

sriesenberg-reply commented 5 months ago

Issue

The function load_config() in awsumepy/lib/config_management.py removes the legacy config directory at ~/.awsume https://github.com/trek10inc/awsume/blob/285d0125179e50b8e023b4ecbd913fbe45a61aae/awsume/awsumepy/lib/config_management.py#L56

This operation fails if the directory is not empty and produces this error:

os.rmdir(constants.AWSUME_DIR_LEGACY_PATH)
OSError: [Errno 66] Directory not empty: '/Users/user1/.awsume'

But the function configure_logger() in autoawsume/main does not consider if the user has set their XDG base directories and still writes to the legacy config directory: https://github.com/trek10inc/awsume/blob/285d0125179e50b8e023b4ecbd913fbe45a61aae/awsume/autoawsume/main.py#L82-L84

Proposal

Adjust configure_logger() to also use awsumepy/lib/conastants.py or something similar and to add and use the XDG_STATE_HOME directory, which defaults to ~/.local/state (see: XDG Base Directory Specification)

lhendrick-t10 commented 4 months ago

Hi @sriesenberg-reply! Thanks for opening a issue with us for this bug - we will go ahead and get this added to our backlog and I hope to have an update for you soon! In the meantime, if you wanted to open a PR with your suggested changes we would greatly appreciate it!

lhendrick-t10 commented 3 months ago

Hello again @sriesenberg-reply - I've merged your PR and have published a release candidate version to PyPI

We'll be publishing the full release soon, but wanted to give you a heads up that I will be closing this issue.

Thanks again for your support of awsume!