mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 04:12:20 +08:00
fedora
This commit is contained in:
parent
afc842785a
commit
401648eefd
37
README.md
37
README.md
@ -12,9 +12,8 @@ Desktop versions use [sciter](https://sciter.com/) for GUI, please download scit
|
|||||||
[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so)
|
[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so)
|
||||||
[Osx](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib)
|
[Osx](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib)
|
||||||
|
|
||||||
## How To Build
|
|
||||||
|
|
||||||
### Steps
|
## Raw Steps to build
|
||||||
* Prepare your Rust development env and C++ build env
|
* Prepare your Rust development env and C++ build env
|
||||||
|
|
||||||
* Install [vcpkg](https://github.com/microsoft/vcpkg), and set `VCPKG_ROOT` env variable correctly
|
* Install [vcpkg](https://github.com/microsoft/vcpkg), and set `VCPKG_ROOT` env variable correctly
|
||||||
@ -23,13 +22,41 @@ Desktop versions use [sciter](https://sciter.com/) for GUI, please download scit
|
|||||||
- Linux/Osx: vcpkg install libvpx libyuv opus
|
- Linux/Osx: vcpkg install libvpx libyuv opus
|
||||||
|
|
||||||
* run `cargo run`
|
* run `cargo run`
|
||||||
### Build on Debain
|
|
||||||
|
## How to build on Linux
|
||||||
|
|
||||||
|
### Ubuntu 18 (Debain 10)
|
||||||
```
|
```
|
||||||
sudo apt install -y git curl wget nasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake
|
sudo apt install -y g++ gcc git curl wget nasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake
|
||||||
git clone https://github.com/microsoft/vcpkg
|
```
|
||||||
|
|
||||||
|
### Fedora 28
|
||||||
|
```
|
||||||
|
yum -y install gcc-c++ git curl wget nasm gcc gtk3-devel clang libxcb-devel libxdo-devel libXfixes-devel pulseaudio-libs-devel cmake alsa-lib-devel
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install VCPKG
|
||||||
|
```
|
||||||
|
git clone https://github.com/microsoft/vcpkg --branch 2020.11-1
|
||||||
vcpkg/bootstrap-vcpkg.sh
|
vcpkg/bootstrap-vcpkg.sh
|
||||||
export VCPKG_ROOT=$HOME/vcpkg
|
export VCPKG_ROOT=$HOME/vcpkg
|
||||||
vcpkg/vcpkg install libvpx libyuv opus
|
vcpkg/vcpkg install libvpx libyuv opus
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fix libvpx (For Fedora)
|
||||||
|
```
|
||||||
|
cd vcpkg/buildtrees/libvpx/src
|
||||||
|
cd *
|
||||||
|
./configure
|
||||||
|
sed -i 's/CFLAGS+=-I/CFLAGS+=-fPIC -I/g' Makefile
|
||||||
|
sed -i 's/CXXFLAGS+=-I/CXXFLAGS+=-fPIC -I/g' Makefile
|
||||||
|
make
|
||||||
|
cp libvpx.a $HOME/vcpkg/installed/x64-linux/lib/
|
||||||
|
cd
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build
|
||||||
|
```
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
source $HOME/.cargo/env
|
source $HOME/.cargo/env
|
||||||
git clone https://github.com/rustdesk/rustdesk
|
git clone https://github.com/rustdesk/rustdesk
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use super::{CursorData, ResultType};
|
use super::{CursorData, ResultType};
|
||||||
use hbb_common::{allow_err, bail, log};
|
use hbb_common::{allow_err, bail, log};
|
||||||
use libc::{c_char, c_int, c_void};
|
use libc::{c_char, c_int, c_void};
|
||||||
|
use std::io::prelude::*;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
sync::{
|
sync::{
|
||||||
@ -30,7 +31,7 @@ extern "C" {
|
|||||||
#[link(name = "X11")]
|
#[link(name = "X11")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn XOpenDisplay(display_name: *const c_char) -> *mut c_void;
|
fn XOpenDisplay(display_name: *const c_char) -> *mut c_void;
|
||||||
// fn XCloseDisplay(d: *mut c_void) -> c_int;
|
// fn XCloseDisplay(d: *mut c_void) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[link(name = "Xfixes")]
|
#[link(name = "Xfixes")]
|
||||||
@ -162,8 +163,36 @@ pub fn start_os_service() {
|
|||||||
if tmp != uid && !tmp.is_empty() {
|
if tmp != uid && !tmp.is_empty() {
|
||||||
uid = tmp;
|
uid = tmp;
|
||||||
log::info!("uid of seat0: {}", uid);
|
log::info!("uid of seat0: {}", uid);
|
||||||
std::env::set_var("XAUTHORITY", format!("/run/user/{}/gdm/Xauthority", uid));
|
let gdm = format!("/run/user/{}/gdm/Xauthority", uid);
|
||||||
std::env::set_var("DISPLAY", get_display());
|
let mut auth = get_env("XAUTHORITY", &uid);
|
||||||
|
if auth.is_empty() {
|
||||||
|
auth = if std::path::Path::new(&gdm).exists() {
|
||||||
|
gdm
|
||||||
|
} else {
|
||||||
|
let username = get_active_username();
|
||||||
|
if username == "root" {
|
||||||
|
format!("/{}/.Xauthority", username)
|
||||||
|
} else {
|
||||||
|
let tmp = format!("/home/{}/.Xauthority", username);
|
||||||
|
if std::path::Path::new(&tmp).exists() {
|
||||||
|
tmp
|
||||||
|
} else {
|
||||||
|
format!("/var/lib/{}/.Xauthority", username)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let mut d = get_env("DISPLAY", &uid);
|
||||||
|
if d.is_empty() {
|
||||||
|
d = get_display();
|
||||||
|
}
|
||||||
|
if d.is_empty() {
|
||||||
|
d = ":0".to_owned()
|
||||||
|
}
|
||||||
|
log::info!("DISPLAY: {}", d);
|
||||||
|
log::info!("XAUTHORITY: {}", auth);
|
||||||
|
std::env::set_var("XAUTHORITY", auth);
|
||||||
|
std::env::set_var("DISPLAY", d);
|
||||||
if let Some(ps) = server.as_mut() {
|
if let Some(ps) = server.as_mut() {
|
||||||
allow_err!(ps.kill());
|
allow_err!(ps.kill());
|
||||||
std::thread::sleep(std::time::Duration::from_millis(30));
|
std::thread::sleep(std::time::Duration::from_millis(30));
|
||||||
@ -245,26 +274,27 @@ fn get_cm() -> bool {
|
|||||||
|
|
||||||
fn get_display() -> String {
|
fn get_display() -> String {
|
||||||
let user = get_active_username();
|
let user = get_active_username();
|
||||||
|
log::debug!("w {}", &user);
|
||||||
if let Ok(output) = std::process::Command::new("w").arg(&user).output() {
|
if let Ok(output) = std::process::Command::new("w").arg(&user).output() {
|
||||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||||
|
log::debug!(" {}", line);
|
||||||
let mut iter = line.split_whitespace();
|
let mut iter = line.split_whitespace();
|
||||||
let a = iter.nth(1);
|
let b = iter.nth(2);
|
||||||
let b = iter.next();
|
if let Some(b) = b {
|
||||||
if a == b {
|
if b.starts_with(":") {
|
||||||
if let Some(b) = b {
|
return b.to_owned();
|
||||||
if b.starts_with(":") {
|
|
||||||
return b.to_owned();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// above not work for gdm user
|
// above not work for gdm user
|
||||||
|
log::debug!("ls -l /tmp/.X11-unix/");
|
||||||
if let Ok(output) = std::process::Command::new("ls")
|
if let Ok(output) = std::process::Command::new("ls")
|
||||||
.args(vec!["-l", "/tmp/.X11-unix/"])
|
.args(vec!["-l", "/tmp/.X11-unix/"])
|
||||||
.output()
|
.output()
|
||||||
{
|
{
|
||||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||||
|
log::debug!(" {}", line);
|
||||||
let mut iter = line.split_whitespace();
|
let mut iter = line.split_whitespace();
|
||||||
if iter.nth(2) == Some(&user) {
|
if iter.nth(2) == Some(&user) {
|
||||||
if let Some(x) = iter.last() {
|
if let Some(x) = iter.last() {
|
||||||
@ -444,3 +474,33 @@ pub fn block_input(_v: bool) {
|
|||||||
pub fn is_installed() -> bool {
|
pub fn is_installed() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn run_cmds(cmds: String) -> ResultType<Option<String>> {
|
||||||
|
let mut tmp = std::env::temp_dir();
|
||||||
|
tmp.push(format!(
|
||||||
|
"{}_{}",
|
||||||
|
hbb_common::config::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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 -m1 '^{}=' | sed 's/{}=//g'", uid, name, name);
|
||||||
|
log::debug!("Run: {}", &cmd);
|
||||||
|
if let Ok(Some(x)) = run_cmds(cmd) {
|
||||||
|
x.trim_end().to_string()
|
||||||
|
} else {
|
||||||
|
"".to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user