Implement RUSTDESK_UNATTENDED_PWD_VISIBILITY to enable visibility of unattended passwords within the Admin UI even when User is logged in.
build / build-linux-amd64 (push) Successful in 1m45s
build / build-linux-amd64 (push) Successful in 1m45s
This commit is contained in:
@@ -211,8 +211,9 @@ async fn render_table(state: &Arc<AppState>, lang: Lang) -> Result<String, ApiEr
|
||||
t(lang, "devices.no_devices"),
|
||||
);
|
||||
}
|
||||
let always_show_pwd = unattended_pwd_always_visible();
|
||||
for d in &devices {
|
||||
render_device_row(&mut s, lang, d, now);
|
||||
render_device_row(&mut s, lang, d, now, always_show_pwd);
|
||||
}
|
||||
let _ = write!(
|
||||
s,
|
||||
@@ -225,11 +226,24 @@ async fn render_table(state: &Arc<AppState>, lang: Lang) -> Result<String, ApiEr
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
/// Resolves the `--unattended-pwd-visibility` setting (env key
|
||||
/// `UNATTENDED-PWD-VISIBILITY`, also settable via `.env`). Returns `true`
|
||||
/// when the admin UI should surface the unattended password even while an
|
||||
/// interactive user is logged in. Default (`logged-out`, or any
|
||||
/// unrecognised value) keeps the original behaviour: shown only when nobody
|
||||
/// is logged in.
|
||||
fn unattended_pwd_always_visible() -> bool {
|
||||
crate::common::get_arg_or("unattended-pwd-visibility", "logged-out".to_owned())
|
||||
.trim()
|
||||
.eq_ignore_ascii_case("always")
|
||||
}
|
||||
|
||||
fn render_device_row(
|
||||
s: &mut String,
|
||||
lang: Lang,
|
||||
d: &DashboardDeviceRow,
|
||||
now: chrono::DateTime<chrono::Utc>,
|
||||
always_show_pwd: bool,
|
||||
) {
|
||||
let parsed: serde_json::Value =
|
||||
serde_json::from_str(&d.sysinfo_payload).unwrap_or(serde_json::Value::Null);
|
||||
@@ -290,11 +304,12 @@ fn render_device_row(
|
||||
// Per-boot unattended-access password reported by hello-agent. Visible
|
||||
// only when (a) the device is online (offline rows show stale data),
|
||||
// (b) no interactive user is logged in (otherwise the supporter
|
||||
// should be using the per-session approval popup, not the password),
|
||||
// and (c) the agent has actually reported one (vanilla rustdesk
|
||||
// should be using the per-session approval popup, not the password)
|
||||
// — unless `--unattended-pwd-visibility=always` overrides (b), and
|
||||
// (c) the agent has actually reported one (vanilla rustdesk
|
||||
// never will). Otherwise show a neutral dash so the column lines up.
|
||||
let unattended_pwd_cell = if is_online
|
||||
&& active_user.is_empty()
|
||||
&& (always_show_pwd || active_user.is_empty())
|
||||
&& !d.unattended_password.is_empty()
|
||||
{
|
||||
format!(
|
||||
|
||||
Reference in New Issue
Block a user