Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong file permissions for version and last-use.txt when installed globally (as root) #294

Open
notorand-it opened this issue Nov 27, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@notorand-it
Copy link

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. Setup:
export TENV_ROOT=/usr/local/share/tenv
export TENV_AUTO_INSTALL=true
  1. Run (as normal user enabled to run sudo) to install and select a specific version (latest here)
sudo --preserve-env=TENV_ROOT,TENV_AUTO_INSTALL tenv tofu use latest

You can choose whatever tool you prefer.

  1. Once installation is completed do:
tofu --version
  1. Output shows two warnings:
$ tofu --version
2024-11-27T11:23:09.935+0100 [WARN]  tenv: Failed to read file: error="open /usr/local/share/tenv/OpenTofu/version: permission denied"
2024-11-27T11:23:09.935+0100 [WARN]  tenv: Unable to write date in file: error="open /usr/local/share/tenv/OpenTofu/1.8.6/last-use.txt: permission denied"
OpenTofu v1.8.6
on linux_amd64

Expected behavior
Latest version and usage timestamp (when needed) of OpenTofu is displayed with no warning.

Screenshots
N/A

Environment (please complete the following information):

  • OS: ArchLinux
  • tenv version v3.2.10

Additional context
I want to make a system-wide installation of tenv as all those tools would be installed by root at a specific version number.
The file /usr/local/share/tenv/OpenTofu/version should be created world-readable (aka 0644). IMHO opinion this is the right approach.
For file /usr/local/share/tenv/*/*/last-use.txt I don't have a clear idea.
Making it world-readable would solve half of the problem.
Making it world-writable (aka 0666) would create more problems than solutions.
Making that file user-local (inside its $HOME) could be an (overly complex?) option to keep the "last use" tracking feature.
Sub-optimal workaround would be to use the variable TENV_QUIET=true. It would remove the warning indeed, but would also remove any other warning.
Adding a new environment variable (like TENV_SKIP_LAST_USE) to either skip just the warning or the "last use" tracking feature seems an effective workaround if not a solution.
Finally, if the tool is installed by root but not run as root that step (and related warning) could be simply skipped. This is my favorite solution.

@kvendingoldo kvendingoldo added the bug Something isn't working label Nov 27, 2024
@dvaumoron dvaumoron self-assigned this Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants