mirror of
https://github.com/coastalwhite/lemurs
synced 2024-11-26 12:00:17 +00:00
Reverse using let-else for lower MSRV
This commit is contained in:
parent
bd2d82755b
commit
acdd0ec58b
1 changed files with 40 additions and 22 deletions
|
@ -71,7 +71,7 @@ impl PostLoginEnvironment {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
info!("Starting Wayland Session");
|
info!("Starting Wayland Session");
|
||||||
let Ok(child) = unsafe {
|
let child = match unsafe {
|
||||||
Command::new("/bin/sh").pre_exec(move || {
|
Command::new("/bin/sh").pre_exec(move || {
|
||||||
// NOTE: The order here is very vital, otherwise permission errors occur
|
// NOTE: The order here is very vital, otherwise permission errors occur
|
||||||
// This is basically a copy of how the nightly standard library does it.
|
// This is basically a copy of how the nightly standard library does it.
|
||||||
|
@ -84,9 +84,13 @@ impl PostLoginEnvironment {
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(script_path)
|
.arg(script_path)
|
||||||
.stdout(Stdio::null()) // TODO: Maybe this should be logged or something?
|
.stdout(Stdio::null()) // TODO: Maybe this should be logged or something?
|
||||||
.spawn() else {
|
.spawn()
|
||||||
error!("Failed to start Wayland Compositor");
|
{
|
||||||
return Err(EnvironmentStartError::WaylandStartError);
|
Ok(child) => child,
|
||||||
|
Err(_) => {
|
||||||
|
error!("Failed to start Wayland Compositor");
|
||||||
|
return Err(EnvironmentStartError::WaylandStartError);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Entered Wayland compositor");
|
info!("Entered Wayland compositor");
|
||||||
|
@ -94,17 +98,23 @@ impl PostLoginEnvironment {
|
||||||
|
|
||||||
let session = add_utmpx_entry(&user_info.name, config.tty, pid);
|
let session = add_utmpx_entry(&user_info.name, config.tty, pid);
|
||||||
|
|
||||||
let Ok(output) = child.wait_with_output() else {
|
let output = match child.wait_with_output() {
|
||||||
error!("Failed to wait on TTY shell, Reason. Returning to Lemurs...");
|
Ok(output) => output,
|
||||||
return Ok(());
|
Err(_) => {
|
||||||
|
error!("Failed to wait on TTY shell, Reason. Returning to Lemurs...");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
drop(session);
|
drop(session);
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let Ok(output_stderr) = std::str::from_utf8(&output.stderr) else {
|
let output_stderr = match std::str::from_utf8(&output.stderr) {
|
||||||
warn!("Failed to read STDERR output as UTF-8");
|
Ok(output_stderr) => output_stderr,
|
||||||
return Ok(());
|
Err(_) => {
|
||||||
|
warn!("Failed to read STDERR output as UTF-8");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !output_stderr.trim().is_empty() {
|
if !output_stderr.trim().is_empty() {
|
||||||
|
@ -126,7 +136,7 @@ impl PostLoginEnvironment {
|
||||||
|
|
||||||
info!("Starting TTY shell");
|
info!("Starting TTY shell");
|
||||||
let shell = &user_info.shell;
|
let shell = &user_info.shell;
|
||||||
let Ok(child) = unsafe {
|
let child = match unsafe {
|
||||||
Command::new(shell).pre_exec(move || {
|
Command::new(shell).pre_exec(move || {
|
||||||
// NOTE: The order here is very vital, otherwise permission errors occur
|
// NOTE: The order here is very vital, otherwise permission errors occur
|
||||||
// This is basically a copy of how the nightly standard library does it.
|
// This is basically a copy of how the nightly standard library does it.
|
||||||
|
@ -139,11 +149,13 @@ impl PostLoginEnvironment {
|
||||||
.stdout(Stdio::inherit())
|
.stdout(Stdio::inherit())
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.stdin(Stdio::inherit())
|
.stdin(Stdio::inherit())
|
||||||
.spawn() else {
|
.spawn()
|
||||||
error!(
|
{
|
||||||
"Failed to start TTY shell. Returning to Lemurs...",
|
Ok(child) => child,
|
||||||
);
|
Err(_) => {
|
||||||
return Ok(());
|
error!("Failed to start TTY shell. Returning to Lemurs...",);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Entered TTY");
|
info!("Entered TTY");
|
||||||
|
@ -151,17 +163,23 @@ impl PostLoginEnvironment {
|
||||||
|
|
||||||
let session = add_utmpx_entry(&user_info.name, config.tty, pid);
|
let session = add_utmpx_entry(&user_info.name, config.tty, pid);
|
||||||
|
|
||||||
let Ok(output) = child.wait_with_output() else {
|
let output = match child.wait_with_output() {
|
||||||
error!("Failed to wait on TTY shell, Reason. Returning to Lemurs...");
|
Ok(output) => output,
|
||||||
return Ok(());
|
Err(_) => {
|
||||||
|
error!("Failed to wait on TTY shell, Reason. Returning to Lemurs...");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
drop(session);
|
drop(session);
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let Ok(output_stderr) = std::str::from_utf8(&output.stderr) else {
|
let output_stderr = match std::str::from_utf8(&output.stderr) {
|
||||||
warn!("Failed to read STDERR output as UTF-8");
|
Ok(output_stderr) => output_stderr,
|
||||||
return Ok(());
|
Err(_) => {
|
||||||
|
warn!("Failed to read STDERR output as UTF-8");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !output_stderr.trim().is_empty() {
|
if !output_stderr.trim().is_empty() {
|
||||||
|
|
Loading…
Reference in a new issue