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

Make permission check more lenient. #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

derula
Copy link

@derula derula commented Oct 7, 2021

Instead of enforcing an arbitrary permission policy, check permissions against current umask.

If permissions are changed from the default, this might be a hint that something shady is going on.

Resolves #152.

Instead of enforcing an arbitrary permission policy, check permissions against  current umask.

If permissions are changed from the default, this might be a hint that something shady is going on.

Resolves MichaelAquilina#152.
@@ -179,15 +179,21 @@ function check_venv()
file_owner="$(/usr/bin/stat -f %u "$venv_path")"
file_permissions="$(/usr/bin/stat -f %OLp "$venv_path")"
fi
if [[ -d "$venv_path" ]]; then
default_permissions=777
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be something I'm missing here - so please correct me if I am wrong

But this seems to change the plugin to require the activated file to be executable, writeable and readable by everyone on the system?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait - you're specifically checking if its a directory here? I'm a bit lost about what we are covering here then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is to figure out what the default permissions of the file would be:

  • If it's a directory, e.g. a .venv folder, the default permissions are 777 & ~umask
  • If it's a regular file, e.g. a Pipfile, the default permissions are 666 & ~umask

So I'm checking for whether it's a directory to figure out what octal value I need to bit-wise AND with umask.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichaelAquilina : Would you be willing to accept an updated/rebased version of this PR? I'm been getting hit with this quite often recently when working with a poetry based env. A lot of the poetry commands seem to rewrite poetry.lock, causing its permission to be reverted to defaults. Since those 664 on my system (Ubuntu 20.04 Desktop), I get this warning every time after the file has been touched :(

Copy link

@philer-jambit philer-jambit May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any update on this? I've also run into the poetry.lock file permissions issue.

Edit: For anyone else who gets here: It appears that poetry respects the permissions of the parent directory, so if you change your project folder to 644 or stricter it seems to work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: I've been using my patch for quite a while, and it's much better, but I've still been running into the problem occasionally (not sure why and don't care enough to track down what's going on), so I'm inclined to just remove the check in my fork entirely... still think it's a useful check in the case where $venv_path is an actual venv folder but for me, it never is.

moha-gh added a commit to moha-gh/zsh-autoswitch-virtualenv that referenced this pull request Aug 8, 2024
Triggers repeatedly when using the plugin in conjunction with poetry (see [0]).

[0]: MichaelAquilina#163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File permission checks problematic for pipenv projects
4 participants