Disallow running CLI with root privileges (#32583)
In #31331, I made a change that prevents Zed from running with root privileges, but I forgot about the CLI. So if you run the CLI without the `--foreground` flag, it just freezes without any messages. This PR fixes that. Release Notes: - N/A
This commit is contained in:
+1
-16
@@ -162,22 +162,7 @@ fn fail_to_open_window(e: anyhow::Error, _cx: &mut App) {
|
||||
|
||||
pub fn main() {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let is_root = nix::unistd::geteuid().is_root();
|
||||
let allow_root = env::var("ZED_ALLOW_ROOT").is_ok_and(|val| val == "true");
|
||||
|
||||
// Prevent running Zed with root privileges on Unix systems unless explicitly allowed
|
||||
if is_root && !allow_root {
|
||||
eprintln!(
|
||||
"\
|
||||
Error: Running Zed as root or via sudo is unsupported.
|
||||
Doing so (even once) may subtly break things for all subsequent non-root usage of Zed.
|
||||
It is untested and not recommended, don't complain when things break.
|
||||
If you wish to proceed anyways, set `ZED_ALLOW_ROOT=true` in your environment."
|
||||
);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
util::prevent_root_execution();
|
||||
|
||||
// Check if there is a pending installer
|
||||
// If there is, run the installer and exit
|
||||
|
||||
Reference in New Issue
Block a user