mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 14:59:02 +08:00
Merge pull request #627 from fufesou/better_linux_run_cmds
better_linux_run_cmds: run cmds without creating tmp files
This commit is contained in:
commit
6c739289ce
@ -42,7 +42,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Invalid IP", "Neplatná IP adresa"),
|
||||
("id_change_tip", "Použít je mozné pouze znaky a-z, A-Z, 0-9 a _ (podtržítko). Dále je třeba aby začínalo na písmeno a-z, A-Z. Délka mezi 6 a 16 znaky."),
|
||||
("Invalid format", "Neplatný formát"),
|
||||
("This function is turned off by the server", "Tato funkce je vypnuta serverem"),
|
||||
("server_not_support", "Server zatím nepodporuje"),
|
||||
("Not available", "Není k dispozici"),
|
||||
("Too frequent", "Příliš časté"),
|
||||
("Cancel", "Storno"),
|
||||
|
@ -42,6 +42,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Invalid IP", "IP nevalida"),
|
||||
("id_change_tip", "Nur la signoj a-z, A-Z, 0-9, _ (substreko) povas esti uzataj. La unua litero povas esti inter a-z, A-Z. La longeco devas esti inter 6 kaj 16."),
|
||||
("Invalid format", "Formato nevalida"),
|
||||
("server_not_support", "Ankoraŭ ne subtenata de la servilo"),
|
||||
("Not available", "Nedisponebla"),
|
||||
("Too frequent", "Tro ofte ŝanĝita, bonvolu reprovi poste"),
|
||||
("Cancel", "Nuligi"),
|
||||
|
@ -42,7 +42,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Invalid IP", ""),
|
||||
("id_change_tip", ""),
|
||||
("Invalid format", ""),
|
||||
("This function is turned off by the server", ""),
|
||||
("server_not_support", ""),
|
||||
("Not available", ""),
|
||||
("Too frequent", ""),
|
||||
("Cancel", ""),
|
||||
|
@ -42,7 +42,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Invalid IP", "Geçersiz IP adresi"),
|
||||
("id_change_tip", "Yalnızca a-z, A-Z, 0-9 ve _ (alt çizgi) karakterlerini kullanabilirsiniz. İlk karakter a-z veya A-Z olmalıdır. Uzunluk 6 ile 16 karakter arasında olmalıdır."),
|
||||
("Invalid format", "Hatalı Format"),
|
||||
("This function is turned off by the server", "Bu özellik sunucu tarafından kapatıldı"),
|
||||
("server_not_support", "Henüz sunucu tarafından desteklenmiyor"),
|
||||
("Not available", "Erişilebilir değil"),
|
||||
("Too frequent", "Çok sık"),
|
||||
("Cancel", "İptal"),
|
||||
|
@ -184,7 +184,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("x11 expected", "預期 x11"),
|
||||
("Port", "連接埠"),
|
||||
("Settings", "設定"),
|
||||
("Username", " 使用者名稱"),
|
||||
("Username", "使用者名稱"),
|
||||
("Invalid port", "連接埠無效"),
|
||||
("Closed manually by the peer", "由對方手動關閉"),
|
||||
("Enable remote configuration modification", "啟用遠端更改設定"),
|
||||
|
@ -1,7 +1,6 @@
|
||||
use super::{CursorData, ResultType};
|
||||
use hbb_common::{allow_err, bail, log};
|
||||
use libc::{c_char, c_int, c_void};
|
||||
use std::io::prelude::*;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
sync::{
|
||||
@ -371,8 +370,7 @@ fn get_display_server_of_session(session: &str) -> String {
|
||||
.replace("TTY=", "")
|
||||
.trim_end()
|
||||
.into();
|
||||
if let Ok(Some(xorg_results)) =
|
||||
run_cmds(format!("ps -e | grep \"{}.\\\\+Xorg\"", tty))
|
||||
if let Ok(xorg_results) = run_cmds(format!("ps -e | grep \"{}.\\\\+Xorg\"", tty))
|
||||
// And check if Xorg is running on that tty
|
||||
{
|
||||
if xorg_results.trim_end().to_string() != "" {
|
||||
@ -441,9 +439,7 @@ pub fn current_is_wayland() -> bool {
|
||||
pub fn modify_default_login() -> String {
|
||||
let dsession = std::env::var("DESKTOP_SESSION").unwrap();
|
||||
let user_name = std::env::var("USERNAME").unwrap();
|
||||
if let Ok(Some(x)) =
|
||||
run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION}-xorg.desktop".to_owned())
|
||||
{
|
||||
if let Ok(x) = run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION}-xorg.desktop".to_owned()) {
|
||||
if x.trim_end().to_string() != "" {
|
||||
match std::process::Command::new("pkexec")
|
||||
.args(vec![
|
||||
@ -471,7 +467,7 @@ pub fn modify_default_login() -> String {
|
||||
return "Fix failed! Please re-login with X server manually".to_owned();
|
||||
}
|
||||
}
|
||||
} else if let Ok(Some(z)) =
|
||||
} else if let Ok(z) =
|
||||
run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION:0:-8}.desktop".to_owned())
|
||||
{
|
||||
if z.trim_end().to_string() != "" {
|
||||
@ -605,20 +601,11 @@ pub fn is_installed() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run_cmds(cmds: String) -> ResultType<Option<String>> {
|
||||
let mut tmp = std::env::temp_dir();
|
||||
tmp.push(format!("{}_{}", crate::get_app_name(), crate::get_time()));
|
||||
let mut file = std::fs::File::create(&tmp)?;
|
||||
file.write_all(cmds.as_bytes())?;
|
||||
file.sync_all()?;
|
||||
if let Ok(output) = std::process::Command::new("bash")
|
||||
.arg(tmp.to_str().unwrap_or(""))
|
||||
.output()
|
||||
{
|
||||
Ok(Some(String::from_utf8_lossy(&output.stdout).to_string()))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
pub fn run_cmds(cmds: String) -> ResultType<String> {
|
||||
let output = std::process::Command::new("sh")
|
||||
.args(vec!["-c", &cmds])
|
||||
.output()?;
|
||||
Ok(String::from_utf8_lossy(&output.stdout).to_string())
|
||||
}
|
||||
|
||||
fn get_env_tries(name: &str, uid: &str, n: usize) -> String {
|
||||
@ -635,7 +622,7 @@ fn get_env_tries(name: &str, uid: &str, n: usize) -> String {
|
||||
fn get_env(name: &str, uid: &str) -> String {
|
||||
let cmd = format!("ps -u {} -o pid= | xargs -I__ cat /proc/__/environ 2>/dev/null | tr '\\0' '\\n' | grep '^{}=' | tail -1 | sed 's/{}=//g'", uid, name, name);
|
||||
log::debug!("Run: {}", &cmd);
|
||||
if let Ok(Some(x)) = run_cmds(cmd) {
|
||||
if let Ok(x) = run_cmds(cmd) {
|
||||
x.trim_end().to_string()
|
||||
} else {
|
||||
"".to_owned()
|
||||
|
Loading…
Reference in New Issue
Block a user