-
Notifications
You must be signed in to change notification settings - Fork 5
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
restrict folder and file permissions created by libvirt-provider #215
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those file permission constants are all over the place. If we want to use constants here, can't we put them globally into a central FS related file?
It is possible and @so-sahu had the same recommendation. I am personally more against it. Main reason are:
I am not strongly against it but i prefer do it for small projects with few packages. Here i maybe keep current solution. But if other people will have different opinion and can rewrite it, no problem. |
Co-authored-by: Andreas Fritzler <[email protected]>
Defining constants for file permissions might be a dangerous thing - but then I would say we stick to the octal numbers directly and don't use constants at all. That way you know that this operation is using 0640 for write a certain file. |
More restricted linters can have problem with that, because they look at it as magic number and best practices for magic number is use variable and add some semantic with name for it. It can be simple solve with ignore specific error regexp. But using constants have some benefits. Maybe good example how names adding semantic meaning in permFolder and permFile. folder needs execution for open of folder by default. file doesn't need that, but if file is binary you can create new constant permBinary and you will directly see why are you using this permission for file. But i am okay with your suggestion but i want to hear more opinion. @so-sahu @lukasfrank @hardikdr |
In my opinion, in a public project with permissions used in multiple places, it makes more sense to use constants with meaningful names. This approach offers several benefits:
Adopting this approach will improve code readability, maintainability, and consistency. |
Below is an in-depth analysis comparing centralizing file permission constants in one package with global environment variables v/s the current decentralized approach. Suggestion 1: Centralizing File Permission Constants
Suggestion 2: Keep Constants Distributed
In conclusion, for larger projects like |
Proposed Changes
Folders permissions were restricted from 0777 to 0750
File permissions were restricted from 0666 to 0640 or 0660
Libvirtd has still access into folder.
Depends on setup current permissions can be problematic. Libvirtd is running as root in my current setup.
@hardikdr @lukasfrank could you retest it in your environment before merge?
Setup of environment will have to been properly documented in follow up issue.
Fixes #197