3liz / qgis-plugin-manager

CLI tools for installing QGIS Plugins
GNU General Public License v3.0
14 stars 2 forks source link

Not working inside docker container running with `--user` or with files owned by a non-existant user #31

Closed dmarteau closed 2 years ago

dmarteau commented 2 years ago

What's happening:

qgis-plugin-manager crash if files are owned by a non-existent user in the container:

> qgis-plugin-manager list
Traceback (most recent call last):
  File "/opt/local/pyqgisserver/bin/qgis-plugin-manager", line 8, in <module>
    sys.exit(main())
  File "/opt/local/pyqgisserver/lib/python3.9/site-packages/qgis_plugin_manager/__main__.py", line 93, in main
    plugins.print_table()
  File "/opt/local/pyqgisserver/lib/python3.9/site-packages/qgis_plugin_manager/local_directory.py", line 197, in print_table
    permissions = f"{pwd.getpwuid(stat_info.st_uid)[0]} : {oct(perms)}"
KeyError: 'getpwuid(): uid not found: 1001'

What should have happened:

Run without crashing even if uid does not relate to existing user on container

It is common to run a container with option -u <uid>:<gid> or using a parametrized uid that does not exists in container, mainly for security reason and because mounted volumes are owned to a different user on the host: this does not prevent application to run as such user.

Note that may also be an issue with nfs mounted volumes.

Gustry commented 2 years ago

5d892a5cfafb1f8403809bd28a0f6d365db28444

It should display the "number" (1001) if the user was not found.

Gustry commented 2 years ago

I think it's fixed with latest commits