forked from pisilinux-rs/yali-rs
Merge branch 'main' into 'main'
Main See merge request ayhanyalcinsoy/yali-rs!3
This commit is contained in:
+1
-47
@@ -1371,6 +1371,7 @@ impl Job for CleanupLiveJob {
|
||||
let _ = tokio::fs::remove_file(format!("{}/usr/share/applications/yali.desktop", mt)).await;
|
||||
let _ = tokio::fs::remove_file(format!("{}/usr/share/applications/yali-bin.desktop", mt)).await;
|
||||
let _ = tokio::fs::remove_dir_all(format!("{}/bootmnt", mt)).await;
|
||||
let _ = run_chroot(&self.mount, &["userdel", "-r", "pisi"]).await;
|
||||
|
||||
|
||||
ui.log("✓ Live temizlik tamamlandı");
|
||||
@@ -1795,53 +1796,6 @@ impl Job for CreateUserJob {
|
||||
// }
|
||||
// }
|
||||
|
||||
/// `chpasswd` komutuna stdin üzerinden kullanıcı:şifre gönderir.
|
||||
async fn set_password_via_chpasswd(mount: &str, input: &str) -> Result<(), String> {
|
||||
if DEMO_MODE.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(2500)).await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::process::Command;
|
||||
|
||||
let mut child = Command::new("chroot")
|
||||
.args([mount, "chpasswd"])
|
||||
// Gerekirse varsayılan algoritmayı garantiye almak için araya "-c", "SHA512" argümanları eklenebilir.
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| format!("chpasswd başlatılamadı: {}", e))?;
|
||||
|
||||
if let Some(mut stdin) = child.stdin.take() {
|
||||
let mut data = input.as_bytes().to_vec();
|
||||
if !data.ends_with(b"\n") {
|
||||
data.push(b'\n');
|
||||
}
|
||||
|
||||
// 1. Veriyi tampon belleğe yaz
|
||||
stdin.write_all(&data).await
|
||||
.map_err(|e| format!("chpasswd stdin yazma hatası: {}", e))?;
|
||||
|
||||
// 2. KRİTİK EKSİK: Tampondaki veriyi chpasswd sürecine zorla gönder (Sıvazla)
|
||||
stdin.flush().await
|
||||
.map_err(|e| format!("chpasswd stdin flush hatası: {}", e))?;
|
||||
|
||||
// 3. Kanalı elinle kapatarak chpasswd'e "bitti" (EOF) sinyali yolla
|
||||
drop(stdin);
|
||||
}
|
||||
|
||||
// wait_with_output zaten arkada kalan süreçleri temizler ve çıktıları toplar
|
||||
let output = child.wait_with_output().await
|
||||
.map_err(|e| format!("chpasswd bekleme hatası: {}", e))?;
|
||||
|
||||
if output.status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(String::from_utf8_lossy(&output.stderr).trim().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// fstab'ı doğrudan dosyaya yazar (genfstab yerine; ISO ortamında daha güvenilir).
|
||||
pub struct GenerateFstabJob {
|
||||
|
||||
Reference in New Issue
Block a user