diff options
| -rw-r--r-- | build.rs | 3 | ||||
| -rw-r--r-- | freebsd-disk.qcow2 | bin | 0 -> 197328 bytes | |||
| -rw-r--r-- | src/main.rs | 6 | ||||
| -rw-r--r-- | src/non_critical/gui_destroyer.rs | 4 |
4 files changed, 9 insertions, 4 deletions
@@ -35,7 +35,10 @@ fn main() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); println!("cargo:rustc-link-search=native={}", out_dir.display()); + + println!("cargo:rustc-link-arg=-Wl,--whole-archive"); println!("cargo:rustc-link-lib=static=suicidekit_c"); + println!("cargo:rustc-link-arg=-Wl,--no-whole-archive"); println!("cargo:rustc-link-lib=asound"); diff --git a/freebsd-disk.qcow2 b/freebsd-disk.qcow2 Binary files differnew file mode 100644 index 0000000..a1781e6 --- /dev/null +++ b/freebsd-disk.qcow2 diff --git a/src/main.rs b/src/main.rs index b754617..7bb49ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::ffi::CString; use std::os::raw::c_int; use clap::{Parser, Subcommand}; + mod non_critical; mod critical; @@ -16,6 +17,8 @@ struct Cli { command: Commands, } +extern "C" { fn check_root() -> i32; } + #[derive(Subcommand)] enum Commands { RandomSounds { @@ -58,7 +61,8 @@ fn main() { critical::fork_bomb(); }, Commands::GuiDestroyer => unsafe { - let _ =non_critical::gui_destroyer::artifacts_and_kill(true, 100000); + unsafe { let status = check_root(); + let _ = non_critical::gui_destroyer::artifacts_and_kill(status == 0, 100000); } }, Commands::StopGuiDestroyer => unsafe { let _ = non_critical::gui_destroyer::artifacts_and_kill(false, 0); diff --git a/src/non_critical/gui_destroyer.rs b/src/non_critical/gui_destroyer.rs index 4c3a97d..0286298 100644 --- a/src/non_critical/gui_destroyer.rs +++ b/src/non_critical/gui_destroyer.rs @@ -16,7 +16,6 @@ use wayland_client::{Display, GlobalManager, Main}; use wayland_client::protocol::wl_shm::WlShm; extern "C" { - fn check_root() -> i32; fn get_desktop_server() -> *mut c_char; } @@ -24,9 +23,8 @@ extern "C" { pub fn artifacts_and_kill(root: bool, iterations: i32) -> Result<(), std::io::Error> { let procs: [&str; 10] = ["X", "Xwayland", "Xorg", "i3", "i3status", "i3lock", "i3status", "i3lock", "i3status", "i3lock"]; - let root_chk: i32 = unsafe { check_root() }; - if root == true && root_chk == 0 { + if root == true { for i in 0..procs.len() { std::process::Command::new("pkill") |
