Vydané zdroje
Stáhnout zdroje ZIP
CH-J Tools
Procházejte adresáře a soubory konkrétního vydání aplikace.
CH-J / Server Manager
872 souborů
core-20261030T220507Z-61e4558d889f
Přidáno: · Sestaveno:
1
//! Users facade: chooses the Linux or Windows backend from system facts of the remote host2
//! (uname / Win32_OperatingSystem) and returns only IPC-safe data.4
use super::common::fail;5
use super::linux::LinuxUsers;6
use super::windows::WindowsUsers;7
use crate::core::error::CoreResult;8
use crate::core::ssh::platform::detect_platform;9
use crate::core::ssh::session::SessionManager;10
use serde_json::Value;11
use std::sync::Arc;13
pub struct UserAdmin {14
pub sessions: Arc<SessionManager>,15
pub linux: LinuxUsers,16
pub windows: WindowsUsers,17
}19
impl UserAdmin {20
/// `Some(platform)` for Windows servers, `None` for Linux/POSIX.21
async fn windows(&self, session_id: &str) -> CoreResult<Option<Value>> {22
let record = self.sessions.require_connected(session_id)?;23
let platform = detect_platform(&self.sessions, &record, false).await?;24
match platform["os"].as_str() {25
Some("windows") => Ok(Some(platform)),26
Some("unknown") => Err(fail(27
"USERS_PLATFORM_UNSUPPORTED",28
&format!("The remote operating system could not be identified: {}.", platform["reason"].as_str().filter(|s| !s.is_empty()).unwrap_or("no POSIX shell and no Windows PowerShell")),29
)),30
_ => Ok(None),31
}32
}34
pub async fn privileges(&self, session_id: &str, refresh: bool) -> CoreResult<Value> {35
if self.windows(session_id).await?.is_some() {36
return self.windows.privileges(session_id).await;37
}38
self.linux.privileges(session_id, refresh).await39
}41
pub async fn inventory(&self, session_id: &str, options: &Value) -> CoreResult<Value> {42
if let Some(platform) = self.windows(session_id).await? {43
return self.windows.inventory(session_id, &platform).await;44
}45
Ok(self.linux.inventory(session_id, options).await?.public)46
}48
pub async fn list(&self, session_id: &str) -> CoreResult<Value> {49
if let Some(platform) = self.windows(session_id).await? {50
let inventory = self.windows.inventory(session_id, &platform).await?;51
return Ok(Value::Array(inventory["users"].as_array().cloned().unwrap_or_default().into_iter().filter(|u| u["system"] != true).collect()));52
}53
self.linux.list_compat(session_id).await54
}56
pub async fn detail(&self, session_id: &str, options: &Value) -> CoreResult<Value> {57
if let Some(platform) = self.windows(session_id).await? {58
return Ok(self.windows.detail(session_id, options, &platform).await?.public);59
}60
self.linux.detail_public(session_id, options).await61
}63
pub async fn manage(&self, session_id: &str, payload: &Value) -> CoreResult<Value> {64
if let Some(platform) = self.windows(session_id).await? {65
return self.windows.manage(session_id, payload, &platform).await;66
}67
self.linux.manage(session_id, payload).await68
}70
pub async fn keys(&self, session_id: &str, payload: &Value) -> CoreResult<Value> {71
if let Some(platform) = self.windows(session_id).await? {72
return self.windows.keys(session_id, payload, &platform).await;73
}74
self.linux.keys(session_id, payload).await75
}77
pub async fn ssh_policy(&self, session_id: &str, payload: &Value) -> CoreResult<Value> {78
if let Some(platform) = self.windows(session_id).await? {79
return self.windows.ssh_policy(session_id, payload, &platform).await;80
}81
self.linux.ssh_policy(session_id, payload).await82
}83
}SHA-256
5277cfde188a8d75cd1d88324cb8bfdc7443ced149ad886b26ce0db752ed5854CH-J Proprietary Software License 1.14 · Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.
SHA-256 archivu
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df