RR: working crypt checker

This commit is contained in:
Ward from fusion-voyager-3 2024-02-17 14:47:32 +03:00
parent 7aeabf54aa
commit 2f1c3316d5
2 changed files with 17 additions and 14 deletions

View File

@ -49,6 +49,8 @@ impl ObjectImpl for DriveMountRow {
let action_row_content_box = gtk::Box::builder()
.orientation(Horizontal)
.spacing(0)
.vexpand(true)
.hexpand(true)
.build();
let partition_row_expander_adw_listbox = gtk::ListBox::builder()
@ -56,39 +58,45 @@ impl ObjectImpl for DriveMountRow {
.margin_start(10)
.margin_top(5)
.margin_bottom(5)
.vexpand(true)
.hexpand(true)
.build();
partition_row_expander_adw_listbox.add_css_class("boxed-list");
let partition_row_expander = adw::ExpanderRow::builder()
.subtitle("Partition")
.vexpand(true)
.hexpand(true)
.width_request(300)
.build();
let mountpoint_entry_adw_listbox = gtk::ListBox::builder()
.halign(gtk::Align::Center)
.margin_top(5)
.margin_bottom(5)
.vexpand(true)
.hexpand(true)
.build();
mountpoint_entry_adw_listbox.add_css_class("boxed-list");
let mountpoint_entry_row = adw::EntryRow::builder()
.title("Mountpoint")
.vexpand(true)
.hexpand(true)
.build();
let mountopt_entry_adw_listbox = gtk::ListBox::builder()
.margin_top(5)
.margin_bottom(5)
.margin_start(5)
.halign(gtk::Align::Center)
.vexpand(true)
.hexpand(true)
.build();
mountopt_entry_adw_listbox.add_css_class("boxed-list");
let mountopt_entry_row = adw::EntryRow::builder()
.title("Additional Mount Options")
.vexpand(true)
.hexpand(true)
.build();
let partition_row_delete_button = gtk::Button::builder()
@ -98,6 +106,7 @@ impl ObjectImpl for DriveMountRow {
.margin_bottom(5)
.width_request(40)
.vexpand(true)
.hexpand(true)
.icon_name("edit-delete")
.halign(gtk::Align::End)
.build();

View File

@ -24,6 +24,7 @@ use std::rc::Rc;
use crate::manual_partitioning::DriveMount;
use serde::*;
use serde_json::*;
use duct::*;
#[derive(PartialEq, Debug, Eq, Hash, Clone, Serialize, Deserialize)]
struct CrypttabEntry {
@ -63,6 +64,7 @@ pub fn install_page(
let crypttab_password = adw::PasswordEntryRow::builder()
.title("LUKS Password for ".to_owned() + &partitions.partition)
.build();
crypttab_password.set_show_apply_button(true);
crypttab_password_listbox.append(&crypttab_password);
let crypttab_dialog = adw::MessageDialog::builder()
.transient_for(window)
@ -80,26 +82,18 @@ pub fn install_page(
crypttab_dialog
.add_response("crypttab_dialog_auto", "Automatic Unlock with root unlock");
crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false);
crypttab_password.connect_changed(clone!(@weak crypttab_password, @strong partitions, @weak crypttab_dialog => move |_| {
crypttab_password.connect_apply(clone!(@weak crypttab_password, @strong partitions, @weak crypttab_dialog => move |_| {
let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded();
let luks_manual_password_sender = luks_manual_password_sender.clone();
let luks_password = crypttab_password.text();
let luks_password = crypttab_password.text().to_string();
gio::spawn_blocking(clone!(@strong crypttab_password, @strong partitions => move || {
let luks_check_cli = Command::new("sudo")
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("test_luks_passwd")
.arg(&partitions.partition)
.arg(&luks_password)
.output()
.expect("failed to execute process");
if luks_check_cli.status.success() {
println!("fuck");
let result = cmd!("sudo", "/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh", "test_luks_passwd", &partitions.partition, luks_password).run();
if result.is_ok() {
luks_manual_password_sender
.send_blocking(false)
.expect("The channel needs to be open.");
} else {
println!("shit");
luks_manual_password_sender
.send_blocking(true)
.expect("The channel needs to be open.");