diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml index a4056376b..2724d9fee 100644 --- a/.github/workflows/flutter-build.yml +++ b/.github/workflows/flutter-build.yml @@ -960,7 +960,7 @@ jobs: files: | signed-apk/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.apk - build-rustdesk-lib-linux: + build-rustdesk-linux: needs: [generate-bridge-linux] name: build-rust-lib ${{ matrix.job.target }} ${{ matrix.job.extra-build-features }} runs-on: ${{ matrix.job.on }} @@ -973,48 +973,12 @@ jobs: arch: x86_64, target: x86_64-unknown-linux-gnu, distro: ubuntu18.04, - extra-build-features: "", - enable-headless: true, - on: ubuntu-20.04, - } - - { - arch: x86_64, - target: x86_64-unknown-linux-gnu, - distro: ubuntu18.04, - extra-build-features: "flatpak", - enable-headless: false, - on: ubuntu-20.04, - } - - { - arch: x86_64, - target: x86_64-unknown-linux-gnu, - distro: ubuntu18.04, - extra-build-features: "appimage", - enable-headless: false, on: ubuntu-20.04, } - { arch: aarch64, target: aarch64-unknown-linux-gnu, distro: ubuntu18.04, - extra-build-features: "", - enable-headless: true, - on: [self-hosted, Linux, ARM64], - } - - { - arch: aarch64, - target: aarch64-unknown-linux-gnu, - distro: ubuntu20.04, - extra-build-features: "flatpak", - enable-headless: false, - on: [self-hosted, Linux, ARM64], - } - - { - arch: aarch64, - target: aarch64-unknown-linux-gnu, - distro: ubuntu20.04, - extra-build-features: "appimage", - enable-headless: false, on: [self-hosted, Linux, ARM64], } steps: @@ -1090,6 +1054,12 @@ jobs: esac shell: bash + - name: Restore bridge files + uses: actions/download-artifact@master + with: + name: bridge-artifact + path: ./ + - uses: rustdesk-org/run-on-arch-action@amd64-support name: Build rustdesk library for ${{ matrix.job.arch }} id: vcpkg @@ -1109,6 +1079,7 @@ jobs: apt-get update -y echo -e "installing deps" apt-get install -y \ + build-essential \ clang \ cmake \ curl \ @@ -1137,7 +1108,11 @@ jobs: ninja-build \ pkg-config \ tree \ - wget + python3 \ + rpm \ + unzip \ + wget \ + xz-utils # we have libopus compiled by us. apt-get remove -y libopus-dev || true # output devs @@ -1163,28 +1138,153 @@ jobs: # start build pushd /workspace export VCPKG_ROOT=/opt/artifacts/vcpkg - export DEFAULT_FEAT="" - if ${{ matrix.job.enable-headless }}; then - export DEFAULT_FEAT=linux_headless - fi if [[ "${{ matrix.job.arch }}" == "aarch64" ]]; then export JOBS="--jobs 3" else export JOBS="" fi echo $JOBS - cargo build --lib $JOBS --features hwcodec,flutter,flutter_texture_render,${{ matrix.job.extra-build-features }},$DEFAULT_FEAT --release + cargo build --lib $JOBS --features hwcodec,flutter,flutter_texture_render --release - - name: Upload Artifacts - uses: actions/upload-artifact@master - if: matrix.job.extra-build-features == '' || env.UPLOAD_ARTIFACT == 'true' + # disable git safe.directory + git config --global --add safe.directory "*" + pushd /workspace + case ${{ matrix.job.arch }} in + aarch64) + export PATH=/opt/flutter-elinux/bin:$PATH + sed -i "s/flutter build linux --release/flutter-elinux build linux --verbose/g" ./build.py + export ARCH=arm64 + sed -i "s/x64\/release/arm64\/release/g" ./build.py + ;; + x86_64) + export PATH=/opt/flutter/bin:$PATH + ;; + esac + popd + # Setup Flutter + pushd /opt + wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz + tar xf flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz + case ${{ matrix.job.arch }} in + aarch64) + # clone repo and reset to flutter ${{ env.FLUTTER_VERSION }} + git clone https://github.com/sony/flutter-elinux.git || true + pushd flutter-elinux + git fetch + git reset --hard ${{ env.FLUTTER_VERSION }} + bin/flutter-elinux doctor -v + bin/flutter-elinux precache --linux + popd + cp -R flutter/bin/cache/artifacts/engine/linux-x64/shader_lib flutter-elinux/flutter/bin/cache/artifacts/engine/linux-arm64 + ;; + x86_64) + flutter doctor -v + ;; + esac + pushd /workspace + export CARGO_INCREMENTAL=0 + python3 ./build.py --flutter --skip-cargo + # rpm package + echo -e "start packaging fedora package" + pushd /workspace + case ${{ matrix.job.arch }} in + aarch64) + sed -i "s/linux\/x64/linux\/arm64/g" ./res/rpm-flutter.spec + ;; + esac + HBB=`pwd` rpmbuild ./res/rpm-flutter.spec -bb + pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} + # rpm suse package + echo -e "start packaging suse package" + pushd /workspace + case ${{ matrix.job.arch }} in + aarch64) + sed -i "s/linux\/x64/linux\/arm64/g" ./res/rpm-flutter-suse.spec + ;; + esac + HBB=`pwd` rpmbuild ./res/rpm-flutter-suse.spec -bb + pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} + for name in rustdesk*??.rpm; do + mv "$name" "${name%%.rpm}-suse.rpm" + done + for name in rustdesk*??.deb; do + mv "$name" "${name%%.deb}-${{ matrix.job.arch }}.deb" + done + + - name: Publish debian/rpm package + if: env.UPLOAD_ARTIFACT == 'true' + uses: softprops/action-gh-release@v1 with: - name: librustdesk-${{ matrix.job.arch }}-${{ matrix.job.extra-build-features }}.so - path: target/release/liblibrustdesk.so + prerelease: true + tag_name: ${{ env.TAG_NAME }} + files: | + rustdesk-*.deb + rustdesk-*.rpm + + - name: Upload Artifact + uses: actions/upload-artifact@master + if: matrix.job.extra-build-features == 'flatpak' && env.UPLOAD_ARTIFACT == 'true' + with: + name: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb + path: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb + + - name: Patch archlinux PKGBUILD + if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' + run: | + sed -i "s/x86_64/${{ matrix.job.arch }}/g" res/PKGBUILD + if [[ "${{ matrix.job.arch }}" == "aarch64" ]]; then + sed -i "s/linux\/x64/linux\/arm64/g" ./res/PKGBUILD + fi + + - name: Build archlinux package + if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' + uses: rustdesk-org/arch-makepkg-action@master + with: + packages: > + llvm + clang + libva + libvdpau + rust + gstreamer + unzip + git + cmake + gcc + curl + wget + nasm + zip + make + pkg-config + clang + gtk3 + xdotool + libxcb + libxfixes + alsa-lib + pipewire + python + ttf-arphic-uming + libappindicator-gtk3 + pam + gst-plugins-base + gst-plugin-pipewire + scripts: | + cd res && HBB=`pwd`/.. FLUTTER=1 makepkg -f + + - name: Publish archlinux package + if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' + uses: softprops/action-gh-release@v1 + with: + prerelease: true + tag_name: ${{ env.TAG_NAME }} + files: | + res/rustdesk-${{ env.VERSION }}*.zst build-rustdesk-sciter-arm: if: ${{ inputs.upload-artifact }} - needs: build-rustdesk-lib-linux # not for dep, just make it run later for parallelism + needs: build-rustdesk-linux # not for dep, just make it run later for parallelism runs-on: [self-hosted, Linux, ARM64] name: build-rustdesk-sciter-arm ${{ matrix.job.target }} strategy: @@ -1198,7 +1298,6 @@ jobs: deb-arch: armhf, use-cross: true, extra-build-features: "", - enable-headless: true, } steps: - name: Export GitHub Actions cache environment variables @@ -1329,12 +1428,8 @@ jobs: python3 ./res/inline-sciter.py export VCPKG_ROOT=/opt/artifacts/vcpkg export ARCH=armhf - export DEFAULT_FEAT="" export CARGO_INCREMENTAL=0 - if ${{ matrix.job.enable-headless }}; then - export DEFAULT_FEAT=linux_headless - fi - cargo build --features inline,${{ matrix.job.extra-build-features }},$DEFAULT_FEAT --release --bins --jobs 3 + cargo build --features inline,${{ matrix.job.extra-build-features }} --release --bins --jobs 3 # package mkdir -p ./Release mv ./target/release/rustdesk ./Release/rustdesk @@ -1365,294 +1460,7 @@ jobs: name: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}-sciter.deb path: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}-sciter.deb - build-rustdesk-linux: - needs: [build-rustdesk-lib-linux] - name: build-rustdesk-liunux ${{ matrix.job.target }} ${{ matrix.job.extra-build-features }} - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - job: - - { - arch: x86_64, - distro: ubuntu18.04, - target: x86_64-unknown-linux-gnu, - extra-build-features: "", - } - - { - arch: x86_64, - distro: ubuntu18.04, - target: x86_64-unknown-linux-gnu, - extra-build-features: "flatpak", - } - - { - arch: x86_64, - distro: ubuntu18.04, - target: x86_64-unknown-linux-gnu, - extra-build-features: "appimage", - } - - { - arch: aarch64, - distro: ubuntu18.04, - target: aarch64-unknown-linux-gnu, - extra-build-features: "", - } - - { - arch: aarch64, - distro: ubuntu20.04, - target: aarch64-unknown-linux-gnu, - extra-build-features: "flatpak", - } - - { - arch: aarch64, - distro: ubuntu20.04, - target: aarch64-unknown-linux-gnu, - extra-build-features: "appimage", - } - steps: - - name: Checkout source code - uses: actions/checkout@v3 - - - name: Restore bridge files - uses: actions/download-artifact@master - with: - name: bridge-artifact - path: ./ - - - name: Prepare env - run: | - sudo apt-get update -y - sudo apt-get install -y \ - curl \ - git \ - libarchive-tools \ - libgtk-3-dev \ - nasm \ - wget - mkdir -p ./target/release/ - - - name: Restore the rustdesk lib file - uses: actions/download-artifact@master - if: matrix.job.extra-build-features == '' || env.UPLOAD_ARTIFACT == 'true' - with: - name: librustdesk-${{ matrix.job.arch }}-${{ matrix.job.extra-build-features }}.so - path: ./target/release/ - - - uses: rustdesk-org/run-on-arch-action@amd64-support - name: flutter build - id: vcpkg - if: matrix.job.extra-build-features == '' || env.UPLOAD_ARTIFACT == 'true' - with: - arch: ${{ matrix.job.arch }} - distro: ${{ matrix.job.distro }} - githubToken: ${{ github.token }} - setup: | - ls -l "${PWD}" - dockerRunArgs: | - --volume "${PWD}:/workspace" - --volume "/opt/artifacts:/opt/artifacts" - shell: /bin/bash - install: | - apt-get update -y - apt-get install -y \ - build-essential \ - clang \ - cmake \ - curl \ - gcc \ - git \ - g++ \ - libappindicator3-dev \ - libgtk-3-dev \ - liblzma-dev \ - nasm \ - ninja-build \ - pkg-config \ - python3 \ - rpm \ - unzip \ - wget \ - xz-utils - run: | - # disable git safe.directory - git config --global --add safe.directory "*" - pushd /workspace - case ${{ matrix.job.arch }} in - aarch64) - export PATH=/opt/flutter-elinux/bin:$PATH - sed -i "s/flutter build linux --release/flutter-elinux build linux --verbose/g" ./build.py - export ARCH=arm64 - sed -i "s/x64\/release/arm64\/release/g" ./build.py - ;; - x86_64) - export PATH=/opt/flutter/bin:$PATH - ;; - esac - popd - # Setup Flutter - pushd /opt - wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz - tar xf flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz - case ${{ matrix.job.arch }} in - aarch64) - # clone repo and reset to flutter ${{ env.FLUTTER_VERSION }} - git clone https://github.com/sony/flutter-elinux.git || true - pushd flutter-elinux - git fetch - git reset --hard ${{ env.FLUTTER_VERSION }} - bin/flutter-elinux doctor -v - bin/flutter-elinux precache --linux - popd - cp -R flutter/bin/cache/artifacts/engine/linux-x64/shader_lib flutter-elinux/flutter/bin/cache/artifacts/engine/linux-arm64 - ;; - x86_64) - flutter doctor -v - ;; - esac - pushd /workspace - export CARGO_INCREMENTAL=0 - python3 ./build.py --flutter --skip-cargo - # rpm package - echo -e "start packaging fedora package" - pushd /workspace - case ${{ matrix.job.arch }} in - aarch64) - sed -i "s/linux\/x64/linux\/arm64/g" ./res/rpm-flutter.spec - ;; - esac - HBB=`pwd` rpmbuild ./res/rpm-flutter.spec -bb - pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} - mkdir -p /opt/artifacts/rpm - for name in rustdesk*??.rpm; do - mv "$name" "/opt/artifacts/rpm/${name%%.rpm}.rpm" - done - # rpm suse package - echo -e "start packaging suse package" - pushd /workspace - case ${{ matrix.job.arch }} in - aarch64) - sed -i "s/linux\/x64/linux\/arm64/g" ./res/rpm-flutter-suse.spec - ;; - esac - HBB=`pwd` rpmbuild ./res/rpm-flutter-suse.spec -bb - pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }} - mkdir -p /opt/artifacts/rpm - for name in rustdesk*??.rpm; do - mv "$name" "/opt/artifacts/rpm/${name%%.rpm}-suse.rpm" - done - - - name: Rename rustdesk - shell: bash - if: matrix.job.extra-build-features == '' || env.UPLOAD_ARTIFACT == 'true' - run: | - for name in rustdesk*??.deb; do - # use cp to duplicate deb files to fit other packages. - cp "$name" "${name%%.deb}-${{ matrix.job.arch }}.deb" - done - - - name: Publish debian package - if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' - uses: softprops/action-gh-release@v1 - with: - prerelease: true - tag_name: ${{ env.TAG_NAME }} - files: | - rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb - - - name: Upload Artifact - uses: actions/upload-artifact@master - if: matrix.job.extra-build-features == 'flatpak' && env.UPLOAD_ARTIFACT == 'true' - with: - name: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb - path: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb - - - name: Patch archlinux PKGBUILD - if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' - run: | - sed -i "s/x86_64/${{ matrix.job.arch }}/g" res/PKGBUILD - if [[ "${{ matrix.job.arch }}" == "aarch64" ]]; then - sed -i "s/linux\/x64/linux\/arm64/g" ./res/PKGBUILD - fi - - - name: Build archlinux package - if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' - uses: rustdesk-org/arch-makepkg-action@master - with: - packages: > - llvm - clang - libva - libvdpau - rust - gstreamer - unzip - git - cmake - gcc - curl - wget - nasm - zip - make - pkg-config - clang - gtk3 - xdotool - libxcb - libxfixes - alsa-lib - pipewire - python - ttf-arphic-uming - libappindicator-gtk3 - pam - gst-plugins-base - gst-plugin-pipewire - scripts: | - cd res && HBB=`pwd`/.. FLUTTER=1 makepkg -f - - - name: Publish archlinux package - if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' - uses: softprops/action-gh-release@v1 - with: - prerelease: true - tag_name: ${{ env.TAG_NAME }} - files: | - res/rustdesk-${{ env.VERSION }}*.zst - - - name: Build appimage package - if: matrix.job.extra-build-features == 'appimage' && env.UPLOAD_ARTIFACT == 'true' - shell: bash - run: | - # set-up appimage-builder - pushd /tmp - wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage - chmod +x appimage-builder-x86_64.AppImage - sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder - popd - # run appimage-builder - pushd appimage - sudo appimage-builder --skip-tests --recipe ./AppImageBuilder-${{ matrix.job.arch }}.yml - - - name: Publish appimage package - if: matrix.job.extra-build-features == 'appimage' && env.UPLOAD_ARTIFACT == 'true' - uses: softprops/action-gh-release@v1 - with: - prerelease: true - tag_name: ${{ env.TAG_NAME }} - files: | - ./appimage/rustdesk-${{ env.VERSION }}-*.AppImage - - - name: Publish fedora package - if: matrix.job.extra-build-features == '' && env.UPLOAD_ARTIFACT == 'true' - uses: softprops/action-gh-release@v1 - with: - prerelease: true - tag_name: ${{ env.TAG_NAME }} - files: | - /opt/artifacts/rpm/*.rpm - - build-flatpak: + build-flatpak-appimage: name: Build Flatpak ${{ matrix.job.target }} needs: [build-rustdesk-linux] runs-on: ${{ matrix.job.on }} @@ -1688,6 +1496,20 @@ jobs: run: | mv rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb rustdesk-${{ env.VERSION }}.deb + - name: Build appimage package + if: matrix.job.extra-build-features == 'appimage' && env.UPLOAD_ARTIFACT == 'true' + shell: bash + run: | + # set-up appimage-builder + pushd /tmp + wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage + chmod +x appimage-builder-x86_64.AppImage + sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder + popd + # run appimage-builder + pushd appimage + sudo appimage-builder --skip-tests --recipe ./AppImageBuilder-${{ matrix.job.arch }}.yml + - uses: rustdesk-org/run-on-arch-action@amd64-support name: Build rustdesk flatpak package for ${{ matrix.job.arch }} id: rpm diff --git a/Cargo.toml b/Cargo.toml index a9bbcef9e..bf404b1df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ default = ["use_dasp"] hwcodec = ["scrap/hwcodec"] vram = ["scrap/vram"] mediacodec = ["scrap/mediacodec"] -linux_headless = ["pam" ] virtual_display_driver = ["virtual_display"] plugin_framework = [] linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"] @@ -158,7 +157,7 @@ mouce = { git="https://github.com/fufesou/mouce.git" } evdev = { git="https://github.com/fufesou/evdev" } dbus = "0.9" dbus-crossroads = "0.5" -pam = { git="https://github.com/fufesou/pam", optional = true } +pam = { git="https://github.com/fufesou/pam" } users = { version = "0.11" } x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch", optional = true} x11rb = {version = "0.12", features = ["all-extensions"], optional = true} diff --git a/appimage/AppImageBuilder-aarch64.yml b/appimage/AppImageBuilder-aarch64.yml index 669118da9..79cf5a543 100644 --- a/appimage/AppImageBuilder-aarch64.yml +++ b/appimage/AppImageBuilder-aarch64.yml @@ -57,6 +57,7 @@ AppDir: - libpulse0 - packagekit-gtk3-module - libcanberra-gtk3-module + - libpam0g exclude: - humanity-icon-theme - hicolor-icon-theme diff --git a/appimage/AppImageBuilder-x86_64.yml b/appimage/AppImageBuilder-x86_64.yml index b1bd2ee3f..8ed9d2a44 100644 --- a/appimage/AppImageBuilder-x86_64.yml +++ b/appimage/AppImageBuilder-x86_64.yml @@ -59,6 +59,7 @@ AppDir: - libpulse0 - packagekit-gtk3-module - libcanberra-gtk3-module + - libpam0g exclude: - humanity-icon-theme - hicolor-icon-theme diff --git a/flatpak/rustdesk.json b/flatpak/rustdesk.json index 798bf58c6..949fc71a5 100644 --- a/flatpak/rustdesk.json +++ b/flatpak/rustdesk.json @@ -8,6 +8,20 @@ "modules": [ "shared-modules/libappindicator/libappindicator-gtk3-12.10.json", "xdotool.json", + { + "name": "pam", + "buildsystem": "simple", + "build-commands": [ + "./configure --prefix=/app && make -j4 install" + ], + "sources": [ + { + "type": "archive", + "url": "https://github.com/linux-pam/linux-pam/releases/download/v1.3.1/Linux-PAM-1.3.1.tar.xz", + "sha256": "eff47a4ecd833fbf18de9686632a70ee8d0794b79aecb217ebd0ce11db4cd0db" + } + ] + }, { "name": "rustdesk", "buildsystem": "simple", diff --git a/src/client.rs b/src/client.rs index c7fe88a79..8fb86cfa7 100644 --- a/src/client.rs +++ b/src/client.rs @@ -81,8 +81,7 @@ pub const SEC30: Duration = Duration::from_secs(30); pub const VIDEO_QUEUE_SIZE: usize = 120; const MAX_DECODE_FAIL_COUNTER: usize = 10; // Currently, failed decode cause refresh_video, so make it small -#[cfg(all(target_os = "linux", feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] +#[cfg(target_os = "linux")] pub const LOGIN_MSG_DESKTOP_NOT_INITED: &str = "Desktop env is not inited"; pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY: &str = "Desktop session not ready"; pub const LOGIN_MSG_DESKTOP_XSESSION_FAILED: &str = "Desktop xsession failed"; diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index a41e8b7a1..cf6e5fef3 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -774,8 +774,7 @@ pub fn main_get_error() -> String { } pub fn main_show_option(_key: String) -> SyncReturn { - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] if _key.eq(config::CONFIG_OPTION_ALLOW_LINUX_HEADLESS) { return SyncReturn(true); } diff --git a/src/platform/linux.rs b/src/platform/linux.rs index a79e25683..ac5b8eddc 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -1,7 +1,5 @@ use super::{CursorData, ResultType}; use desktop::Desktop; -#[cfg(all(feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] use hbb_common::config::CONFIG_OPTION_ALLOW_LINUX_HEADLESS; pub use hbb_common::platform::linux::*; use hbb_common::{ @@ -96,8 +94,6 @@ pub struct xcb_xfixes_get_cursor_image { } #[inline] -#[cfg(feature = "linux_headless")] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] pub fn is_headless_allowed() -> bool { Config::get_option(CONFIG_OPTION_ALLOW_LINUX_HEADLESS) == "Y" } diff --git a/src/platform/linux_desktop_manager.rs b/src/platform/linux_desktop_manager.rs index 21b123799..5616277c5 100644 --- a/src/platform/linux_desktop_manager.rs +++ b/src/platform/linux_desktop_manager.rs @@ -44,8 +44,8 @@ fn check_desktop_manager() { } } -// --server process pub fn start_xdesktop() { + debug_assert!(crate::is_sever()); std::thread::spawn(|| { *DESKTOP_MANAGER.lock().unwrap() = Some(DesktopManager::new()); @@ -91,6 +91,7 @@ fn detect_headless() -> Option<&'static str> { } pub fn try_start_desktop(_username: &str, _passsword: &str) -> String { + debug_assert!(crate::is_sever()); if _username.is_empty() { let username = get_username(); if username.is_empty() { diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 6f7a028f3..a01362872 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -20,8 +20,7 @@ pub mod delegate; #[cfg(target_os = "linux")] pub mod linux; -#[cfg(all(target_os = "linux", feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] +#[cfg(target_os = "linux")] pub mod linux_desktop_manager; #[cfg(not(any(target_os = "android", target_os = "ios")))] diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 58c4fee15..7527035ba 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -15,8 +15,8 @@ use hbb_common::{ config::{self, Config, CONNECT_TIMEOUT, READ_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT}, futures::future::join_all, log, - proxy::Proxy, protobuf::Message as _, + proxy::Proxy, rendezvous_proto::*, sleep, socket_client::{self, connect_tcp, is_ipv4}, @@ -89,9 +89,10 @@ impl RendezvousMediator { }); } // It is ok to run xdesktop manager when the headless function is not allowed. - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] - crate::platform::linux_desktop_manager::start_xdesktop(); + #[cfg(target_os = "linux")] + if crate::is_server() { + crate::platform::linux_desktop_manager::start_xdesktop(); + } loop { let conn_start_time = Instant::now(); *SOLVING_PK_MISMATCH.lock().await = "".to_owned(); @@ -128,11 +129,6 @@ impl RendezvousMediator { } } } - // It should be better to call stop_xdesktop. - // But for server, it also is Ok without calling this method. - // #[cfg(all(target_os = "linux", feature = "linux_headless"))] - // #[cfg(not(any(feature = "flatpak", feature = "appimage")))] - // crate::platform::linux_desktop_manager::stop_xdesktop(); } fn get_host_prefix(host: &str) -> String { diff --git a/src/server.rs b/src/server.rs index d54629345..93906cf08 100644 --- a/src/server.rs +++ b/src/server.rs @@ -560,8 +560,7 @@ async fn sync_and_watch_config_dir() { let mut cfg0 = (Config::get(), Config2::get()); let mut synced = false; - let is_server = std::env::args().nth(1) == Some("--server".to_owned()); - let tries = if is_server { 30 } else { 3 }; + let tries = if crate::is_server() { 30 } else { 3 }; log::debug!("#tries of ipc service connection: {}", tries); use hbb_common::sleep; for i in 1..=tries { diff --git a/src/server/connection.rs b/src/server/connection.rs index 1dc9e1d1b..f5330b323 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -7,8 +7,7 @@ use crate::common::update_clipboard; use crate::keyboard::client::map_key_to_control_key; #[cfg(target_os = "linux")] use crate::platform::linux::is_x11; -#[cfg(all(target_os = "linux", feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] +#[cfg(target_os = "linux")] use crate::platform::linux_desktop_manager; #[cfg(any(target_os = "windows", target_os = "linux"))] use crate::platform::WallPaperRemover; @@ -24,8 +23,7 @@ use crate::{ #[cfg(any(target_os = "android", target_os = "ios"))] use crate::{common::DEVICE_NAME, flutter::connection_manager::start_channel}; use cidr_utils::cidr::IpCidr; -#[cfg(all(target_os = "linux", feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] +#[cfg(target_os = "linux")] use hbb_common::platform::linux::run_cmds; #[cfg(target_os = "android")] use hbb_common::protobuf::EnumOrUnknown; @@ -224,8 +222,7 @@ pub struct Connection { options_in_login: Option, #[cfg(not(any(target_os = "ios")))] pressed_modifiers: HashSet, - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] linux_headless_handle: LinuxHeadlessHandle, closed: bool, delay_response_instant: Instant, @@ -312,8 +309,7 @@ impl Connection { let (tx_cm_stream_ready, _rx_cm_stream_ready) = mpsc::channel(1); #[cfg(not(any(target_os = "android", target_os = "ios")))] let (_tx_desktop_ready, rx_desktop_ready) = mpsc::channel(1); - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] let linux_headless_handle = LinuxHeadlessHandle::new(_rx_cm_stream_ready, _tx_desktop_ready); @@ -376,8 +372,7 @@ impl Connection { options_in_login: None, #[cfg(not(any(target_os = "ios")))] pressed_modifiers: Default::default(), - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] linux_headless_handle, closed: false, delay_response_instant: Instant::now(), @@ -1128,8 +1123,7 @@ impl Connection { if crate::platform::current_is_wayland() { platform_additions.insert("is_wayland".into(), json!(true)); } - #[cfg(feature = "linux_headless")] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] if crate::platform::is_headless_allowed() { if linux_desktop_manager::is_headless() { platform_additions.insert("headless".into(), json!(true)); @@ -1670,14 +1664,9 @@ impl Connection { #[cfg(not(any(target_os = "android", target_os = "ios")))] self.try_start_cm_ipc(); - #[cfg(any( - feature = "flatpak", - feature = "appimage", - not(all(target_os = "linux", feature = "linux_headless")) - ))] + #[cfg(not(target_os = "linux"))] let err_msg = "".to_owned(); - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] let err_msg = self .linux_headless_handle .try_start_desktop(lr.os_login.as_ref()); @@ -1714,8 +1703,7 @@ impl Connection { return false; } else if self.is_recent_session(false) { if err_msg.is_empty() { - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] self.linux_headless_handle.wait_desktop_cm_ready().await; self.send_logon_response().await; self.try_start_cm(lr.my_id.clone(), lr.my_name.clone(), self.authorized); @@ -1751,8 +1739,7 @@ impl Connection { } else { self.update_failure(failure, true, 0); if err_msg.is_empty() { - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] self.linux_headless_handle.wait_desktop_cm_ready().await; self.send_logon_response().await; self.try_start_cm(lr.my_id, lr.my_name, self.authorized); @@ -3226,8 +3213,7 @@ async fn start_ipc( let mut user = None; // Cm run as user, wait until desktop session is ready. - #[cfg(all(target_os = "linux", feature = "linux_headless"))] - #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + #[cfg(target_os = "linux")] if crate::platform::is_headless_allowed() && linux_desktop_manager::is_headless() { let mut username = linux_desktop_manager::get_username(); loop { @@ -3545,8 +3531,7 @@ impl Drop for Connection { } } -#[cfg(all(target_os = "linux", feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] +#[cfg(target_os = "linux")] struct LinuxHeadlessHandle { pub is_headless_allowed: bool, pub is_headless: bool, @@ -3555,11 +3540,10 @@ struct LinuxHeadlessHandle { pub tx_desktop_ready: mpsc::Sender<()>, } -#[cfg(all(target_os = "linux", feature = "linux_headless"))] -#[cfg(not(any(feature = "flatpak", feature = "appimage")))] +#[cfg(target_os = "linux")] impl LinuxHeadlessHandle { pub fn new(rx_cm_stream_ready: mpsc::Receiver<()>, tx_desktop_ready: mpsc::Sender<()>) -> Self { - let is_headless_allowed = crate::platform::is_headless_allowed(); + let is_headless_allowed = crate::is_server() && crate::platform::is_headless_allowed(); let is_headless = is_headless_allowed && linux_desktop_manager::is_headless(); Self { is_headless_allowed, diff --git a/src/ui.rs b/src/ui.rs index 16a7b1a65..39c94e233 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -41,15 +41,23 @@ pub fn start(args: &mut [String]) { crate::platform::delegate::show_dock(); #[cfg(all(target_os = "linux", feature = "inline"))] { - #[cfg(feature = "appimage")] - let prefix = std::env::var("APPDIR").unwrap_or("".to_string()); - #[cfg(not(feature = "appimage"))] - let prefix = "".to_string(); - #[cfg(feature = "flatpak")] - let dir = "/app"; - #[cfg(not(feature = "flatpak"))] - let dir = "/usr"; - sciter::set_library(&(prefix + dir + "/lib/rustdesk/libsciter-gtk.so")).ok(); + let app_dir = std::env::var("APPDIR").unwrap_or("".to_string()); + let mut so_path = "/usr/lib/rustdesk/libsciter-gtk.so".to_owned(); + for (prefix, dir) in [ + ("", "/usr"), + ("", "/app"), + (&app_dir, "/usr"), + (&app_dir, "/app"), + ] + .iter() + { + let path = format!("{prefix}{dir}/lib/rustdesk/libsciter-gtk.so"); + if std::path::Path::new(&path).exists() { + so_path = path; + break; + } + } + sciter::set_library(&so_path).ok(); } #[cfg(windows)] // Check if there is a sciter.dll nearby. diff --git a/src/ui_interface.rs b/src/ui_interface.rs index c6309f599..eb36cdae9 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -913,8 +913,6 @@ pub fn is_root() -> bool { #[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] #[inline] pub fn check_super_user_permission() -> bool { - #[cfg(feature = "flatpak")] - return true; #[cfg(any(windows, target_os = "linux", target_os = "macos"))] return crate::platform::check_super_user_permission().unwrap_or(false); #[cfg(not(any(windows, target_os = "linux", target_os = "macos")))]