Compare commits
12 Commits
KASM-1810_
...
KASM-1910-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f1f88d6b2 | ||
|
|
2f91fbd235 | ||
|
|
3500489bb8 | ||
|
|
22362e73ad | ||
|
|
0a1f705637 | ||
|
|
02dc1a4b53 | ||
|
|
33dd45b6e5 | ||
|
|
c5d61ca63e | ||
|
|
bb2dc1787d | ||
|
|
2bdfd0f70a | ||
|
|
c9a4319ca7 | ||
|
|
b367d1711d |
14
.ci/check_if_build_was_already_uploaded
Executable file
14
.ci/check_if_build_was_already_uploaded
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
check_directory_exists() {
|
||||
local remote_dir="$1"
|
||||
|
||||
curl --output /dev/null --silent --head --fail "$remote_dir"
|
||||
}
|
||||
|
||||
S3_URL="https://${S3_BUCKET}.s3.amazonaws.com/${S3_BUILD_DIRECTORY}/";
|
||||
if check_directory_exists "$S3_URL"; then
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
is_kasmvnc() {
|
||||
is_kasmvnc_package() {
|
||||
local package="$1";
|
||||
|
||||
echo "$package" | grep -q 'kasmvncserver_'
|
||||
echo "$package" | grep -E -q 'kasmvncserver_|rpm'
|
||||
}
|
||||
|
||||
function prepare_upload_filename() {
|
||||
local package="$1";
|
||||
|
||||
if ! is_kasmvnc "$package"; then
|
||||
if ! is_kasmvnc_package "$package"; then
|
||||
export upload_filename="$package"
|
||||
return
|
||||
fi
|
||||
|
||||
133
.gitlab-ci.yml
133
.gitlab-ci.yml
@@ -6,63 +6,37 @@ variables:
|
||||
GITLAB_SHARED_DIND_DIR: /builds/$CI_PROJECT_PATH/shared
|
||||
GIT_SUBMODULE_STRATEGY: normal
|
||||
GIT_FETCH_EXTRA_FLAGS: --tags
|
||||
# S3_BUILD_DIRECTORY: kasmvnc/${CI_COMMIT_SHA}
|
||||
S3_BUILD_DIRECTORY: kasmvnc/159d7527955f131e096cf1602b7f9f66cc5d66cb
|
||||
|
||||
stages:
|
||||
- www
|
||||
- check_if_build_was_already_uploaded_for_the_commit
|
||||
- build
|
||||
- upload
|
||||
|
||||
check_if_build_was_already_uploaded_for_the_commit:
|
||||
stage: check_if_build_was_already_uploaded_for_the_commit
|
||||
script:
|
||||
- apk add bash
|
||||
- apk add curl
|
||||
# - TODO: Try uploading and fail if the file .lock exists.
|
||||
- .ci/check_if_build_was_already_uploaded
|
||||
|
||||
.prepare_build: &prepare_build
|
||||
- ls -l
|
||||
- pwd
|
||||
- apk add bash
|
||||
- mkdir -p "$GITLAB_SHARED_DIND_DIR" && chmod 777 "$GITLAB_SHARED_DIND_DIR"
|
||||
|
||||
.prepare_www: &prepare_www
|
||||
- tar -zxf output/www/kasm_www.tar.gz -C builder/
|
||||
|
||||
.prepare_artfacts: &prepare_artfacts
|
||||
- mkdir output
|
||||
- cp -r builder/build/* output/
|
||||
- rm output/*.tar.gz
|
||||
|
||||
build_www:
|
||||
stage: www
|
||||
allow_failure: false
|
||||
before_script:
|
||||
- *prepare_build
|
||||
script:
|
||||
- webpacked_www=$PWD/builder/www
|
||||
- src_www=kasmweb
|
||||
- docker build -t kasmweb/www -f builder/dockerfile.www.build .
|
||||
- docker run --rm -v $PWD/builder/www:/build kasmweb/www:latest
|
||||
- mkdir -p output/www
|
||||
- cd builder
|
||||
- tar -zcvf ../output/www/kasm_www.tar.gz www
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_ubuntu_bionic:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package ubuntu bionic
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_ubuntu_bionic_arm:
|
||||
stage: build
|
||||
allow_failure: false
|
||||
tags:
|
||||
- arm
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
@@ -73,10 +47,8 @@ build_ubuntu_bionic_arm:
|
||||
|
||||
build_ubuntu_bionic_libjpeg_turbo:
|
||||
stage: build
|
||||
allow_failure: false
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
@@ -87,118 +59,44 @@ build_ubuntu_bionic_libjpeg_turbo:
|
||||
|
||||
build_ubuntu_focal:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package ubuntu focal;
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /\[full [Cc][Ii]\]/
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_ubuntu_focal_arm:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
tags:
|
||||
- arm
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package ubuntu focal;
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /\[full [Cc][Ii]\]/
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_debian_buster:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package debian buster;
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_debian_buster_arm:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
tags:
|
||||
- arm
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package debian buster;
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_debian_bullseye:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package debian bullseye;
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_debian_bullseye_arm:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
tags:
|
||||
- arm
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
- bash builder/build-package debian bullseye;
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/
|
||||
artifacts:
|
||||
paths:
|
||||
- output/
|
||||
|
||||
build_kali_rolling:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
@@ -209,10 +107,8 @@ build_kali_rolling:
|
||||
|
||||
build_centos7:
|
||||
stage: build
|
||||
allow_failure: true
|
||||
before_script:
|
||||
- *prepare_build
|
||||
- *prepare_www
|
||||
after_script:
|
||||
- *prepare_artfacts
|
||||
script:
|
||||
@@ -227,7 +123,6 @@ upload:
|
||||
before_script:
|
||||
- . .ci/upload.sh
|
||||
script:
|
||||
- export S3_BUILD_DIRECTORY="kasmvnc/${CI_COMMIT_SHA}"
|
||||
- prepare_to_run_scripts_and_s3_uploads
|
||||
- export RELEASE_VERSION=$(.ci/next_release_version "$CI_COMMIT_REF_NAME")
|
||||
- for package in `find output/ -type f -name '*.deb' -or -name '*.rpm'`; do
|
||||
@@ -235,6 +130,4 @@ upload:
|
||||
echo;
|
||||
echo "File to upload $upload_filename";
|
||||
upload_to_s3 "$package" "$upload_filename";
|
||||
UPLOAD_NAME=$(echo $upload_filename | sed 's#kasmvncserver_##' | sed -r 's#_([0-9]{1,3}\.){2}[0-9]{1,2}_\S+?([a-f0-9]{6})##' | sed -r 's#\.(deb|rpm)##');
|
||||
curl --request POST --header "PRIVATE-TOKEN:${GITLAB_API_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/statuses/${CI_COMMIT_SHA}?state=success&name=${UPLOAD_NAME}&target_url=${S3_URL}";
|
||||
done
|
||||
|
||||
15
Pipfile
15
Pipfile
@@ -1,15 +0,0 @@
|
||||
[[source]]
|
||||
url = "https://pypi.python.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
mamba = "*"
|
||||
expects = "*"
|
||||
"path.py" = "*"
|
||||
pexpect = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
136
Pipfile.lock
generated
136
Pipfile.lock
generated
@@ -1,136 +0,0 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "6745d5e5d90e44a18d73a0e23bc3d3e68acb950af0b87df50b45272d25b9e615"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.python.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"args": {
|
||||
"hashes": [
|
||||
"sha256:a785b8d837625e9b61c39108532d95b85274acd679693b71ebb5156848fcf814"
|
||||
],
|
||||
"version": "==0.1.0"
|
||||
},
|
||||
"clint": {
|
||||
"hashes": [
|
||||
"sha256:05224c32b1075563d0b16d0015faaf9da43aa214e4a2140e51f08789e7a4c5aa"
|
||||
],
|
||||
"version": "==0.5.1"
|
||||
},
|
||||
"coverage": {
|
||||
"hashes": [
|
||||
"sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c",
|
||||
"sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6",
|
||||
"sha256:040af6c32813fa3eae5305d53f18875bedd079960822ef8ec067a66dd8afcd45",
|
||||
"sha256:06191eb60f8d8a5bc046f3799f8a07a2d7aefb9504b0209aff0b47298333302a",
|
||||
"sha256:13034c4409db851670bc9acd836243aeee299949bd5673e11844befcb0149f03",
|
||||
"sha256:13c4ee887eca0f4c5a247b75398d4114c37882658300e153113dafb1d76de529",
|
||||
"sha256:184a47bbe0aa6400ed2d41d8e9ed868b8205046518c52464fde713ea06e3a74a",
|
||||
"sha256:18ba8bbede96a2c3dde7b868de9dcbd55670690af0988713f0603f037848418a",
|
||||
"sha256:1aa846f56c3d49205c952d8318e76ccc2ae23303351d9270ab220004c580cfe2",
|
||||
"sha256:217658ec7187497e3f3ebd901afdca1af062b42cfe3e0dafea4cced3983739f6",
|
||||
"sha256:24d4a7de75446be83244eabbff746d66b9240ae020ced65d060815fac3423759",
|
||||
"sha256:2910f4d36a6a9b4214bb7038d537f015346f413a975d57ca6b43bf23d6563b53",
|
||||
"sha256:2949cad1c5208b8298d5686d5a85b66aae46d73eec2c3e08c817dd3513e5848a",
|
||||
"sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4",
|
||||
"sha256:2cafbbb3af0733db200c9b5f798d18953b1a304d3f86a938367de1567f4b5bff",
|
||||
"sha256:2e0d881ad471768bf6e6c2bf905d183543f10098e3b3640fc029509530091502",
|
||||
"sha256:30c77c1dc9f253283e34c27935fded5015f7d1abe83bc7821680ac444eaf7793",
|
||||
"sha256:3487286bc29a5aa4b93a072e9592f22254291ce96a9fbc5251f566b6b7343cdb",
|
||||
"sha256:372da284cfd642d8e08ef606917846fa2ee350f64994bebfbd3afb0040436905",
|
||||
"sha256:41179b8a845742d1eb60449bdb2992196e211341818565abded11cfa90efb821",
|
||||
"sha256:44d654437b8ddd9eee7d1eaee28b7219bec228520ff809af170488fd2fed3e2b",
|
||||
"sha256:4a7697d8cb0f27399b0e393c0b90f0f1e40c82023ea4d45d22bce7032a5d7b81",
|
||||
"sha256:51cb9476a3987c8967ebab3f0fe144819781fca264f57f89760037a2ea191cb0",
|
||||
"sha256:52596d3d0e8bdf3af43db3e9ba8dcdaac724ba7b5ca3f6358529d56f7a166f8b",
|
||||
"sha256:53194af30d5bad77fcba80e23a1441c71abfb3e01192034f8246e0d8f99528f3",
|
||||
"sha256:5fec2d43a2cc6965edc0bb9e83e1e4b557f76f843a77a2496cbe719583ce8184",
|
||||
"sha256:6c90e11318f0d3c436a42409f2749ee1a115cd8b067d7f14c148f1ce5574d701",
|
||||
"sha256:74d881fc777ebb11c63736622b60cb9e4aee5cace591ce274fb69e582a12a61a",
|
||||
"sha256:7501140f755b725495941b43347ba8a2777407fc7f250d4f5a7d2a1050ba8e82",
|
||||
"sha256:796c9c3c79747146ebd278dbe1e5c5c05dd6b10cc3bcb8389dfdf844f3ead638",
|
||||
"sha256:869a64f53488f40fa5b5b9dcb9e9b2962a66a87dab37790f3fcfb5144b996ef5",
|
||||
"sha256:8963a499849a1fc54b35b1c9f162f4108017b2e6db2c46c1bed93a72262ed083",
|
||||
"sha256:8d0a0725ad7c1a0bcd8d1b437e191107d457e2ec1084b9f190630a4fb1af78e6",
|
||||
"sha256:900fbf7759501bc7807fd6638c947d7a831fc9fdf742dc10f02956ff7220fa90",
|
||||
"sha256:92b017ce34b68a7d67bd6d117e6d443a9bf63a2ecf8567bb3d8c6c7bc5014465",
|
||||
"sha256:970284a88b99673ccb2e4e334cfb38a10aab7cd44f7457564d11898a74b62d0a",
|
||||
"sha256:972c85d205b51e30e59525694670de6a8a89691186012535f9d7dbaa230e42c3",
|
||||
"sha256:9a1ef3b66e38ef8618ce5fdc7bea3d9f45f3624e2a66295eea5e57966c85909e",
|
||||
"sha256:af0e781009aaf59e25c5a678122391cb0f345ac0ec272c7961dc5455e1c40066",
|
||||
"sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf",
|
||||
"sha256:b7895207b4c843c76a25ab8c1e866261bcfe27bfaa20c192de5190121770672b",
|
||||
"sha256:c0891a6a97b09c1f3e073a890514d5012eb256845c451bd48f7968ef939bf4ae",
|
||||
"sha256:c2723d347ab06e7ddad1a58b2a821218239249a9e4365eaff6649d31180c1669",
|
||||
"sha256:d1f8bf7b90ba55699b3a5e44930e93ff0189aa27186e96071fac7dd0d06a1873",
|
||||
"sha256:d1f9ce122f83b2305592c11d64f181b87153fc2c2bbd3bb4a3dde8303cfb1a6b",
|
||||
"sha256:d314ed732c25d29775e84a960c3c60808b682c08d86602ec2c3008e1202e3bb6",
|
||||
"sha256:d636598c8305e1f90b439dbf4f66437de4a5e3c31fdf47ad29542478c8508bbb",
|
||||
"sha256:deee1077aae10d8fa88cb02c845cfba9b62c55e1183f52f6ae6a2df6a2187160",
|
||||
"sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c",
|
||||
"sha256:f030f8873312a16414c0d8e1a1ddff2d3235655a2174e3648b4fa66b3f2f1079",
|
||||
"sha256:f0b278ce10936db1a37e6954e15a3730bea96a0997c26d7fee88e6c396c2086d",
|
||||
"sha256:f11642dddbb0253cc8853254301b51390ba0081750a8ac03f20ea8103f0c56b6"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
|
||||
"version": "==5.5"
|
||||
},
|
||||
"expects": {
|
||||
"hashes": [
|
||||
"sha256:419902ccafe81b7e9559eeb6b7a07ef9d5c5604eddb93000f0642b3b2d594f4c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.9.0"
|
||||
},
|
||||
"mamba": {
|
||||
"hashes": [
|
||||
"sha256:75cfc6dfd287dcccaf86dd753cf48e0a7337487c7c3fafda05a6a67ded6da496"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.11.2"
|
||||
},
|
||||
"path": {
|
||||
"hashes": [
|
||||
"sha256:2de925e8d421f93bcea80d511b81accfb6a7e6b249afa4a5559557b0cf817097",
|
||||
"sha256:340054c5bb459fc9fd40e7eb6768c5989f3e599d18224238465b5333bc8faa7d"
|
||||
],
|
||||
"markers": "python_version >= '3.6'",
|
||||
"version": "==16.2.0"
|
||||
},
|
||||
"path.py": {
|
||||
"hashes": [
|
||||
"sha256:8d885e8b2497aed005703d94e0fd97943401f035e42a136810308bff034529a8",
|
||||
"sha256:a43e82eb2c344c3fd0b9d6352f6b856f40b8b7d3d65cc05978b42c3715668496"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==12.5.0"
|
||||
},
|
||||
"pexpect": {
|
||||
"hashes": [
|
||||
"sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937",
|
||||
"sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==4.8.0"
|
||||
},
|
||||
"ptyprocess": {
|
||||
"hashes": [
|
||||
"sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35",
|
||||
"sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"
|
||||
],
|
||||
"version": "==0.7.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
36
README.md
36
README.md
@@ -42,30 +42,30 @@ Future Goals:
|
||||
#### Debian-based
|
||||
|
||||
```sh
|
||||
wget https://github.com/kasmtech/KasmVNC/releases/download/v0.9.2-beta/kasmvncserver_ubuntu_bionic_0.9.2_amd64.deb
|
||||
wget -qO- https://github.com/kasmtech/KasmVNC/releases/download/v0.9.1-beta/kasmvncserver_0.9.1~beta-1_amd64.deb
|
||||
|
||||
sudo apt-get install ./kasmvncserver_0.9.1~beta-1_amd64.deb
|
||||
sudo dpkg -i kasmvncserver_0.9.1~beta-1_amd64.deb
|
||||
sudo apt-get -f install
|
||||
|
||||
# We provide an example script to run KasmVNC at #
|
||||
# /usr/share/doc/kasmvncserver/examples/kasmvncserver-easy-start. It runs a VNC
|
||||
# server on display :10 and on interface 0.0.0.0. If you're happy with those
|
||||
# defaults you can just use it as is:
|
||||
sudo ln -s /usr/share/doc/kasmvncserver/examples/kasmvncserver-easy-start /usr/bin/
|
||||
|
||||
# Add your user to the ssl-cert group
|
||||
sudo addgroup $USER ssl-cert
|
||||
# You will need to re-connect in order to pick up the group change
|
||||
|
||||
# Run KasmVNC on display :10 and on interface 0.0.0.0:
|
||||
KASMVNC_OPTIONS=':10 -depth 24 -geometry 1280x1050
|
||||
-cert /etc/ssl/certs/ssl-cert-snakeoil.pem
|
||||
-key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24
|
||||
-interface 0.0.0.0 -httpd /usr/share/kasmvnc/www'
|
||||
vncserver $KASMVNC_OPTIONS
|
||||
# Create ~/.vnc directory and corresponding files.
|
||||
kasmvncserver-easy-start -d && kasmvncserver-easy-start -kill
|
||||
|
||||
# On the first run, vncserver will ask you to create a KasmVNC user and choose a desktop
|
||||
# environment you want to run. It can detect Cinnamon, Mate, LXDE, KDE, Gnome,
|
||||
# XFCE. You can also choose to manually edit xstartup.
|
||||
# After you chose a desktop environment or to manually edit xstartup,
|
||||
# vncserver won't ask you again, unless you run it as:
|
||||
vncserver $KASMVNC_OPTIONS -select-de
|
||||
# Modify vncstartup to launch your environment of choice, in this example LXDE
|
||||
# This may be optional depending on your system configuration
|
||||
echo '/usr/bin/lxsession -s LXDE &' >> ~/.vnc/xstartup
|
||||
|
||||
# You can select a specific Desktop Environment like this:
|
||||
vncserver $KASMVNC_OPTIONS -select-de mate
|
||||
# Start KasmVNC with debug logging:
|
||||
kasmvncserver-easy-start -d
|
||||
|
||||
# Tail the logs
|
||||
tail -f ~/.vnc/`hostname`:10.log
|
||||
@@ -73,10 +73,10 @@ tail -f ~/.vnc/`hostname`:10.log
|
||||
|
||||
Now navigate to your system at https://[ip-address]:8443/
|
||||
|
||||
To stop the KasmVNC you started earlier on display 10:
|
||||
To stop a running KasmVNC:
|
||||
|
||||
```sh
|
||||
vncserver -kill :10
|
||||
kasmvncserver-easy-start -kill
|
||||
```
|
||||
|
||||
The options for vncserver:
|
||||
|
||||
@@ -79,25 +79,6 @@ packages installed with XFCE.
|
||||
```
|
||||
builder/test-deb-barebones ubuntu focal
|
||||
```
|
||||
|
||||
# Preparing a release
|
||||
|
||||
Deb and rpm packages need their versions bumped to the new release version. It
|
||||
can be done with:
|
||||
|
||||
```
|
||||
builder/bump-package-version 0.9.4-beta
|
||||
```
|
||||
|
||||
This will update corresponding package files, use `git diff` to see changes.
|
||||
|
||||
If you've ran the command and curious about Debian version specifics, here's an
|
||||
explanation:
|
||||
Deb version will be `0.9.4~beta-1`. `~` (and not `-`) is required by packaging
|
||||
guidelines, and `-1` is Debian package revision for `0.9.4` upstream release. If
|
||||
a Debian-specific patch was later added on top of `0.9.4`, it'd be `-2` for the
|
||||
next Debian version. Rpm has a corresponding revision in its .spec file.
|
||||
|
||||
# CI development
|
||||
|
||||
S3 upload code is extracted to various files in `.ci`. It's possible to iterate
|
||||
@@ -109,33 +90,3 @@ bash -c '
|
||||
prepare_upload_filename "bionic/kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb";
|
||||
echo $upload_filename;'
|
||||
```
|
||||
|
||||
# ARM
|
||||
|
||||
KasmVNC is supported on ARM, however, the build process needs to be broken into two parts with one occuring on a x64 system and the other on an ARM system. All our testing and official builds are done on AWS Graviton instances.
|
||||
|
||||
### Build www code on x86 System
|
||||
The www code is webpacked for performance and thus requires building. There are NPM packages, phantomjs, which do not have an ARM build. Therefore, this must be built on x86 and then copied over to the ARM system for final packaging.
|
||||
|
||||
```
|
||||
cd ~/KasmVNC
|
||||
mkdir builder/www
|
||||
sudo docker build -t kasmweb/www -f builder/dockerfile.www.build .
|
||||
sudo docker run --rm -v $PWD/builder/www:/build kasmweb/www:latest
|
||||
cd builder
|
||||
tar -zcvf /tmp/kasm_www.tar.gz www
|
||||
```
|
||||
|
||||
Now transfer ```kasm_www.tar.gz``` to the ARM system.
|
||||
|
||||
### Build KasmVNC ARM
|
||||
These instructions assume KasmVNC has been cloned at $HOME and ```kasm_www.tar.gz``` has been placed at $HOME as well, adjust for your environment.
|
||||
|
||||
```
|
||||
cd ~
|
||||
tar -zxf kasm_www.tar.gz -C KasmVNC/builder/
|
||||
cd KasmVNC
|
||||
sudo builder/build-package ubuntu bionic
|
||||
```
|
||||
The resulting deb package can be found under ~/KasmVNC/builder/build/bionic
|
||||
Replace ```bionic``` with ```focal``` to build for Ubuntu 20.04LTS. At this time, only Ubuntu Bionic has been tested, however, other Debian based builds we support should also work.
|
||||
|
||||
@@ -17,7 +17,7 @@ cd /tmp
|
||||
# default to the version of x in Ubuntu 18.04, otherwise caller will need to specify
|
||||
XORG_VER=${XORG_VER:-"1.19.6"}
|
||||
XORG_PATCH=$(echo "$XORG_VER" | grep -Po '^\d.\d+' | sed 's#\.##')
|
||||
wget --no-check-certificate https://www.x.org/archive/individual/xserver/xorg-server-${XORG_VER}.tar.bz2
|
||||
wget https://www.x.org/archive/individual/xserver/xorg-server-${XORG_VER}.tar.bz2
|
||||
|
||||
#git clone https://kasmweb@bitbucket.org/kasmtech/kasmvnc.git
|
||||
#cd kasmvnc
|
||||
@@ -30,19 +30,16 @@ sed -i -e '/find_package(FLTK/s@^@#@' \
|
||||
-e '/add_subdirectory(tests/s@^@#@' \
|
||||
CMakeLists.txt
|
||||
|
||||
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . -DBUILD_VIEWER:BOOL=OFF
|
||||
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo .
|
||||
make -j5
|
||||
|
||||
tar -C unix/xserver -xf /tmp/xorg-server-${XORG_VER}.tar.bz2 --strip-components=1
|
||||
tar -C unix/xserver -xvf /tmp/xorg-server-${XORG_VER}.tar.bz2 --strip-components=1
|
||||
|
||||
cd unix/xserver
|
||||
patch -Np1 -i ../xserver${XORG_PATCH}.patch
|
||||
case "$XORG_VER" in
|
||||
1.20.*)
|
||||
if [ -f ../xserver120.7.patch ]; then
|
||||
if [[ $XORG_VER =~ ^1\.20\..*$ ]]; then
|
||||
patch -Np1 -i ../xserver120.7.patch
|
||||
fi ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
autoreconf -i
|
||||
# Configuring Xorg is long and has many distro-specific paths.
|
||||
@@ -75,8 +72,6 @@ mkdir lib
|
||||
cd lib
|
||||
if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then
|
||||
ln -s /usr/lib/x86_64-linux-gnu/dri dri
|
||||
elif [ -d /usr/lib/aarch64-linux-gnu/dri ]; then
|
||||
ln -s /usr/lib/aarch64-linux-gnu/dri dri
|
||||
else
|
||||
ln -s /usr/lib64/dri dri
|
||||
fi
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
update_version_to_meet_packaging_standards() {
|
||||
new_version=$(echo "$new_version" |
|
||||
sed -e 's/\([0-9]\)-\([a-zA-Z]\)/\1~\2/')
|
||||
}
|
||||
|
||||
add_debian_revision_to_new_version() {
|
||||
echo "$new_version-1"
|
||||
}
|
||||
|
||||
bump_rpm() {
|
||||
sed -i "s/^Version:.\+/Version: $new_version/" centos/kasmvncserver.spec
|
||||
}
|
||||
|
||||
bump_deb() {
|
||||
local image="debbump_package_version:dev"
|
||||
local L_UID=$(id -u)
|
||||
local L_GID=$(id -g)
|
||||
local debian_version=$(add_debian_revision_to_new_version)
|
||||
|
||||
docker build -t "$image" -f builder/dockerfile.bump-package-version .
|
||||
docker run --rm -v "$PWD":/src --user "$L_UID:$L_GID" \
|
||||
"$image" /bin/bash -c \
|
||||
"cd /src && builder/bump-package-version-inside-docker-deb $debian_version"
|
||||
}
|
||||
|
||||
new_version="$1"
|
||||
|
||||
if [[ -z "$new_version" ]]; then
|
||||
echo >&2 "Usage: $(basename "$0") <new_version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
update_version_to_meet_packaging_standards
|
||||
bump_rpm
|
||||
bump_deb
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
new_version="$1"
|
||||
|
||||
update_version() {
|
||||
dch --newversion $new_version 'New upstream release.'
|
||||
}
|
||||
|
||||
mark_as_released() {
|
||||
dch --release ""
|
||||
}
|
||||
|
||||
update_version
|
||||
mark_as_released
|
||||
@@ -1,6 +0,0 @@
|
||||
FROM debian:buster
|
||||
|
||||
ENV DEBEMAIL="Kasm Technologies LLC <info@kasmweb.com>"
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install vim devscripts
|
||||
@@ -3,7 +3,6 @@ FROM centos:centos7
|
||||
ENV KASMVNC_BUILD_OS centos
|
||||
ENV KASMVNC_BUILD_OS_CODENAME core
|
||||
|
||||
RUN yum update -y ca-certificates
|
||||
RUN yum install -y build-dep xorg-server libxfont-dev sudo
|
||||
RUN yum install -y gcc cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||
RUN yum install -y libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev openssl-devel
|
||||
@@ -16,7 +15,7 @@ RUN yum install -y mesa-dri-drivers
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -37,7 +37,6 @@ RUN yum install -y epel-release && yum groupinstall xfce -y
|
||||
RUN yum erase -y pm-utils xscreensaver*
|
||||
RUN yum install -y redhat-lsb-core
|
||||
RUN yum install -y vim less
|
||||
RUN yum localinstall -y --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
|
||||
|
||||
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libg
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libg
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -34,14 +34,6 @@ RUN apt-get purge -y pm-utils xscreensaver*
|
||||
RUN apt-get update && apt-get install -y vim less
|
||||
RUN apt-get update && apt-get -y install lsb-release
|
||||
|
||||
RUN apt-get update && apt-get install -y task-cinnamon-desktop
|
||||
RUN apt-get update && apt-get install -y task-gnome-desktop
|
||||
RUN mkdir -p /usr/share/man/man1
|
||||
RUN apt-get update && apt-get install -y apt-utils openjdk-11-jre
|
||||
RUN apt-get update && apt-get install -y task-lxde-desktop
|
||||
RUN apt-get update && apt-get install -y task-mate-desktop
|
||||
RUN apt-get update && apt-get install -y task-kde-desktop
|
||||
|
||||
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
|
||||
|
||||
RUN mkdir -p $STARTUPDIR
|
||||
|
||||
@@ -24,7 +24,7 @@ RUN dnf install -y bzip2 redhat-lsb-core
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libg
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -20,7 +20,7 @@ RUN export MAKEFLAGS=-j`nproc`; cd libjpeg-turbo && cmake -DCMAKE_INSTALL_PREFIX
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -15,7 +15,7 @@ RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libg
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libg
|
||||
|
||||
# Additions for webp
|
||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||
RUN cd /tmp/libwebp-1.0.2 && \
|
||||
./configure --enable-static --disable-shared && \
|
||||
make && make install
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
FROM ubuntu:focal
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV VNC_PORT 8443
|
||||
ENV VNC_PORT2 8444
|
||||
ENV VNC_PORT3 8445
|
||||
EXPOSE $VNC_PORT
|
||||
EXPOSE $VNC_PORT2
|
||||
EXPOSE $VNC_PORT3
|
||||
|
||||
RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal xterm libnss-wrapper gettext wget
|
||||
RUN apt-get update && apt-get install -y vim less
|
||||
RUN apt-get update && apt-get -y install lsb-release
|
||||
RUN apt-get update && apt-get -y install net-tools
|
||||
|
||||
# RUN mkdir -p /usr/share/man/man1
|
||||
# RUN apt-get update && apt-get install -y apt-utils openjdk-11-jre
|
||||
RUN apt-get update && apt-get install -y ubuntu-mate-desktop
|
||||
RUN apt-get update && apt-get install -y lxde
|
||||
RUN apt-get update && apt-get install -y lxqt
|
||||
RUN apt-get update && apt-get install -y kde-full
|
||||
RUN apt-get update && apt-get install -y cinnamon
|
||||
RUN apt-get update && apt-get install -y ubuntu-gnome-desktop
|
||||
RUN apt-get purge -y pm-utils xscreensaver*
|
||||
RUN apt-get purge -y clipit magnus kgpg
|
||||
|
||||
RUN apt-get update && apt-get install -y python3-pip
|
||||
RUN apt-get update && apt-get install -y strace
|
||||
|
||||
RUN useradd -m docker
|
||||
ENV USER docker
|
||||
|
||||
ARG KASMVNC_PACKAGE_DIR
|
||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
||||
|
||||
ENV HOME /home/docker
|
||||
RUN chown -R 1000:0 $HOME
|
||||
USER 1000:ssl-cert
|
||||
WORKDIR $HOME
|
||||
|
||||
RUN pip3 install --user pipenv
|
||||
RUN echo 'PATH="/src/unix:~/.local/bin/:$PATH"' >> ~/.bashrc
|
||||
RUN echo 'alias s="sh /src/s"' >> ~/.bashrc
|
||||
RUN echo 'alias k="vncserver -kill :1; pkill baloo_file; pkill gpg-agent; pkill ssh-agent; pkill xiccd"' >> ~/.bashrc
|
||||
RUN echo 'alias r="k; s"' >> ~/.bashrc
|
||||
RUN echo 'alias go="sh /src/s; vncserver -kill :1"' >> ~/.bashrc
|
||||
RUN echo 'alias ns="netstat -nltp"' >> ~/.bashrc
|
||||
RUN echo 'alias mamba="pipenv run mamba spec/"' >> ~/.bashrc
|
||||
|
||||
ENV LC_ALL=C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
ENTRYPOINT ["bash", "-ic", "cd /src && pipenv install; exec bash"]
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
debug() {
|
||||
if [ -z "$debug" ]; then return; fi
|
||||
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
enable_debug() {
|
||||
debug=1
|
||||
log_option="-log *:stderr:100"
|
||||
}
|
||||
|
||||
kill_vnc_server() {
|
||||
vncserver -kill $display
|
||||
}
|
||||
|
||||
process_cli_options() {
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
--help)
|
||||
show_help
|
||||
exit
|
||||
;;
|
||||
-d|--debug)
|
||||
enable_debug
|
||||
;;
|
||||
-k|--kill)
|
||||
kill_vnc_server
|
||||
exit
|
||||
;;
|
||||
-s|--select-de)
|
||||
action=select-de-and-start
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Unsupported argument: $option"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
show_help() {
|
||||
cat >&2 <<-USAGE
|
||||
Usage: $(basename "$0") [options]
|
||||
-d, --debug Debug output
|
||||
-k, --kill Kill vncserver
|
||||
-s, --select-de Select desktop environent to run
|
||||
--help Show this help
|
||||
USAGE
|
||||
}
|
||||
@@ -4,8 +4,43 @@ set -e
|
||||
|
||||
display=:10
|
||||
interface=0.0.0.0
|
||||
cert_group=ssl-cert
|
||||
|
||||
if [[ "$1" = "--help" ]]; then
|
||||
cat >&2 <<-USAGE
|
||||
Usage: `basename $0` [options]
|
||||
-d Debug output
|
||||
-kill Kill vncserver
|
||||
--help show this help
|
||||
USAGE
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "$1" = "-d" ]]; then
|
||||
log_option="-log *:stderr:100"
|
||||
fi
|
||||
|
||||
action=start
|
||||
if [[ "$1" = "-kill" ]]; then
|
||||
action=kill
|
||||
fi
|
||||
|
||||
if groups | grep -qvw ssl-cert; then
|
||||
cat <<-EOF
|
||||
Can't access TLS certificate.
|
||||
Please add your user to $cert_group via 'addgroup <user> ssl-cert'
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$action" = "kill" ]]; then
|
||||
vncserver -kill $display
|
||||
exit
|
||||
fi
|
||||
|
||||
vncserver $display -interface $interface
|
||||
vncserver -kill $display
|
||||
vncserver $display -depth 24 -geometry 1280x1050 -websocketPort 8443 \
|
||||
-cert /etc/ssl/certs/ssl-cert-snakeoil.pem \
|
||||
-key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24 \
|
||||
-interface $interface -httpd /usr/share/kasmvnc/www
|
||||
-interface $interface -httpd /usr/share/kasmvnc/www $log_option
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
xstartup_script=~/.vnc/xstartup
|
||||
de_was_selected_file="$HOME/.vnc/.de-was-selected"
|
||||
|
||||
debug() {
|
||||
if [ -z "$debug" ]; then return; fi
|
||||
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
enable_debug() {
|
||||
debug=1
|
||||
}
|
||||
|
||||
process_cli_options() {
|
||||
while [ $# -gt 0 ]; do
|
||||
local option="$1"
|
||||
shift
|
||||
|
||||
case "$option" in
|
||||
--help|-h)
|
||||
show_help
|
||||
exit
|
||||
;;
|
||||
-d|--debug)
|
||||
enable_debug
|
||||
;;
|
||||
-y|--assume-yes)
|
||||
assume_yes=1
|
||||
;;
|
||||
-s|--select-de)
|
||||
action=select-de
|
||||
if [[ -n "$1" && "${1:0:1}" != "-" ]]; then
|
||||
selected_de="$1"
|
||||
assume_yes_for_xstartup_overwrite=1
|
||||
if [ "$selected_de" = "manual" ]; then
|
||||
selected_de="$manual_xstartup_choice"
|
||||
fi
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Unsupported argument: $option"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
show_help() {
|
||||
cat >&2 <<-USAGE
|
||||
Usage: $(basename "$0") [options]
|
||||
-d, --debug Debug output
|
||||
-y, --assume-yes Automatic "yes" to prompts
|
||||
-s, --select-de Select desktop environent to run
|
||||
--help Show this help
|
||||
USAGE
|
||||
}
|
||||
|
||||
add_uppercase_desktop_environment_keys() {
|
||||
local de_cmd
|
||||
|
||||
for de in "${!all_desktop_environments[@]}"; do
|
||||
de_cmd=${all_desktop_environments[$de]};
|
||||
all_desktop_environments[${de^^}]="$de_cmd"
|
||||
done
|
||||
}
|
||||
|
||||
process_cli_options "$@"
|
||||
|
||||
manual_xstartup_choice="Manually edit xstartup"
|
||||
declare -A all_desktop_environments=(
|
||||
[Cinnamon]="exec cinnamon-session"
|
||||
[Mate]="XDG_CURRENT_DESKTOP=MATE exec dbus-launch --exit-with-session mate-session"
|
||||
[LXDE]="exec lxsession"
|
||||
[Lxqt]="exec startlxqt"
|
||||
[KDE]="exec startkde"
|
||||
[Gnome]="XDG_CURRENT_DESKTOP=GNOME exec dbus-launch --exit-with-session /usr/bin/gnome-session"
|
||||
[XFCE]="exec xfce4-session")
|
||||
|
||||
readarray -t sorted_desktop_environments < <(for de in "${!all_desktop_environments[@]}"; do echo "$de"; done | sort)
|
||||
|
||||
all_desktop_environments[$manual_xstartup_choice]=""
|
||||
sorted_desktop_environments+=("$manual_xstartup_choice")
|
||||
add_uppercase_desktop_environment_keys
|
||||
|
||||
detected_desktop_environments=()
|
||||
declare -A numbered_desktop_environments
|
||||
|
||||
print_detected_desktop_environments() {
|
||||
declare -i i=1
|
||||
|
||||
echo "Please choose Desktop Environment to run:"
|
||||
for detected_de in "${detected_desktop_environments[@]}"; do
|
||||
echo "[$i] $detected_de"
|
||||
numbered_desktop_environments[$i]=$detected_de
|
||||
i+=1
|
||||
done
|
||||
}
|
||||
|
||||
detect_desktop_environments() {
|
||||
for de_name in "${sorted_desktop_environments[@]}"; do
|
||||
if [[ "$de_name" = "$manual_xstartup_choice" ]]; then
|
||||
detected_desktop_environments+=("$de_name")
|
||||
continue;
|
||||
fi
|
||||
|
||||
local executable=${all_desktop_environments[$de_name]}
|
||||
executable=($executable)
|
||||
executable=${executable[-1]}
|
||||
|
||||
if detect_desktop_environment "$de_name" "$executable"; then
|
||||
detected_desktop_environments+=("$de_name")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
ask_user_to_choose_de() {
|
||||
while : ; do
|
||||
print_detected_desktop_environments
|
||||
read -r de_number_to_run
|
||||
de_name_from_number "$de_number_to_run"
|
||||
if [[ -n "$de_name" ]]; then
|
||||
break;
|
||||
fi
|
||||
|
||||
echo "Incorrect number: $de_number_to_run"
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
remember_de_choice() {
|
||||
touch "$de_was_selected_file"
|
||||
}
|
||||
|
||||
de_was_selected_on_previous_run() {
|
||||
[[ -f "$de_was_selected_file" ]]
|
||||
}
|
||||
|
||||
detect_desktop_environment() {
|
||||
local de_name="$1"
|
||||
local executable="$2"
|
||||
|
||||
if command -v "$executable" &>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
did_user_forbid_replacing_xstartup() {
|
||||
grep -q -v KasmVNC-safe-to-replace-this-file "$xstartup_script"
|
||||
}
|
||||
|
||||
de_cmd_from_name() {
|
||||
de_cmd=${all_desktop_environments[${de_name^^}]}
|
||||
}
|
||||
|
||||
de_name_from_number() {
|
||||
local de_number_to_run="$1"
|
||||
|
||||
de_name=${numbered_desktop_environments[$de_number_to_run]}
|
||||
}
|
||||
|
||||
warn_xstartup_will_be_overwriten() {
|
||||
if [[ -n "$assume_yes" || -n "$assume_yes_for_xstartup_overwrite" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f "$xstartup_script" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo -n "WARNING: $xstartup_script will be overwritten y/N?"
|
||||
read -r do_overwrite_xstartup
|
||||
if [[ "$do_overwrite_xstartup" = "y" || "$do_overwrite_xstartup" = "Y" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
setup_de_to_run_via_xstartup() {
|
||||
warn_xstartup_will_be_overwriten
|
||||
generate_xstartup "$de_name"
|
||||
}
|
||||
|
||||
generate_xstartup() {
|
||||
local de_name="$1"
|
||||
|
||||
de_cmd_from_name
|
||||
|
||||
cat <<-SCRIPT > "$xstartup_script"
|
||||
#!/bin/sh
|
||||
$de_cmd
|
||||
SCRIPT
|
||||
chmod +x "$xstartup_script"
|
||||
}
|
||||
|
||||
user_asked_to_select_de() {
|
||||
[[ "$action" = "select-de" ]]
|
||||
}
|
||||
|
||||
user_specified_de() {
|
||||
[ -n "$selected_de" ]
|
||||
}
|
||||
|
||||
check_de_name_is_valid() {
|
||||
local selected_de="$1"
|
||||
local de_cmd=${all_desktop_environments["${selected_de^^}"]:-}
|
||||
if [ -z "$de_cmd" ]; then
|
||||
echo >&2 "'$selected_de': not supported Desktop Environment"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
de_installed() {
|
||||
local de_name="${1^^}"
|
||||
|
||||
for de in "${detected_desktop_environments[@]}"; do
|
||||
if [ "${de^^}" = "$de_name" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
check_de_installed() {
|
||||
local de_name="$1"
|
||||
|
||||
if ! de_installed "$de_name"; then
|
||||
echo >&2 "'$de_name': Desktop Environment not installed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if user_asked_to_select_de || ! de_was_selected_on_previous_run; then
|
||||
if user_specified_de; then
|
||||
check_de_name_is_valid "$selected_de"
|
||||
fi
|
||||
|
||||
detect_desktop_environments
|
||||
if user_specified_de; then
|
||||
check_de_installed "$selected_de"
|
||||
de_name="$selected_de"
|
||||
else
|
||||
ask_user_to_choose_de
|
||||
fi
|
||||
|
||||
debug "You selected $de_name desktop environment"
|
||||
if [[ "$de_name" != "$manual_xstartup_choice" ]]; then
|
||||
setup_de_to_run_via_xstartup
|
||||
fi
|
||||
remember_de_choice
|
||||
fi
|
||||
@@ -61,6 +61,9 @@ kasmvncpasswd -d -u "$VNC_USER-to-delete" $HOME/.kasmpasswd
|
||||
chmod 0600 $HOME/.kasmpasswd
|
||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $HOME/.vnc/self.pem -out $HOME/.vnc/self.pem -subj "/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
|
||||
|
||||
vncserver :1 -interface 0.0.0.0
|
||||
vncserver -kill :1
|
||||
|
||||
if [[ -f $PASSWD_PATH ]]; then
|
||||
rm -f $PASSWD_PATH
|
||||
fi
|
||||
@@ -83,10 +86,10 @@ vncserver -kill $DISPLAY &> $HOME/.vnc/vnc_startup.log \
|
||||
|
||||
detect_www_dir
|
||||
detect_cert_location
|
||||
[ -n "$KASMVNC_VERBOSE_LOGGING" ] && verbose_logging_option="-debug"
|
||||
[ -n "$KASMVNC_VERBOSE_LOGGING" ] && verbose_logging_option="-log *:stderr:100"
|
||||
|
||||
echo -e "start vncserver with param: VNC_COL_DEPTH=$VNC_COL_DEPTH, VNC_RESOLUTION=$VNC_RESOLUTION\n..."
|
||||
vncserver $DISPLAY -select-de xfce -depth $VNC_COL_DEPTH -geometry $VNC_RESOLUTION -FrameRate=$MAX_FRAME_RATE -websocketPort $VNC_PORT $cert_option -sslOnly -interface 0.0.0.0 $VNCOPTIONS $package_www_dir_option $verbose_logging_option #&> $STARTUPDIR/no_vnc_startup.log
|
||||
vncserver $DISPLAY -depth $VNC_COL_DEPTH -geometry $VNC_RESOLUTION -FrameRate=$MAX_FRAME_RATE -websocketPort $VNC_PORT $cert_option -sslOnly -interface 0.0.0.0 $VNCOPTIONS $package_www_dir_option $verbose_logging_option #&> $STARTUPDIR/no_vnc_startup.log
|
||||
|
||||
PID_SUN=$!
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
. ./os_ver_cli.sh
|
||||
|
||||
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os_codename}" \
|
||||
-t kasmvnctester_${os}:$os_codename \
|
||||
-f dockerfile.${os}_${os_codename}.vncserver.test .
|
||||
docker run -it -v $(realpath ${PWD}/..):/src -p 8443:8443 -p 8444:8444 \
|
||||
-p 8445:8445 --rm \
|
||||
-e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \
|
||||
-e "VNC_USER=foo" -e "VNC_PW=foobar" \
|
||||
kasmvnctester_${os}:$os_codename
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: kasmvncserver
|
||||
Version: 0.9.3~beta
|
||||
Version: 0.9.1~beta
|
||||
Release: 1%{?dist}
|
||||
Summary: VNC server accessible from a web browser
|
||||
|
||||
@@ -7,7 +7,7 @@ License: GPLv2+
|
||||
URL: https://github.com/kasmtech/KasmVNC
|
||||
|
||||
BuildRequires: rsync
|
||||
Requires: xorg-x11-xauth, xorg-x11-xkb-utils, xkeyboard-config, xorg-x11-server-utils, openssl, perl, perl-Switch, rpmfusion-free-release, perl-Hash-Merge-Simple, perl-Scalar-List-Utils
|
||||
Requires: xorg-x11-xauth, xorg-x11-xkb-utils, xkeyboard-config, xorg-x11-server-utils, openssl, perl
|
||||
Conflicts: tigervnc-server, tigervnc-server-minimal
|
||||
|
||||
%description
|
||||
@@ -48,12 +48,11 @@ DESTDIR=$RPM_BUILD_ROOT
|
||||
DST_MAN=$DESTDIR/usr/share/man/man1
|
||||
|
||||
mkdir -p $DESTDIR/usr/bin $DESTDIR/usr/share/man/man1 \
|
||||
$DESTDIR/usr/share/doc/kasmvncserver $DESTDIR/usr/lib
|
||||
$DESTDIR/usr/share/doc/kasmvncserver
|
||||
cp $SRC_BIN/Xvnc $DESTDIR/usr/bin;
|
||||
cp $SRC_BIN/vncserver $DESTDIR/usr/bin;
|
||||
cp $SRC_BIN/vncconfig $DESTDIR/usr/bin;
|
||||
cp $SRC_BIN/kasmvncpasswd $DESTDIR/usr/bin;
|
||||
cp -r $SRC/lib/kasmvnc/ $DESTDIR/usr/lib/kasmvncserver
|
||||
cd $DESTDIR/usr/bin && ln -s kasmvncpasswd vncpasswd;
|
||||
cp -r $SRC/share/doc/kasmvnc*/* $DESTDIR/usr/share/doc/kasmvncserver/
|
||||
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
||||
@@ -67,7 +66,6 @@ cd $DST_MAN && ln -s vncpasswd.1 kasmvncpasswd.1;
|
||||
|
||||
%files
|
||||
/usr/bin/*
|
||||
/usr/lib/kasmvncserver
|
||||
/usr/share/man/man1/*
|
||||
/usr/share/kasmvnc/www
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ static const char *parse_get(const char * const in, const char * const opt, unsi
|
||||
return "";
|
||||
}
|
||||
|
||||
static void percent_decode(const char *src, char *dst, const uint8_t filter) {
|
||||
static void percent_decode(const char *src, char *dst) {
|
||||
while (1) {
|
||||
if (!*src)
|
||||
break;
|
||||
@@ -127,32 +127,7 @@ static void percent_decode(const char *src, char *dst, const uint8_t filter) {
|
||||
hex[2] = '\0';
|
||||
|
||||
src += 2;
|
||||
*dst = strtol(hex, NULL, 16);
|
||||
|
||||
if (filter) {
|
||||
// Avoid directory traversal
|
||||
if (*dst == '/')
|
||||
*dst = '_';
|
||||
}
|
||||
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
static void percent_encode(const char *src, char *dst) {
|
||||
while (1) {
|
||||
if (!*src)
|
||||
break;
|
||||
if (isalnum(*src) || *src == '.' || *src == ',') {
|
||||
*dst++ = *src++;
|
||||
} else {
|
||||
*dst++ = '%';
|
||||
sprintf(dst, "%02X", *src);
|
||||
dst += 2;
|
||||
src++;
|
||||
*dst++ = strtol(hex, NULL, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,7 +746,6 @@ def:
|
||||
|
||||
static void dirlisting(ws_ctx_t *ws_ctx, const char fullpath[], const char path[]) {
|
||||
char buf[4096];
|
||||
char enc[PATH_MAX * 3 + 1];
|
||||
unsigned i;
|
||||
|
||||
// Redirect?
|
||||
@@ -805,13 +779,11 @@ static void dirlisting(ws_ctx_t *ws_ctx, const char fullpath[], const char path[
|
||||
if (!strcmp(names[i]->d_name, ".") || !strcmp(names[i]->d_name, ".."))
|
||||
continue;
|
||||
|
||||
percent_encode(names[i]->d_name, enc);
|
||||
|
||||
if (names[i]->d_type == DT_DIR)
|
||||
sprintf(buf, "<li><a href=\"%s/\">%s/</a></li>", enc,
|
||||
sprintf(buf, "<li><a href=\"%s/\">%s/</a></li>", names[i]->d_name,
|
||||
names[i]->d_name);
|
||||
else
|
||||
sprintf(buf, "<li><a href=\"%s\">%s</a></li>", enc,
|
||||
sprintf(buf, "<li><a href=\"%s\">%s</a></li>", names[i]->d_name,
|
||||
names[i]->d_name);
|
||||
|
||||
ws_send(ws_ctx, buf, strlen(buf));
|
||||
@@ -850,15 +822,13 @@ static void servefile(ws_ctx_t *ws_ctx, const char *in) {
|
||||
len = strlen(path);
|
||||
}
|
||||
|
||||
percent_decode(path, buf, 1);
|
||||
|
||||
wserr("Requested file '%s'\n", buf);
|
||||
sprintf(fullpath, "%s/%s", settings.httpdir, buf);
|
||||
wserr("Requested file '%s'\n", path);
|
||||
sprintf(fullpath, "%s/%s", settings.httpdir, path);
|
||||
|
||||
DIR *dir = opendir(fullpath);
|
||||
if (dir) {
|
||||
closedir(dir);
|
||||
dirlisting(ws_ctx, fullpath, buf);
|
||||
dirlisting(ws_ctx, fullpath, path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1006,14 +976,14 @@ static uint8_t ownerapi(ws_ctx_t *ws_ctx, const char *in) {
|
||||
if (len) {
|
||||
memcpy(buf, param, len);
|
||||
buf[len] = '\0';
|
||||
percent_decode(buf, decname, 0);
|
||||
percent_decode(buf, decname);
|
||||
}
|
||||
|
||||
param = parse_get(args, "password", &len);
|
||||
if (len) {
|
||||
memcpy(buf, param, len);
|
||||
buf[len] = '\0';
|
||||
percent_decode(buf, decpw, 0);
|
||||
percent_decode(buf, decpw);
|
||||
|
||||
struct crypt_data cdata;
|
||||
cdata.initialized = 0;
|
||||
@@ -1053,7 +1023,7 @@ static uint8_t ownerapi(ws_ctx_t *ws_ctx, const char *in) {
|
||||
if (len) {
|
||||
memcpy(buf, param, len);
|
||||
buf[len] = '\0';
|
||||
percent_decode(buf, decname, 0);
|
||||
percent_decode(buf, decname);
|
||||
}
|
||||
|
||||
if (!decname[0])
|
||||
@@ -1082,7 +1052,7 @@ static uint8_t ownerapi(ws_ctx_t *ws_ctx, const char *in) {
|
||||
if (len) {
|
||||
memcpy(buf, param, len);
|
||||
buf[len] = '\0';
|
||||
percent_decode(buf, decname, 0);
|
||||
percent_decode(buf, decname);
|
||||
}
|
||||
|
||||
if (!decname[0])
|
||||
@@ -1127,7 +1097,7 @@ static uint8_t ownerapi(ws_ctx_t *ws_ctx, const char *in) {
|
||||
if (len) {
|
||||
memcpy(buf, param, len);
|
||||
buf[len] = '\0';
|
||||
percent_decode(buf, decname, 0);
|
||||
percent_decode(buf, decname);
|
||||
} else {
|
||||
wserr("client param required\n");
|
||||
goto nope;
|
||||
@@ -1350,8 +1320,6 @@ ws_ctx_t *do_handshake(int sock) {
|
||||
} else {
|
||||
// Client tried an empty password, just fail them
|
||||
response[0] = '\0';
|
||||
authbuf[0] = 'a';
|
||||
authbuf[1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
int maxfd, client = ws_ctx->sockfd;
|
||||
unsigned int opcode, left, ret;
|
||||
unsigned int tout_start, tout_end, cout_start, cout_end;
|
||||
unsigned int tin_end;
|
||||
unsigned int tin_start, tin_end;
|
||||
ssize_t len, bytes;
|
||||
|
||||
tout_start = tout_end = cout_start = cout_end =
|
||||
tin_end = 0;
|
||||
tin_start = tin_end = 0;
|
||||
maxfd = client > target ? client+1 : target+1;
|
||||
|
||||
while (1) {
|
||||
@@ -165,7 +165,7 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
}
|
||||
|
||||
if (FD_ISSET(client, &rlist)) {
|
||||
bytes = ws_recv(ws_ctx, ws_ctx->tin_buf + tin_end, BUFSIZE-1-tin_end);
|
||||
bytes = ws_recv(ws_ctx, ws_ctx->tin_buf + tin_end, BUFSIZE-1);
|
||||
if (pipe_error) { break; }
|
||||
if (bytes <= 0) {
|
||||
handler_emsg("client closed connection\n");
|
||||
@@ -180,13 +180,13 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
printf("\n");
|
||||
*/
|
||||
if (ws_ctx->hybi) {
|
||||
len = decode_hybi(ws_ctx->tin_buf,
|
||||
tin_end,
|
||||
len = decode_hybi(ws_ctx->tin_buf + tin_start,
|
||||
tin_end-tin_start,
|
||||
ws_ctx->tout_buf, BUFSIZE-1,
|
||||
&opcode, &left);
|
||||
} else {
|
||||
len = decode_hixie(ws_ctx->tin_buf,
|
||||
tin_end,
|
||||
len = decode_hixie(ws_ctx->tin_buf + tin_start,
|
||||
tin_end-tin_start,
|
||||
ws_ctx->tout_buf, BUFSIZE-1,
|
||||
&opcode, &left);
|
||||
}
|
||||
@@ -208,13 +208,10 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
break;
|
||||
}
|
||||
if (left) {
|
||||
const unsigned tin_start = tin_end - left;
|
||||
//handler_emsg("partial frame from client, %u left, start %u end %u, lens %lu %lu\n",
|
||||
// left, tin_start, tin_end, bytes, len);
|
||||
memmove(ws_ctx->tin_buf, ws_ctx->tin_buf + tin_start, left);
|
||||
tin_end = left;
|
||||
tin_start = tin_end - left;
|
||||
//printf("partial frame from client");
|
||||
} else {
|
||||
//handler_emsg("handled %lu/%lu bytes\n", bytes, len);
|
||||
tin_start = 0;
|
||||
tin_end = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1024,7 +1024,7 @@ PixelBuffer *rfb::progressiveBilinearScale(const PixelBuffer *pb,
|
||||
rdr::U8 *newpx = ((ManagedPixelBuffer *) newpb)->getBufferRW(newpb->getRect(),
|
||||
&newstride);
|
||||
|
||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtw / (float) oldw);
|
||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtdiff);
|
||||
if (del)
|
||||
delete pb;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@ namespace rfb {
|
||||
virtual void pointerEvent(const Point& __unused_attr pos,
|
||||
int __unused_attr buttonMask,
|
||||
const bool __unused_attr skipClick,
|
||||
const bool __unused_attr skipRelease,
|
||||
int scrollX,
|
||||
int scrollY) { }
|
||||
const bool __unused_attr skipRelease) { }
|
||||
virtual void clientCutText(const char* __unused_attr str,
|
||||
int __unused_attr len) { }
|
||||
};
|
||||
|
||||
@@ -284,26 +284,74 @@ void SConnection::setEncodings(int nEncodings, const rdr::S32* encodings)
|
||||
}
|
||||
|
||||
SMsgHandler::setEncodings(nEncodings, encodings);
|
||||
|
||||
if (cp.supportsExtendedClipboard) {
|
||||
rdr::U32 sizes[] = { 0 };
|
||||
writer()->writeClipboardCaps(rfb::clipboardUTF8 |
|
||||
rfb::clipboardRequest |
|
||||
rfb::clipboardPeek |
|
||||
rfb::clipboardNotify |
|
||||
rfb::clipboardProvide,
|
||||
sizes);
|
||||
}
|
||||
}
|
||||
|
||||
void SConnection::clearBinaryClipboard()
|
||||
void SConnection::clientCutText(const char* str, int len)
|
||||
{
|
||||
binaryClipboard.clear();
|
||||
hasLocalClipboard = false;
|
||||
|
||||
strFree(clientClipboard);
|
||||
clientClipboard = NULL;
|
||||
|
||||
clientClipboard = latin1ToUTF8(str);
|
||||
|
||||
handleClipboardAnnounce(true);
|
||||
}
|
||||
|
||||
void SConnection::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len)
|
||||
void SConnection::handleClipboardRequest(rdr::U32 flags)
|
||||
{
|
||||
binaryClipboard_t bin;
|
||||
strncpy(bin.mime, mime, sizeof(bin.mime));
|
||||
bin.mime[sizeof(bin.mime) - 1] = '\0';
|
||||
|
||||
bin.data.resize(len);
|
||||
memcpy(&bin.data[0], data, len);
|
||||
|
||||
binaryClipboard.push_back(bin);
|
||||
if (!(flags & rfb::clipboardUTF8))
|
||||
return;
|
||||
if (!hasLocalClipboard)
|
||||
return;
|
||||
handleClipboardRequest();
|
||||
}
|
||||
|
||||
void SConnection::handleClipboardPeek(rdr::U32 flags)
|
||||
{
|
||||
if (!hasLocalClipboard)
|
||||
return;
|
||||
if (cp.clipboardFlags() & rfb::clipboardNotify)
|
||||
writer()->writeClipboardNotify(rfb::clipboardUTF8);
|
||||
}
|
||||
|
||||
void SConnection::handleClipboardNotify(rdr::U32 flags)
|
||||
{
|
||||
strFree(clientClipboard);
|
||||
clientClipboard = NULL;
|
||||
|
||||
if (flags & rfb::clipboardUTF8) {
|
||||
handleClipboardAnnounce(true);
|
||||
hasLocalClipboard = false;
|
||||
} else {
|
||||
handleClipboardAnnounce(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SConnection::handleClipboardProvide(rdr::U32 flags,
|
||||
const size_t* lengths,
|
||||
const rdr::U8* const* data)
|
||||
{
|
||||
if (!(flags & rfb::clipboardUTF8))
|
||||
return;
|
||||
|
||||
strFree(clientClipboard);
|
||||
clientClipboard = NULL;
|
||||
|
||||
clientClipboard = convertLF((const char*)data[0], lengths[0]);
|
||||
|
||||
handleClipboardData(clientClipboard, strlen(clientClipboard));
|
||||
}
|
||||
|
||||
void SConnection::supportsQEMUKeyEvent()
|
||||
{
|
||||
@@ -397,13 +445,56 @@ void SConnection::enableContinuousUpdates(bool enable,
|
||||
{
|
||||
}
|
||||
|
||||
void SConnection::handleClipboardRequest()
|
||||
{
|
||||
}
|
||||
|
||||
void SConnection::handleClipboardAnnounce(bool available)
|
||||
{
|
||||
}
|
||||
|
||||
void SConnection::handleClipboardData(const char* data, int len)
|
||||
{
|
||||
}
|
||||
|
||||
void SConnection::requestClipboard()
|
||||
{
|
||||
if (clientClipboard != NULL) {
|
||||
handleClipboardData(clientClipboard, strlen(clientClipboard));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cp.supportsExtendedClipboard &&
|
||||
(cp.clipboardFlags() & rfb::clipboardRequest))
|
||||
writer()->writeClipboardRequest(rfb::clipboardUTF8);
|
||||
}
|
||||
|
||||
void SConnection::announceClipboard(bool available)
|
||||
{
|
||||
hasLocalClipboard = available;
|
||||
|
||||
if (cp.supportsExtendedClipboard &&
|
||||
(cp.clipboardFlags() & rfb::clipboardNotify))
|
||||
writer()->writeClipboardNotify(available ? rfb::clipboardUTF8 : 0);
|
||||
else {
|
||||
if (available)
|
||||
handleClipboardRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void SConnection::sendClipboardData(const char* data, int len)
|
||||
{
|
||||
if (cp.supportsExtendedClipboard &&
|
||||
(cp.clipboardFlags() & rfb::clipboardProvide)) {
|
||||
CharArray filtered(convertCRLF(data));
|
||||
size_t sizes[1] = { strlen(filtered.buf) + 1 };
|
||||
const rdr::U8* data[1] = { (const rdr::U8*)filtered.buf };
|
||||
writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, data);
|
||||
} else {
|
||||
CharArray latin1(utf8ToLatin1(data));
|
||||
|
||||
writer()->writeServerCutText(latin1.buf, strlen(latin1.buf));
|
||||
}
|
||||
}
|
||||
|
||||
void SConnection::writeFakeColourMap(void)
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <rdr/OutStream.h>
|
||||
#include <rfb/SMsgHandler.h>
|
||||
#include <rfb/SecurityServer.h>
|
||||
#include <vector>
|
||||
|
||||
namespace rfb {
|
||||
|
||||
@@ -74,9 +73,14 @@ namespace rfb {
|
||||
|
||||
virtual void setEncodings(int nEncodings, const rdr::S32* encodings);
|
||||
|
||||
virtual void clearBinaryClipboard();
|
||||
virtual void addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len);
|
||||
virtual void clientCutText(const char* str, int len);
|
||||
|
||||
virtual void handleClipboardRequest(rdr::U32 flags);
|
||||
virtual void handleClipboardPeek(rdr::U32 flags);
|
||||
virtual void handleClipboardNotify(rdr::U32 flags);
|
||||
virtual void handleClipboardProvide(rdr::U32 flags,
|
||||
const size_t* lengths,
|
||||
const rdr::U8* const* data);
|
||||
|
||||
virtual void supportsQEMUKeyEvent();
|
||||
|
||||
@@ -123,11 +127,25 @@ namespace rfb {
|
||||
virtual void enableContinuousUpdates(bool enable,
|
||||
int x, int y, int w, int h);
|
||||
|
||||
// handleClipboardRequest() is called whenever the client requests
|
||||
// the server to send over its clipboard data. It will only be
|
||||
// called after the server has first announced a clipboard change
|
||||
// via announceClipboard().
|
||||
virtual void handleClipboardRequest();
|
||||
|
||||
// handleClipboardAnnounce() is called to indicate a change in the
|
||||
// clipboard on the client. Call requestClipboard() to access the
|
||||
// actual data.
|
||||
virtual void handleClipboardAnnounce(bool available);
|
||||
|
||||
// handleClipboardData() is called when the client has sent over
|
||||
// the clipboard data as a result of a previous call to
|
||||
// requestClipboard(). Note that this function might never be
|
||||
// called if the clipboard data was no longer available when the
|
||||
// client received the request.
|
||||
virtual void handleClipboardData(const char* data, int len);
|
||||
|
||||
|
||||
virtual void add_changed_all() {}
|
||||
|
||||
// setAccessRights() allows a security package to limit the access rights
|
||||
@@ -148,11 +166,22 @@ namespace rfb {
|
||||
|
||||
// Other methods
|
||||
|
||||
// requestClipboard() will result in a request to the client to
|
||||
// transfer its clipboard data. A call to handleClipboardData()
|
||||
// will be made once the data is available.
|
||||
virtual void requestClipboard();
|
||||
|
||||
// announceClipboard() informs the client of changes to the
|
||||
// clipboard on the server. The client may later request the
|
||||
// clipboard data via handleClipboardRequest().
|
||||
virtual void announceClipboard(bool available);
|
||||
|
||||
// sendClipboardData() transfers the clipboard data to the client
|
||||
// and should be called whenever the client has requested the
|
||||
// clipboard via handleClipboardRequest().
|
||||
virtual void sendClipboardData(const char* data, int len);
|
||||
|
||||
|
||||
// authenticated() returns true if the client has authenticated
|
||||
// successfully.
|
||||
bool authenticated() { return (state_ == RFBSTATE_INITIALISATION ||
|
||||
@@ -192,19 +221,12 @@ namespace rfb {
|
||||
|
||||
rdr::S32 getPreferredEncoding() { return preferredEncoding; }
|
||||
|
||||
struct binaryClipboard_t {
|
||||
char mime[32];
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
protected:
|
||||
void setState(stateEnum s) { state_ = s; }
|
||||
|
||||
void setReader(SMsgReader *r) { reader_ = r; }
|
||||
void setWriter(SMsgWriter *w) { writer_ = w; }
|
||||
|
||||
std::vector<binaryClipboard_t> binaryClipboard;
|
||||
|
||||
private:
|
||||
void writeFakeColourMap(void);
|
||||
|
||||
|
||||
@@ -78,13 +78,23 @@ namespace rfb {
|
||||
// the relevant RFB protocol messages from clients.
|
||||
// See InputHandler for method signatures.
|
||||
|
||||
// handleClipboardRequest() is called whenever a client requests
|
||||
// the server to send over its clipboard data. It will only be
|
||||
// called after the server has first announced a clipboard change
|
||||
// via VNCServer::announceClipboard().
|
||||
virtual void handleClipboardRequest() {}
|
||||
|
||||
// handleClipboardAnnounce() is called to indicate a change in the
|
||||
// clipboard on a client. Call VNCServer::requestClipboard() to
|
||||
// access the actual data.
|
||||
virtual void handleClipboardAnnounce(bool __unused_attr available) {}
|
||||
|
||||
virtual void handleClipboardAnnounceBinary(const unsigned __unused_attr num,
|
||||
const char __unused_attr mimes[][32]) {}
|
||||
// handleClipboardData() is called when a client has sent over
|
||||
// the clipboard data as a result of a previous call to
|
||||
// VNCServer::requestClipboard(). Note that this function might
|
||||
// never be called if the clipboard data was no longer available
|
||||
// when the client received the request.
|
||||
virtual void handleClipboardData(const char* __unused_attr data, int len __unused_attr) {}
|
||||
|
||||
protected:
|
||||
virtual ~SDesktop() {}
|
||||
|
||||
@@ -64,16 +64,26 @@ void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings)
|
||||
supportsQEMUKeyEvent();
|
||||
}
|
||||
|
||||
void SMsgHandler::handleClipboardAnnounceBinary(const unsigned, const char mimes[][32])
|
||||
void SMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths)
|
||||
{
|
||||
cp.setClipboardCaps(flags, lengths);
|
||||
}
|
||||
|
||||
void SMsgHandler::handleClipboardRequest(rdr::U32 flags)
|
||||
{
|
||||
}
|
||||
|
||||
void SMsgHandler::clearBinaryClipboard()
|
||||
void SMsgHandler::handleClipboardPeek(rdr::U32 flags)
|
||||
{
|
||||
}
|
||||
|
||||
void SMsgHandler::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len)
|
||||
void SMsgHandler::handleClipboardNotify(rdr::U32 flags)
|
||||
{
|
||||
}
|
||||
|
||||
void SMsgHandler::handleClipboardProvide(rdr::U32 flags,
|
||||
const size_t* lengths,
|
||||
const rdr::U8* const* data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,14 @@ namespace rfb {
|
||||
virtual void enableContinuousUpdates(bool enable,
|
||||
int x, int y, int w, int h) = 0;
|
||||
|
||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
||||
virtual void clearBinaryClipboard();
|
||||
virtual void addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len);
|
||||
virtual void handleClipboardCaps(rdr::U32 flags,
|
||||
const rdr::U32* lengths);
|
||||
virtual void handleClipboardRequest(rdr::U32 flags);
|
||||
virtual void handleClipboardPeek(rdr::U32 flags);
|
||||
virtual void handleClipboardNotify(rdr::U32 flags);
|
||||
virtual void handleClipboardProvide(rdr::U32 flags,
|
||||
const size_t* lengths,
|
||||
const rdr::U8* const* data);
|
||||
|
||||
virtual void sendStats(const bool toClient = true) = 0;
|
||||
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render) = 0;
|
||||
|
||||
@@ -35,6 +35,8 @@ using namespace rfb;
|
||||
|
||||
static LogWriter vlog("SMsgReader");
|
||||
|
||||
static IntParameter maxCutText("MaxCutText", "Maximum permitted length of an incoming clipboard update", 256*1024);
|
||||
|
||||
SMsgReader::SMsgReader(SMsgHandler* handler_, rdr::InStream* is_)
|
||||
: handler(handler_), is(is_)
|
||||
{
|
||||
@@ -81,9 +83,6 @@ void SMsgReader::readMsg()
|
||||
case msgTypeFrameStats:
|
||||
readFrameStats();
|
||||
break;
|
||||
case msgTypeBinaryClipboard:
|
||||
readBinaryClipboard();
|
||||
break;
|
||||
case msgTypeKeyEvent:
|
||||
readKeyEvent();
|
||||
break;
|
||||
@@ -224,9 +223,7 @@ void SMsgReader::readPointerEvent()
|
||||
int mask = is->readU8();
|
||||
int x = is->readU16();
|
||||
int y = is->readU16();
|
||||
int scrollX = is->readS16();
|
||||
int scrollY = is->readS16();
|
||||
handler->pointerEvent(Point(x, y), mask, false, false, scrollX, scrollY);
|
||||
handler->pointerEvent(Point(x, y), mask, false, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -241,54 +238,109 @@ void SMsgReader::readClientCutText()
|
||||
readExtendedClipboard(slen);
|
||||
return;
|
||||
}
|
||||
if (len > (size_t)maxCutText) {
|
||||
is->skip(len);
|
||||
vlog.error("Client sent old cuttext msg, ignoring");
|
||||
}
|
||||
|
||||
void SMsgReader::readBinaryClipboard()
|
||||
{
|
||||
const rdr::U8 num = is->readU8();
|
||||
rdr::U8 i, valid = 0;
|
||||
char tmpmimes[num][32];
|
||||
|
||||
handler->clearBinaryClipboard();
|
||||
for (i = 0; i < num; i++) {
|
||||
const rdr::U8 mimelen = is->readU8();
|
||||
if (mimelen > 32 - 1) {
|
||||
vlog.error("Mime too long (%u)", mimelen);
|
||||
vlog.error("Cut text too long (%d bytes) - ignoring", len);
|
||||
return;
|
||||
}
|
||||
|
||||
char mime[mimelen + 1];
|
||||
mime[mimelen] = '\0';
|
||||
is->readBytes(mime, mimelen);
|
||||
|
||||
strncpy(tmpmimes[valid], mime, 32);
|
||||
tmpmimes[valid][31] = '\0';
|
||||
|
||||
const rdr::U32 len = is->readU32();
|
||||
CharArray ca(len);
|
||||
CharArray ca(len+1);
|
||||
ca.buf[len] = 0;
|
||||
is->readBytes(ca.buf, len);
|
||||
|
||||
if (rfb::Server::DLP_ClipAcceptMax && len > (unsigned) rfb::Server::DLP_ClipAcceptMax) {
|
||||
vlog.info("DLP: refused to receive binary clipboard, too large");
|
||||
continue;
|
||||
}
|
||||
|
||||
vlog.debug("Received binary clipboard, type %s, %u bytes", mime, len);
|
||||
|
||||
handler->addBinaryClipboard(mime, (rdr::U8 *) ca.buf, len);
|
||||
valid++;
|
||||
}
|
||||
|
||||
handler->handleClipboardAnnounceBinary(valid, tmpmimes);
|
||||
handler->clientCutText(ca.buf, len);
|
||||
}
|
||||
|
||||
void SMsgReader::readExtendedClipboard(rdr::S32 len)
|
||||
{
|
||||
rdr::U32 flags;
|
||||
rdr::U32 action;
|
||||
|
||||
if (len < 4)
|
||||
throw Exception("Invalid extended clipboard message");
|
||||
vlog.error("Client sent old cuttext msg, ignoring");
|
||||
if (len > maxCutText) {
|
||||
vlog.error("Extended clipboard message too long (%d bytes) - ignoring", len);
|
||||
is->skip(len);
|
||||
return;
|
||||
}
|
||||
|
||||
flags = is->readU32();
|
||||
action = flags & clipboardActionMask;
|
||||
|
||||
if (action & clipboardCaps) {
|
||||
int i;
|
||||
size_t num;
|
||||
rdr::U32 lengths[16];
|
||||
|
||||
num = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (flags & (1 << i))
|
||||
num++;
|
||||
}
|
||||
|
||||
if (len < (rdr::S32)(4 + 4*num))
|
||||
throw Exception("Invalid extended clipboard message");
|
||||
|
||||
num = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (flags & (1 << i))
|
||||
lengths[num++] = is->readU32();
|
||||
}
|
||||
|
||||
handler->handleClipboardCaps(flags, lengths);
|
||||
} else if (action == clipboardProvide) {
|
||||
rdr::ZlibInStream zis;
|
||||
|
||||
int i;
|
||||
size_t num;
|
||||
size_t lengths[16];
|
||||
rdr::U8* buffers[16];
|
||||
|
||||
zis.setUnderlying(is, len - 4);
|
||||
|
||||
num = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (!(flags & 1 << i))
|
||||
continue;
|
||||
|
||||
lengths[num] = zis.readU32();
|
||||
if (lengths[num] > (size_t)maxCutText) {
|
||||
vlog.error("Extended clipboard data too long (%d bytes) - ignoring",
|
||||
(unsigned)lengths[num]);
|
||||
zis.skip(lengths[num]);
|
||||
flags &= ~(1 << i);
|
||||
continue;
|
||||
}
|
||||
|
||||
buffers[num] = new rdr::U8[lengths[num]];
|
||||
zis.readBytes(buffers[num], lengths[num]);
|
||||
num++;
|
||||
}
|
||||
|
||||
zis.flushUnderlying();
|
||||
zis.setUnderlying(NULL, 0);
|
||||
|
||||
handler->handleClipboardProvide(flags, lengths, buffers);
|
||||
|
||||
num = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (!(flags & 1 << i))
|
||||
continue;
|
||||
delete [] buffers[num++];
|
||||
}
|
||||
} else {
|
||||
switch (action) {
|
||||
case clipboardRequest:
|
||||
handler->handleClipboardRequest(flags);
|
||||
break;
|
||||
case clipboardPeek:
|
||||
handler->handleClipboardPeek(flags);
|
||||
break;
|
||||
case clipboardNotify:
|
||||
handler->handleClipboardNotify(flags);
|
||||
break;
|
||||
default:
|
||||
throw Exception("Invalid extended clipboard action");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SMsgReader::readRequestStats()
|
||||
|
||||
@@ -58,7 +58,6 @@ namespace rfb {
|
||||
void readExtendedClipboard(rdr::S32 len);
|
||||
void readRequestStats();
|
||||
void readFrameStats();
|
||||
void readBinaryClipboard();
|
||||
|
||||
void readQEMUMessage();
|
||||
void readQEMUKeyEvent();
|
||||
|
||||
@@ -85,21 +85,118 @@ void SMsgWriter::writeBell()
|
||||
endMsg();
|
||||
}
|
||||
|
||||
void SMsgWriter::writeBinaryClipboard(const std::vector<SConnection::binaryClipboard_t> &b)
|
||||
void SMsgWriter::writeServerCutText(const char* str, int len)
|
||||
{
|
||||
startMsg(msgTypeBinaryClipboard);
|
||||
startMsg(msgTypeServerCutText);
|
||||
os->pad(3);
|
||||
os->writeU32(len);
|
||||
os->writeBytes(str, len);
|
||||
endMsg();
|
||||
}
|
||||
|
||||
os->writeU8(b.size());
|
||||
rdr::U8 i;
|
||||
for (i = 0; i < b.size(); i++) {
|
||||
const rdr::U8 mimelen = strlen(b[i].mime);
|
||||
os->writeU8(mimelen);
|
||||
os->writeBytes(b[i].mime, mimelen);
|
||||
void SMsgWriter::writeClipboardCaps(rdr::U32 caps,
|
||||
const rdr::U32* lengths)
|
||||
{
|
||||
size_t i, count;
|
||||
|
||||
os->writeU32(b[i].data.size());
|
||||
os->writeBytes(&b[i].data[0], b[i].data.size());
|
||||
if (!cp->supportsExtendedClipboard)
|
||||
throw Exception("Client does not support extended clipboard");
|
||||
|
||||
count = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (caps & (1 << i))
|
||||
count++;
|
||||
}
|
||||
|
||||
startMsg(msgTypeServerCutText);
|
||||
os->pad(3);
|
||||
os->writeS32(-(4 + 4 * count));
|
||||
|
||||
os->writeU32(caps | clipboardCaps);
|
||||
|
||||
count = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (caps & (1 << i))
|
||||
os->writeU32(lengths[count++]);
|
||||
}
|
||||
|
||||
endMsg();
|
||||
}
|
||||
|
||||
void SMsgWriter::writeClipboardRequest(rdr::U32 flags)
|
||||
{
|
||||
if (!cp->supportsExtendedClipboard)
|
||||
throw Exception("Client does not support extended clipboard");
|
||||
if (!(cp->clipboardFlags() & clipboardRequest))
|
||||
throw Exception("Client does not support clipboard \"request\" action");
|
||||
|
||||
startMsg(msgTypeServerCutText);
|
||||
os->pad(3);
|
||||
os->writeS32(-4);
|
||||
os->writeU32(flags | clipboardRequest);
|
||||
endMsg();
|
||||
}
|
||||
|
||||
void SMsgWriter::writeClipboardPeek(rdr::U32 flags)
|
||||
{
|
||||
if (!cp->supportsExtendedClipboard)
|
||||
throw Exception("Client does not support extended clipboard");
|
||||
if (!(cp->clipboardFlags() & clipboardPeek))
|
||||
throw Exception("Client does not support clipboard \"peek\" action");
|
||||
|
||||
startMsg(msgTypeServerCutText);
|
||||
os->pad(3);
|
||||
os->writeS32(-4);
|
||||
os->writeU32(flags | clipboardPeek);
|
||||
endMsg();
|
||||
}
|
||||
|
||||
void SMsgWriter::writeClipboardNotify(rdr::U32 flags)
|
||||
{
|
||||
if (!cp->supportsExtendedClipboard)
|
||||
throw Exception("Client does not support extended clipboard");
|
||||
if (!(cp->clipboardFlags() & clipboardNotify))
|
||||
throw Exception("Client does not support clipboard \"notify\" action");
|
||||
|
||||
startMsg(msgTypeServerCutText);
|
||||
os->pad(3);
|
||||
os->writeS32(-4);
|
||||
os->writeU32(flags | clipboardNotify);
|
||||
endMsg();
|
||||
}
|
||||
|
||||
void SMsgWriter::writeClipboardProvide(rdr::U32 flags,
|
||||
const size_t* lengths,
|
||||
const rdr::U8* const* data)
|
||||
{
|
||||
rdr::MemOutStream mos;
|
||||
rdr::ZlibOutStream zos;
|
||||
|
||||
int i, count;
|
||||
|
||||
if (!cp->supportsExtendedClipboard)
|
||||
throw Exception("Client does not support extended clipboard");
|
||||
if (!(cp->clipboardFlags() & clipboardProvide))
|
||||
throw Exception("Client does not support clipboard \"provide\" action");
|
||||
|
||||
zos.setUnderlying(&mos);
|
||||
|
||||
count = 0;
|
||||
for (i = 0;i < 16;i++) {
|
||||
if (!(flags & (1 << i)))
|
||||
continue;
|
||||
zos.writeU32(lengths[count]);
|
||||
zos.writeBytes(data[count], lengths[count]);
|
||||
count++;
|
||||
}
|
||||
|
||||
zos.flush();
|
||||
|
||||
startMsg(msgTypeServerCutText);
|
||||
os->pad(3);
|
||||
os->writeS32(-(4 + mos.length()));
|
||||
os->writeU32(flags | clipboardProvide);
|
||||
os->writeBytes(mos.data(), mos.length());
|
||||
endMsg();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include <rdr/types.h>
|
||||
#include <rfb/encodings.h>
|
||||
#include <rfb/ScreenSet.h>
|
||||
#include <rfb/SConnection.h>
|
||||
#include <vector>
|
||||
|
||||
namespace rdr { class OutStream; }
|
||||
|
||||
@@ -56,8 +54,14 @@ namespace rfb {
|
||||
|
||||
// writeBell() and writeServerCutText() do the obvious thing.
|
||||
void writeBell();
|
||||
void writeServerCutText(const char* str, int len);
|
||||
|
||||
void writeBinaryClipboard(const std::vector<SConnection::binaryClipboard_t> &b);
|
||||
void writeClipboardCaps(rdr::U32 caps, const rdr::U32* lengths);
|
||||
void writeClipboardRequest(rdr::U32 flags);
|
||||
void writeClipboardPeek(rdr::U32 flags);
|
||||
void writeClipboardNotify(rdr::U32 flags);
|
||||
void writeClipboardProvide(rdr::U32 flags, const size_t* lengths,
|
||||
const rdr::U8* const* data);
|
||||
|
||||
void writeStats(const char* str, int len);
|
||||
|
||||
|
||||
@@ -149,15 +149,15 @@ rfb::IntParameter rfb::Server::webpVideoQuality
|
||||
rfb::IntParameter rfb::Server::DLP_ClipSendMax
|
||||
("DLP_ClipSendMax",
|
||||
"Limit clipboard bytes to send to clients in one transaction",
|
||||
0, 0, INT_MAX);
|
||||
10000, 0, INT_MAX);
|
||||
rfb::IntParameter rfb::Server::DLP_ClipAcceptMax
|
||||
("DLP_ClipAcceptMax",
|
||||
"Limit clipboard bytes to receive from clients in one transaction",
|
||||
0, 0, INT_MAX);
|
||||
10000, 0, INT_MAX);
|
||||
rfb::IntParameter rfb::Server::DLP_ClipDelay
|
||||
("DLP_ClipDelay",
|
||||
"This many milliseconds must pass between clipboard actions",
|
||||
0, 0, INT_MAX);
|
||||
1000, 0, INT_MAX);
|
||||
rfb::IntParameter rfb::Server::DLP_KeyRateLimit
|
||||
("DLP_KeyRateLimit",
|
||||
"Reject keyboard presses over this many per second",
|
||||
@@ -171,10 +171,6 @@ rfb::StringParameter rfb::Server::DLP_Region
|
||||
("DLP_Region",
|
||||
"Black out anything outside this region",
|
||||
"");
|
||||
rfb::StringParameter rfb::Server::DLP_Clip_Types
|
||||
("DLP_ClipTypes",
|
||||
"Allowed binary clipboard mimetypes",
|
||||
"text/html,image/png");
|
||||
|
||||
rfb::BoolParameter rfb::Server::DLP_RegionAllowClick
|
||||
("DLP_RegionAllowClick",
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace rfb {
|
||||
static IntParameter DLP_KeyRateLimit;
|
||||
static StringParameter DLP_ClipLog;
|
||||
static StringParameter DLP_Region;
|
||||
static StringParameter DLP_Clip_Types;
|
||||
static BoolParameter DLP_RegionAllowClick;
|
||||
static BoolParameter DLP_RegionAllowRelease;
|
||||
static IntParameter jpegVideoQuality;
|
||||
|
||||
@@ -71,12 +71,12 @@ static const struct TightWEBPConfiguration conf[10] = {
|
||||
{ 24, 0 }, // 1
|
||||
{ 30, 0 }, // 2
|
||||
{ 37, 0 }, // 3
|
||||
{ 42, 0 }, // 4
|
||||
{ 65, 0 }, // 5
|
||||
{ 78, 0 }, // 6
|
||||
{ 85, 0 }, // 7
|
||||
{ 88, 0 }, // 8
|
||||
{ 100, 0 } // 9
|
||||
{ 42, 1 }, // 4
|
||||
{ 65, 1 }, // 5
|
||||
{ 78, 1 }, // 6
|
||||
{ 85, 2 }, // 7
|
||||
{ 88, 3 }, // 8
|
||||
{ 100, 4 } // 9
|
||||
};
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void TightWEBPEncoder::compressOnly(const PixelBuffer* pb, const uint8_t quality
|
||||
method = conf[qualityIn].method;
|
||||
} else {
|
||||
quality = 8;
|
||||
method = 0;
|
||||
method = 4;
|
||||
}
|
||||
|
||||
WebPConfigInit(&cfg);
|
||||
@@ -214,7 +214,7 @@ void TightWEBPEncoder::writeRect(const PixelBuffer* pb, const Palette& palette)
|
||||
method = conf[qualityLevel].method;
|
||||
} else {
|
||||
quality = 8;
|
||||
method = 0;
|
||||
method = 4;
|
||||
}
|
||||
|
||||
WebPConfigInit(&cfg);
|
||||
@@ -265,7 +265,7 @@ rdr::U32 TightWEBPEncoder::benchmark() const
|
||||
rdr::U8* buffer;
|
||||
struct timeval start;
|
||||
int stride, i;
|
||||
const uint8_t quality = 8, method = 2;
|
||||
const uint8_t quality = 8, method = 4;
|
||||
WebPConfig cfg;
|
||||
WebPPicture pic;
|
||||
WebPMemoryWriter wrt;
|
||||
|
||||
@@ -57,8 +57,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
|
||||
inProcessMessages(false),
|
||||
pendingSyncFence(false), syncFence(false), fenceFlags(0),
|
||||
fenceDataLen(0), fenceData(NULL), congestionTimer(this),
|
||||
losslessTimer(this), kbdLogTimer(this), binclipTimer(this),
|
||||
server(server_), updates(false),
|
||||
losslessTimer(this), kbdLogTimer(this), server(server_), updates(false),
|
||||
updateRenderedCursor(false), removeRenderedCursor(false),
|
||||
continuousUpdates(false), encodeManager(this, &server_->encCache),
|
||||
needsPermCheck(false), pointerEventTime(0),
|
||||
@@ -414,6 +413,18 @@ static void keylog(unsigned keysym, const char *client) {
|
||||
flushKeylog(client);
|
||||
}
|
||||
|
||||
void VNCSConnectionST::requestClipboardOrClose()
|
||||
{
|
||||
try {
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
if (!rfb::Server::acceptCutText) return;
|
||||
if (state() != RFBSTATE_NORMAL) return;
|
||||
requestClipboard();
|
||||
} catch(rdr::Exception& e) {
|
||||
close(e.str());
|
||||
}
|
||||
}
|
||||
|
||||
void VNCSConnectionST::announceClipboardOrClose(bool available)
|
||||
{
|
||||
try {
|
||||
@@ -426,51 +437,29 @@ void VNCSConnectionST::announceClipboardOrClose(bool available)
|
||||
}
|
||||
}
|
||||
|
||||
void VNCSConnectionST::clearBinaryClipboardData()
|
||||
{
|
||||
clearBinaryClipboard();
|
||||
}
|
||||
|
||||
void VNCSConnectionST::sendBinaryClipboardDataOrClose(const char* mime,
|
||||
const unsigned char *data,
|
||||
const unsigned len)
|
||||
void VNCSConnectionST::sendClipboardDataOrClose(const char* data)
|
||||
{
|
||||
try {
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
if (!rfb::Server::sendCutText) return;
|
||||
if (rfb::Server::DLP_ClipSendMax && len > (unsigned) rfb::Server::DLP_ClipSendMax) {
|
||||
vlog.info("DLP: client %s: refused to send binary clipboard, too large",
|
||||
if (msSince(&lastClipboardOp) < (unsigned) rfb::Server::DLP_ClipDelay) {
|
||||
vlog.info("DLP: client %s: refused to send clipboard, too soon",
|
||||
sock->getPeerAddress());
|
||||
return;
|
||||
}
|
||||
|
||||
cliplog((const char *) data, len, len, "sent", sock->getPeerAddress());
|
||||
int len = strlen(data);
|
||||
const int origlen = len;
|
||||
if (rfb::Server::DLP_ClipSendMax && len > rfb::Server::DLP_ClipSendMax)
|
||||
len = rfb::Server::DLP_ClipSendMax;
|
||||
cliplog(data, len, origlen, "sent", sock->getPeerAddress());
|
||||
if (state() != RFBSTATE_NORMAL) return;
|
||||
|
||||
addBinaryClipboard(mime, data, len);
|
||||
binclipTimer.start(100);
|
||||
sendClipboardData(data, len);
|
||||
gettimeofday(&lastClipboardOp, NULL);
|
||||
} catch(rdr::Exception& e) {
|
||||
close(e.str());
|
||||
}
|
||||
}
|
||||
|
||||
void VNCSConnectionST::getBinaryClipboardData(const char* mime, const unsigned char **data,
|
||||
unsigned *len)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < binaryClipboard.size(); i++) {
|
||||
if (!strcmp(binaryClipboard[i].mime, mime)) {
|
||||
*data = &binaryClipboard[i].data[0];
|
||||
*len = binaryClipboard[i].data.size();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vlog.error("Binary clipboard data for mime %s not found", mime);
|
||||
*data = (const unsigned char *) "";
|
||||
*len = 1;
|
||||
}
|
||||
|
||||
void VNCSConnectionST::setDesktopNameOrClose(const char *name)
|
||||
{
|
||||
try {
|
||||
@@ -703,7 +692,7 @@ void VNCSConnectionST::setPixelFormat(const PixelFormat& pf)
|
||||
setCursor();
|
||||
}
|
||||
|
||||
void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease, int scrollX, int scrollY)
|
||||
void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease)
|
||||
{
|
||||
pointerEventTime = lastEventTime = time(0);
|
||||
server->lastUserInputTime = lastEventTime;
|
||||
@@ -731,7 +720,7 @@ void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool
|
||||
}
|
||||
}
|
||||
|
||||
server->desktop->pointerEvent(pointerEventPos, buttonMask, skipclick, skiprelease, scrollX, scrollY);
|
||||
server->desktop->pointerEvent(pointerEventPos, buttonMask, skipclick, skiprelease);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1025,6 +1014,12 @@ void VNCSConnectionST::enableContinuousUpdates(bool enable,
|
||||
}
|
||||
}
|
||||
|
||||
void VNCSConnectionST::handleClipboardRequest()
|
||||
{
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
server->handleClipboardRequest(this);
|
||||
}
|
||||
|
||||
void VNCSConnectionST::handleClipboardAnnounce(bool available)
|
||||
{
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
@@ -1032,13 +1027,25 @@ void VNCSConnectionST::handleClipboardAnnounce(bool available)
|
||||
server->handleClipboardAnnounce(this, available);
|
||||
}
|
||||
|
||||
void VNCSConnectionST::handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32])
|
||||
void VNCSConnectionST::handleClipboardData(const char* data, int len)
|
||||
{
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
if (!rfb::Server::acceptCutText) return;
|
||||
server->handleClipboardAnnounceBinary(this, num, mimes);
|
||||
if (msSince(&lastClipboardOp) < (unsigned) rfb::Server::DLP_ClipDelay) {
|
||||
vlog.info("DLP: client %s: refused to receive clipboard, too soon",
|
||||
sock->getPeerAddress());
|
||||
return;
|
||||
}
|
||||
const int origlen = len;
|
||||
if (rfb::Server::DLP_ClipAcceptMax && len > rfb::Server::DLP_ClipAcceptMax)
|
||||
len = rfb::Server::DLP_ClipAcceptMax;
|
||||
cliplog(data, len, origlen, "received", sock->getPeerAddress());
|
||||
|
||||
gettimeofday(&lastClipboardOp, NULL);
|
||||
server->handleClipboardData(this, data, len);
|
||||
}
|
||||
|
||||
|
||||
// supportsLocalCursor() is called whenever the status of
|
||||
// cp.supportsLocalCursor has changed. If the client does now support local
|
||||
// cursor, we make sure that the old server-side rendered cursor is cleaned up
|
||||
@@ -1082,8 +1089,6 @@ bool VNCSConnectionST::handleTimeout(Timer* t)
|
||||
writeFramebufferUpdate();
|
||||
else if (t == &kbdLogTimer)
|
||||
flushKeylog(sock->getPeerAddress());
|
||||
else if (t == &binclipTimer)
|
||||
writeBinaryClipboard();
|
||||
} catch (rdr::Exception& e) {
|
||||
close(e.str());
|
||||
}
|
||||
@@ -1441,18 +1446,6 @@ void VNCSConnectionST::writeDataUpdate()
|
||||
requested.clear();
|
||||
}
|
||||
|
||||
void VNCSConnectionST::writeBinaryClipboard()
|
||||
{
|
||||
if (msSince(&lastClipboardOp) < (unsigned) rfb::Server::DLP_ClipDelay) {
|
||||
vlog.info("DLP: client %s: refused to send binary clipboard, too soon",
|
||||
sock->getPeerAddress());
|
||||
return;
|
||||
}
|
||||
|
||||
writer()->writeBinaryClipboard(binaryClipboard);
|
||||
|
||||
gettimeofday(&lastClipboardOp, NULL);
|
||||
}
|
||||
|
||||
void VNCSConnectionST::screenLayoutChange(rdr::U16 reason)
|
||||
{
|
||||
|
||||
@@ -77,12 +77,9 @@ namespace rfb {
|
||||
void bellOrClose();
|
||||
void setDesktopNameOrClose(const char *name);
|
||||
void setLEDStateOrClose(unsigned int state);
|
||||
void requestClipboardOrClose();
|
||||
void announceClipboardOrClose(bool available);
|
||||
void clearBinaryClipboardData();
|
||||
void sendBinaryClipboardDataOrClose(const char* mime, const unsigned char *data,
|
||||
const unsigned len);
|
||||
void getBinaryClipboardData(const char* mime, const unsigned char **data,
|
||||
unsigned *len);
|
||||
void sendClipboardDataOrClose(const char* data);
|
||||
|
||||
// checkIdleTimeout() returns the number of milliseconds left until the
|
||||
// idle timeout expires. If it has expired, the connection is closed and
|
||||
@@ -207,7 +204,7 @@ namespace rfb {
|
||||
virtual void queryConnection(const char* userName);
|
||||
virtual void clientInit(bool shared);
|
||||
virtual void setPixelFormat(const PixelFormat& pf);
|
||||
virtual void pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease, int scrollX, int scrollY);
|
||||
virtual void pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease);
|
||||
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
||||
virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
|
||||
virtual void setDesktopSize(int fb_width, int fb_height,
|
||||
@@ -215,8 +212,9 @@ namespace rfb {
|
||||
virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
|
||||
virtual void enableContinuousUpdates(bool enable,
|
||||
int x, int y, int w, int h);
|
||||
virtual void handleClipboardRequest();
|
||||
virtual void handleClipboardAnnounce(bool available);
|
||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
||||
virtual void handleClipboardData(const char* data, int len);
|
||||
virtual void supportsLocalCursor();
|
||||
virtual void supportsFence();
|
||||
virtual void supportsContinuousUpdates();
|
||||
@@ -262,8 +260,6 @@ namespace rfb {
|
||||
void writeNoDataUpdate();
|
||||
void writeDataUpdate();
|
||||
|
||||
void writeBinaryClipboard();
|
||||
|
||||
void screenLayoutChange(rdr::U16 reason);
|
||||
void setCursor();
|
||||
void setCursorPos();
|
||||
@@ -286,7 +282,6 @@ namespace rfb {
|
||||
Timer congestionTimer;
|
||||
Timer losslessTimer;
|
||||
Timer kbdLogTimer;
|
||||
Timer binclipTimer;
|
||||
|
||||
VNCServerST* server;
|
||||
SimpleUpdateTracker updates;
|
||||
|
||||
@@ -52,11 +52,22 @@ namespace rfb {
|
||||
// getPixelBuffer() returns a pointer to the PixelBuffer object.
|
||||
virtual PixelBuffer* getPixelBuffer() const = 0;
|
||||
|
||||
// requestClipboard() will result in a request to a client to
|
||||
// transfer its clipboard data. A call to
|
||||
// SDesktop::handleClipboardData() will be made once the data is
|
||||
// available.
|
||||
virtual void requestClipboard() = 0;
|
||||
|
||||
// announceClipboard() informs all clients of changes to the
|
||||
// clipboard on the server. A client may later request the
|
||||
// clipboard data via SDesktop::handleClipboardRequest().
|
||||
virtual void announceClipboard(bool available) = 0;
|
||||
|
||||
// sendClipboardData() transfers the clipboard data to a client
|
||||
// and should be called whenever a client has requested the
|
||||
// clipboard via SDesktop::handleClipboardRequest().
|
||||
virtual void sendClipboardData(const char* data) = 0;
|
||||
|
||||
// bell() tells the server that it should make all clients make a bell sound.
|
||||
virtual void bell() = 0;
|
||||
|
||||
|
||||
@@ -518,6 +518,14 @@ void VNCServerST::setScreenLayout(const ScreenSet& layout)
|
||||
}
|
||||
}
|
||||
|
||||
void VNCServerST::requestClipboard()
|
||||
{
|
||||
if (clipboardClient == NULL)
|
||||
return;
|
||||
|
||||
clipboardClient->requestClipboard();
|
||||
}
|
||||
|
||||
void VNCServerST::announceClipboard(bool available)
|
||||
{
|
||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
||||
@@ -533,31 +541,20 @@ void VNCServerST::announceClipboard(bool available)
|
||||
}
|
||||
}
|
||||
|
||||
void VNCServerST::sendBinaryClipboardData(const char* mime, const unsigned char *data,
|
||||
const unsigned len)
|
||||
void VNCServerST::sendClipboardData(const char* data)
|
||||
{
|
||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
||||
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
||||
ci_next = ci; ci_next++;
|
||||
(*ci)->sendBinaryClipboardDataOrClose(mime, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
void VNCServerST::getBinaryClipboardData(const char* mime, const unsigned char **data,
|
||||
unsigned *len)
|
||||
{
|
||||
if (!clipboardClient)
|
||||
return;
|
||||
clipboardClient->getBinaryClipboardData(mime, data, len);
|
||||
}
|
||||
if (strchr(data, '\r') != NULL)
|
||||
throw Exception("Invalid carriage return in clipboard data");
|
||||
|
||||
void VNCServerST::clearBinaryClipboardData()
|
||||
{
|
||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
||||
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
||||
for (ci = clipboardRequestors.begin();
|
||||
ci != clipboardRequestors.end(); ci = ci_next) {
|
||||
ci_next = ci; ci_next++;
|
||||
(*ci)->clearBinaryClipboardData();
|
||||
(*ci)->sendClipboardDataOrClose(data);
|
||||
}
|
||||
|
||||
clipboardRequestors.clear();
|
||||
}
|
||||
|
||||
void VNCServerST::bell()
|
||||
@@ -1201,6 +1198,13 @@ bool VNCServerST::getComparerState()
|
||||
return false;
|
||||
}
|
||||
|
||||
void VNCServerST::handleClipboardRequest(VNCSConnectionST* client)
|
||||
{
|
||||
clipboardRequestors.push_back(client);
|
||||
if (clipboardRequestors.size() == 1)
|
||||
desktop->handleClipboardRequest();
|
||||
}
|
||||
|
||||
void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
|
||||
bool available)
|
||||
{
|
||||
@@ -1214,10 +1218,11 @@ void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
|
||||
desktop->handleClipboardAnnounce(available);
|
||||
}
|
||||
|
||||
void VNCServerST::handleClipboardAnnounceBinary(VNCSConnectionST* client,
|
||||
const unsigned num,
|
||||
const char mimes[][32])
|
||||
void VNCServerST::handleClipboardData(VNCSConnectionST* client,
|
||||
const char* data, int len)
|
||||
{
|
||||
clipboardClient = client;
|
||||
desktop->handleClipboardAnnounceBinary(num, mimes);
|
||||
if (client != clipboardClient)
|
||||
return;
|
||||
desktop->handleClipboardData(data, len);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,12 +96,9 @@ namespace rfb {
|
||||
virtual void setPixelBuffer(PixelBuffer* pb);
|
||||
virtual void setScreenLayout(const ScreenSet& layout);
|
||||
virtual PixelBuffer* getPixelBuffer() const { if (DLPRegion.enabled && blackedpb) return blackedpb; else return pb; }
|
||||
virtual void requestClipboard();
|
||||
virtual void announceClipboard(bool available);
|
||||
virtual void clearBinaryClipboardData();
|
||||
virtual void sendBinaryClipboardData(const char* mime, const unsigned char *data,
|
||||
const unsigned len);
|
||||
virtual void getBinaryClipboardData(const char *mime, const unsigned char **ptr,
|
||||
unsigned *len);
|
||||
virtual void sendClipboardData(const char* data);
|
||||
virtual void add_changed(const Region ®ion);
|
||||
virtual void add_copied(const Region &dest, const Point &delta);
|
||||
virtual void setCursor(int width, int height, const Point& hotspot,
|
||||
@@ -194,9 +191,9 @@ namespace rfb {
|
||||
|
||||
void setAPIMessager(network::GetAPIMessager *msgr) { apimessager = msgr; }
|
||||
|
||||
void handleClipboardRequest(VNCSConnectionST* client);
|
||||
void handleClipboardAnnounce(VNCSConnectionST* client, bool available);
|
||||
void handleClipboardAnnounceBinary(VNCSConnectionST* client, const unsigned num,
|
||||
const char mimes[][32]);
|
||||
void handleClipboardData(VNCSConnectionST* client, const char* data, int len);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace rfb {
|
||||
// kasm
|
||||
const int msgTypeStats = 178;
|
||||
const int msgTypeRequestFrameStats = 179;
|
||||
const int msgTypeBinaryClipboard = 180;
|
||||
|
||||
const int msgTypeServerFence = 248;
|
||||
|
||||
@@ -50,7 +49,6 @@ namespace rfb {
|
||||
// kasm
|
||||
const int msgTypeRequestStats = 178;
|
||||
const int msgTypeFrameStats = 179;
|
||||
//const int msgTypeBinaryClipboard = 180;
|
||||
|
||||
const int msgTypeClientFence = 248;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ void SSE2_halve(const uint8_t *oldpx,
|
||||
|
||||
uint8_t * const dst = newpx + newstride * (y / 2) * 4;
|
||||
|
||||
for (x = 0; x < srcw - 3; x += 4) {
|
||||
for (x = 0; x < srcw; x += 4) {
|
||||
__m128i lo, hi, a, b, c, d;
|
||||
lo = _mm_loadu_si128((__m128i *) &row0[x * 4]);
|
||||
hi = _mm_loadu_si128((__m128i *) &row1[x * 4]);
|
||||
@@ -141,7 +141,7 @@ void SSE2_scale(const uint8_t *oldpx,
|
||||
const __m128i vertmul = _mm_set1_epi16(top);
|
||||
const __m128i vertmul2 = _mm_set1_epi16(bot);
|
||||
|
||||
for (x = 0; x < tgtw - 1; x += 2) {
|
||||
for (x = 0; x < tgtw; x += 2) {
|
||||
const float nx[2] = {
|
||||
x * invdiff,
|
||||
(x + 1) * invdiff,
|
||||
|
||||
3
debian/Makefile.to_fakebuild_tar_package
vendored
3
debian/Makefile.to_fakebuild_tar_package
vendored
@@ -11,12 +11,11 @@ install: unpack_tarball
|
||||
echo "TAR_DATA: $(TAR_DATA)"
|
||||
echo "installing files"
|
||||
mkdir -p $(DESTDIR)/usr/bin $(DESTDIR)/usr/share/man/man1 \
|
||||
$(DESTDIR)/usr/share/doc/kasmvncserver $(DESTDIR)/usr/lib
|
||||
$(DESTDIR)/usr/share/doc/kasmvncserver
|
||||
cp $(SRC_BIN)/Xvnc $(DESTDIR)/usr/bin/Xkasmvnc
|
||||
cp $(SRC_BIN)/vncserver $(DESTDIR)/usr/bin/kasmvncserver
|
||||
cp $(SRC_BIN)/vncconfig $(DESTDIR)/usr/bin/kasmvncconfig
|
||||
cp $(SRC_BIN)/kasmvncpasswd $(DESTDIR)/usr/bin/
|
||||
cp -r $(SRC)/lib/kasmvnc/ $(DESTDIR)/usr/lib/kasmvncserver
|
||||
cp -r $(SRC)/share/doc/kasmvnc*/* $(DESTDIR)/usr/share/doc/kasmvncserver/
|
||||
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
||||
--exclude www/utils/ --exclude .eslintrc \
|
||||
|
||||
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,9 +1,3 @@
|
||||
kasmvnc (0.9.3~beta-1) unstable; urgency=medium
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Dmitry Maksyoma <ledestin@gmail.com> Fri, 29 Oct 2021 19:16:33 +1300
|
||||
|
||||
kasmvnc (0.9.1~beta-1) unstable; urgency=medium
|
||||
|
||||
* Initial release of the Debian package.
|
||||
|
||||
7
debian/control
vendored
7
debian/control
vendored
@@ -3,17 +3,16 @@ Section: x11
|
||||
Priority: optional
|
||||
Maintainer: Kasm Technologies LLC <info@kasmweb.com>
|
||||
Build-Depends: debhelper (>= 11), rsync, libjpeg-dev, libjpeg-dev, libpng-dev,
|
||||
libtiff-dev, libgif-dev, libavcodec-dev, libssl-dev, libgl1, libxfont2, libsm6, libunwind8
|
||||
libtiff-dev, libgif-dev, libavcodec-dev, libssl-dev, libgl1, libxfont2, libsm6
|
||||
Standards-Version: 4.1.3
|
||||
Homepage: https://github.com/kasmtech/KasmVNC
|
||||
#Vcs-Browser: https://salsa.debian.org/debian/kasmvnc
|
||||
#Vcs-Git: https://salsa.debian.org/debian/kasmvnc.git
|
||||
|
||||
Package: kasmvncserver
|
||||
Architecture: amd64 arm64
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, ssl-cert, xauth,
|
||||
x11-xkb-utils, xkb-data, procps, libswitch-perl, libyaml-tiny-perl,
|
||||
libhash-merge-simple-perl, libscalar-list-utils-perl
|
||||
x11-xkb-utils, xkb-data, procps
|
||||
Provides: vnc-server
|
||||
Description: VNC server accessible from a web browser
|
||||
VNC stands for Virtual Network Computing. It is, in essence, a remote
|
||||
|
||||
2
kasmweb
2
kasmweb
Submodule kasmweb updated: 9383783efd...d1e4bda4b3
@@ -50,8 +50,6 @@ if [ $SERVER = 1 ]; then
|
||||
install -m 644 ./xorg.build/man/man1/Xserver.1 $OUTDIR/man/man1/Xserver.1
|
||||
mkdir -p $OUTDIR/lib/dri/
|
||||
install -m 755 ./xorg.build/lib/dri/swrast_dri.so $OUTDIR/lib/dri/
|
||||
mkdir -p $OUTDIR/lib/kasmvnc
|
||||
install -m 755 $SRCDIR/builder/startup/deb/select-de.sh $OUTDIR/lib/kasmvnc
|
||||
mkdir -p $OUTDIR/share/kasmvnc
|
||||
cp -r $SRCDIR/builder/www $OUTDIR/share/kasmvnc/www
|
||||
fi
|
||||
|
||||
12
run-specs
12
run-specs
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
export PYTHONPATH=${PWD}/spec
|
||||
|
||||
RUN_CMD="pipenv run mamba"
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
$RUN_CMD "$1"
|
||||
else
|
||||
$RUN_CMD spec/*_spec.py
|
||||
fi
|
||||
@@ -1,70 +0,0 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import pexpect
|
||||
from path import Path
|
||||
from expects import expect, equal
|
||||
|
||||
vncserver_cmd = 'vncserver :1 -cert /etc/ssl/certs/ssl-cert-snakeoil.pem -key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24 -interface 0.0.0.0 -httpd /usr/share/kasmvnc/www -depth 24 -geometry 1280x1050 -log *:stderr:100'
|
||||
running_xvnc = False
|
||||
|
||||
|
||||
def clean_env():
|
||||
clean_kasm_users()
|
||||
|
||||
home_dir = os.environ['HOME']
|
||||
vnc_dir = os.path.join(home_dir, ".vnc")
|
||||
Path(vnc_dir).rmtree(ignore_errors=True)
|
||||
|
||||
|
||||
def clean_kasm_users():
|
||||
home_dir = os.environ['HOME']
|
||||
password_file = os.path.join(home_dir, ".kasmpasswd")
|
||||
Path(password_file).remove_p()
|
||||
|
||||
|
||||
def start_xvnc_pexpect(extra_args="", **kwargs):
|
||||
global running_xvnc
|
||||
|
||||
# ":;" is a hack. Without it, Xvnc doesn't run. No idea what happens, but
|
||||
# when I run top, Xvnc just isn't there. I suspect a race.
|
||||
child = pexpect.spawn('/bin/bash',
|
||||
['-ic', f':;{vncserver_cmd} {extra_args}'],
|
||||
timeout=5, encoding='utf-8', **kwargs)
|
||||
running_xvnc = True
|
||||
|
||||
return child
|
||||
|
||||
|
||||
def start_xvnc(extra_args="", **kwargs):
|
||||
global running_xvnc
|
||||
completed_process = run_cmd(f'{vncserver_cmd} {extra_args}', **kwargs)
|
||||
if completed_process.returncode == 0:
|
||||
running_xvnc = True
|
||||
|
||||
return completed_process
|
||||
|
||||
|
||||
def run_cmd(cmd, **kwargs):
|
||||
completed_process = subprocess.run(cmd, shell=True, text=True,
|
||||
capture_output=True,
|
||||
executable='/bin/bash', **kwargs)
|
||||
if completed_process.returncode != 0:
|
||||
print(completed_process.stdout)
|
||||
print(completed_process.stderr)
|
||||
|
||||
return completed_process
|
||||
|
||||
|
||||
def add_kasmvnc_user_docker():
|
||||
completed_process = run_cmd('echo -e "password\\npassword\\n" | vncpasswd -u docker')
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
|
||||
def kill_xvnc():
|
||||
global running_xvnc
|
||||
if not running_xvnc:
|
||||
return
|
||||
|
||||
run_cmd('vncserver -kill :1')
|
||||
running_xvnc = False
|
||||
@@ -1,125 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import pexpect
|
||||
from mamba import description, context, it, fit, before, after
|
||||
from expects import expect, equal
|
||||
|
||||
from helper.spec_helper import start_xvnc, kill_xvnc, run_cmd, clean_env, \
|
||||
add_kasmvnc_user_docker, clean_kasm_users, start_xvnc_pexpect
|
||||
|
||||
# WIP. Plan to move to start_xvnc_pexpect(), because pexpect provides a way to
|
||||
# wait for vncserver output. start_xvnc() just blindly prints input to vncserver
|
||||
# without knowing what it prints back.
|
||||
|
||||
|
||||
def select_de(de_name):
|
||||
try:
|
||||
extra_args = f'-select-de {de_name}'
|
||||
completed_process = start_xvnc(extra_args)
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
finally:
|
||||
kill_xvnc()
|
||||
|
||||
|
||||
def check_de_was_setup_to_run(de_name):
|
||||
completed_process = run_cmd(f'grep -q {de_name} ~/.vnc/xstartup')
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
|
||||
with description('vncserver') as self:
|
||||
with before.each:
|
||||
clean_env()
|
||||
with after.each:
|
||||
kill_xvnc()
|
||||
|
||||
with context('on the first run'):
|
||||
with before.each:
|
||||
add_kasmvnc_user_docker()
|
||||
|
||||
with it('asks user to select a DE'):
|
||||
choose_cinnamon = "1\n"
|
||||
completed_process = start_xvnc(input=choose_cinnamon)
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
check_de_was_setup_to_run('cinnamon')
|
||||
|
||||
with it('asks to select a DE, when ran with -select-de'):
|
||||
choose_cinnamon = "1\n"
|
||||
completed_process = start_xvnc('-select-de', input=choose_cinnamon)
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
check_de_was_setup_to_run('cinnamon')
|
||||
|
||||
with it('selects passed DE with -s'):
|
||||
select_de('mate')
|
||||
check_de_was_setup_to_run('mate')
|
||||
|
||||
with context('after DE was selected'):
|
||||
with before.each:
|
||||
add_kasmvnc_user_docker()
|
||||
|
||||
with it("don't ask to choose DE by default"):
|
||||
select_de('mate')
|
||||
|
||||
completed_process = start_xvnc()
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
check_de_was_setup_to_run('mate')
|
||||
|
||||
with it('asks to select a DE, when ran with -select-de'):
|
||||
select_de('mate')
|
||||
|
||||
choose_cinnamon_and_answer_yes = "1\ny\n"
|
||||
completed_process = start_xvnc('-select-de',
|
||||
input=choose_cinnamon_and_answer_yes)
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
check_de_was_setup_to_run('cinnamon')
|
||||
|
||||
with it('selects passed DE with -s'):
|
||||
select_de('mate')
|
||||
|
||||
completed_process = start_xvnc('-select-de cinnamon')
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
check_de_was_setup_to_run('cinnamon')
|
||||
|
||||
with context('guided user creation'):
|
||||
with fit('asks to create a user if none exist'):
|
||||
clean_kasm_users()
|
||||
|
||||
child = start_xvnc_pexpect('-select-de cinnamon')
|
||||
child.expect('Enter username')
|
||||
child.sendline()
|
||||
child.expect('Password:')
|
||||
child.sendline('password')
|
||||
child.expect('Verify:')
|
||||
child.sendline('password')
|
||||
child.expect(pexpect.EOF)
|
||||
child.close()
|
||||
expect(child.exitstatus).to(equal(0))
|
||||
|
||||
home_dir = os.environ['HOME']
|
||||
user = os.environ['USER']
|
||||
completed_process = run_cmd(f'grep -qw {user} {home_dir}/.kasmpasswd')
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
with fit('specify custom username'):
|
||||
custom_username = 'custom_username'
|
||||
child = start_xvnc_pexpect('-select-de cinnamon')
|
||||
child.logfile_read = sys.stderr
|
||||
child.expect('Enter username')
|
||||
child.sendline(custom_username)
|
||||
child.expect('Password:')
|
||||
child.sendline('password')
|
||||
child.expect('Verify:')
|
||||
child.sendline('password')
|
||||
child.expect(pexpect.EOF)
|
||||
child.wait()
|
||||
# expect(child.exitstatus).to(equal(0))
|
||||
|
||||
home_dir = os.environ['HOME']
|
||||
completed_process = run_cmd(f'grep -qw {custom_username} {home_dir}/.kasmpasswd')
|
||||
expect(completed_process.returncode).to(equal(0))
|
||||
|
||||
# os.system(f'pgrep Xvnc >/dev/null || cat {home_dir}/.vnc/*.log')
|
||||
1349
unix/vncserver
Executable file → Normal file
1349
unix/vncserver
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +0,0 @@
|
||||
---
|
||||
network:
|
||||
ssl:
|
||||
pem_certificate: lol
|
||||
@@ -1,142 +0,0 @@
|
||||
---
|
||||
desktop:
|
||||
resolution:
|
||||
width: 1024
|
||||
height: 768
|
||||
allow_resize: true
|
||||
pixel_depth: 16|24|32
|
||||
|
||||
network:
|
||||
protocol: http|vnc
|
||||
interface: 0.0.0.0
|
||||
websocket_port: default
|
||||
use_ipv4: true
|
||||
use_ipv6: true
|
||||
ssl:
|
||||
pem_certificate: [/etc/...]
|
||||
pem_key: [/etc/...]
|
||||
require_ssl: true
|
||||
|
||||
user_session:
|
||||
concurrent_connections_mode: always-allow|prompt|block-new-connections|disconnect-current
|
||||
approval_dialog_timeout: 10
|
||||
|
||||
force_session_type: shared|exclusive
|
||||
new_session_disconnects_existing_exlusive_session: true
|
||||
ask_user_to_vet_new_sessions: false
|
||||
vetting_dialog_duration: 10
|
||||
idle_timeout: never
|
||||
|
||||
keyboard:
|
||||
remap_keys:
|
||||
- 0x22->0x40
|
||||
- 0x24->0x40
|
||||
# If NumLock is on (as it usually is), then pressing a key on the numeric
|
||||
# keypad while holding the shift key overrides NumLock and instead generates
|
||||
# the arrow key (or other navigation key) printed in small print under the big
|
||||
# digits.
|
||||
ignore_numlock: false
|
||||
raw_keyboard: false
|
||||
|
||||
# Mouse, trackpad, etc.
|
||||
pointer:
|
||||
enabled: true
|
||||
|
||||
runtime_configuration:
|
||||
allow_client_to_override_server_settings: true
|
||||
allow_override_list:
|
||||
- pointer.allow_client_to_override_server_settings
|
||||
|
||||
logging:
|
||||
log_writer_name: all|*|<string>
|
||||
log_to: stderr|stdout|syslog
|
||||
# 0 - silent(?), 100 - most verbose
|
||||
level: 0..100
|
||||
|
||||
security:
|
||||
brute_force_protection:
|
||||
blacklist_threshold: 5
|
||||
blacklist_timeout: 10
|
||||
|
||||
data_loss_prevention:
|
||||
visible_region:
|
||||
top: 10
|
||||
left: 10
|
||||
right: 40
|
||||
bottom: 40
|
||||
concealed_region:
|
||||
allow_click_down: false
|
||||
allow_click_release: false
|
||||
clipboard:
|
||||
delay_between_operations: none
|
||||
# Cut buffers and CLIPBOARD selection.
|
||||
server_to_client:
|
||||
enabled: true
|
||||
size: 10000|unlimited
|
||||
primary_clipboard_enabled: false
|
||||
client_to_server:
|
||||
enabled: true
|
||||
size: 10000|unlimited
|
||||
keyboard:
|
||||
enabled: true
|
||||
rate_limit: 1|unlimited
|
||||
# LOGS YOUR PRIVATE INFORMATION. Keypresses and clipboard content.
|
||||
logging:
|
||||
level: off|info|verbose
|
||||
|
||||
# legacy:
|
||||
# pixel_format: 16|24|32
|
||||
# inetd: false
|
||||
# desktop_name: default
|
||||
# rfb_port: 5900
|
||||
# rfb_unix_socket_path:
|
||||
# rfb_unix_mode: 0600
|
||||
# password_file:
|
||||
# password:
|
||||
# plain_user_list:
|
||||
# - foo
|
||||
# - bar
|
||||
# pam_service: vnc
|
||||
# use_protocol_3.3: false
|
||||
# x509_certificate:
|
||||
# x509_key:
|
||||
# gnu_tls_priority: NORMAL
|
||||
|
||||
encoding:
|
||||
max_frame_rate: 60
|
||||
native_resolution_mode:
|
||||
min_quality: 7
|
||||
max_quality: 8
|
||||
treat_this_quality_level_as_lossless: 10
|
||||
prefer_bandwidth_over_quality: false
|
||||
rectangle_compress_threads: auto|number
|
||||
|
||||
video_mode:
|
||||
jpeg_quality: auto
|
||||
webp_quality: auto
|
||||
max_resolution:
|
||||
width: 1920
|
||||
height: 1080
|
||||
enter_video_mode:
|
||||
time_threshold: 5
|
||||
area_threshold: 45
|
||||
exit_video_mode:
|
||||
time_threshold: 3
|
||||
logging:
|
||||
level: off|info
|
||||
scaling_algorithm: nearest|bilinear|progressive_bilinear
|
||||
|
||||
compare_framebuffer: off|always|auto
|
||||
zrle_zlib_level: 0..9
|
||||
hextile_improved_compression: true
|
||||
|
||||
server:
|
||||
advanced:
|
||||
x_font_path: default
|
||||
httpd_directory: /usr/share/kasmvnc/www
|
||||
kasm_password_file: ~/.kasmpasswd
|
||||
x_authtority_file: default
|
||||
auto_shutdown:
|
||||
no_user_session_timeout: never
|
||||
active_user_session_timeout: never
|
||||
inactive_user_session_timeout: never
|
||||
@@ -234,14 +234,6 @@ void vncPointerMove(int x, int y)
|
||||
cursorPosY = y;
|
||||
}
|
||||
|
||||
void vncScroll(int x, int y) {
|
||||
ValuatorMask mask;
|
||||
valuator_mask_zero(&mask);
|
||||
valuator_mask_set(&mask, 2, x);
|
||||
valuator_mask_set(&mask, 3, y);
|
||||
QueuePointerEvents(vncPointerDev, MotionNotify, 0, POINTER_RELATIVE, &mask);
|
||||
}
|
||||
|
||||
void vncGetPointerPos(int *x, int *y)
|
||||
{
|
||||
if (vncPointerDev != NULL) {
|
||||
@@ -269,7 +261,7 @@ static int vncPointerProc(DeviceIntPtr pDevice, int onoff)
|
||||
* is not a bug.
|
||||
*/
|
||||
Atom btn_labels[BUTTONS];
|
||||
Atom axes_labels[4];
|
||||
Atom axes_labels[2];
|
||||
|
||||
switch (onoff) {
|
||||
case DEVICE_INIT:
|
||||
@@ -286,29 +278,11 @@ static int vncPointerProc(DeviceIntPtr pDevice, int onoff)
|
||||
|
||||
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
||||
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
||||
axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
|
||||
axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
|
||||
|
||||
|
||||
InitPointerDeviceStruct(pDev, map, BUTTONS, btn_labels,
|
||||
(PtrCtrlProcPtr)NoopDDA,
|
||||
GetMotionHistorySize(),
|
||||
4, axes_labels);
|
||||
|
||||
InitValuatorAxisStruct(pDevice, 2, axes_labels[2], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
|
||||
InitValuatorAxisStruct(pDevice, 3, axes_labels[3], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
|
||||
|
||||
char* envScrollFactorH = getenv("SCROLL_FACTOR_H");
|
||||
char* envScrollFactorV = getenv("SCROLL_FACTOR_V");
|
||||
|
||||
float scrollFactorH = envScrollFactorH ? atof(envScrollFactorH) : 50.0;
|
||||
float scrollFactorV = envScrollFactorV ? atof(envScrollFactorV) : 50.0;
|
||||
|
||||
LOG_INFO("Mouse horizonatl scroll factor: %f", scrollFactorH);
|
||||
LOG_INFO("Mouse vertical scroll factor: %f", scrollFactorV);
|
||||
|
||||
SetScrollValuator(pDevice, 2, SCROLL_TYPE_HORIZONTAL, scrollFactorH, SCROLL_FLAG_NONE);
|
||||
SetScrollValuator(pDevice, 3, SCROLL_TYPE_VERTICAL, scrollFactorV, SCROLL_FLAG_PREFERRED);
|
||||
2, axes_labels);
|
||||
break;
|
||||
case DEVICE_ON:
|
||||
pDev->on = TRUE;
|
||||
|
||||
@@ -35,7 +35,6 @@ void vncInitInputDevice(void);
|
||||
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
|
||||
const unsigned char skiprelease);
|
||||
void vncPointerMove(int x, int y);
|
||||
void vncScroll(int x, int y);
|
||||
void vncGetPointerPos(int *x, int *y);
|
||||
|
||||
void vncKeyboardEvent(KeySym keysym, unsigned xtcode, int down);
|
||||
|
||||
@@ -176,6 +176,15 @@ XserverDesktop::queryConnection(network::Socket* sock,
|
||||
return rfb::VNCServerST::PENDING;
|
||||
}
|
||||
|
||||
void XserverDesktop::requestClipboard()
|
||||
{
|
||||
try {
|
||||
server->requestClipboard();
|
||||
} catch (rdr::Exception& e) {
|
||||
vlog.error("XserverDesktop::requestClipboard: %s",e.str());
|
||||
}
|
||||
}
|
||||
|
||||
void XserverDesktop::announceClipboard(bool available)
|
||||
{
|
||||
try {
|
||||
@@ -185,34 +194,12 @@ void XserverDesktop::announceClipboard(bool available)
|
||||
}
|
||||
}
|
||||
|
||||
void XserverDesktop::clearBinaryClipboardData()
|
||||
void XserverDesktop::sendClipboardData(const char* data)
|
||||
{
|
||||
try {
|
||||
server->clearBinaryClipboardData();
|
||||
server->sendClipboardData(data);
|
||||
} catch (rdr::Exception& e) {
|
||||
vlog.error("XserverDesktop::clearBinaryClipboardData: %s",e.str());
|
||||
}
|
||||
}
|
||||
|
||||
void XserverDesktop::sendBinaryClipboardData(const char* mime,
|
||||
const unsigned char *data,
|
||||
const unsigned len)
|
||||
{
|
||||
try {
|
||||
server->sendBinaryClipboardData(mime, data, len);
|
||||
} catch (rdr::Exception& e) {
|
||||
vlog.error("XserverDesktop::sendBinaryClipboardData: %s",e.str());
|
||||
}
|
||||
}
|
||||
|
||||
void XserverDesktop::getBinaryClipboardData(const char* mime,
|
||||
const unsigned char **data,
|
||||
unsigned *len)
|
||||
{
|
||||
try {
|
||||
server->getBinaryClipboardData(mime, data, len);
|
||||
} catch (rdr::Exception& e) {
|
||||
vlog.error("XserverDesktop::getBinaryClipboardData: %s",e.str());
|
||||
vlog.error("XserverDesktop::sendClipboardData: %s",e.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,14 +446,11 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
|
||||
|
||||
|
||||
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask,
|
||||
const bool skipClick, const bool skipRelease, int scrollX, int scrollY)
|
||||
const bool skipClick, const bool skipRelease)
|
||||
{
|
||||
if (scrollX == 0 && scrollY == 0) {
|
||||
vncPointerMove(pos.x + vncGetScreenX(screenIndex), pos.y + vncGetScreenY(screenIndex));
|
||||
vncPointerMove(pos.x + vncGetScreenX(screenIndex),
|
||||
pos.y + vncGetScreenY(screenIndex));
|
||||
vncPointerButtonAction(buttonMask, skipClick, skipRelease);
|
||||
} else {
|
||||
vncScroll(scrollX, scrollY);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
||||
@@ -485,14 +469,19 @@ unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void XserverDesktop::handleClipboardRequest()
|
||||
{
|
||||
vncHandleClipboardRequest();
|
||||
}
|
||||
|
||||
void XserverDesktop::handleClipboardAnnounce(bool available)
|
||||
{
|
||||
vncHandleClipboardAnnounce(available);
|
||||
}
|
||||
|
||||
void XserverDesktop::handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32])
|
||||
void XserverDesktop::handleClipboardData(const char* data_, int len)
|
||||
{
|
||||
vncHandleClipboardAnnounceBinary(num, mimes);
|
||||
vncHandleClipboardData(data_, len);
|
||||
}
|
||||
|
||||
void XserverDesktop::grabRegion(const rfb::Region& region)
|
||||
|
||||
@@ -62,11 +62,7 @@ public:
|
||||
void refreshScreenLayout();
|
||||
void requestClipboard();
|
||||
void announceClipboard(bool available);
|
||||
void clearBinaryClipboardData();
|
||||
void sendBinaryClipboardData(const char* mime, const unsigned char *data,
|
||||
const unsigned len);
|
||||
void getBinaryClipboardData(const char *mime, const unsigned char **ptr,
|
||||
unsigned *len);
|
||||
void sendClipboardData(const char* data);
|
||||
void bell();
|
||||
void setLEDState(unsigned int state);
|
||||
void setDesktopName(const char* name);
|
||||
@@ -94,12 +90,13 @@ public:
|
||||
|
||||
// rfb::SDesktop callbacks
|
||||
virtual void pointerEvent(const rfb::Point& pos, int buttonMask,
|
||||
const bool skipClick, const bool skipRelease, int scrollX = 0, int scrollY = 0);
|
||||
const bool skipClick, const bool skipRelease);
|
||||
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
||||
virtual unsigned int setScreenLayout(int fb_width, int fb_height,
|
||||
const rfb::ScreenSet& layout);
|
||||
virtual void handleClipboardRequest();
|
||||
virtual void handleClipboardAnnounce(bool available);
|
||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
||||
virtual void handleClipboardData(const char* data, int len);
|
||||
|
||||
// rfb::PixelBuffer callbacks
|
||||
virtual void grabRegion(const rfb::Region& r);
|
||||
|
||||
@@ -137,7 +137,7 @@ Send clipboard changes to clients. Default is on.
|
||||
.TP
|
||||
.B \-SendPrimary
|
||||
Send the primary selection and cut buffer to the server as well as the
|
||||
clipboard selection. Default is off.
|
||||
clipboard selection. Default is on.
|
||||
.
|
||||
.TP
|
||||
.B \-AcceptPointerEvents
|
||||
@@ -295,22 +295,17 @@ Allow click releases inside the blacked-out region.
|
||||
.
|
||||
.TP
|
||||
.B \-DLP_ClipSendMax \fIbytes\fP
|
||||
Limit clipboard bytes to send to clients in one transaction. Default 0.
|
||||
Limit clipboard bytes to send to clients in one transaction. Default 10,000.
|
||||
0 disables the limit, use \fBSendCutText\fP to disable clipboard sending entirely.
|
||||
.
|
||||
.TP
|
||||
.B \-DLP_ClipAcceptMax \fIbytes\fP
|
||||
Limit clipboard bytes to receive from clients in one transaction. Default 0.
|
||||
Limit clipboard bytes to receive from clients in one transaction. Default 10,000.
|
||||
0 disables the limit, use \fBAcceptCutText\fP to disable clipboard receiving entirely.
|
||||
.
|
||||
.TP
|
||||
.B \-DLP_ClipDelay \fIms\fP
|
||||
This many milliseconds must pass between clipboard actions. Default 0, 0 disables the limit.
|
||||
.
|
||||
.TP
|
||||
.B \-DLP_ClipTypes \fIa,b\fP
|
||||
Allowed binary clipboard mimetypes, separated by commas. Default
|
||||
chromium/x-web-custom-data,text/html,image/png
|
||||
This many milliseconds must pass between clipboard actions. Default 1000.
|
||||
.
|
||||
.TP
|
||||
.B \-DLP_KeyRateLimit \fIkeys-per-second\fP
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <rfb/Configuration.h>
|
||||
#include <rfb/Logger_stdio.h>
|
||||
@@ -66,8 +64,6 @@ int vncFbstride[MAXSCREENS];
|
||||
|
||||
int vncInetdSock = -1;
|
||||
|
||||
static std::vector<dlp_mimetype_t> dlp_mimetypes;
|
||||
|
||||
struct CaseInsensitiveCompare {
|
||||
bool operator() (const std::string &a, const std::string &b) const {
|
||||
return strcasecmp(a.c_str(), b.c_str()) < 0;
|
||||
@@ -107,7 +103,7 @@ rfb::BoolParameter setPrimary("SetPrimary", "Set the PRIMARY as well "
|
||||
"as the CLIPBOARD selection", true);
|
||||
rfb::BoolParameter sendPrimary("SendPrimary",
|
||||
"Send the PRIMARY as well as the CLIPBOARD selection",
|
||||
false);
|
||||
true);
|
||||
|
||||
static PixelFormat vncGetPixelFormat(int scrIdx)
|
||||
{
|
||||
@@ -151,38 +147,6 @@ static void parseOverrideList(const char *text, ParamSet &out)
|
||||
}
|
||||
}
|
||||
|
||||
static void parseClipTypes()
|
||||
{
|
||||
char *str = strdup(Server::DLP_Clip_Types);
|
||||
char * const origstr = str;
|
||||
|
||||
while (1) {
|
||||
char *cur = strsep(&str, ",");
|
||||
if (!cur)
|
||||
break;
|
||||
if (!cur[0])
|
||||
continue;
|
||||
|
||||
// Hardcoded filters
|
||||
if (!strcmp(cur, "TEXT") ||
|
||||
!strcmp(cur, "STRING") ||
|
||||
strstr(cur, "text/plain") ||
|
||||
!strcmp(cur, "UTF8_STRING"))
|
||||
continue;
|
||||
|
||||
struct dlp_mimetype_t m;
|
||||
strncpy(m.mime, cur, sizeof(m.mime));
|
||||
m.mime[sizeof(m.mime) - 1] = '\0';
|
||||
|
||||
dlp_mimetypes.push_back(m);
|
||||
|
||||
vlog.debug("Adding DLP binary mime type %s", m.mime);
|
||||
}
|
||||
vlog.debug("Total %u binary mime types", dlp_mimetypes.size());
|
||||
|
||||
free(origstr);
|
||||
}
|
||||
|
||||
void vncExtensionInit(void)
|
||||
{
|
||||
if (vncExtGeneration == vncGetServerGeneration()) {
|
||||
@@ -199,8 +163,6 @@ void vncExtensionInit(void)
|
||||
|
||||
vncAddExtension();
|
||||
|
||||
if (!initialised)
|
||||
parseClipTypes();
|
||||
vncSelectionInit();
|
||||
|
||||
vlog.info("VNC extension running!");
|
||||
@@ -353,30 +315,22 @@ void vncUpdateDesktopName(void)
|
||||
desktop[scr]->setDesktopName(desktopName);
|
||||
}
|
||||
|
||||
void vncRequestClipboard(void)
|
||||
{
|
||||
for (int scr = 0; scr < vncGetScreenCount(); scr++)
|
||||
desktop[scr]->requestClipboard();
|
||||
}
|
||||
|
||||
void vncAnnounceClipboard(int available)
|
||||
{
|
||||
for (int scr = 0; scr < vncGetScreenCount(); scr++)
|
||||
desktop[scr]->announceClipboard(available);
|
||||
}
|
||||
|
||||
void vncSendBinaryClipboardData(const char* mime, const unsigned char *data,
|
||||
const unsigned len)
|
||||
void vncSendClipboardData(const char* data)
|
||||
{
|
||||
for (int scr = 0; scr < vncGetScreenCount(); scr++)
|
||||
desktop[scr]->sendBinaryClipboardData(mime, data, len);
|
||||
}
|
||||
|
||||
void vncGetBinaryClipboardData(const char *mime, const unsigned char **ptr,
|
||||
unsigned *len)
|
||||
{
|
||||
for (int scr = 0; scr < vncGetScreenCount(); scr++)
|
||||
desktop[scr]->getBinaryClipboardData(mime, ptr, len);
|
||||
}
|
||||
|
||||
void vncClearBinaryClipboardData()
|
||||
{
|
||||
for (int scr = 0; scr < vncGetScreenCount(); scr++)
|
||||
desktop[scr]->clearBinaryClipboardData();
|
||||
desktop[scr]->sendClipboardData(data);
|
||||
}
|
||||
|
||||
int vncConnectClient(const char *addr)
|
||||
@@ -532,13 +486,3 @@ int vncOverrideParam(const char *nameAndValue)
|
||||
|
||||
return rfb::Configuration::setParam(nameAndValue);
|
||||
}
|
||||
|
||||
unsigned dlp_num_mimetypes()
|
||||
{
|
||||
return dlp_mimetypes.size();
|
||||
}
|
||||
|
||||
const char *dlp_get_mimetype(const unsigned i)
|
||||
{
|
||||
return dlp_mimetypes[i].mime;
|
||||
}
|
||||
|
||||
@@ -45,13 +45,6 @@ int vncNotifyQueryConnect(void);
|
||||
extern void* vncFbptr[];
|
||||
extern int vncFbstride[];
|
||||
|
||||
struct dlp_mimetype_t {
|
||||
char mime[32];
|
||||
};
|
||||
|
||||
unsigned dlp_num_mimetypes();
|
||||
const char *dlp_get_mimetype(const unsigned i);
|
||||
|
||||
extern int vncInetdSock;
|
||||
|
||||
void vncExtensionInit(void);
|
||||
@@ -67,12 +60,9 @@ int vncGetSendPrimary(void);
|
||||
|
||||
void vncUpdateDesktopName(void);
|
||||
|
||||
void vncRequestClipboard(void);
|
||||
void vncAnnounceClipboard(int available);
|
||||
void vncClearBinaryClipboardData();
|
||||
void vncSendBinaryClipboardData(const char* mime, const unsigned char *data,
|
||||
const unsigned len);
|
||||
void vncGetBinaryClipboardData(const char *mime, const unsigned char **ptr,
|
||||
unsigned *len);
|
||||
void vncSendClipboardData(const char* data);
|
||||
|
||||
int vncConnectClient(const char *addr);
|
||||
|
||||
|
||||
@@ -43,14 +43,6 @@
|
||||
|
||||
static Atom xaPRIMARY, xaCLIPBOARD;
|
||||
static Atom xaTARGETS, xaTIMESTAMP, xaSTRING, xaTEXT, xaUTF8_STRING;
|
||||
static Atom xaINCR;
|
||||
static Atom *xaBinclips;
|
||||
static unsigned xaHtmlIndex, xaPngIndex;
|
||||
static Bool htmlPngPresent;
|
||||
|
||||
static unsigned *mimeIndexesFromClient;
|
||||
static unsigned numMimesFromClient;
|
||||
static Bool textFromClient;
|
||||
|
||||
static WindowPtr pWindow;
|
||||
static Window wid;
|
||||
@@ -74,7 +66,8 @@ static int vncCreateSelectionWindow(void);
|
||||
static int vncOwnSelection(Atom selection);
|
||||
static int vncConvertSelection(ClientPtr client, Atom selection,
|
||||
Atom target, Atom property,
|
||||
Window requestor, CARD32 time);
|
||||
Window requestor, CARD32 time,
|
||||
const char* data, int len);
|
||||
static int vncProcConvertSelection(ClientPtr client);
|
||||
static void vncSelectionRequest(Atom selection, Atom target);
|
||||
static int vncProcSendEvent(ClientPtr client);
|
||||
@@ -97,32 +90,6 @@ void vncSelectionInit(void)
|
||||
xaTEXT = MakeAtom("TEXT", 4, TRUE);
|
||||
xaUTF8_STRING = MakeAtom("UTF8_STRING", 11, TRUE);
|
||||
|
||||
xaINCR = MakeAtom("INCR", 4, TRUE);
|
||||
|
||||
unsigned i;
|
||||
mimeIndexesFromClient = calloc(dlp_num_mimetypes(), sizeof(unsigned));
|
||||
numMimesFromClient = 0;
|
||||
textFromClient = FALSE;
|
||||
xaBinclips = calloc(dlp_num_mimetypes(), sizeof(Atom));
|
||||
htmlPngPresent = FALSE;
|
||||
Bool htmlfound = FALSE, pngfound = FALSE;
|
||||
for (i = 0; i < dlp_num_mimetypes(); i++) {
|
||||
const char *cur = dlp_get_mimetype(i);
|
||||
xaBinclips[i] = MakeAtom(cur, strlen(cur), TRUE);
|
||||
|
||||
if (!strcmp(cur, "text/html")) {
|
||||
xaHtmlIndex = i;
|
||||
htmlfound = TRUE;
|
||||
}
|
||||
if (!strcmp(cur, "image/png")) {
|
||||
xaPngIndex = i;
|
||||
pngfound = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (htmlfound && pngfound)
|
||||
htmlPngPresent = TRUE;
|
||||
|
||||
/* There are no hooks for when these are internal windows, so
|
||||
* override the relevant handlers. */
|
||||
origProcConvertSelection = ProcVector[X_ConvertSelection];
|
||||
@@ -136,7 +103,7 @@ void vncSelectionInit(void)
|
||||
FatalError("Add VNC ClientStateCallback failed\n");
|
||||
}
|
||||
|
||||
static void vncHandleClipboardRequest(void)
|
||||
void vncHandleClipboardRequest(void)
|
||||
{
|
||||
if (activeSelection == None) {
|
||||
LOG_DEBUG("Got request for local clipboard although no clipboard is active");
|
||||
@@ -194,55 +161,24 @@ void vncHandleClipboardAnnounce(int available)
|
||||
}
|
||||
}
|
||||
|
||||
void vncHandleClipboardAnnounceBinary(const unsigned num, const char mimes[][32])
|
||||
void vncHandleClipboardData(const char* data, int len)
|
||||
{
|
||||
if (num) {
|
||||
int rc;
|
||||
|
||||
LOG_DEBUG("Remote binary clipboard announced, grabbing local ownership");
|
||||
|
||||
if (vncGetSetPrimary()) {
|
||||
rc = vncOwnSelection(xaPRIMARY);
|
||||
if (rc != Success)
|
||||
LOG_ERROR("Could not set PRIMARY selection");
|
||||
}
|
||||
|
||||
rc = vncOwnSelection(xaCLIPBOARD);
|
||||
if (rc != Success)
|
||||
LOG_ERROR("Could not set CLIPBOARD selection");
|
||||
|
||||
unsigned i, valid = 0;
|
||||
for (i = 0; i < num; i++) {
|
||||
unsigned j;
|
||||
for (j = 0; j < dlp_num_mimetypes(); j++) {
|
||||
if (!strcmp(dlp_get_mimetype(j), mimes[i])) {
|
||||
mimeIndexesFromClient[valid] = j;
|
||||
valid++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(mimes[i], "text/plain"))
|
||||
textFromClient = TRUE;
|
||||
}
|
||||
numMimesFromClient = valid;
|
||||
LOG_DEBUG("Client sent %u mimes, %u were valid", num, valid);
|
||||
} else {
|
||||
struct VncDataTarget* next;
|
||||
numMimesFromClient = 0;
|
||||
textFromClient = FALSE;
|
||||
|
||||
if (pWindow == NULL)
|
||||
return;
|
||||
LOG_DEBUG("Got remote clipboard data, sending to X11 clients");
|
||||
|
||||
LOG_DEBUG("Remote binary clipboard lost, removing local ownership");
|
||||
|
||||
DeleteWindowFromAnySelections(pWindow);
|
||||
|
||||
/* Abort any pending transfer */
|
||||
while (vncDataTargetHead != NULL) {
|
||||
int rc;
|
||||
xEvent event;
|
||||
|
||||
rc = vncConvertSelection(vncDataTargetHead->client,
|
||||
vncDataTargetHead->selection,
|
||||
vncDataTargetHead->target,
|
||||
vncDataTargetHead->property,
|
||||
vncDataTargetHead->requestor,
|
||||
vncDataTargetHead->time,
|
||||
data, len);
|
||||
if (rc != Success) {
|
||||
event.u.u.type = SelectionNotify;
|
||||
event.u.selectionNotify.time = vncDataTargetHead->time;
|
||||
event.u.selectionNotify.requestor = vncDataTargetHead->requestor;
|
||||
@@ -250,12 +186,12 @@ void vncHandleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]
|
||||
event.u.selectionNotify.target = vncDataTargetHead->target;
|
||||
event.u.selectionNotify.property = None;
|
||||
WriteEventsToClient(vncDataTargetHead->client, 1, &event);
|
||||
}
|
||||
|
||||
next = vncDataTargetHead->next;
|
||||
free(vncDataTargetHead);
|
||||
vncDataTargetHead = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int vncCreateSelectionWindow(void)
|
||||
@@ -341,22 +277,10 @@ static int vncOwnSelection(Atom selection)
|
||||
return Success;
|
||||
}
|
||||
|
||||
static Bool clientHasBinaryAtom(const Atom target, unsigned *which)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < numMimesFromClient; i++) {
|
||||
if (xaBinclips[mimeIndexesFromClient[i]] == target) {
|
||||
*which = mimeIndexesFromClient[i];
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int vncConvertSelection(ClientPtr client, Atom selection,
|
||||
Atom target, Atom property,
|
||||
Window requestor, CARD32 time)
|
||||
Window requestor, CARD32 time,
|
||||
const char* data, int len)
|
||||
{
|
||||
Selection *pSel;
|
||||
WindowPtr pWin;
|
||||
@@ -366,8 +290,13 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
|
||||
|
||||
xEvent event;
|
||||
|
||||
if (data == NULL) {
|
||||
LOG_DEBUG("Selection request for %s (type %s)",
|
||||
NameForAtom(selection), NameForAtom(target));
|
||||
} else {
|
||||
LOG_DEBUG("Sending data for selection request for %s (type %s)",
|
||||
NameForAtom(selection), NameForAtom(target));
|
||||
}
|
||||
|
||||
rc = dixLookupSelection(&pSel, selection, client, DixGetAttrAccess);
|
||||
if (rc != Success)
|
||||
@@ -386,23 +315,14 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
|
||||
realProperty = target;
|
||||
|
||||
/* FIXME: MULTIPLE target */
|
||||
unsigned binatomidx;
|
||||
|
||||
if (target == xaTARGETS) {
|
||||
Atom targets[5 + numMimesFromClient];
|
||||
targets[0] = xaTARGETS;
|
||||
targets[1] = xaTIMESTAMP;
|
||||
targets[2] = xaSTRING;
|
||||
targets[3] = xaTEXT;
|
||||
targets[4] = xaUTF8_STRING;
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < numMimesFromClient; i++)
|
||||
targets[5 + i] = xaBinclips[mimeIndexesFromClient[i]];
|
||||
Atom targets[] = { xaTARGETS, xaTIMESTAMP,
|
||||
xaSTRING, xaTEXT, xaUTF8_STRING };
|
||||
|
||||
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
|
||||
XA_ATOM, 32, PropModeReplace,
|
||||
5 + numMimesFromClient,
|
||||
sizeof(targets)/sizeof(targets[0]),
|
||||
targets, TRUE);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
@@ -413,22 +333,37 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
|
||||
TRUE);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
} else if (clientHasBinaryAtom(target, &binatomidx)) {
|
||||
const unsigned char *data;
|
||||
unsigned len;
|
||||
vncGetBinaryClipboardData(dlp_get_mimetype(binatomidx), &data, &len);
|
||||
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
|
||||
xaBinclips[binatomidx], 8, PropModeReplace,
|
||||
len, (unsigned char *) data, TRUE);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
} else if (textFromClient) {
|
||||
const unsigned char *data;
|
||||
unsigned len;
|
||||
vncGetBinaryClipboardData("text/plain", &data, &len);
|
||||
} else {
|
||||
if (data == NULL) {
|
||||
struct VncDataTarget* vdt;
|
||||
|
||||
if ((target != xaSTRING) && (target != xaTEXT) &&
|
||||
(target != xaUTF8_STRING))
|
||||
return BadMatch;
|
||||
|
||||
vdt = calloc(1, sizeof(struct VncDataTarget));
|
||||
if (vdt == NULL)
|
||||
return BadAlloc;
|
||||
|
||||
vdt->client = client;
|
||||
vdt->selection = selection;
|
||||
vdt->target = target;
|
||||
vdt->property = property;
|
||||
vdt->requestor = requestor;
|
||||
vdt->time = time;
|
||||
|
||||
vdt->next = vncDataTargetHead;
|
||||
vncDataTargetHead = vdt;
|
||||
|
||||
LOG_DEBUG("Requesting clipboard data from client");
|
||||
|
||||
vncRequestClipboard();
|
||||
|
||||
return Success;
|
||||
} else {
|
||||
if ((target == xaSTRING) || (target == xaTEXT)) {
|
||||
char* latin1;
|
||||
|
||||
latin1 = vncUTF8ToLatin1(data, (size_t)-1);
|
||||
if (latin1 == NULL)
|
||||
return BadAlloc;
|
||||
@@ -444,16 +379,13 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
|
||||
} else if (target == xaUTF8_STRING) {
|
||||
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
|
||||
xaUTF8_STRING, 8, PropModeReplace,
|
||||
len, (char *) data, TRUE);
|
||||
len, data, TRUE);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
} else {
|
||||
return BadMatch;
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("Text clipboard paste requested, but client sent no text");
|
||||
|
||||
return BadMatch;
|
||||
}
|
||||
}
|
||||
|
||||
event.u.u.type = SelectionNotify;
|
||||
@@ -492,7 +424,7 @@ static int vncProcConvertSelection(ClientPtr client)
|
||||
pSel->window == wid) {
|
||||
rc = vncConvertSelection(client, stuff->selection,
|
||||
stuff->target, stuff->property,
|
||||
stuff->requestor, stuff->time);
|
||||
stuff->requestor, stuff->time, NULL, 0);
|
||||
if (rc != Success) {
|
||||
xEvent event;
|
||||
|
||||
@@ -551,21 +483,6 @@ static Bool vncHasAtom(Atom atom, const Atom list[], size_t size)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool vncHasBinaryClipboardAtom(const Atom list[], size_t size)
|
||||
{
|
||||
size_t i, b;
|
||||
const unsigned num = dlp_num_mimetypes();
|
||||
|
||||
for (i = 0;i < size;i++) {
|
||||
for (b = 0; b < num; b++) {
|
||||
if (list[i] == xaBinclips[b])
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void vncHandleSelection(Atom selection, Atom target,
|
||||
Atom property, Atom requestor,
|
||||
TimeStamp time)
|
||||
@@ -585,9 +502,6 @@ static void vncHandleSelection(Atom selection, Atom target,
|
||||
if (target != property)
|
||||
return;
|
||||
|
||||
if (prop->type == xaINCR)
|
||||
LOG_INFO("Incremental clipboard transfer denied, too large");
|
||||
|
||||
if (target == xaTARGETS) {
|
||||
if (prop->format != 32)
|
||||
return;
|
||||
@@ -596,36 +510,16 @@ static void vncHandleSelection(Atom selection, Atom target,
|
||||
|
||||
if (probing) {
|
||||
if (vncHasAtom(xaSTRING, (const Atom*)prop->data, prop->size) ||
|
||||
vncHasAtom(xaUTF8_STRING, (const Atom*)prop->data, prop->size) ||
|
||||
vncHasBinaryClipboardAtom((const Atom*)prop->data, prop->size)) {
|
||||
vncHasAtom(xaUTF8_STRING, (const Atom*)prop->data, prop->size)) {
|
||||
LOG_DEBUG("Compatible format found, notifying clients");
|
||||
vncClearBinaryClipboardData();
|
||||
activeSelection = selection;
|
||||
vncAnnounceClipboard(TRUE);
|
||||
vncHandleClipboardRequest();
|
||||
}
|
||||
} else {
|
||||
if (vncHasAtom(xaUTF8_STRING, (const Atom*)prop->data, prop->size))
|
||||
vncSelectionRequest(selection, xaUTF8_STRING);
|
||||
else if (vncHasAtom(xaSTRING, (const Atom*)prop->data, prop->size))
|
||||
vncSelectionRequest(selection, xaSTRING);
|
||||
|
||||
unsigned i;
|
||||
|
||||
Bool skiphtml = FALSE;
|
||||
if (htmlPngPresent &&
|
||||
vncHasAtom(xaBinclips[xaHtmlIndex], (const Atom*)prop->data, prop->size) &&
|
||||
vncHasAtom(xaBinclips[xaPngIndex], (const Atom*)prop->data, prop->size))
|
||||
skiphtml = TRUE;
|
||||
|
||||
for (i = 0; i < dlp_num_mimetypes(); i++) {
|
||||
if (skiphtml && i == xaHtmlIndex)
|
||||
continue;
|
||||
if (vncHasAtom(xaBinclips[i], (const Atom*)prop->data, prop->size)) {
|
||||
vncSelectionRequest(selection, xaBinclips[i]);
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (target == xaSTRING) {
|
||||
char* filtered;
|
||||
@@ -645,10 +539,10 @@ static void vncHandleSelection(Atom selection, Atom target,
|
||||
if (utf8 == NULL)
|
||||
return;
|
||||
|
||||
LOG_DEBUG("Sending text part of binary clipboard to clients (%d bytes)",
|
||||
LOG_DEBUG("Sending clipboard to clients (%d bytes)",
|
||||
(int)strlen(utf8));
|
||||
|
||||
vncSendBinaryClipboardData("text/plain", utf8, strlen(utf8));
|
||||
vncSendClipboardData(utf8);
|
||||
|
||||
vncStrFree(utf8);
|
||||
} else if (target == xaUTF8_STRING) {
|
||||
@@ -663,31 +557,12 @@ static void vncHandleSelection(Atom selection, Atom target,
|
||||
if (filtered == NULL)
|
||||
return;
|
||||
|
||||
LOG_DEBUG("Sending text part of binary clipboard to clients (%d bytes)",
|
||||
LOG_DEBUG("Sending clipboard to clients (%d bytes)",
|
||||
(int)strlen(filtered));
|
||||
|
||||
vncSendBinaryClipboardData("text/plain", filtered, strlen(filtered));
|
||||
vncSendClipboardData(filtered);
|
||||
|
||||
vncStrFree(filtered);
|
||||
} else {
|
||||
unsigned i;
|
||||
|
||||
if (prop->format != 8)
|
||||
return;
|
||||
|
||||
for (i = 0; i < dlp_num_mimetypes(); i++) {
|
||||
if (target == xaBinclips[i]) {
|
||||
if (prop->type != xaBinclips[i])
|
||||
return;
|
||||
|
||||
LOG_DEBUG("Sending binary clipboard to clients (%d bytes)",
|
||||
prop->size);
|
||||
|
||||
vncSendBinaryClipboardData(dlp_get_mimetype(i), prop->data, prop->size);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ extern "C" {
|
||||
|
||||
void vncSelectionInit(void);
|
||||
|
||||
void vncHandleClipboardRequest(void);
|
||||
void vncHandleClipboardAnnounce(int available);
|
||||
void vncHandleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
||||
void vncHandleClipboardData(const char* data, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user