-
Notifications
You must be signed in to change notification settings - Fork 267
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
Add root check #821
Add root check #821
Conversation
just look for |
Not only docker env runs as root. Normal user may invoke linutil as root |
this allows the user run the script to run it in docker/podman/ andy other container system. this is because users do not usally create users in containers, and insted default to the root user pre-created. we just need to tweak the scripts to allow the scripts to skip elevation checks if the user is root |
Running scripts as root may break many things. For example configuration files should not be in root permission. An application or non-root user may not be able to rw the configuration file due to insufficient permissions. And why would someone try to run linutil in a docker container ?? |
I need to set up the bash scripts as I can't stand the default one |
@jeevithakannan2 instead of precluding the use, it might be worth implementing a root warning and doing a refactor to just leave |
I don't like this. Running a ubuntu docker container should generally the same as running as root in a bare-metal ubuntu install, unless you're running a crazy stripped-down image. There are better solutions to make this workable for this kind of use-case |
Ok will go through this one more time. If root is disabled arch server setup cannot be run. We could add a param to allow running as root like compatible mode |
Also, I made a PR (jeevithakannan2#1) on your dev branch that implements a warning prompt notifying users that they are running as root. Since we're not really testing these scripts with standard user perms, it's probably best to notify users that they are outside the bounds of the current user story |
I also would remove the cli flag since most users are probably going to be using the network runner |
Yeah removed it thanks for the PR |
3135d3a
to
9d3f97b
Compare
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.
I think this implementation is wrong and overengineered. We can just check the UID or even file permissions. This will only slow linutil down.
? |
This PR is adding another rust dependency, more checks and code that has to be maintained. I just think this can be easily avoided with a more efficient approach. |
Getting the inlined superuser check functional would need even more code to maintain, and it would be hard to beat 8 lines of bash except by just unquoting all references to |
Tbh, I think unquoting would be the simplest @jeevithakannan2 |
Mmm 🤔 |
So I undo the changes and not use a crate. If yes I have solution for that too !! |
Fair point |
We can check the USER env right for running as root ? @cartercanedy What do you think should I just check the |
@jeevithakannan2 You can use Rust's |
Co-authored-by: Adam Perkowski <[email protected]>
I'm not sure what all this discussion is, it's already been decided that we're going to adapt the scripts to work on root (as as been done in the recent commits here) rather than prohibiting linutil from launching as root. Please drop c997a3d. By the way, @adamperkowski, both crates mentioned here, nix and this unmaintained sudo crate use libc::getuid() anyways. I think it's a poor idea to religiously avoid writing a line of unsafe code, just to pick up another dependency which calls quite literally the exact same function. That does the opposite of improving security. |
I am aware that they do use |
I think you should check the files changed before suggesting. That commit was reverted |
We should use a |
refactor: Reduce nesting in root module
@ChrisTitusTech All the scripts have shellcheck warning and formatting issues that need to be resolved in a separate PR. This PR has no issues. |
? |
I was just about to say... |
Only merge this at last after merging all the script PRs
Type of Change
Description
Caution
This is going to cause many merge conflicts. Merge other PRs first and I will update this PR later.
nix
crateTesting
Issues / other PRs related
Checklist