Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05814e9da7 | ||
|
|
cc43a88ade | ||
|
|
b5f3bac256 | ||
|
|
688e3e4ee7 | ||
|
|
2f76b3d4eb | ||
|
|
c67998a540 | ||
|
|
bdd2fc9883 | ||
|
|
91c480c274 | ||
|
|
ba1a70f3ce | ||
|
|
56c3babfe7 | ||
|
|
a91c04fa64 | ||
|
|
739cf7234b | ||
|
|
24d935ea61 | ||
|
|
00a92dabeb | ||
|
|
05b63991a8 | ||
|
|
42ac612916 | ||
|
|
56516abc62 | ||
|
|
308957283b | ||
|
|
0425ee6ddb | ||
|
|
9d8c3b4e34 | ||
|
|
9e4f45997e | ||
|
|
e2a64ed7d4 | ||
|
|
3882e29b0e | ||
|
|
32bac9b675 | ||
|
|
0e1aedce82 | ||
|
|
8eb4d48887 | ||
|
|
87f91e3c13 | ||
|
|
dbab0150fe | ||
|
|
1c9bef6e63 | ||
|
|
f9f9dd8abe | ||
|
|
2283d4a076 | ||
|
|
59102edfb5 | ||
|
|
aa41998e58 | ||
|
|
a3397e81a7 | ||
|
|
2910870371 | ||
|
|
fb82bb4b8d | ||
|
|
630e8ec0de | ||
|
|
890daea78f | ||
|
|
8e57f5723b | ||
|
|
bfb27a279f | ||
|
|
b33701a83f | ||
|
|
193dfc247f | ||
|
|
08389271f0 | ||
|
|
842df3201b | ||
|
|
cd8eb1d9eb | ||
|
|
32cd228c02 | ||
|
|
8b4821948d | ||
|
|
79b7837189 | ||
|
|
b62db0e9a1 | ||
|
|
581710a770 | ||
|
|
c92bdaed1d | ||
|
|
58738f6fd7 | ||
|
|
ada320044b | ||
|
|
fb35e6ee1c | ||
|
|
d75e422c1d | ||
|
|
4cfa9a9b5b | ||
|
|
d1d9f0c6fc | ||
|
|
cc4d35c228 | ||
|
|
17d1555155 | ||
|
|
588790f2d5 | ||
|
|
918abeb9bc | ||
|
|
812965f020 | ||
|
|
5c3b7d118a | ||
|
|
4fdcb15629 | ||
|
|
88f4623f52 | ||
|
|
0c2d4830b5 | ||
|
|
3d2dfe4be0 | ||
|
|
3c49eab0c8 | ||
|
|
13ec7dfc37 | ||
|
|
e98fd7894a | ||
|
|
6f860d3dff | ||
|
|
5902bee5ff | ||
|
|
8c831b1fc2 | ||
|
|
912bf3046d | ||
|
|
4a12de6156 | ||
|
|
b0b8e5ec32 | ||
|
|
cfe8430cae | ||
|
|
7ae09aad8c | ||
|
|
40b35804e7 | ||
|
|
6999b2725e | ||
|
|
0a528b4aae | ||
|
|
7134d92ee8 | ||
|
|
d21b909a0d | ||
|
|
e066362c92 | ||
|
|
fd9b48cd90 | ||
|
|
2c29dda2ac | ||
|
|
d3845678ab | ||
|
|
355f8d82aa | ||
|
|
2ca6b80728 | ||
|
|
c0c517806e | ||
|
|
537e12d706 | ||
|
|
4197927f56 | ||
|
|
1b7380d2f2 | ||
|
|
090e479e20 | ||
|
|
cbce8b5609 | ||
|
|
6edd3408aa | ||
|
|
5da7b45407 | ||
|
|
bd064713a8 | ||
|
|
822d10528f | ||
|
|
ce8cc5b8dd | ||
|
|
b407c56239 | ||
|
|
9c1428fb72 | ||
|
|
ce97729984 | ||
|
|
3817227942 | ||
|
|
88975379bf | ||
|
|
11b410f1d9 | ||
|
|
917e1091a1 | ||
|
|
68f35cc582 | ||
|
|
293cd56930 | ||
|
|
ca221e3488 | ||
|
|
6e01164a56 | ||
|
|
d83bb22c58 | ||
|
|
e808ccbdb5 | ||
|
|
f17dd27d55 | ||
|
|
2b7b97f0e4 | ||
|
|
3a2398e677 | ||
|
|
7a373813ce | ||
|
|
8a41765c53 | ||
|
|
7a16e6bce8 | ||
|
|
6d23d41797 | ||
|
|
5263c03889 | ||
|
|
c44be546c3 | ||
|
|
63c873a906 | ||
|
|
3c16026acc | ||
|
|
81fcd253d3 | ||
|
|
4f94a28ad2 | ||
|
|
f403f19164 | ||
|
|
ab10af726b | ||
|
|
52f719d192 | ||
|
|
6723685385 | ||
|
|
aa14c67e92 | ||
|
|
fa14b94520 | ||
|
|
ded66586b2 | ||
|
|
cb1716ba9c | ||
|
|
25cca2831b | ||
|
|
66f48b3ff6 | ||
|
|
0f7d065628 | ||
|
|
494e4a5331 | ||
|
|
b5b71df6e6 | ||
|
|
49f410e63b | ||
|
|
225acf13aa | ||
|
|
61d2b702c0 | ||
|
|
3276ac0f9a | ||
|
|
0b037e158c | ||
|
|
10e94e0b81 | ||
|
|
0f76539075 | ||
|
|
f9b8c55924 | ||
|
|
a708ce0115 | ||
|
|
b3f4ba0a32 | ||
|
|
02cf4a0b26 | ||
|
|
370189cbee | ||
|
|
6746cf64c3 | ||
|
|
40739739b5 | ||
|
|
dc7a200b93 | ||
|
|
f49b6471f3 | ||
|
|
4da922aa3b | ||
|
|
ecc9c9f09c | ||
|
|
b32002710b | ||
|
|
7b6d20a003 | ||
|
|
d27029fad8 | ||
|
|
1b488ba696 | ||
|
|
f78f7c9bc8 | ||
|
|
7e11693ce3 | ||
|
|
c601fa9aa2 | ||
|
|
536a43773f | ||
|
|
ae4cbedd3b | ||
|
|
fe55d11fc4 | ||
|
|
34f1feaf43 | ||
|
|
f640b4d325 | ||
|
|
a35b4a289e | ||
|
|
a7a5d9bf96 | ||
|
|
888dc93643 | ||
|
|
f98e0336dc | ||
|
|
7a571f9b27 | ||
|
|
67de92044f | ||
|
|
7d63836e35 | ||
|
|
3e23fc7d22 | ||
|
|
8bf05d381e | ||
|
|
1ab36a1137 | ||
|
|
18b788e664 | ||
|
|
ebadab8f06 | ||
|
|
81d13deaab | ||
|
|
6f91a79081 | ||
|
|
4d252fa31c | ||
|
|
398475c649 | ||
|
|
13d4aa398c | ||
|
|
9423665fe5 | ||
|
|
5e8dbfa26d | ||
|
|
d96b3f9c0d | ||
|
|
7720942681 | ||
|
|
f129ca7ea1 | ||
|
|
628d0febdd | ||
|
|
add284d3b4 | ||
|
|
a3f2224952 | ||
|
|
966bcc554b | ||
|
|
d6e3a212f2 | ||
|
|
e45b4a4145 | ||
|
|
93a7f4bd10 | ||
|
|
d1401171d8 | ||
|
|
9591ca287e | ||
|
|
46c80ecc93 | ||
|
|
99d2a26d45 | ||
|
|
067037517e | ||
|
|
c04b49fe11 | ||
|
|
a044cb35ad | ||
|
|
ac4b6240ef | ||
|
|
0c3af0d60d | ||
|
|
6289e1539a | ||
|
|
08a77f9d38 | ||
|
|
fb6db0dc12 | ||
|
|
731a0d895c | ||
|
|
ab58dd6cec | ||
|
|
cdcf03ff2f | ||
|
|
1d715f059d | ||
|
|
88951d863b | ||
|
|
0d5d06ead0 | ||
|
|
3171bb9fd1 | ||
|
|
d48b29025e | ||
|
|
d06ce925ac | ||
|
|
5ace087f92 | ||
|
|
a51f034036 | ||
|
|
982562874a | ||
|
|
45fe7165f3 | ||
|
|
d0f6a67be1 | ||
|
|
8461c73bc3 | ||
|
|
238a4ee1e3 | ||
|
|
253f995dc6 | ||
|
|
0972c89ee1 | ||
|
|
13a4b928ed | ||
|
|
c6b47eef6a | ||
|
|
a1afe3f1e3 | ||
|
|
a3672ba764 | ||
|
|
d01ef9d394 | ||
|
|
dad4f13f64 | ||
|
|
4f477901d9 | ||
|
|
d3ffefa897 | ||
|
|
93f786452d | ||
|
|
635fd9f8bf | ||
|
|
e4295a6ce8 | ||
|
|
e4426df6a2 | ||
|
|
65a93041aa | ||
|
|
8287a669fb | ||
|
|
48d96dbb9d | ||
|
|
bd613382bc | ||
|
|
3eda3afba4 | ||
|
|
d7ec1c16a2 | ||
|
|
d241d48f52 | ||
|
|
67954d7c4b | ||
|
|
977725868a | ||
|
|
e2acdd7df2 | ||
|
|
ae50155fbd | ||
|
|
24f9bbbccb | ||
|
|
1b4ea720a6 | ||
|
|
7d87442f73 | ||
|
|
f398ccadb7 | ||
|
|
740c79af9b | ||
|
|
d0096c6cb2 | ||
|
|
e4701c1bd8 | ||
|
|
a08ae655cf | ||
|
|
a917e16e62 | ||
|
|
8ed3304e61 | ||
|
|
c40fd051e5 | ||
|
|
09cd8ecb18 | ||
|
|
a4e1743691 | ||
|
|
801a339525 | ||
|
|
49a7cbfe99 | ||
|
|
603975bfe0 | ||
|
|
49fe7447ff | ||
|
|
7048248268 | ||
|
|
cad5ca3d68 | ||
|
|
9e9ab6fb7d | ||
|
|
8e55698271 | ||
|
|
47338b21a8 | ||
|
|
4c307e05f5 | ||
|
|
b56659b0b4 | ||
|
|
e3c3b6e89e | ||
|
|
f1a8a3c19a | ||
|
|
986b63391a | ||
|
|
9b180ad90c | ||
|
|
6079dc6aee | ||
|
|
2bd7371c7a | ||
|
|
e1eb191def | ||
|
|
a9d2de06b5 | ||
|
|
2aa875a626 | ||
|
|
e4fa429dcc | ||
|
|
5ba7bf2e18 | ||
|
|
11925a372d | ||
|
|
e1eb9e20f1 | ||
|
|
1d3aa889d5 | ||
|
|
c1ab26aef3 | ||
|
|
ea9819d161 | ||
|
|
dc9480fd71 | ||
|
|
fa2849a080 | ||
|
|
c70c7ee5b9 | ||
|
|
fe3d3df662 | ||
|
|
2f90b73683 | ||
|
|
5186e80c6f | ||
|
|
4ff1c1dc1f | ||
|
|
c1427040f6 | ||
|
|
a7ad02acb6 | ||
|
|
b188d61be1 | ||
|
|
ec85e857bc | ||
|
|
d37ccafdc2 | ||
|
|
0c9b8e6c63 | ||
|
|
8f8ad466f4 | ||
|
|
0f67be465b | ||
|
|
ed7c8ca1a1 | ||
|
|
f71e29de5c | ||
|
|
a641453388 | ||
|
|
366b95ce1f | ||
|
|
136c870d1f | ||
|
|
0c411a542f | ||
|
|
1e70dd088f | ||
|
|
2dc7f97ff0 | ||
|
|
6542d677a9 | ||
|
|
222fe26cea | ||
|
|
ed413ee029 | ||
|
|
516d685c9e | ||
|
|
54e2371022 | ||
|
|
511cc5ebd7 | ||
|
|
30bec40338 | ||
|
|
0bb9353a11 | ||
|
|
80134f5a2b | ||
|
|
57e20fe478 | ||
|
|
9317430968 | ||
|
|
f92b04e99a | ||
|
|
a1c63f8498 | ||
|
|
9460d498fc | ||
|
|
c2a6a436a5 | ||
|
|
c578e35178 | ||
|
|
90cd9a46f6 | ||
|
|
6616389a5f | ||
|
|
f5f5d358b4 | ||
|
|
5cb9432f21 | ||
|
|
fb8fb21450 | ||
|
|
370a32f1b5 | ||
|
|
68227b64a2 | ||
|
|
2a0880bfee | ||
|
|
26dbd8d312 | ||
|
|
6357a4087d | ||
|
|
f482bd077b | ||
|
|
148468eee3 | ||
|
|
79083e5664 | ||
|
|
c52d2bc0b6 | ||
|
|
54d4f2ec57 | ||
|
|
a25b5cb894 | ||
|
|
6caa8fcd84 | ||
|
|
66270eee77 | ||
|
|
6119976027 | ||
|
|
a286b5e418 | ||
|
|
882ab4001d | ||
|
|
52b6fa6fbd | ||
|
|
3bb115bd2d | ||
|
|
e08f239176 | ||
|
|
a01c55e38d | ||
|
|
af51bc257b | ||
|
|
90a8c11acb | ||
|
|
92b858884c | ||
|
|
159673652c | ||
|
|
200d13ef15 | ||
|
|
ddeef46d2e | ||
|
|
97c3998383 | ||
|
|
93aea4ee60 | ||
|
|
546dbf542e | ||
|
|
005410d40b | ||
|
|
3b384a199a | ||
|
|
b62b024a8b | ||
|
|
4fbd373e29 | ||
|
|
ae211a923a | ||
|
|
d94d730a44 | ||
|
|
18ae1c5fa5 | ||
|
|
a0afabeb04 | ||
|
|
1158ab9095 | ||
|
|
54ccb761e5 | ||
|
|
f72dbd1dec | ||
|
|
0814c3153a | ||
|
|
9f085e8b8c | ||
|
|
0188752c0a | ||
|
|
a884c41813 | ||
|
|
879b977321 | ||
|
|
e9cb253be1 | ||
|
|
07eacae385 | ||
|
|
8446874290 | ||
|
|
c347f97b95 | ||
|
|
29cfa9e24b | ||
|
|
1b1ce882a5 | ||
|
|
e9f2dbf9ea | ||
|
|
7c6ae315e1 | ||
|
|
cec0d22dc8 | ||
|
|
b2ca82e105 | ||
|
|
5ba6b1d5fc | ||
|
|
a96e77c758 | ||
|
|
79e0f0c7c1 | ||
|
|
187ca778f2 | ||
|
|
2d1aa3ba8c | ||
|
|
08bd4efefa | ||
|
|
558485f5a9 | ||
|
|
cff2ff9dbe | ||
|
|
d5d92cfbee | ||
|
|
a00f6a8cba | ||
|
|
59dee3d767 | ||
|
|
e94661b213 | ||
|
|
9dea81bdff | ||
|
|
6ff552c1ec | ||
|
|
c1b1ea1a67 | ||
|
|
167a8f4037 | ||
|
|
47776d54d9 | ||
|
|
5767c252b7 | ||
|
|
a2efcada02 | ||
|
|
e68aa0ffa6 | ||
|
|
66bcccabe4 | ||
|
|
3736189308 | ||
|
|
c408482c55 | ||
|
|
00b0b8eb84 | ||
|
|
b14294f131 | ||
|
|
db9249bd61 | ||
|
|
662e4d0b8a | ||
|
|
13be9179f5 | ||
|
|
0a55506077 | ||
|
|
8860efa82e | ||
|
|
9bc0994a8e | ||
|
|
1f50e4d82b | ||
|
|
995d1216ea | ||
|
|
196e91289c | ||
|
|
b2bb35994f | ||
|
|
6fe6a1387a |
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 8
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Always
|
||||||
|
ColumnLimit: 80
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM ubuntu:18.04
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
ARG USERNAME=vscode
|
ARG USERNAME=vscode
|
||||||
ARG USER_UID=1000
|
ARG USER_UID=1000
|
||||||
@@ -7,45 +7,63 @@ ARG USER_GID=$USER_UID
|
|||||||
ENV RUSTUP_HOME=/usr/local/rustup \
|
ENV RUSTUP_HOME=/usr/local/rustup \
|
||||||
CARGO_HOME=/usr/local/cargo \
|
CARGO_HOME=/usr/local/cargo \
|
||||||
PATH=/usr/local/cargo/bin:$PATH \
|
PATH=/usr/local/cargo/bin:$PATH \
|
||||||
RUST_VERSION=1.75.0
|
RUST_VERSION=1.89.0 \
|
||||||
|
DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# Install all system dependencies in a single layer and clean up apt cache
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
|
# Common utilities
|
||||||
|
dh-autoreconf \
|
||||||
sudo \
|
sudo \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
gnupg \
|
gnupg \
|
||||||
git \
|
git \
|
||||||
less \
|
less \
|
||||||
|
wget \
|
||||||
|
file \
|
||||||
software-properties-common \
|
software-properties-common \
|
||||||
|
# libopenconnect-dev to install the related dependencies for building openconnect from source
|
||||||
|
# Otherwise, we have to install them manually one by one
|
||||||
|
libopenconnect-dev \
|
||||||
# Tauri dependencies
|
# Tauri dependencies
|
||||||
libwebkit2gtk-4.0-dev build-essential wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev; \
|
libwebkit2gtk-4.1-dev \
|
||||||
# Install openconnect
|
build-essential \
|
||||||
add-apt-repository ppa:yuezk/globalprotect-openconnect; \
|
libxdo-dev \
|
||||||
apt-get update; \
|
libssl-dev \
|
||||||
apt-get install -y openconnect libopenconnect-dev; \
|
libayatana-appindicator3-dev \
|
||||||
# Create a non-root user
|
librsvg2-dev; \
|
||||||
|
# Clean up apt cache to reduce image size
|
||||||
|
apt-get clean; \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Create a non-root user
|
||||||
|
RUN set -eux; \
|
||||||
groupadd --gid $USER_GID $USERNAME; \
|
groupadd --gid $USER_GID $USERNAME; \
|
||||||
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; \
|
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; \
|
||||||
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME; \
|
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME; \
|
||||||
chmod 0440 /etc/sudoers.d/$USERNAME; \
|
chmod 0440 /etc/sudoers.d/$USERNAME
|
||||||
# Install Node.js
|
|
||||||
mkdir -p /etc/apt/keyrings; \
|
# Install Rust
|
||||||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
|
RUN set -eux; \
|
||||||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION --profile minimal; \
|
||||||
apt-get update; \
|
|
||||||
apt-get install -y nodejs; \
|
|
||||||
corepack enable; \
|
|
||||||
# Install diff-so-fancy
|
|
||||||
npm install -g diff-so-fancy; \
|
|
||||||
# Install Rust
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION; \
|
|
||||||
chown -R $USERNAME:$USERNAME $RUSTUP_HOME $CARGO_HOME; \
|
chown -R $USERNAME:$USERNAME $RUSTUP_HOME $CARGO_HOME; \
|
||||||
rustup --version; \
|
rustup --version; \
|
||||||
cargo --version; \
|
cargo --version; \
|
||||||
rustc --version
|
rustc --version
|
||||||
|
|
||||||
|
# Install Node.js and global npm packages
|
||||||
|
RUN set -eux; \
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -; \
|
||||||
|
apt-get install -y --no-install-recommends nodejs; \
|
||||||
|
corepack enable; \
|
||||||
|
npm install -g diff-so-fancy; \
|
||||||
|
# Clean up apt cache
|
||||||
|
apt-get clean; \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
USER $USERNAME
|
USER $USERNAME
|
||||||
|
|
||||||
# Install Oh My Zsh
|
# Install Oh My Zsh
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.build
|
||||||
|
.git
|
||||||
|
.vendor
|
||||||
|
apps/gpgui-helper/node_modules
|
||||||
|
target
|
||||||
|
vendor.tar.xz
|
||||||
@@ -7,3 +7,10 @@ indent_size = 2
|
|||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[{*.c,*.h}]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 8
|
||||||
|
|
||||||
|
[{Makefile,Makefile.in}]
|
||||||
|
indent_style = tab
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Logs**
|
||||||
|
- For the GUI version, you can find the logs at `~/.local/share/gpclient/gpclient.log`
|
||||||
|
- For the CLI version, copy the output of the `gpclient` command.
|
||||||
|
|
||||||
|
**Environment:**
|
||||||
|
- OS: [e.g. Ubuntu 22.04]
|
||||||
|
- Desktop Environment: [e.g. GNOME or KDE]
|
||||||
|
- Output of `ps aux | grep 'gnome-keyring\|kwalletd5' | grep -v grep`: [Required for secure store error]
|
||||||
|
- Is remote SSH? [Yes/No]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
@@ -1,5 +1,30 @@
|
|||||||
name: Build GPGUI
|
name: Build
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
gp_branch:
|
||||||
|
description: 'GlobalProtect-openconnect branch to use for the snapshot release'
|
||||||
|
required: true
|
||||||
|
default: dev
|
||||||
|
gpgui_branch:
|
||||||
|
description: 'gpgui branch to use for the snapshot release'
|
||||||
|
required: true
|
||||||
|
default: dev
|
||||||
|
build_macos:
|
||||||
|
description: 'Build Apple Silicon artifacts for the snapshot release'
|
||||||
|
required: true
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
build_bsd:
|
||||||
|
description: 'Build FreeBSD/OpenBSD packages for the snapshot release'
|
||||||
|
required: true
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
build_bsd_arm64:
|
||||||
|
description: 'Build optional FreeBSD/OpenBSD arm64 packages for the snapshot release. Slow and disabled by default'
|
||||||
|
required: true
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- LICENSE
|
- LICENSE
|
||||||
@@ -8,109 +33,809 @@ on:
|
|||||||
- .devcontainer
|
- .devcontainer
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
# tags:
|
- hotfix/*
|
||||||
# - v*.*.*
|
- feature/*
|
||||||
|
- release/*
|
||||||
|
tags:
|
||||||
|
- v*.*.*
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && 'release' || github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Include arm64 if ref is a tag
|
test-gp:
|
||||||
setup-matrix:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
||||||
steps:
|
|
||||||
- name: Set up matrix
|
|
||||||
id: set-matrix
|
|
||||||
run: |
|
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
||||||
echo "matrix=[\"amd64\", \"arm64\"]" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "matrix=[\"amd64\"]" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
build-fe:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout gpgui repo
|
- name: Checkout GlobalProtect-openconnect
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
repository: yuezk/gpgui
|
|
||||||
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
with:
|
|
||||||
version: 8
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
cd app
|
|
||||||
pnpm install
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
cd app
|
|
||||||
pnpm run build
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: gpgui-fe
|
|
||||||
path: app/dist
|
|
||||||
|
|
||||||
build-tauri:
|
|
||||||
needs: [setup-matrix, build-fe]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
arch: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout gpgui repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
repository: yuezk/gpgui
|
|
||||||
path: gpgui
|
|
||||||
|
|
||||||
- name: Checkout gp repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GH_PAT }}
|
token: ${{ secrets.GH_PAT }}
|
||||||
repository: yuezk/GlobalProtect-openconnect
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
path: gp
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
submodules: recursive
|
||||||
|
- name: Run Rust tests in Docker
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
--user root \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-e LIBXML2_STATIC=1 \
|
||||||
|
-e PKEXEC_UID=1000 \
|
||||||
|
-v "$(pwd):/workspace" \
|
||||||
|
-w /workspace \
|
||||||
|
yuezk/gpdev:binary-builder-tauri2 \
|
||||||
|
cargo test --workspace
|
||||||
|
|
||||||
- name: Download gpgui-fe artifact
|
tarball:
|
||||||
uses: actions/download-artifact@v4
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: pnpm/action-setup@v5
|
||||||
with:
|
with:
|
||||||
name: gpgui-fe
|
version: 9
|
||||||
path: gpgui/app/dist
|
- name: Prepare workspace
|
||||||
|
run: rm -rf source && mkdir -p source/artifacts
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Checkout GlobalProtect-openconnect
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
platforms: ${{ matrix.arch }}
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
path: source/gp
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Create tarball
|
||||||
|
run: |
|
||||||
|
cd source/gp
|
||||||
|
# Generate the SNAPSHOT file for non-tagged commits
|
||||||
|
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
|
||||||
|
touch SNAPSHOT
|
||||||
|
fi
|
||||||
|
make tarball
|
||||||
|
|
||||||
|
mv -v .build/tarball/*.tar.gz ../artifacts/
|
||||||
|
|
||||||
|
- name: Generate RPM spec file
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
cd source/gp
|
||||||
|
|
||||||
|
make init-rpm \
|
||||||
|
REVISION='1%{?dist}' \
|
||||||
|
RPM_SOURCE=https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${RELEASE_TAG}/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
|
mv -v .build/rpm/*.spec ../artifacts/
|
||||||
|
|
||||||
|
- name: Upload tarball
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: artifact-source
|
||||||
|
if-no-files-found: error
|
||||||
|
path: |
|
||||||
|
source/artifacts/*
|
||||||
|
|
||||||
|
tarball-offline:
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- tarball
|
||||||
|
steps:
|
||||||
|
- uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 9
|
||||||
|
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf source-offline && mkdir source-offline
|
||||||
|
|
||||||
|
- name: Download tarball
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: artifact-source
|
||||||
|
path: source-offline
|
||||||
|
|
||||||
|
- name: Create offline tarball
|
||||||
|
run: |
|
||||||
|
cd source-offline
|
||||||
|
|
||||||
|
offline_tarball=$(basename *.tar.gz .tar.gz).offline.tar.gz
|
||||||
|
|
||||||
|
# Extract the tarball
|
||||||
|
tar -xzf *.tar.gz
|
||||||
|
|
||||||
|
cd */
|
||||||
|
make tarball OFFLINE=1
|
||||||
|
|
||||||
|
# Rename the tarball to .offline.tar.gz
|
||||||
|
mv -v .build/tarball/*.tar.gz ../$offline_tarball
|
||||||
|
|
||||||
|
- name: Upload offline tarball
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
path: source-offline/*.offline.tar.gz
|
||||||
|
name: artifact-source-offline
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
build-gp:
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
needs:
|
||||||
|
- tarball
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
arch: amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
arch: ubuntu-24.04-arm
|
||||||
|
package: [deb, rpm, pkg, apk, binary, ubuntu-rolling]
|
||||||
|
runs-on: ${{ matrix.os.runner }}
|
||||||
|
name: build-gp (${{ matrix.package }}, ${{ matrix.os.arch }})
|
||||||
|
steps:
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: |
|
||||||
|
rm -rf build-gp-${{ matrix.package }}
|
||||||
|
mkdir -p build-gp-${{ matrix.package }}
|
||||||
|
- name: Download tarball
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: artifact-source
|
||||||
|
path: build-gp-${{ matrix.package }}
|
||||||
|
- name: Build ${{ matrix.package }} package in Docker
|
||||||
|
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-e LIBXML2_STATIC=1 \
|
||||||
|
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
||||||
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||||
|
- name: Install ${{ matrix.package }} package in Docker
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-e GPGUI_INSTALLED=0 \
|
||||||
|
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
||||||
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||||
|
bash install.sh
|
||||||
|
# Don't upload package for ubuntu-rolling because it's duplicate of deb package
|
||||||
|
- name: Upload ${{ matrix.package }} package
|
||||||
|
if: ${{ matrix.package != 'ubuntu-rolling' }}
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: artifact-gp-${{ matrix.package }}-${{ matrix.os.arch }}
|
||||||
|
if-no-files-found: error
|
||||||
|
path: |
|
||||||
|
build-gp-${{ matrix.package }}/artifacts/*
|
||||||
|
|
||||||
|
build-docker-image:
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
platform: linux/amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
platform: linux/arm64
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
submodules: recursive
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Build and push by digest
|
||||||
- name: Build Tauri in Docker
|
id: build
|
||||||
run: |
|
uses: docker/build-push-action@v7
|
||||||
docker run \
|
|
||||||
--rm \
|
|
||||||
-v $(pwd):/${{ github.workspace }} \
|
|
||||||
-w ${{ github.workspace }} \
|
|
||||||
-e CI=true \
|
|
||||||
--platform linux/${{ matrix.arch }} \
|
|
||||||
yuezk/gpdev:main \
|
|
||||||
"./gpgui/scripts/build.sh"
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: artifact-${{ matrix.arch }}-tauri
|
context: .
|
||||||
|
file: packaging/docker/alpine/Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
- name: Verify CLI tools
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
DIGEST: ${{ steps.build.outputs.digest }}
|
||||||
|
run: |
|
||||||
|
docker run --rm "$IMAGE@$DIGEST" --help
|
||||||
|
docker run --rm --entrypoint gpauth "$IMAGE@$DIGEST" --help
|
||||||
|
docker run --rm --entrypoint sh "$IMAGE@$DIGEST" -lc 'test "$(id -u gp)" = "1000" && test "$SUDO_UID" = "1000"'
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
build-gpgui:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
arch: amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
arch: ubuntu-24.04-arm
|
||||||
|
libc:
|
||||||
|
- name: glibc
|
||||||
|
builder: gpgui-builder-tauri2
|
||||||
|
artifact_suffix: ""
|
||||||
|
- name: musl
|
||||||
|
builder: gpgui-alpine-builder-tauri2
|
||||||
|
artifact_suffix: "-musl"
|
||||||
|
runs-on: ${{ matrix.os.runner }}
|
||||||
|
name: build-gpgui (${{ matrix.libc.name }}, ${{ matrix.os.arch }})
|
||||||
|
steps:
|
||||||
|
- uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 9
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf gpgui-source && mkdir gpgui-source
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
path: gpgui-source/gp
|
||||||
|
submodules: recursive
|
||||||
|
- name: Checkout gpgui
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/gpgui
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||||
|
path: gpgui-source/gpgui
|
||||||
|
- name: Verify Linux desktop assets
|
||||||
|
if: matrix.os.arch == 'amd64' && matrix.libc.name == 'glibc'
|
||||||
|
run: gpgui-source/gp/scripts/verify-linux-desktop-assets.sh gpgui-source/gpgui
|
||||||
|
- name: Tarball
|
||||||
|
run: |
|
||||||
|
cd gpgui-source
|
||||||
|
tar -czf gpgui.tar.gz gpgui gp
|
||||||
|
- name: Build gpgui in Docker
|
||||||
|
env:
|
||||||
|
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-e GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }} \
|
||||||
|
-e GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }} \
|
||||||
|
-e GPGUI_LICENSE_SIGNING_KEYS \
|
||||||
|
-v $(pwd)/gpgui-source:/workspace yuezk/gpdev:${{ matrix.libc.builder }}
|
||||||
|
- name: Install gpgui in Docker
|
||||||
|
run: |
|
||||||
|
cd gpgui-source
|
||||||
|
tar -xJf *.bin.tar.xz
|
||||||
|
docker run --rm \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-v $(pwd):/workspace yuezk/gpdev:${{ matrix.libc.builder }} \
|
||||||
|
bash -c "cd /workspace/gpgui_*/ && ./gpgui --version"
|
||||||
|
- name: Upload gpgui
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: artifact-gpgui${{ matrix.libc.artifact_suffix }}-${{ matrix.os.arch }}
|
||||||
|
if-no-files-found: error
|
||||||
path: |
|
path: |
|
||||||
gpgui/.tmp/artifact
|
gpgui-source/*.bin.tar.xz
|
||||||
|
gpgui-source/*.bin.tar.xz.sha256
|
||||||
|
|
||||||
|
trigger-gpgui-macos:
|
||||||
|
if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_macos) }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: trigger private macOS release
|
||||||
|
outputs:
|
||||||
|
run_id: ${{ steps.dispatch.outputs.run_id }}
|
||||||
|
run_url: ${{ steps.dispatch.outputs.run_url }}
|
||||||
|
steps:
|
||||||
|
- name: Dispatch private macOS release
|
||||||
|
id: dispatch
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
|
||||||
|
PUBLIC_GH_TOKEN: ${{ github.token }}
|
||||||
|
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }}
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
|
GP_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref_name }}
|
||||||
|
GPGUI_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||||
|
BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
|
||||||
|
REQUEST_ID: ${{ github.run_id }}.${{ github.run_attempt }}.macos
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ -z "${GH_TOKEN:-}" ]]; then
|
||||||
|
echo "GPGUI_ACTIONS_TOKEN is not configured" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gp_ref_path="$(jq -rn --arg ref "$GP_REF" '$ref | @uri')"
|
||||||
|
gpgui_ref_path="$(jq -rn --arg ref "$GPGUI_REF" '$ref | @uri')"
|
||||||
|
gp_sha="$(GH_TOKEN="$PUBLIC_GH_TOKEN" gh api \
|
||||||
|
"repos/yuezk/GlobalProtect-openconnect/commits/$gp_ref_path" --jq .sha)"
|
||||||
|
gpgui_sha="$(gh api "repos/yuezk/gpgui/commits/$gpgui_ref_path" --jq .sha)"
|
||||||
|
if [[ -z "$gp_sha" || -z "$gpgui_sha" ]]; then
|
||||||
|
echo "Could not resolve release source refs" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
expected_title="macOS $CHANNEL $RELEASE_TAG ($REQUEST_ID)"
|
||||||
|
jq -n \
|
||||||
|
--arg workflow_ref "$GPGUI_REF" \
|
||||||
|
--arg request_id "$REQUEST_ID" \
|
||||||
|
--arg build_version "$BUILD_VERSION" \
|
||||||
|
--arg channel "$CHANNEL" \
|
||||||
|
--arg release_tag "$RELEASE_TAG" \
|
||||||
|
--arg gp_ref "$gp_sha" \
|
||||||
|
--arg gpgui_ref "$gpgui_sha" \
|
||||||
|
'{
|
||||||
|
ref: $workflow_ref,
|
||||||
|
inputs: {
|
||||||
|
request_id: $request_id,
|
||||||
|
build_version: $build_version,
|
||||||
|
channel: $channel,
|
||||||
|
release_tag: $release_tag,
|
||||||
|
gp_ref: $gp_ref,
|
||||||
|
gpgui_ref: $gpgui_ref
|
||||||
|
}
|
||||||
|
}' | gh api --method POST \
|
||||||
|
repos/yuezk/gpgui/actions/workflows/release-macos.yaml/dispatches \
|
||||||
|
--input -
|
||||||
|
|
||||||
|
run_id=""
|
||||||
|
run_url=""
|
||||||
|
for _ in {1..40}; do
|
||||||
|
runs="$(gh api \
|
||||||
|
'repos/yuezk/gpgui/actions/workflows/release-macos.yaml/runs?event=workflow_dispatch&per_page=50')"
|
||||||
|
run_id="$(jq -r --arg title "$expected_title" \
|
||||||
|
'[.workflow_runs[] | select(.display_title == $title)] | first | .id // empty' \
|
||||||
|
<<<"$runs")"
|
||||||
|
run_url="$(jq -r --arg title "$expected_title" \
|
||||||
|
'[.workflow_runs[] | select(.display_title == $title)] | first | .html_url // empty' \
|
||||||
|
<<<"$runs")"
|
||||||
|
if [[ -n "$run_id" ]]; then
|
||||||
|
{
|
||||||
|
echo "run_id=$run_id"
|
||||||
|
echo "run_url=$run_url"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Triggered private workflow: $run_url"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Could not locate the dispatched private workflow run" >&2
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
setup-bsd-matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
enabled: ${{ steps.matrix.outputs.enabled }}
|
||||||
|
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- name: Build matrix
|
||||||
|
id: matrix
|
||||||
|
env:
|
||||||
|
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
BUILD_BSD: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd }}
|
||||||
|
BUILD_BSD_ARM64: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd_arm64 }}
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
build_bsd = os.environ["IS_TAG"] == "true" or os.environ["BUILD_BSD"] == "true"
|
||||||
|
build_bsd_arm64 = os.environ["BUILD_BSD_ARM64"] == "true"
|
||||||
|
include = []
|
||||||
|
|
||||||
|
def add(os_name, arch):
|
||||||
|
include.append({
|
||||||
|
"os": os_name,
|
||||||
|
"arch": arch,
|
||||||
|
"workspace": f"{os_name}-{arch}-source",
|
||||||
|
"artifact": f"artifact-bsd-{os_name}-{arch}",
|
||||||
|
"package_target": f"package-{os_name}",
|
||||||
|
"artifact_dir": os_name,
|
||||||
|
})
|
||||||
|
|
||||||
|
if build_bsd:
|
||||||
|
add("freebsd", "x86_64")
|
||||||
|
add("openbsd", "x86_64")
|
||||||
|
if build_bsd_arm64:
|
||||||
|
add("freebsd", "arm64")
|
||||||
|
add("openbsd", "arm64")
|
||||||
|
|
||||||
|
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
|
||||||
|
output.write(f"enabled={str(bool(include)).lower()}\n")
|
||||||
|
output.write(f"matrix={json.dumps({'include': include}, separators=(',', ':'))}\n")
|
||||||
|
PY
|
||||||
|
|
||||||
|
build-gpgui-frontend:
|
||||||
|
needs: setup-bsd-matrix
|
||||||
|
if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: pnpm/action-setup@v5
|
||||||
|
with:
|
||||||
|
version: 9
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf gpgui-frontend && mkdir gpgui-frontend
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
path: gpgui-frontend/gp
|
||||||
|
submodules: recursive
|
||||||
|
- name: Checkout gpgui
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/gpgui
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||||
|
path: gpgui-frontend/gpgui
|
||||||
|
- name: Build gpgui frontend
|
||||||
|
run: |
|
||||||
|
cd gpgui-frontend/gpgui/apps/desktop
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
pnpm build
|
||||||
|
- name: Upload gpgui frontend
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: bsd-gpgui-frontend
|
||||||
|
if-no-files-found: error
|
||||||
|
path: gpgui-frontend/gpgui/apps/desktop/dist/**
|
||||||
|
|
||||||
|
build-bsd:
|
||||||
|
needs:
|
||||||
|
- setup-bsd-matrix
|
||||||
|
- build-gpgui-frontend
|
||||||
|
if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: build-${{ matrix.os }} (${{ matrix.arch }})
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix: ${{ fromJson(needs.setup-bsd-matrix.outputs.matrix) }}
|
||||||
|
steps:
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf "${{ matrix.workspace }}" && mkdir "${{ matrix.workspace }}"
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
path: ${{ matrix.workspace }}/gp
|
||||||
|
submodules: recursive
|
||||||
|
- name: Checkout gpgui
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/gpgui
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||||
|
path: ${{ matrix.workspace }}/gpgui
|
||||||
|
- name: Download gpgui frontend
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: bsd-gpgui-frontend
|
||||||
|
path: ${{ matrix.workspace }}/gpgui/apps/desktop/dist
|
||||||
|
- name: Build on FreeBSD
|
||||||
|
if: ${{ matrix.os == 'freebsd' }}
|
||||||
|
uses: vmactions/freebsd-vm@v1
|
||||||
|
with:
|
||||||
|
release: "14.4"
|
||||||
|
arch: ${{ matrix.arch }}
|
||||||
|
usesh: true
|
||||||
|
prepare: |
|
||||||
|
pkg install -y \
|
||||||
|
git \
|
||||||
|
rust \
|
||||||
|
libiconv \
|
||||||
|
gettext-tools \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
libtool \
|
||||||
|
patch \
|
||||||
|
gmake \
|
||||||
|
pkgconf \
|
||||||
|
libxml2 \
|
||||||
|
gnutls \
|
||||||
|
p11-kit \
|
||||||
|
nettle \
|
||||||
|
gmp \
|
||||||
|
gnome-keyring \
|
||||||
|
libayatana-appindicator \
|
||||||
|
polkit \
|
||||||
|
webkit2-gtk_41
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
|
||||||
|
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }}
|
||||||
|
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
||||||
|
|
||||||
|
cd "${{ matrix.workspace }}/gp"
|
||||||
|
cargo build --release --workspace
|
||||||
|
|
||||||
|
cd ../gpgui/apps/desktop/src-tauri
|
||||||
|
cargo build --release --workspace
|
||||||
|
|
||||||
|
cd ../../../../gp
|
||||||
|
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
|
||||||
|
pkg install -y ".build/${{ matrix.artifact_dir }}"/artifacts/*.pkg
|
||||||
|
gpclient --version
|
||||||
|
gpauth --version
|
||||||
|
gpgui --version
|
||||||
|
rm -rf target ../gpgui/target
|
||||||
|
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
|
||||||
|
- name: Build on OpenBSD
|
||||||
|
if: ${{ matrix.os == 'openbsd' }}
|
||||||
|
uses: vmactions/openbsd-vm@v1
|
||||||
|
with:
|
||||||
|
release: "7.9"
|
||||||
|
arch: ${{ matrix.arch }}
|
||||||
|
usesh: true
|
||||||
|
prepare: |
|
||||||
|
set -eu
|
||||||
|
pkg_add -u -I
|
||||||
|
pkg_add -I \
|
||||||
|
git \
|
||||||
|
rust \
|
||||||
|
libiconv \
|
||||||
|
gettext-tools \
|
||||||
|
autoconf%2.72 \
|
||||||
|
automake%1.17 \
|
||||||
|
libtool \
|
||||||
|
gmake \
|
||||||
|
libxml \
|
||||||
|
gnutls \
|
||||||
|
p11-kit \
|
||||||
|
gmp \
|
||||||
|
lz4 \
|
||||||
|
dbus \
|
||||||
|
gnome-keyring \
|
||||||
|
polkit \
|
||||||
|
webkitgtk41 \
|
||||||
|
xdg-utils
|
||||||
|
ln -sf /usr/local/bin/autoreconf-2.72 /usr/local/bin/autoreconf
|
||||||
|
ln -sf /usr/local/bin/autoconf-2.72 /usr/local/bin/autoconf
|
||||||
|
ln -sf /usr/local/bin/autoheader-2.72 /usr/local/bin/autoheader
|
||||||
|
ln -sf /usr/local/bin/autom4te-2.72 /usr/local/bin/autom4te
|
||||||
|
ln -sf /usr/local/bin/aclocal-1.17 /usr/local/bin/aclocal
|
||||||
|
ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
export AUTOCONF_VERSION=2.72
|
||||||
|
export AUTOMAKE_VERSION=1.17
|
||||||
|
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
|
||||||
|
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && 'snapshot' || 'stable' }}
|
||||||
|
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
||||||
|
|
||||||
|
cd "${{ matrix.workspace }}/gp"
|
||||||
|
cargo build --release --workspace
|
||||||
|
|
||||||
|
cd ../gpgui/apps/desktop/src-tauri
|
||||||
|
cargo build --release --workspace
|
||||||
|
|
||||||
|
cd ../../../../gp
|
||||||
|
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
|
||||||
|
pkg_add -D unsigned ".build/${{ matrix.artifact_dir }}"/artifacts/*.tgz
|
||||||
|
gpclient --version
|
||||||
|
gpauth --version
|
||||||
|
gpgui --version
|
||||||
|
rm -rf target ../gpgui/target
|
||||||
|
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
|
||||||
|
- name: Upload BSD package
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.artifact }}
|
||||||
|
if-no-files-found: error
|
||||||
|
path: |
|
||||||
|
${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/*
|
||||||
|
|
||||||
|
gh-release:
|
||||||
|
if: ${{ always() && (github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')) }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
attestations: write
|
||||||
|
artifact-metadata: write
|
||||||
|
needs:
|
||||||
|
- tarball
|
||||||
|
- tarball-offline
|
||||||
|
- build-gp
|
||||||
|
- build-docker-image
|
||||||
|
- build-gpgui
|
||||||
|
- setup-bsd-matrix
|
||||||
|
- build-gpgui-frontend
|
||||||
|
- build-bsd
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check required jobs
|
||||||
|
env:
|
||||||
|
NEEDS_JSON: ${{ toJson(needs) }}
|
||||||
|
BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }}
|
||||||
|
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
needs = json.loads(os.environ["NEEDS_JSON"])
|
||||||
|
bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true"
|
||||||
|
is_tag = os.environ["IS_TAG"] == "true"
|
||||||
|
failed = []
|
||||||
|
|
||||||
|
for name, data in needs.items():
|
||||||
|
result = data["result"]
|
||||||
|
if result in {"failure", "cancelled"}:
|
||||||
|
failed.append(f"{name}: {result}")
|
||||||
|
elif name in {"build-gp", "build-docker-image"} and result == "skipped" and is_tag:
|
||||||
|
continue
|
||||||
|
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
|
||||||
|
continue
|
||||||
|
elif result == "skipped":
|
||||||
|
failed.append(f"{name}: {result}")
|
||||||
|
|
||||||
|
if failed:
|
||||||
|
print("Required jobs did not complete successfully:")
|
||||||
|
for item in failed:
|
||||||
|
print(f" - {item}")
|
||||||
|
sys.exit(1)
|
||||||
|
PY
|
||||||
|
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf gh-release && mkdir gh-release
|
||||||
|
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
path: gh-release/gp
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: gh-release/gp/.build/artifacts
|
||||||
|
|
||||||
|
- name: Rename APK artifacts
|
||||||
|
run: |
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
for file in gh-release/gp/.build/artifacts/artifact-gp-apk-amd64/*.apk; do
|
||||||
|
mv "$file" "${file%.apk}-x86_64.apk"
|
||||||
|
done
|
||||||
|
for file in gh-release/gp/.build/artifacts/artifact-gp-apk-ubuntu-24.04-arm/*.apk; do
|
||||||
|
mv "$file" "${file%.apk}-aarch64.apk"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Generate release asset checksums
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
cd gh-release/gp
|
||||||
|
mkdir -p .build
|
||||||
|
scripts/release-assets.sh "$RELEASE_TAG" > .build/release-assets.txt
|
||||||
|
if [ ! -s .build/release-assets.txt ]; then
|
||||||
|
echo "No release assets found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
while IFS= read -r file; do
|
||||||
|
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
|
||||||
|
printf '%s %s\n' "$digest" "$(basename "$file")"
|
||||||
|
done < .build/release-assets.txt > .build/release-assets.sha256
|
||||||
|
|
||||||
|
- name: Attest release assets
|
||||||
|
uses: actions/attest-build-provenance@v4
|
||||||
|
with:
|
||||||
|
subject-checksums: gh-release/gp/.build/release-assets.sha256
|
||||||
|
|
||||||
|
- name: Create GH release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
||||||
|
|
||||||
|
wait-gpgui-macos:
|
||||||
|
if: ${{ always() && needs.trigger-gpgui-macos.result != 'skipped' }}
|
||||||
|
needs:
|
||||||
|
- gh-release
|
||||||
|
- trigger-gpgui-macos
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 130
|
||||||
|
steps:
|
||||||
|
- name: Wait for private macOS release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
|
||||||
|
PUBLIC_RELEASE_RESULT: ${{ needs.gh-release.result }}
|
||||||
|
PRIVATE_RUN_ID: ${{ needs.trigger-gpgui-macos.outputs.run_id }}
|
||||||
|
PRIVATE_RUN_URL: ${{ needs.trigger-gpgui-macos.outputs.run_url }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ -z "$PRIVATE_RUN_ID" ]]; then
|
||||||
|
echo "The private macOS workflow was not started" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$PUBLIC_RELEASE_RESULT" != "success" ]]; then
|
||||||
|
gh api --method POST \
|
||||||
|
"repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID/cancel" >/dev/null || true
|
||||||
|
echo "The public release failed; cancelled $PRIVATE_RUN_URL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for _ in $(seq 1 480); do
|
||||||
|
run="$(gh api "repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID")"
|
||||||
|
status="$(jq -r '.status' <<<"$run")"
|
||||||
|
conclusion="$(jq -r '.conclusion // ""' <<<"$run")"
|
||||||
|
if [[ "$status" == "completed" ]]; then
|
||||||
|
echo "Private macOS workflow completed: $PRIVATE_RUN_URL"
|
||||||
|
if [[ "$conclusion" != "success" ]]; then
|
||||||
|
echo "Private macOS workflow concluded with: $conclusion" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 15
|
||||||
|
done
|
||||||
|
|
||||||
|
gh api --method POST \
|
||||||
|
"repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID/cancel" >/dev/null || true
|
||||||
|
echo "Private macOS workflow timed out: $PRIVATE_RUN_URL" >&2
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
publish-docker-image:
|
||||||
|
needs:
|
||||||
|
- build-docker-image
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Publish Docker manifest
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create -t "$IMAGE:$RELEASE_TAG" \
|
||||||
|
$(printf "$IMAGE@sha256:%s " *)
|
||||||
|
|
||||||
|
docker buildx imagetools inspect "$IMAGE:$RELEASE_TAG"
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
name: Nix
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "flake.nix"
|
||||||
|
- "flake.lock"
|
||||||
|
- "nix/**"
|
||||||
|
- ".github/workflows/nix.yaml"
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "flake.nix"
|
||||||
|
- "flake.lock"
|
||||||
|
- "nix/**"
|
||||||
|
- ".github/workflows/nix.yaml"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
standalone-package:
|
||||||
|
name: standalone-package (${{ matrix.platform.system }})
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
system: x86_64-linux
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
system: aarch64-linux
|
||||||
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Build standalone prebuilt package
|
||||||
|
run: |
|
||||||
|
nix build .#prebuilt \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--print-build-logs
|
||||||
|
|
||||||
|
- name: Inspect prebuilt package
|
||||||
|
run: |
|
||||||
|
test -x result/bin/gpclient
|
||||||
|
test -x result/bin/gpauth
|
||||||
|
test -x result/bin/gpservice
|
||||||
|
test -x result/bin/gpgui-helper
|
||||||
|
test -x result/bin/gpgui
|
||||||
|
|
||||||
|
nixos-module:
|
||||||
|
name: nixos-module (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
system: x86_64-linux
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
system: aarch64-linux
|
||||||
|
nixpkgs:
|
||||||
|
- nixos-25.11
|
||||||
|
- nixos-26.05
|
||||||
|
- nixpkgs-unstable
|
||||||
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Build package through host NixOS module
|
||||||
|
env:
|
||||||
|
NIXPKGS_URL: github:NixOS/nixpkgs/${{ matrix.nixpkgs }}
|
||||||
|
NIX_SYSTEM: ${{ matrix.platform.system }}
|
||||||
|
run: |
|
||||||
|
nix build \
|
||||||
|
--impure \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--print-build-logs \
|
||||||
|
--expr '
|
||||||
|
let
|
||||||
|
gp = builtins.getFlake (toString ./.);
|
||||||
|
hostNixpkgs =
|
||||||
|
builtins.getFlake (builtins.getEnv "NIXPKGS_URL");
|
||||||
|
|
||||||
|
hostSystem = hostNixpkgs.lib.nixosSystem {
|
||||||
|
system = builtins.getEnv "NIX_SYSTEM";
|
||||||
|
modules = [
|
||||||
|
gp.nixosModules.default
|
||||||
|
{
|
||||||
|
programs.globalprotect-openconnect.enable = true;
|
||||||
|
system.stateVersion = "25.11";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
package =
|
||||||
|
hostSystem.config.programs.globalprotect-openconnect.package;
|
||||||
|
in
|
||||||
|
assert builtins.elem package
|
||||||
|
hostSystem.config.environment.systemPackages;
|
||||||
|
assert hostSystem.config.services.ayatana-indicators.enable;
|
||||||
|
package
|
||||||
|
'
|
||||||
|
|
||||||
|
- name: Inspect module package
|
||||||
|
run: |
|
||||||
|
test -x result/bin/gpclient
|
||||||
|
test -x result/bin/gpauth
|
||||||
|
test -x result/bin/gpservice
|
||||||
|
test -x result/bin/gpgui-helper
|
||||||
|
test -x result/bin/gpgui
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
name: Publish AUR git package
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
build-package:
|
||||||
|
type: boolean
|
||||||
|
description: "Build the package before publishing"
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
publish:
|
||||||
|
type: boolean
|
||||||
|
description: "Push PKGBUILD, .SRCINFO, and gp.install to AUR"
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- packaging/aur/globalprotect-openconnect-git/**
|
||||||
|
- .github/workflows/publish-aur-git.yaml
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
name: Validate AUR package
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: archlinux:base-devel
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
AUR_PACKAGE_DIR: packaging/aur/globalprotect-openconnect-git
|
||||||
|
steps:
|
||||||
|
- name: Install checkout tools
|
||||||
|
run: pacman -Syu --noconfirm --needed git openssh
|
||||||
|
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install build tools
|
||||||
|
run: |
|
||||||
|
pacman -Syu --noconfirm --needed \
|
||||||
|
appmenu-gtk-module \
|
||||||
|
cargo \
|
||||||
|
curl \
|
||||||
|
desktop-file-utils \
|
||||||
|
file \
|
||||||
|
git \
|
||||||
|
libappindicator-gtk3 \
|
||||||
|
libsecret \
|
||||||
|
libxml2 \
|
||||||
|
namcap \
|
||||||
|
openconnect \
|
||||||
|
openssl \
|
||||||
|
pkgconf \
|
||||||
|
librsvg \
|
||||||
|
shared-mime-info \
|
||||||
|
vpnc \
|
||||||
|
wget \
|
||||||
|
webkit2gtk-4.1
|
||||||
|
|
||||||
|
- name: Save committed .SRCINFO
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
run: cp "$AUR_PACKAGE_DIR/.SRCINFO" /tmp/committed.SRCINFO
|
||||||
|
|
||||||
|
- name: Prepare build user
|
||||||
|
run: |
|
||||||
|
useradd -m builder
|
||||||
|
chown -R builder:builder "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
- name: Refresh VCS package version
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
run: |
|
||||||
|
cd "$AUR_PACKAGE_DIR"
|
||||||
|
runuser -u builder -- makepkg --nobuild --noconfirm --cleanbuild
|
||||||
|
|
||||||
|
- name: Regenerate .SRCINFO
|
||||||
|
run: |
|
||||||
|
cd "$AUR_PACKAGE_DIR"
|
||||||
|
runuser -u builder -- makepkg --printsrcinfo > .SRCINFO
|
||||||
|
|
||||||
|
- name: Check committed .SRCINFO
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
run: |
|
||||||
|
cmp -s /tmp/committed.SRCINFO "$AUR_PACKAGE_DIR/.SRCINFO" || {
|
||||||
|
diff -u /tmp/committed.SRCINFO "$AUR_PACKAGE_DIR/.SRCINFO"
|
||||||
|
echo ".SRCINFO is out of date. Regenerate it with makepkg --printsrcinfo." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Run namcap
|
||||||
|
run: |
|
||||||
|
cd "$AUR_PACKAGE_DIR"
|
||||||
|
runuser -u builder -- namcap PKGBUILD
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs['build-package'] }}
|
||||||
|
run: |
|
||||||
|
cd "$AUR_PACKAGE_DIR"
|
||||||
|
runuser -u builder -- makepkg --noconfirm --clean --cleanbuild
|
||||||
|
|
||||||
|
- name: Upload AUR package metadata
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }}
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: aur-package-metadata
|
||||||
|
path: |
|
||||||
|
${{ env.AUR_PACKAGE_DIR }}/PKGBUILD
|
||||||
|
${{ env.AUR_PACKAGE_DIR }}/.SRCINFO
|
||||||
|
${{ env.AUR_PACKAGE_DIR }}/gp.install
|
||||||
|
if-no-files-found: error
|
||||||
|
include-hidden-files: true
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
|
publish:
|
||||||
|
name: Publish to AUR
|
||||||
|
needs: validate
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: archlinux:base-devel
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
AUR_PACKAGE_DIR: /tmp/aur-package
|
||||||
|
AUR_REPO: ssh://[email protected]/globalprotect-openconnect-git.git
|
||||||
|
steps:
|
||||||
|
- name: Install publish tools
|
||||||
|
run: pacman -Syu --noconfirm --needed git openssh
|
||||||
|
|
||||||
|
- name: Download AUR package metadata
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: aur-package-metadata
|
||||||
|
path: ${{ env.AUR_PACKAGE_DIR }}
|
||||||
|
|
||||||
|
- name: Configure SSH
|
||||||
|
env:
|
||||||
|
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||||
|
run: |
|
||||||
|
if [[ -z "$AUR_SSH_PRIVATE_KEY" ]]; then
|
||||||
|
echo "AUR_SSH_PRIVATE_KEY is required to publish to AUR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -d -m 700 ~/.ssh
|
||||||
|
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
|
||||||
|
chmod 600 ~/.ssh/aur
|
||||||
|
ssh-keyscan -t rsa,ecdsa,ed25519 aur.archlinux.org > ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Publish to AUR
|
||||||
|
env:
|
||||||
|
GIT_SSH_COMMAND: ssh -i /github/home/.ssh/aur -o UserKnownHostsFile=/github/home/.ssh/known_hosts -o StrictHostKeyChecking=yes
|
||||||
|
run: |
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
git clone "$AUR_REPO" "$workdir/aur"
|
||||||
|
|
||||||
|
cp "$AUR_PACKAGE_DIR"/PKGBUILD "$workdir/aur/PKGBUILD"
|
||||||
|
cp "$AUR_PACKAGE_DIR"/.SRCINFO "$workdir/aur/.SRCINFO"
|
||||||
|
cp "$AUR_PACKAGE_DIR"/gp.install "$workdir/aur/gp.install"
|
||||||
|
|
||||||
|
cd "$workdir/aur"
|
||||||
|
if git diff --quiet; then
|
||||||
|
echo "AUR package is already up to date"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add PKGBUILD .SRCINFO gp.install
|
||||||
|
git commit -m "Update globalprotect-openconnect-git"
|
||||||
|
git push origin master
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
name: Publish COPR
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag to publish'
|
||||||
|
required: true
|
||||||
|
revision:
|
||||||
|
description: 'Package revision'
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
default: "1"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-copr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: fedora:latest
|
||||||
|
steps:
|
||||||
|
- name: Install tools
|
||||||
|
run: dnf install -y copr-cli gh
|
||||||
|
|
||||||
|
- name: Check inputs
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: |
|
||||||
|
if [[ ! "$REVISION" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
|
echo "Revision must be a positive integer" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh api "repos/${{ github.repository }}/git/ref/tags/$TAG" >/dev/null
|
||||||
|
|
||||||
|
- name: Download published spec
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
run: |
|
||||||
|
mkdir -p publish-copr
|
||||||
|
|
||||||
|
gh release download "$TAG" \
|
||||||
|
--repo "${{ github.repository }}" \
|
||||||
|
--pattern globalprotect-openconnect.spec \
|
||||||
|
--dir publish-copr
|
||||||
|
|
||||||
|
- name: Set package revision
|
||||||
|
env:
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: |
|
||||||
|
spec=publish-copr/globalprotect-openconnect.spec
|
||||||
|
|
||||||
|
if [[ "$(grep -c '^Release:' "$spec")" -ne 1 ]]; then
|
||||||
|
echo "Expected exactly one Release field in $spec" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -Ei \
|
||||||
|
"s/^Release:[[:space:]]+.*/Release: ${REVISION}%{?dist}/" \
|
||||||
|
"$spec"
|
||||||
|
|
||||||
|
grep '^Release:' "$spec"
|
||||||
|
|
||||||
|
- name: Configure COPR authentication
|
||||||
|
env:
|
||||||
|
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
|
||||||
|
run: |
|
||||||
|
install -d -m 700 "$HOME/.config"
|
||||||
|
printf '%s\n' "$COPR_CONFIG" > "$HOME/.config/copr"
|
||||||
|
chmod 600 "$HOME/.config/copr"
|
||||||
|
|
||||||
|
- name: Build and publish COPR package
|
||||||
|
run: |
|
||||||
|
copr-cli build \
|
||||||
|
yuezk/globalprotect-openconnect \
|
||||||
|
publish-copr/globalprotect-openconnect.spec
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
name: Publish OBS
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag to publish'
|
||||||
|
required: true
|
||||||
|
revision:
|
||||||
|
description: 'Package revision'
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
default: "1"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-obs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check inputs
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: |
|
||||||
|
if [[ ! "$REVISION" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
|
echo "Revision must be a positive integer" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh api "repos/${{ github.repository }}/git/ref/tags/$TAG" >/dev/null
|
||||||
|
|
||||||
|
- name: Prepare OBS package
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: |
|
||||||
|
version="${TAG#v}"
|
||||||
|
archive="globalprotect-openconnect-${version}.offline.tar.gz"
|
||||||
|
source_dir="publish-obs/source/globalprotect-openconnect-${version}"
|
||||||
|
|
||||||
|
mkdir -p publish-obs/files publish-obs/source
|
||||||
|
|
||||||
|
gh release download "$TAG" \
|
||||||
|
--repo "${{ github.repository }}" \
|
||||||
|
--pattern "$archive" \
|
||||||
|
--dir publish-obs
|
||||||
|
|
||||||
|
tar -xzf "publish-obs/$archive" -C publish-obs/source
|
||||||
|
|
||||||
|
make -C "$source_dir" init-rpm \
|
||||||
|
REVISION="$REVISION" \
|
||||||
|
RPM_SOURCE='%{name}.tar.gz'
|
||||||
|
|
||||||
|
mv "publish-obs/$archive" \
|
||||||
|
publish-obs/files/globalprotect-openconnect.tar.gz
|
||||||
|
cp "$source_dir/.build/rpm/globalprotect-openconnect.spec" \
|
||||||
|
"$source_dir/.build/rpm/globalprotect-openconnect.changes" \
|
||||||
|
publish-obs/files/
|
||||||
|
|
||||||
|
- name: Publish OBS package
|
||||||
|
uses: yuezk/publish-obs-package@main
|
||||||
|
with:
|
||||||
|
project: home:yuezk
|
||||||
|
package: globalprotect-openconnect
|
||||||
|
username: yuezk
|
||||||
|
password: ${{ secrets.OBS_PASSWORD }}
|
||||||
|
files: ./publish-obs/files/*
|
||||||
|
commit_message: 'Release ${{ inputs.tag }}-${{ inputs.revision }}'
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
name: Publish PPA
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag to publish'
|
||||||
|
required: true
|
||||||
|
revision:
|
||||||
|
description: 'Package revision'
|
||||||
|
required: false
|
||||||
|
default: "1"
|
||||||
|
series:
|
||||||
|
description: 'Space-separated Ubuntu series. Leave empty to publish all supported series.'
|
||||||
|
type: "string"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
rust:
|
||||||
|
description: 'Rust version to use'
|
||||||
|
type: "string"
|
||||||
|
required: true
|
||||||
|
default: "1.91"
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check tag exists
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
run: |
|
||||||
|
if ! gh api "repos/${{ github.repository }}/git/ref/tags/$TAG" >/dev/null 2>&1; then
|
||||||
|
echo "Tag $TAG does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
resolve-series:
|
||||||
|
needs: check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.resolve.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- name: Resolve Ubuntu series
|
||||||
|
id: resolve
|
||||||
|
env:
|
||||||
|
INPUT_SERIES: ${{ inputs.series }}
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y distro-info distro-info-data
|
||||||
|
|
||||||
|
if [[ "$INPUT_SERIES" == *","* ]]; then
|
||||||
|
echo "Use space-separated series, for example: jammy noble" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
series=()
|
||||||
|
if [[ -z "${INPUT_SERIES// }" ]]; then
|
||||||
|
while IFS= read -r item; do
|
||||||
|
[[ -n "$item" ]] && series+=("$item")
|
||||||
|
done < <(ubuntu-distro-info --supported)
|
||||||
|
else
|
||||||
|
read -r -a series <<< "$INPUT_SERIES"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${#series[@]}" -eq 0 ]]; then
|
||||||
|
echo "No Ubuntu series resolved" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for item in "${series[@]}"; do
|
||||||
|
ubuntu-distro-info --series "$item" >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
matrix="$(printf '%s\n' "${series[@]}" | jq -R . | jq -s -c '{series: .}')"
|
||||||
|
echo "Resolved matrix: $matrix"
|
||||||
|
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
publish-ppa:
|
||||||
|
needs: [check, resolve-series]
|
||||||
|
name: publish-ppa (${{ matrix.series }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ubuntu:${{ matrix.series }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix: ${{ fromJSON(needs.resolve-series.outputs.matrix) }}
|
||||||
|
steps:
|
||||||
|
- name: Install container tools
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y ca-certificates curl gpg sudo
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
||||||
|
| gpg --dearmor -o /etc/apt/keyrings/githubcli-archive-keyring.gpg
|
||||||
|
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
|
||||||
|
> /etc/apt/sources.list.d/github-cli.list
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gh
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf publish-ppa && mkdir publish-ppa
|
||||||
|
- name: Download ${{ inputs.tag }} offline source code
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
gh -R yuezk/GlobalProtect-openconnect \
|
||||||
|
release download ${{ inputs.tag }} \
|
||||||
|
--pattern '*.offline.tar.gz' \
|
||||||
|
--dir publish-ppa
|
||||||
|
- name: Patch the source code
|
||||||
|
run: |
|
||||||
|
cd publish-ppa
|
||||||
|
|
||||||
|
# Rename the source tarball without the offline suffix
|
||||||
|
mv -v *.tar.gz $(basename *.tar.gz .offline.tar.gz).tar.gz
|
||||||
|
|
||||||
|
# Extract the source tarball
|
||||||
|
tar -xzf *.tar.gz
|
||||||
|
|
||||||
|
# Prepare the debian directory with custom files
|
||||||
|
cd globalprotect-openconnect-*/
|
||||||
|
|
||||||
|
# Prepare the debian directory with custom files
|
||||||
|
mkdir -p .build/debian
|
||||||
|
|
||||||
|
cp -v packaging/deb/control.in .build/debian/control
|
||||||
|
cp -v packaging/deb/rules.in .build/debian/rules
|
||||||
|
cp -v packaging/deb/compat .build/debian/compat
|
||||||
|
cp -v packaging/deb/postrm .build/debian/postrm
|
||||||
|
|
||||||
|
sed -i "s/@BUILD_GUI_HELPER@/1/g" .build/debian/rules
|
||||||
|
sed -i "s/@BUILD_WEBVIEW_AUTH@/1/g" .build/debian/rules
|
||||||
|
|
||||||
|
# Update the control file with the correct Rust version
|
||||||
|
sed -i "s/@RUST_VERSION@/${{ inputs.rust }}/g" .build/debian/control
|
||||||
|
sed -i "s/@RUST_VERSION@/${{ inputs.rust }}/g" .build/debian/rules
|
||||||
|
sed -i "s/DISABLE_RUST_TOOLCHAIN = 0/DISABLE_RUST_TOOLCHAIN = 1/g" .build/debian/rules
|
||||||
|
|
||||||
|
- name: Publish to PPA
|
||||||
|
uses: yuezk/publish-ppa-package@main
|
||||||
|
with:
|
||||||
|
repository: "yuezk/globalprotect-openconnect"
|
||||||
|
gpg_private_key: ${{ secrets.PPA_GPG_PRIVATE_KEY }}
|
||||||
|
gpg_passphrase: ${{ secrets.PPA_GPG_PASSPHRASE }}
|
||||||
|
tarball: publish-ppa/globalprotect-openconnect-*.tar.gz
|
||||||
|
debian_dir: publish-ppa/globalprotect-openconnect-*/.build/debian
|
||||||
|
deb_email: ${{ vars.DEB_EMAIL }}
|
||||||
|
deb_fullname: ${{ vars.DEB_FULLNAME }}
|
||||||
|
extra_ppa: "yuezk/globalprotect-openconnect"
|
||||||
|
series: ${{ matrix.series }}
|
||||||
|
revision: ${{ inputs.revision }}
|
||||||
@@ -0,0 +1,314 @@
|
|||||||
|
name: GH Release Packages
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag to release'
|
||||||
|
required: true
|
||||||
|
arch:
|
||||||
|
type: choice
|
||||||
|
description: 'Architecture to build'
|
||||||
|
required: true
|
||||||
|
default: all
|
||||||
|
options:
|
||||||
|
- all
|
||||||
|
- x86_64
|
||||||
|
- arm64
|
||||||
|
release-deb:
|
||||||
|
type: boolean
|
||||||
|
description: 'Build DEB package'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
release-rpm:
|
||||||
|
type: boolean
|
||||||
|
description: 'Build RPM package'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
release-pkg:
|
||||||
|
type: boolean
|
||||||
|
description: 'Build PKG package'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
release-apk:
|
||||||
|
type: boolean
|
||||||
|
description: 'Build APK package'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
release-binary:
|
||||||
|
type: boolean
|
||||||
|
description: 'Build binary package'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
release-docker:
|
||||||
|
type: boolean
|
||||||
|
description: 'Publish Docker image'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
gh-release:
|
||||||
|
type: boolean
|
||||||
|
description: 'Update GitHub release'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check tag exists
|
||||||
|
uses: mukunku/[email protected]
|
||||||
|
id: check-tag
|
||||||
|
with:
|
||||||
|
tag: ${{ inputs.tag }}
|
||||||
|
- name: Exit if tag does not exist
|
||||||
|
run: |
|
||||||
|
if [[ "${{ steps.check-tag.outputs.exists }}" == "false" ]]; then
|
||||||
|
echo "Tag ${{ inputs.tag }} does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
setup-matrix:
|
||||||
|
needs:
|
||||||
|
- check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.result }}
|
||||||
|
steps:
|
||||||
|
- name: Set up matrix
|
||||||
|
id: set-matrix
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
result-encoding: string
|
||||||
|
script: |
|
||||||
|
const inputs = ${{ toJson(inputs) }}
|
||||||
|
const { arch } = inputs
|
||||||
|
const osMap = {
|
||||||
|
"all": ["ubuntu-latest", "ubuntu-24.04-arm"],
|
||||||
|
"x86_64": ["ubuntu-latest"],
|
||||||
|
"arm64": ["ubuntu-24.04-arm"]
|
||||||
|
}
|
||||||
|
|
||||||
|
const package = Object.entries(inputs)
|
||||||
|
.filter(([key, value]) => key.startsWith('release-') && key !== 'release-docker' && value)
|
||||||
|
.map(([key, value]) => key.replace('release-', ''))
|
||||||
|
|
||||||
|
return JSON.stringify({
|
||||||
|
os: osMap[arch],
|
||||||
|
package,
|
||||||
|
})
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs:
|
||||||
|
- setup-matrix
|
||||||
|
strategy:
|
||||||
|
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf build-${{ matrix.package }} && mkdir -p build-${{ matrix.package }}
|
||||||
|
|
||||||
|
- name: Download ${{ inputs.tag }} source code
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
gh -R yuezk/GlobalProtect-openconnect \
|
||||||
|
release download ${{ inputs.tag }} \
|
||||||
|
--pattern '*[^offline].tar.gz' \
|
||||||
|
--dir build-${{ matrix.package }}
|
||||||
|
|
||||||
|
- name: Build ${{ matrix.package }} package in Docker
|
||||||
|
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-e LIBXML2_STATIC=1 \
|
||||||
|
-e INCLUDE_GUI=1 \
|
||||||
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.package }} package in Docker
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
|
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
||||||
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||||
|
bash install.sh
|
||||||
|
|
||||||
|
- name: Upload ${{ matrix.package }} package
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: artifact-${{ matrix.os }}-${{ matrix.package }}
|
||||||
|
if-no-files-found: error
|
||||||
|
path: |
|
||||||
|
build-${{ matrix.package }}/artifacts/*
|
||||||
|
|
||||||
|
build-docker-image:
|
||||||
|
needs:
|
||||||
|
- check
|
||||||
|
if: ${{ inputs.release-docker }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
platform: linux/amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
platform: linux/arm64
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf docker-image && mkdir -p docker-image/source
|
||||||
|
|
||||||
|
- name: Download ${{ inputs.tag }} source code
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
gh -R yuezk/GlobalProtect-openconnect \
|
||||||
|
release download ${{ inputs.tag }} \
|
||||||
|
--pattern '*[^offline].tar.gz' \
|
||||||
|
--dir docker-image
|
||||||
|
tar -xzf docker-image/*.tar.gz -C docker-image/source --strip-components=1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: docker-image/source
|
||||||
|
file: docker-image/source/packaging/docker/alpine/Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
- name: Verify CLI tools
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
DIGEST: ${{ steps.build.outputs.digest }}
|
||||||
|
run: |
|
||||||
|
docker run --rm "$IMAGE@$DIGEST" --help
|
||||||
|
docker run --rm --entrypoint gpauth "$IMAGE@$DIGEST" --help
|
||||||
|
docker run --rm --entrypoint sh "$IMAGE@$DIGEST" -lc 'test "$(id -u gp)" = "1000" && test "$SUDO_UID" = "1000"'
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
publish-docker-image:
|
||||||
|
needs:
|
||||||
|
- build-docker-image
|
||||||
|
if: ${{ inputs.release-docker }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Publish Docker manifest
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
run: |
|
||||||
|
VERSION="${TAG#v}"
|
||||||
|
tags=(-t "$IMAGE:$TAG")
|
||||||
|
|
||||||
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
tags+=(-t "$IMAGE:$VERSION" -t "$IMAGE:latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker buildx imagetools create "${tags[@]}" \
|
||||||
|
$(printf "$IMAGE@sha256:%s " *)
|
||||||
|
|
||||||
|
docker buildx imagetools inspect "$IMAGE:$TAG"
|
||||||
|
|
||||||
|
gh-release:
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ inputs.gh-release }}
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
attestations: write
|
||||||
|
artifact-metadata: write
|
||||||
|
steps:
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf gh-release && mkdir gh-release
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
path: gh-release/gp
|
||||||
|
submodules: recursive
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: gh-release
|
||||||
|
- name: Rename APK artifacts
|
||||||
|
run: |
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
for file in gh-release/artifact-ubuntu-latest-apk/*.apk; do
|
||||||
|
mv "$file" "${file%.apk}-x86_64.apk"
|
||||||
|
done
|
||||||
|
for file in gh-release/artifact-ubuntu-24.04-arm-apk/*.apk; do
|
||||||
|
mv "$file" "${file%.apk}-aarch64.apk"
|
||||||
|
done
|
||||||
|
- name: Generate release asset checksums
|
||||||
|
run: |
|
||||||
|
cd gh-release/gp
|
||||||
|
mkdir -p .build
|
||||||
|
scripts/release-assets.sh all "$GITHUB_WORKSPACE/gh-release" > .build/release-assets.txt
|
||||||
|
if [ ! -s .build/release-assets.txt ]; then
|
||||||
|
echo "No release assets found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
while IFS= read -r file; do
|
||||||
|
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
|
||||||
|
printf '%s %s\n' "$digest" "$(basename "$file")"
|
||||||
|
done < .build/release-assets.txt > .build/release-assets.sha256
|
||||||
|
- name: Attest release assets
|
||||||
|
uses: actions/attest-build-provenance@v4
|
||||||
|
with:
|
||||||
|
subject-checksums: gh-release/gp/.build/release-assets.sha256
|
||||||
|
- name: Upload release assets
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
mapfile -t files < gh-release/gp/.build/release-assets.txt
|
||||||
|
if [[ "${{ inputs.tag }}" == "snapshot" ]]; then
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
gh release upload snapshot "$file" --clobber \
|
||||||
|
--repo yuezk/GlobalProtect-openconnect
|
||||||
|
done
|
||||||
|
else
|
||||||
|
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
name: Update flake hashes
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Release version. Defaults to Cargo.toml workspace version."
|
||||||
|
required: false
|
||||||
|
release_tag:
|
||||||
|
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
|
||||||
|
required: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-flake-hashes:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Update Nixpkgs lock
|
||||||
|
run: |
|
||||||
|
nix flake update nixpkgs \
|
||||||
|
--extra-experimental-features "nix-command flakes"
|
||||||
|
|
||||||
|
- name: Update flake hashes
|
||||||
|
env:
|
||||||
|
RELEASE_VERSION: ${{ inputs.version }}
|
||||||
|
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||||
|
run: |
|
||||||
|
if [[ -n "$RELEASE_VERSION" ]]; then
|
||||||
|
scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||||
|
else
|
||||||
|
scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload updated flake
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: updated-flake
|
||||||
|
path: |
|
||||||
|
flake.nix
|
||||||
|
flake.lock
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
validate-nix-prebuilt:
|
||||||
|
needs:
|
||||||
|
- update-flake-hashes
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
runner:
|
||||||
|
- ubuntu-latest
|
||||||
|
- ubuntu-24.04-arm
|
||||||
|
nixpkgs:
|
||||||
|
- locked
|
||||||
|
- nixos-25.11
|
||||||
|
- nixos-26.05
|
||||||
|
- nixpkgs-unstable
|
||||||
|
exclude:
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
nixpkgs: locked
|
||||||
|
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Download updated flake
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: updated-flake
|
||||||
|
path: .
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Build prebuilt Nix package
|
||||||
|
env:
|
||||||
|
NIXPKGS: ${{ matrix.nixpkgs }}
|
||||||
|
run: |
|
||||||
|
if [[ "$NIXPKGS" == "locked" ]]; then
|
||||||
|
nix build .#prebuilt \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--print-build-logs
|
||||||
|
else
|
||||||
|
nix build .#prebuilt \
|
||||||
|
--override-input nixpkgs "github:NixOS/nixpkgs/$NIXPKGS" \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--print-build-logs
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Inspect prebuilt Nix package
|
||||||
|
run: |
|
||||||
|
test -x result/bin/gpclient
|
||||||
|
test -x result/bin/gpauth
|
||||||
|
test -x result/bin/gpservice
|
||||||
|
test -x result/bin/gpgui-helper
|
||||||
|
test -x result/bin/gpgui
|
||||||
|
test ! -L result/bin/gpservice
|
||||||
|
head -n1 result/bin/gpclient | grep '^#!'
|
||||||
|
head -n1 result/bin/gpservice | grep '^#!'
|
||||||
|
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
|
||||||
|
grep -q 'gpservice_public=.*/bin/gpservice' result/bin/gpclient
|
||||||
|
grep -q 'exec .*/bin/gpservice' result/bin/gpservice
|
||||||
|
! grep -q '@gpservice_public@\|@gpservice_fhs@\|\$out/bin/gpservice' result/bin/gpclient result/bin/gpservice
|
||||||
|
|
||||||
|
! grep -R '/usr/bin/gp' result/share
|
||||||
|
|
||||||
|
open-pull-request:
|
||||||
|
needs:
|
||||||
|
- validate-nix-prebuilt
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Download updated flake
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: updated-flake
|
||||||
|
path: .
|
||||||
|
|
||||||
|
- name: Open pull request
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
RELEASE_VERSION: ${{ inputs.version }}
|
||||||
|
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||||
|
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||||
@@ -1,4 +1,18 @@
|
|||||||
.idea
|
.idea
|
||||||
|
.DS_Store
|
||||||
/target
|
/target
|
||||||
.pnpm-store
|
.pnpm-store
|
||||||
.env
|
.env
|
||||||
|
.vendor
|
||||||
|
*.tar.xz
|
||||||
|
|
||||||
|
.cargo
|
||||||
|
.build
|
||||||
|
SNAPSHOT
|
||||||
|
SOURCE_COMMIT
|
||||||
|
|
||||||
|
# Tauri generated files
|
||||||
|
gen
|
||||||
|
|
||||||
|
# Nix files
|
||||||
|
result
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[submodule "crates/openconnect/deps/openconnect"]
|
||||||
|
path = crates/openconnect/deps/openconnect
|
||||||
|
url = https://github.com/yuezk/openconnect.git
|
||||||
|
branch = globalprotect
|
||||||
|
[submodule "crates/openconnect/deps/libxml2"]
|
||||||
|
path = crates/openconnect/deps/libxml2
|
||||||
|
url = https://github.com/GNOME/libxml2.git
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Mac",
|
||||||
|
"includePath": ["crates/openconnect/deps/openconnect"],
|
||||||
|
"macFrameworkPath": ["/System/Library/Frameworks", "/Library/Frameworks"],
|
||||||
|
"intelliSenseMode": "macos-clang-x64",
|
||||||
|
"compilerPath": "/usr/bin/clang",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"authcookie",
|
"authcookie",
|
||||||
|
"badssl",
|
||||||
"bincode",
|
"bincode",
|
||||||
"chacha",
|
"chacha",
|
||||||
"clientos",
|
"clientos",
|
||||||
|
"cstring",
|
||||||
"datetime",
|
"datetime",
|
||||||
"disconnectable",
|
"disconnectable",
|
||||||
"distro",
|
"distro",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
"dtls",
|
||||||
"getconfig",
|
"getconfig",
|
||||||
"globalprotect",
|
"globalprotect",
|
||||||
"globalprotectcallback",
|
"globalprotectcallback",
|
||||||
@@ -20,11 +23,17 @@
|
|||||||
"gpgui",
|
"gpgui",
|
||||||
"gpservice",
|
"gpservice",
|
||||||
"hidpi",
|
"hidpi",
|
||||||
|
"Ivars",
|
||||||
"jnlp",
|
"jnlp",
|
||||||
"LOGNAME",
|
"LOGNAME",
|
||||||
|
"NSHTTPURL",
|
||||||
|
"NSURL",
|
||||||
|
"objc",
|
||||||
"oneshot",
|
"oneshot",
|
||||||
"openconnect",
|
"openconnect",
|
||||||
|
"pkcs",
|
||||||
"pkexec",
|
"pkexec",
|
||||||
|
"pkey",
|
||||||
"Prelogin",
|
"Prelogin",
|
||||||
"prelogon",
|
"prelogon",
|
||||||
"prelogonuserauthcookie",
|
"prelogonuserauthcookie",
|
||||||
@@ -34,6 +43,7 @@
|
|||||||
"rspc",
|
"rspc",
|
||||||
"servercert",
|
"servercert",
|
||||||
"specta",
|
"specta",
|
||||||
|
"sslkey",
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"tanstack",
|
"tanstack",
|
||||||
"tauri",
|
"tauri",
|
||||||
@@ -49,9 +59,16 @@
|
|||||||
"Vite",
|
"Vite",
|
||||||
"vpnc",
|
"vpnc",
|
||||||
"vpninfo",
|
"vpninfo",
|
||||||
|
"webbrowser",
|
||||||
"wmctrl",
|
"wmctrl",
|
||||||
"XAUTHORITY",
|
"XAUTHORITY",
|
||||||
"yuezk"
|
"yuezk"
|
||||||
],
|
],
|
||||||
"rust-analyzer.cargo.features": "all",
|
"rust-analyzer.cargo.features": "all",
|
||||||
|
"files.associations": {
|
||||||
|
"unistd.h": "c",
|
||||||
|
"utsname.h": "c",
|
||||||
|
"vpn.h": "c",
|
||||||
|
"openconnect.h": "c"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,77 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
members = ["crates/*", "apps/gpclient", "apps/gpservice", "apps/gpauth"]
|
members = [
|
||||||
|
"crates/*",
|
||||||
|
"apps/gpclient",
|
||||||
|
"apps/gpservice",
|
||||||
|
"apps/gpauth",
|
||||||
|
"apps/gpgui-helper/src-tauri",
|
||||||
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "2.0.0-beta7"
|
rust-version = "1.91"
|
||||||
|
version = "2.6.5"
|
||||||
authors = ["Kevin Yue <[email protected]>"]
|
authors = ["Kevin Yue <[email protected]>"]
|
||||||
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
base64 = "0.21"
|
askama = "0.16"
|
||||||
clap = { version = "4.4.2", features = ["derive"] }
|
base64 = "0.22"
|
||||||
|
chrono = "0.4"
|
||||||
|
clap = { version = "4", features = ["derive"] }
|
||||||
|
clap-verbosity-flag = "3"
|
||||||
ctrlc = "3.4"
|
ctrlc = "3.4"
|
||||||
directories = "5.0"
|
directories = "6.0"
|
||||||
env_logger = "0.10"
|
dns-lookup = "3"
|
||||||
|
env_logger = "0.11"
|
||||||
is_executable = "1.0"
|
is_executable = "1.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
reqwest = { version = "0.11", features = ["native-tls-vendored", "json"] }
|
reqwest = { version = "0.13", default-features = false, features = ["native-tls", "charset", "http2", "system-proxy", "json", "form", "query"] }
|
||||||
roxmltree = "0.18"
|
openssl = "0.10"
|
||||||
|
pem = "3"
|
||||||
|
xmltree = { version = "0.12", features = ["attribute-order"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sysinfo = "0.29"
|
# Use 0.36 as newer versions requires Rust 1.88+
|
||||||
|
sysinfo = "0.36"
|
||||||
tempfile = "3.8"
|
tempfile = "3.8"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1" }
|
||||||
tokio-util = "0.7"
|
tokio-util = "0.7"
|
||||||
url = "2.4"
|
url = "2.4"
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
axum = "0.7"
|
axum = "0.8"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
tokio-tungstenite = "0.20.1"
|
uzers = "0.12"
|
||||||
specta = "=2.0.0-rc.1"
|
whoami = "2"
|
||||||
specta-macros = "=2.0.0-rc.1"
|
thiserror = "2"
|
||||||
uzers = "0.11"
|
|
||||||
whoami = "1"
|
|
||||||
tauri = { version = "1.5" }
|
|
||||||
thiserror = "1"
|
|
||||||
redact-engine = "0.1"
|
redact-engine = "0.1"
|
||||||
dotenvy_macro = "0.15"
|
|
||||||
compile-time = "0.2"
|
compile-time = "0.2"
|
||||||
|
serde_urlencoded = "0.7"
|
||||||
|
md5 = "0.8"
|
||||||
|
sha256 = "1"
|
||||||
|
which = "8"
|
||||||
|
uuid = "1"
|
||||||
|
netdev = "0.40"
|
||||||
|
humantime = "2"
|
||||||
|
snow = { version = "0.10", default-features = false, features = ["std", "use-getrandom", "use-curve25519", "use-chacha20poly1305", "use-sha2"] }
|
||||||
|
zeroize = "1"
|
||||||
|
|
||||||
|
# Tauri dependencies
|
||||||
|
tauri = { version = "2" }
|
||||||
|
specta = "=2.0.0-rc.20"
|
||||||
|
proptest = "1"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
# Restore BSD GTK resize hit testing until https://github.com/tauri-apps/tao/pull/1356 is released.
|
||||||
|
tao = { git = "https://github.com/yuezk/tao", rev = "1452ae7a42c9f134296ba199f91f514fc9077f61" }
|
||||||
|
# Use one macro source for Tao and Wry so Cargo can vendor the workspace.
|
||||||
|
tao-macros = { git = "https://github.com/yuezk/tao", rev = "1452ae7a42c9f134296ba199f91f514fc9077f61" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 'z' # Optimize for size
|
opt-level = 'z' # Optimize for size
|
||||||
|
|||||||
@@ -0,0 +1,504 @@
|
|||||||
|
SHELL := /bin/sh
|
||||||
|
.SHELLFLAGS := -ec
|
||||||
|
|
||||||
|
INCLUDE_GUI ?= 0
|
||||||
|
CARGO ?= cargo
|
||||||
|
DISABLE_RUST_TOOLCHAIN ?= 0
|
||||||
|
RUST_VERSION ?= 1.91
|
||||||
|
IGNORE_RUST_VERSION ?= 0
|
||||||
|
|
||||||
|
VERSION = $(shell grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')
|
||||||
|
SOURCE_COMMIT_VALUE := $(shell \
|
||||||
|
if [ -n "$$SOURCE_GIT_COMMIT" ]; then \
|
||||||
|
printf '%s' "$$SOURCE_GIT_COMMIT" | cut -c1-9; \
|
||||||
|
elif [ -n "$$GITHUB_SHA" ]; then \
|
||||||
|
printf '%s' "$$GITHUB_SHA" | cut -c1-9; \
|
||||||
|
elif [ -f SOURCE_COMMIT ]; then \
|
||||||
|
head -n1 SOURCE_COMMIT | tr -d '[:space:]' | cut -c1-9; \
|
||||||
|
else \
|
||||||
|
git rev-parse --short=9 HEAD 2>/dev/null || printf unknown; \
|
||||||
|
fi)
|
||||||
|
GUI_LIBC_SUFFIX ?= $(shell ldd --version 2>&1 | grep -qi musl && echo -musl || true)
|
||||||
|
REVISION ?= 1
|
||||||
|
RPM_SOURCE ?= %{name}.tar.gz
|
||||||
|
|
||||||
|
PPA_REVISION ?= 1
|
||||||
|
PKG_NAME = globalprotect-openconnect
|
||||||
|
PKG = $(PKG_NAME)-$(VERSION)
|
||||||
|
SERIES ?= $(shell lsb_release -cs)
|
||||||
|
PUBLISH ?= 0
|
||||||
|
|
||||||
|
# Indicates whether to build the GUI components
|
||||||
|
BUILD_GUI_HELPER ?= 1
|
||||||
|
|
||||||
|
# Indicates whether to build embedded webview auth support into gpauth
|
||||||
|
BUILD_WEBVIEW_AUTH ?= 1
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
|
||||||
|
|
||||||
|
export DEBEMAIL = [email protected]
|
||||||
|
export DEBFULLNAME = Kevin Yue
|
||||||
|
export SNAPSHOT = $(shell test -f SNAPSHOT && echo "true" || echo "false")
|
||||||
|
export OFFLINE_BUILD = $(shell test -f OFFLINE_BUILD && echo "1" || echo "0")
|
||||||
|
# If OFFLINE is not set, use OFFLINE_BUILD
|
||||||
|
ifndef OFFLINE
|
||||||
|
OFFLINE = $(OFFLINE_BUILD)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SNAPSHOT), true)
|
||||||
|
RELEASE_TAG = snapshot
|
||||||
|
else
|
||||||
|
RELEASE_TAG = v$(VERSION)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CARGO_BUILD_ARGS = --release
|
||||||
|
|
||||||
|
ifeq ($(OFFLINE), 1)
|
||||||
|
CARGO_BUILD_ARGS += --frozen
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(IGNORE_RUST_VERSION), 1)
|
||||||
|
CARGO_BUILD_ARGS += --ignore-rust-version
|
||||||
|
endif
|
||||||
|
|
||||||
|
default: build
|
||||||
|
|
||||||
|
dev-service:
|
||||||
|
./scripts/dev-service.sh
|
||||||
|
|
||||||
|
version:
|
||||||
|
@echo $(VERSION)
|
||||||
|
|
||||||
|
clean-tarball:
|
||||||
|
rm -rf .build/tarball
|
||||||
|
rm -rf .vendor
|
||||||
|
rm -rf vendor.tar.xz
|
||||||
|
rm -rf .cargo
|
||||||
|
rm -f SOURCE_COMMIT
|
||||||
|
|
||||||
|
# Create a tarball, include the cargo dependencies if OFFLINE is set to 1
|
||||||
|
tarball: clean-tarball
|
||||||
|
mkdir -p .cargo
|
||||||
|
mkdir -p .build/tarball
|
||||||
|
printf '%s\n' "$(SOURCE_COMMIT_VALUE)" > SOURCE_COMMIT
|
||||||
|
|
||||||
|
# If OFFLINE is set to 1, vendor all cargo dependencies
|
||||||
|
# Generate a OFFLINE_BUILD file to indicate offline build
|
||||||
|
if [ $(OFFLINE) -eq 1 ]; then \
|
||||||
|
$(CARGO) vendor .vendor > .cargo/config.toml; \
|
||||||
|
tar -cJf vendor.tar.xz .vendor; \
|
||||||
|
touch OFFLINE_BUILD; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
@echo "Creating tarball..."
|
||||||
|
tar --exclude .vendor --exclude target --transform 's,^,${PKG}/,' -czf .build/tarball/${PKG}.tar.gz * .cargo
|
||||||
|
|
||||||
|
download-gui:
|
||||||
|
rm -rf .build/gpgui
|
||||||
|
|
||||||
|
if [ $(INCLUDE_GUI) -eq 1 ]; then \
|
||||||
|
echo "Downloading GlobalProtect GUI..."; \
|
||||||
|
mkdir -p .build/gpgui; \
|
||||||
|
curl -sSL https://github.com/yuezk/GlobalProtect-openconnect/releases/download/$(RELEASE_TAG)/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz \
|
||||||
|
-o .build/gpgui/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz; \
|
||||||
|
tar -xJf .build/gpgui/*.tar.xz -C .build/gpgui; \
|
||||||
|
else \
|
||||||
|
echo "Skipping GlobalProtect GUI download (INCLUDE_GUI=0)"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
build: download-gui build-rs
|
||||||
|
|
||||||
|
build-rs:
|
||||||
|
if [ $(OFFLINE) -eq 1 ]; then \
|
||||||
|
tar -xJf vendor.tar.xz; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove the rust-toolchain.toml if DISABLE_RUST_TOOLCHAIN is set to 1
|
||||||
|
if [ $(DISABLE_RUST_TOOLCHAIN) -eq 1 ]; then \
|
||||||
|
rm -vf rust-toolchain.toml; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice
|
||||||
|
|
||||||
|
# Build gpauth with or without embedded webview auth support
|
||||||
|
if [ $(BUILD_WEBVIEW_AUTH) -eq 1 ]; then \
|
||||||
|
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth; \
|
||||||
|
else \
|
||||||
|
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth --no-default-features; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Only build the GUI components if BUILD_GUI_HELPER is set to 1
|
||||||
|
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
|
||||||
|
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(CARGO) clean
|
||||||
|
rm -rf .build
|
||||||
|
rm -rf .vendor
|
||||||
|
rm -rf apps/gpgui-helper/node_modules
|
||||||
|
|
||||||
|
install:
|
||||||
|
@echo "Installing $(PKG_NAME)..."
|
||||||
|
|
||||||
|
install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient
|
||||||
|
install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth
|
||||||
|
install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice
|
||||||
|
install -Dm755 target/release/gp-hip-runner $(DESTDIR)/usr/libexec/gpclient/gp-hip-runner
|
||||||
|
install -Dm755 target/release/gp-hip-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-hip-script-installer
|
||||||
|
install -Dm755 target/release/gp-vpnc-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
|
||||||
|
|
||||||
|
# Install the GUI components if BUILD_GUI_HELPER is set to 1
|
||||||
|
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
|
||||||
|
install -Dm755 target/release/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f .build/gpgui/gpgui_*/gpgui ]; then \
|
||||||
|
install -Dm755 .build/gpgui/gpgui_*/gpgui $(DESTDIR)/usr/bin/gpgui; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -Dm755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
||||||
|
install -Dm755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
|
||||||
|
|
||||||
|
# Install the disconnect hooks
|
||||||
|
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||||
|
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||||
|
|
||||||
|
install -Dm644 packaging/files/usr/share/applications/gpgui.desktop $(DESTDIR)/usr/share/applications/gpgui.desktop
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/256x256/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/gpgui.png
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg
|
||||||
|
install -Dm644 packaging/files/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
|
||||||
|
|
||||||
|
install-bsd:
|
||||||
|
@echo "Installing $(PKG_NAME) for BSD under $(PREFIX)..."
|
||||||
|
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/bin
|
||||||
|
install -m 755 target/release/gpclient $(DESTDIR)$(PREFIX)/bin/gpclient
|
||||||
|
install -m 755 target/release/gpauth $(DESTDIR)$(PREFIX)/bin/gpauth
|
||||||
|
install -m 755 target/release/gpservice $(DESTDIR)$(PREFIX)/bin/gpservice
|
||||||
|
|
||||||
|
if [ "$(BUILD_GUI_HELPER)" = "1" ]; then \
|
||||||
|
install -m 755 target/release/gpgui-helper $(DESTDIR)$(PREFIX)/bin/gpgui-helper; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "$(GPGUI_BINARY)" ]; then \
|
||||||
|
install -m 755 "$(GPGUI_BINARY)" $(DESTDIR)$(PREFIX)/bin/gpgui; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/libexec/gpclient
|
||||||
|
install -m 755 target/release/gp-hip-runner $(DESTDIR)$(PREFIX)/libexec/gpclient/gp-hip-runner
|
||||||
|
install -m 755 target/release/gp-hip-script-installer $(DESTDIR)$(PREFIX)/libexec/gpclient/gp-hip-script-installer
|
||||||
|
install -m 755 target/release/gp-vpnc-script-installer $(DESTDIR)$(PREFIX)/libexec/gpclient/gp-vpnc-script-installer
|
||||||
|
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script
|
||||||
|
install -m 755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)$(PREFIX)/libexec/gpclient/hipreport.sh
|
||||||
|
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/applications
|
||||||
|
install -m 644 packaging/bsd/gpgui.desktop $(DESTDIR)$(PREFIX)/share/applications/gpgui.desktop
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256@2/apps
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/gpgui.svg
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/gpgui.png
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/gpgui.png
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/256x256/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/gpgui.png
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256@2/apps/gpgui.png
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg
|
||||||
|
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/share/polkit-1/actions
|
||||||
|
install -m 644 packaging/bsd/com.yuezk.gpgui.policy $(DESTDIR)$(PREFIX)/share/polkit-1/actions/com.yuezk.gpgui.policy
|
||||||
|
|
||||||
|
clean-bsd-package:
|
||||||
|
rm -rf .build/$(BSD_FLAVOR)
|
||||||
|
|
||||||
|
bsd-gpgui-tarball:
|
||||||
|
test -x "$(GPGUI_BINARY)"
|
||||||
|
rm -rf .build/$(BSD_FLAVOR)/gpgui
|
||||||
|
mkdir -p .build/$(BSD_FLAVOR)/artifacts .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)
|
||||||
|
cp "$(GPGUI_BINARY)" .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)/
|
||||||
|
tar -cf - -C .build/$(BSD_FLAVOR)/gpgui gpgui_$(VERSION) | xz -c > .build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz
|
||||||
|
file=.build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz; \
|
||||||
|
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$$file" | cut -d ' ' -f 1; \
|
||||||
|
elif command -v sha256 >/dev/null 2>&1; then sha256 -q "$$file"; \
|
||||||
|
else cksum -a sha256 "$$file" | awk '{print $$1}'; fi > "$$file.sha256"
|
||||||
|
|
||||||
|
package-freebsd: BSD_FLAVOR=freebsd
|
||||||
|
package-freebsd: clean-bsd-package
|
||||||
|
test -x "$(GPGUI_BINARY)"
|
||||||
|
mkdir -p .build/freebsd/pkgroot .build/freebsd/artifacts .build/freebsd/metadata
|
||||||
|
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/freebsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||||
|
find .build/freebsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/freebsd/pkgroot$(PREFIX)/||' | sort > .build/freebsd/PLIST
|
||||||
|
freebsd_major=$$(freebsd-version -u | sed 's/\..*//'); \
|
||||||
|
freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \
|
||||||
|
sed \
|
||||||
|
-e 's/@PKG_NAME@/$(PKG_NAME)/g' \
|
||||||
|
-e 's/@VERSION@/$(VERSION)/g' \
|
||||||
|
-e "s/@ABI@/FreeBSD:$$freebsd_major:$$freebsd_arch/g" \
|
||||||
|
-e "s/@ARCH@/freebsd:$$freebsd_major:$$freebsd_arch/g" \
|
||||||
|
-e 's|@PREFIX@|$(PREFIX)|g' \
|
||||||
|
packaging/bsd/freebsd/MANIFEST.in > .build/freebsd/metadata/+MANIFEST
|
||||||
|
cp packaging/bsd/freebsd/POST_DEINSTALL .build/freebsd/metadata/+POST_DEINSTALL
|
||||||
|
pkg create -r .build/freebsd/pkgroot -M .build/freebsd/metadata -p .build/freebsd/PLIST -o .build/freebsd/artifacts
|
||||||
|
freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \
|
||||||
|
mv .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION).pkg .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION)-freebsd-$$freebsd_arch.pkg
|
||||||
|
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=freebsd GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||||
|
|
||||||
|
package-openbsd: BSD_FLAVOR=openbsd
|
||||||
|
package-openbsd: clean-bsd-package
|
||||||
|
test -x "$(GPGUI_BINARY)"
|
||||||
|
mkdir -p .build/openbsd/pkgroot .build/openbsd/artifacts
|
||||||
|
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/openbsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||||
|
cp packaging/bsd/openbsd/COMMENT .build/openbsd/+COMMENT
|
||||||
|
cp packaging/bsd/openbsd/DESC .build/openbsd/+DESC
|
||||||
|
{ \
|
||||||
|
echo '@unexec-delete /bin/rm -f /usr/local/libexec/gpclient/gpgui /var/db/gpclient/scripts/vpnc-script /var/db/gpclient/scripts/vpnc-script.metadata || echo "Warning: failed to remove gpclient runtime files" >&2'; \
|
||||||
|
echo '@unexec-delete /bin/rmdir /usr/local/libexec/gpclient 2>/dev/null || true'; \
|
||||||
|
echo '@unexec-delete /bin/rmdir /var/db/gpclient/scripts 2>/dev/null || true'; \
|
||||||
|
echo '@unexec-delete /bin/rmdir /var/db/gpclient 2>/dev/null || true'; \
|
||||||
|
find .build/openbsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/openbsd/pkgroot$(PREFIX)/||' | sort; \
|
||||||
|
} > .build/openbsd/PLIST
|
||||||
|
comment=$$(cat .build/openbsd/+COMMENT); \
|
||||||
|
openbsd_arch=$$(uname -m | sed 's/x86_64/amd64/'); \
|
||||||
|
gnome_keyring_pkg=$$(pkg_info -e 'gnome-keyring-*' | sed 's/^inst://' | head -n 1); \
|
||||||
|
dbus_pkg=$$(pkg_info -e 'dbus-*' | sed 's/^inst://' | head -n 1); \
|
||||||
|
polkit_pkg=$$(pkg_info -e 'polkit-*' | sed 's/^inst://' | head -n 1); \
|
||||||
|
webkitgtk_pkg=$$(pkg_info -e 'webkitgtk41-*' | sed 's/^inst://' | head -n 1); \
|
||||||
|
xdg_utils_pkg=$$(pkg_info -e 'xdg-utils-*' | sed 's/^inst://' | head -n 1); \
|
||||||
|
pkg_create \
|
||||||
|
-B .build/openbsd/pkgroot \
|
||||||
|
-D COMMENT="$$comment" \
|
||||||
|
-d .build/openbsd/+DESC \
|
||||||
|
-f .build/openbsd/PLIST \
|
||||||
|
-p $(PREFIX) \
|
||||||
|
-P x11/gnome/keyring:gnome-keyring-*:$$gnome_keyring_pkg \
|
||||||
|
-P x11/dbus:dbus-*:$$dbus_pkg \
|
||||||
|
-P sysutils/polkit:polkit-*:$$polkit_pkg \
|
||||||
|
-P www/webkitgtk4,webkitgtk41:webkitgtk41-*:$$webkitgtk_pkg \
|
||||||
|
-P devel/xdg-utils:xdg-utils-*:$$xdg_utils_pkg \
|
||||||
|
.build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz
|
||||||
|
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
@echo "Uninstalling $(PKG_NAME)..."
|
||||||
|
|
||||||
|
rm -f $(DESTDIR)/usr/bin/gpclient
|
||||||
|
rm -f $(DESTDIR)/usr/bin/gpauth
|
||||||
|
rm -f $(DESTDIR)/usr/bin/gpservice
|
||||||
|
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-hip-runner
|
||||||
|
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-hip-script-installer
|
||||||
|
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
||||||
|
rm -f $(DESTDIR)/usr/bin/gpgui
|
||||||
|
|
||||||
|
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
||||||
|
rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
|
||||||
|
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
|
||||||
|
|
||||||
|
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||||
|
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||||
|
|
||||||
|
rm -f $(DESTDIR)/usr/share/applications/gpgui.desktop
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/gpgui.png
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg
|
||||||
|
rm -f $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
|
||||||
|
|
||||||
|
rm -f $(DESTDIR)/var/lib/gpclient/gpgui \
|
||||||
|
$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script \
|
||||||
|
$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata || \
|
||||||
|
echo "Warning: failed to remove gpclient runtime files" >&2
|
||||||
|
rmdir $(DESTDIR)/var/lib/gpclient/scripts 2>/dev/null || true
|
||||||
|
rmdir $(DESTDIR)/var/lib/gpclient 2>/dev/null || true
|
||||||
|
|
||||||
|
clean-debian:
|
||||||
|
rm -rf .build/deb
|
||||||
|
|
||||||
|
# Generate the debian package structure, without the changelog
|
||||||
|
init-debian: clean-debian tarball
|
||||||
|
mkdir -p .build/deb
|
||||||
|
cp .build/tarball/${PKG}.tar.gz .build/deb
|
||||||
|
|
||||||
|
tar -xzf .build/deb/${PKG}.tar.gz -C .build/deb
|
||||||
|
cd .build/deb/${PKG} && debmake
|
||||||
|
|
||||||
|
cp -f packaging/deb/control.in .build/deb/$(PKG)/debian/control
|
||||||
|
cp -f packaging/deb/rules.in .build/deb/$(PKG)/debian/rules
|
||||||
|
cp -f packaging/deb/postrm .build/deb/$(PKG)/debian/postrm
|
||||||
|
cp -f packaging/deb/compat .build/deb/$(PKG)/debian/compat
|
||||||
|
|
||||||
|
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/control
|
||||||
|
|
||||||
|
# Remove the GUI dependencies if neither GUI component is included
|
||||||
|
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
|
||||||
|
sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \
|
||||||
|
sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \
|
||||||
|
sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove WebKitGTK only if no included component needs it
|
||||||
|
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
|
||||||
|
sed -i "/libwebkit2gtk-4.1-dev/d" .build/deb/$(PKG)/debian/control; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i "s/@INCLUDE_GUI@/$(INCLUDE_GUI)/g" .build/deb/$(PKG)/debian/rules
|
||||||
|
sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules
|
||||||
|
sed -i "s/@BUILD_WEBVIEW_AUTH@/$(BUILD_WEBVIEW_AUTH)/g" .build/deb/$(PKG)/debian/rules
|
||||||
|
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/rules
|
||||||
|
|
||||||
|
rm -f .build/deb/$(PKG)/debian/changelog
|
||||||
|
|
||||||
|
deb: init-debian
|
||||||
|
cd .build/deb/$(PKG) && dch --create --distribution unstable --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION) "Bugfix and improvements."
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
cd .build/deb/$(PKG) && sudo mk-build-deps --install --remove debian/control || echo "mk-build-deps failed, continuing"
|
||||||
|
|
||||||
|
cd .build/deb/$(PKG) && debuild --preserve-env -e PATH -us -uc -b -d
|
||||||
|
|
||||||
|
check-ppa:
|
||||||
|
if [ $(OFFLINE) -eq 0 ]; then \
|
||||||
|
echo "Error: ppa build requires offline mode (OFFLINE=1)"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Usage: make ppa SERIES=focal OFFLINE=1 PUBLISH=1
|
||||||
|
ppa: check-ppa init-debian
|
||||||
|
$(eval SERIES_VER = $(shell distro-info --series $(SERIES) -r | cut -d' ' -f1))
|
||||||
|
@echo "Building for $(SERIES) $(SERIES_VER)"
|
||||||
|
|
||||||
|
rm -rf .build/deb/$(PKG)/debian/changelog
|
||||||
|
cd .build/deb/$(PKG) && dch --create --distribution $(SERIES) --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION)ppa$(PPA_REVISION)~ubuntu$(SERIES_VER) "Bugfix and improvements."
|
||||||
|
|
||||||
|
cd .build/deb/$(PKG) && echo "y" | debuild -e PATH -S -sa -k"$(GPG_KEY_ID)" -p"gpg --batch --passphrase $(GPG_KEY_PASS) --pinentry-mode loopback"
|
||||||
|
|
||||||
|
if [ $(PUBLISH) -eq 1 ]; then \
|
||||||
|
cd .build/deb/$(PKG) && dput ppa:yuezk/globalprotect-openconnect ../*.changes; \
|
||||||
|
else \
|
||||||
|
echo "Skipping ppa publish (PUBLISH=0)"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean-rpm:
|
||||||
|
rm -rf .build/rpm
|
||||||
|
|
||||||
|
# Generate RPM sepc file
|
||||||
|
init-rpm: clean-rpm
|
||||||
|
mkdir -p .build/rpm
|
||||||
|
|
||||||
|
cp packaging/rpm/globalprotect-openconnect.spec.in .build/rpm/globalprotect-openconnect.spec
|
||||||
|
cp packaging/rpm/globalprotect-openconnect.changes.in .build/rpm/globalprotect-openconnect.changes
|
||||||
|
|
||||||
|
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.spec
|
||||||
|
sed -i "s/@REVISION@/$(REVISION)/g" .build/rpm/globalprotect-openconnect.spec
|
||||||
|
sed -i "s|@SOURCE@|$(RPM_SOURCE)|g" .build/rpm/globalprotect-openconnect.spec
|
||||||
|
sed -i "s/@DATE@/$(shell LC_ALL=en.US date "+%a %b %d %Y")/g" .build/rpm/globalprotect-openconnect.spec
|
||||||
|
|
||||||
|
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.changes
|
||||||
|
sed -i "s/@DATE@/$(shell LC_ALL=en.US date -u "+%a %b %e %T %Z %Y")/g" .build/rpm/globalprotect-openconnect.changes
|
||||||
|
|
||||||
|
rpm: init-rpm tarball
|
||||||
|
rm -rf $(HOME)/rpmbuild
|
||||||
|
rpmdev-setuptree
|
||||||
|
|
||||||
|
cp .build/tarball/${PKG}.tar.gz $(HOME)/rpmbuild/SOURCES/${PKG_NAME}.tar.gz
|
||||||
|
rpmbuild -ba .build/rpm/globalprotect-openconnect.spec
|
||||||
|
|
||||||
|
# Copy RPM package from build directory
|
||||||
|
cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm
|
||||||
|
|
||||||
|
# Copy the SRPM only for x86_64.
|
||||||
|
if [ "$(shell uname -m)" = "x86_64" ]; then \
|
||||||
|
cp $(HOME)/rpmbuild/SRPMS/$(PKG_NAME)*.rpm .build/rpm; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean-pkgbuild:
|
||||||
|
rm -rf .build/pkgbuild
|
||||||
|
|
||||||
|
init-pkgbuild: clean-pkgbuild tarball
|
||||||
|
mkdir -p .build/pkgbuild
|
||||||
|
|
||||||
|
cp .build/tarball/${PKG}.tar.gz .build/pkgbuild
|
||||||
|
cp packaging/pkgbuild/PKGBUILD.in .build/pkgbuild/PKGBUILD
|
||||||
|
cp packaging/pkgbuild/gp.install .build/pkgbuild/gp.install
|
||||||
|
|
||||||
|
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/pkgbuild/PKGBUILD
|
||||||
|
sed -i "s/@VERSION@/$(VERSION)/g" .build/pkgbuild/PKGBUILD
|
||||||
|
sed -i "s/@REVISION@/$(REVISION)/g" .build/pkgbuild/PKGBUILD
|
||||||
|
|
||||||
|
pkgbuild: init-pkgbuild
|
||||||
|
cd .build/pkgbuild && makepkg -s --noconfirm
|
||||||
|
|
||||||
|
clean-apk:
|
||||||
|
rm -rf .build/apk
|
||||||
|
|
||||||
|
init-apk: clean-apk tarball
|
||||||
|
mkdir -p .build/apk
|
||||||
|
|
||||||
|
cp .build/tarball/${PKG}.tar.gz .build/apk
|
||||||
|
cp packaging/apk/APKBUILD.in .build/apk/APKBUILD
|
||||||
|
cp packaging/apk/post-deinstall .build/apk/$(PKG_NAME).post-deinstall
|
||||||
|
|
||||||
|
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/apk/APKBUILD
|
||||||
|
sed -i "s/@VERSION@/$(VERSION)/g" .build/apk/APKBUILD
|
||||||
|
sed -i "s/@REVISION@/$(REVISION)/g" .build/apk/APKBUILD
|
||||||
|
checksum=$$(sha512sum .build/apk/${PKG}.tar.gz | cut -d' ' -f1); \
|
||||||
|
sed -i "s/@SHA512@/$$checksum/g" .build/apk/APKBUILD
|
||||||
|
|
||||||
|
# Remove the GUI dependencies if neither GUI component is included
|
||||||
|
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
|
||||||
|
sed -i "/^\tlibayatana-appindicator$$/d" .build/apk/APKBUILD; \
|
||||||
|
sed -i "/^\tlibsecret$$/d" .build/apk/APKBUILD; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove WebKitGTK only if no included component needs it
|
||||||
|
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
|
||||||
|
sed -i "/^\twebkit2gtk-4.1$$/d" .build/apk/APKBUILD; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
apk: init-apk
|
||||||
|
cd .build/apk && abuild -r -P "$(CURDIR)/.build/apk/packages"
|
||||||
|
|
||||||
|
find .build/apk/packages -type f -name "$(PKG_NAME)-*.apk" -exec cp {} .build/apk \;
|
||||||
|
|
||||||
|
clean-binary:
|
||||||
|
rm -rf .build/binary
|
||||||
|
|
||||||
|
binary: clean-binary tarball
|
||||||
|
mkdir -p .build/binary
|
||||||
|
|
||||||
|
cp .build/tarball/${PKG}.tar.gz .build/binary
|
||||||
|
tar -xzf .build/binary/${PKG}.tar.gz -C .build/binary
|
||||||
|
|
||||||
|
mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
||||||
|
|
||||||
|
make -C .build/binary/${PKG} build INCLUDE_GUI=$(INCLUDE_GUI)
|
||||||
|
make -C .build/binary/${PKG} install DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
||||||
|
|
||||||
|
cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)/Makefile
|
||||||
|
|
||||||
|
# Create a tarball for the binary package
|
||||||
|
tar -cJf .build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz -C .build/binary $(PKG_NAME)_$(VERSION)
|
||||||
|
|
||||||
|
# Generate sha256sum
|
||||||
|
cd .build/binary && sha256sum $(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz | cut -d' ' -f1 > $(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz.sha256
|
||||||
@@ -1,70 +1,119 @@
|
|||||||
# GlobalProtect-openconnect
|
# GlobalProtect-openconnect
|
||||||
|
|
||||||
A GUI for GlobalProtect VPN, based on OpenConnect, supports the SSO authentication method. Inspired by [gp-saml-gui](https://github.com/dlenski/gp-saml-gui).
|
A modern GlobalProtect VPN client for Linux, built on OpenConnect with full support for SSO authentication. This project provides both command-line and graphical interfaces for seamless VPN connectivity.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img width="300" src="https://github.com/yuezk/GlobalProtect-openconnect/assets/3297602/9242df9c-217d-42ab-8c21-8f9f69cd4eb5">
|
<img width="300" src="https://github.com/user-attachments/assets/2fb6116c-dc57-43f2-af75-9c3d97ab7122">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
> **Inspired by** [gp-saml-gui](https://github.com/dlenski/gp-saml-gui)
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
- [Features](#features)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Command-Line Interface](#command-line-interface)
|
||||||
|
- [Graphical User Interface](#graphical-user-interface)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Debian / Ubuntu](#debian--ubuntu)
|
||||||
|
- [Arch Linux / Manjaro](#arch-linux--manjaro)
|
||||||
|
- [Fedora 38+ / Rawhide](#fedora-38--rawhide)
|
||||||
|
- [openSUSE Leap 15.6+ / Tumbleweed](#opensuse-leap-156--tumbleweed)
|
||||||
|
- [Other RPM-based Distributions](#other-rpm-based-distributions)
|
||||||
|
- [Alpine Linux](#alpine-linux)
|
||||||
|
- [Gentoo](#gentoo)
|
||||||
|
- [NixOS](#nixos)
|
||||||
|
- [Official Docker Image](#official-docker-image)
|
||||||
|
- [Other Distributions](#other-distributions)
|
||||||
|
- [Building from Source](#building-from-source)
|
||||||
|
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||||
|
- [NetworkManager Integration](#networkmanager-integration)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- [x] Better Linux support
|
- **Cross-Platform Linux Support** – Optimized for various Linux distributions
|
||||||
- [x] Support both CLI and GUI
|
- **Dual Interface** – Available as both CLI and GUI applications
|
||||||
- [x] Support both SSO and non-SSO authentication
|
- **Flexible Authentication** – Supports SSO, non-SSO, FIDO2 (e.g., YubiKey), and client certificate authentication
|
||||||
- [x] Support authentication using default browser
|
- **Browser Integration** – Authenticate using your default browser or any specified browser
|
||||||
- [x] Support multiple portals
|
- **Multi-Portal Support** – Connect to multiple portals and gateways
|
||||||
- [x] Support gateway selection
|
- **Direct Gateway Connection** – Bypass portal selection when needed
|
||||||
- [x] Support auto-connect on startup
|
- **Auto-Connect** – Automatically connect on system startup
|
||||||
- [x] Support system tray icon
|
- **System Tray Integration** – Convenient system tray icon (requires [gnome-shell-extension-appindicator](https://extensions.gnome.org/extension/615/appindicator-support/) on GNOME)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### CLI
|
### Command-Line Interface
|
||||||
|
|
||||||
The CLI version is always free and open source in this repo. It has almost the same features as the GUI version.
|
The CLI version is fully open source and feature-rich, providing nearly identical functionality to the GUI version.
|
||||||
|
|
||||||
```
|
#### Basic Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
Usage: gpclient [OPTIONS] <COMMAND>
|
Usage: gpclient [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
connect Connect to a portal server
|
connect Connect to a portal server
|
||||||
disconnect Disconnect from the server
|
disconnect Disconnect from the server
|
||||||
launch-gui Launch the GUI
|
launch-gui Launch the GUI
|
||||||
|
hip Generate HIP report
|
||||||
help Print this message or the help of the given subcommand(s)
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--fix-openssl Get around the OpenSSL `unsafe legacy renegotiation` error
|
--fix-openssl Uses extended compatibility mode for OpenSSL operations to support a broader range of systems and formats.
|
||||||
--ignore-tls-errors Ignore the TLS errors
|
--ignore-tls-errors Ignore the TLS errors
|
||||||
-h, --help Print help
|
--log-format <LOG_FORMAT> Log output format. JSON is intended for non-interactive consumers; interactive prompts remain text. [default: text] [possible values: text, json]
|
||||||
|
-v, --verbose... Enable verbose output, -v for debug, -vv for trace
|
||||||
|
-q, --quiet... Decrease logging verbosity, -q for warnings, -qq for errors
|
||||||
|
-h, --help Print help (see more with '--help')
|
||||||
-V, --version Print version
|
-V, --version Print version
|
||||||
|
|
||||||
See 'gpclient help <command>' for more information on a specific command.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### GUI
|
> **Tip:** Use `gpclient help <command>` for detailed information on a specific command.
|
||||||
|
|
||||||
The GUI version is also available after you installed it. You can launch it from the application menu or run `gpclient launch-gui` in the terminal.
|
#### External Browser Authentication
|
||||||
|
|
||||||
|
For browser-based authentication with the CLI:
|
||||||
|
|
||||||
|
**Method 1:** Using sudo with environment preservation:
|
||||||
|
```bash
|
||||||
|
sudo gpclient connect --browser <portal>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Method 2:** Using authentication piping:
|
||||||
|
```bash
|
||||||
|
gpauth <portal> --browser 2>/dev/null | sudo gpclient connect <portal> --cookie-on-stdin
|
||||||
|
```
|
||||||
|
|
||||||
|
**Browser Options:**
|
||||||
|
- Use `--browser` to auto-select Chrome, Firefox, then the system default browser
|
||||||
|
- Use `--browser default` to use the system default browser
|
||||||
|
- Use `--browser <browser>` to specify a browser (e.g., `firefox`, `chrome`)
|
||||||
|
- Use `--browser remote` for headless servers – this provides a URL you can access from another machine to complete authentication
|
||||||
|
|
||||||
|
### Graphical User Interface
|
||||||
|
|
||||||
|
The GUI application provides an intuitive interface for managing VPN connections. Launch it from your application menu or via the terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpclient launch-gui
|
||||||
|
```
|
||||||
|
|
||||||
> [!Note]
|
> [!Note]
|
||||||
>
|
>
|
||||||
> The GUI version is partially open source. Its background service is open sourced in this repo as [gpservice](./apps/gpservice/). The GUI part is a wrapper of the background service, which is not open sourced.
|
> The GUI version is partially open source. The background service ([gpservice](./apps/gpservice/)) is open source, while the GUI wrapper is proprietary.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
> [!Note]
|
> [!Note]
|
||||||
>
|
>
|
||||||
> This instruction is for the 2.x version. The 1.x version is still available on the [1.x](https://github.com/yuezk/GlobalProtect-openconnect/tree/1.x) branch, you can build it from the source code by following the instructions in the `README.md` file.
|
> For older Linux distributions, use [v2.3.13](https://github.com/yuezk/GlobalProtect-openconnect/releases/tag/v2.3.13) instead of the latest release. It provides release assets for common distro families, including Debian/Ubuntu (`.deb`), Arch Linux / Manjaro (`.pkg.tar.zst`), RPM-based distros such as Fedora / RHEL / Rocky / AlmaLinux / CentOS (`.rpm`), and generic Linux tarballs (`.bin.tar.xz`).
|
||||||
|
|
||||||
> [!Warning]
|
### Debian / Ubuntu
|
||||||
>
|
|
||||||
> The client requires `openconnect >= 8.20`, please make sure you have it installed, you can check it with `openconnect --version`.
|
|
||||||
> Installing the client from PPA will automatically install the required version of `openconnect`.
|
|
||||||
|
|
||||||
### Debian/Ubuntu based distributions
|
#### Option 1: Install from PPA (Recommended)
|
||||||
|
|
||||||
#### Install from PPA
|
```bash
|
||||||
|
|
||||||
```
|
|
||||||
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
|
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install globalprotect-openconnect
|
sudo apt-get install globalprotect-openconnect
|
||||||
@@ -72,57 +121,396 @@ sudo apt-get install globalprotect-openconnect
|
|||||||
|
|
||||||
> [!Note]
|
> [!Note]
|
||||||
>
|
>
|
||||||
> For Linux Mint, you might need to import the GPG key with: `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7937C393082992E5D6E4A60453FC26B43838D761` if you encountered an error `gpg: keyserver receive failed: General error`.
|
> **For Linux Mint users:** If you encounter a GPG key error, import the key manually:
|
||||||
|
> ```bash
|
||||||
|
> sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7937C393082992E5D6E4A60453FC26B43838D761
|
||||||
|
> ```
|
||||||
|
|
||||||
#### Install from deb package
|
#### Option 2: Install from DEB Package
|
||||||
|
|
||||||
Download the latest deb package from [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page. Then install it with `dpkg`:
|
Download the latest `.deb` package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo dpkg -i globalprotect-openconnect_*.deb
|
sudo apt install --fix-broken globalprotect-openconnect_*.deb
|
||||||
```
|
```
|
||||||
|
|
||||||
### Arch Linux / Manjaro
|
### Arch Linux / Manjaro
|
||||||
|
|
||||||
#### Install from AUR
|
#### Option 1: Install from AUR
|
||||||
|
|
||||||
Install from AUR: [globalprotect-openconnect-git](https://aur.archlinux.org/packages/globalprotect-openconnect-git/)
|
Package: [globalprotect-openconnect-git](https://aur.archlinux.org/packages/globalprotect-openconnect-git/)
|
||||||
|
|
||||||
```
|
You can install it using an AUR helper like [`yay`](https://github.com/Jguer/yay):
|
||||||
|
|
||||||
|
```bash
|
||||||
yay -S globalprotect-openconnect-git
|
yay -S globalprotect-openconnect-git
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Install from package
|
#### Option 2: Install from the Official Extra Repository
|
||||||
|
|
||||||
Download the latest package from [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page. Then install it with `pacman`:
|
The package is also available in the official Arch Linux Extra repository.
|
||||||
|
|
||||||
|
Package: [globalprotect-openconnect](https://archlinux.org/packages/extra/x86_64/globalprotect-openconnect/)
|
||||||
|
|
||||||
|
> [!Note]
|
||||||
|
>
|
||||||
|
> Since the official package does not include the system tray support dependency, you need to install `libappindicator` manually:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo pacman -S libappindicator globalprotect-openconnect
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Option 3: Install from Package
|
||||||
|
|
||||||
|
Download the latest package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo pacman -U globalprotect-openconnect-*.pkg.tar.zst
|
sudo pacman -U globalprotect-openconnect-*.pkg.tar.zst
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fedora/OpenSUSE/CentOS/RHEL
|
### Fedora 38+ / Rawhide
|
||||||
|
|
||||||
#### Install from COPR
|
#### Install from COPR
|
||||||
|
|
||||||
The package is available on [COPR](https://copr.fedorainfracloud.org/coprs/yuezk/globalprotect-openconnect/) for various RPM-based distributions. You can install it with the following commands:
|
The package is available on [COPR](https://copr.fedorainfracloud.org/coprs/yuezk/globalprotect-openconnect/) for RPM-based distributions:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
sudo dnf copr enable yuezk/globalprotect-openconnect
|
sudo dnf copr enable yuezk/globalprotect-openconnect
|
||||||
sudo dnf install globalprotect-openconnect
|
sudo dnf install globalprotect-openconnect
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Install from OBS
|
### openSUSE Leap 15.6+ / Tumbleweed
|
||||||
|
|
||||||
The package is also available on [OBS](https://build.opensuse.org/package/show/home:yuezk/globalprotect-openconnect) for various RPM-based distributions. You can follow the instructions [on this page](https://software.opensuse.org//download.html?project=home%3Ayuezk&package=globalprotect-openconnect) to install it.
|
#### Install from OBS (openSUSE Build Service)
|
||||||
|
|
||||||
#### Install from RPM package
|
Packages are available on the [openSUSE Build Service](https://build.opensuse.org/package/show/home:yuezk/globalprotect-openconnect). Follow the [installation instructions](https://software.opensuse.org//download.html?project=home%3Ayuezk&package=globalprotect-openconnect) for your distribution.
|
||||||
|
|
||||||
Download the latest RPM package from [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page.
|
### Other RPM-based Distributions
|
||||||
|
|
||||||
### Other distributions
|
#### Install from RPM Package
|
||||||
|
|
||||||
The project depends on `openconnect >= 8.20`, `webkit2gtk`, `libsecret`, `libayatana-appindicator` or `libappindicator-gtk3`. You can install them first and then download the latest binary release (i.e., `*.bin.tar.gz`) from [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page.
|
Download the latest RPM package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
|
||||||
|
|
||||||
## [License](./LICENSE)
|
```bash
|
||||||
|
sudo rpm -i globalprotect-openconnect-*.rpm
|
||||||
|
```
|
||||||
|
|
||||||
GPLv3
|
### Alpine Linux
|
||||||
|
|
||||||
|
Download the latest `.apk` package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apk add --allow-untrusted globalprotect-openconnect-*.apk
|
||||||
|
```
|
||||||
|
|
||||||
|
The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`.
|
||||||
|
|
||||||
|
### FreeBSD
|
||||||
|
|
||||||
|
Download the latest FreeBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo pkg install ./globalprotect-openconnect-*-freebsd-*.pkg
|
||||||
|
```
|
||||||
|
|
||||||
|
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
|
||||||
|
|
||||||
|
### OpenBSD
|
||||||
|
|
||||||
|
Download the latest OpenBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
doas pkg_add -D unsigned ./globalprotect-openconnect-*-openbsd-*.tgz
|
||||||
|
```
|
||||||
|
|
||||||
|
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
|
||||||
|
|
||||||
|
### Gentoo
|
||||||
|
|
||||||
|
Available via the `guru` and `lamdness` overlays:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo eselect repository enable guru
|
||||||
|
sudo emerge --sync guru
|
||||||
|
sudo emerge --ask --verbose net-vpn/GlobalProtect-openconnect
|
||||||
|
```
|
||||||
|
|
||||||
|
### NixOS
|
||||||
|
|
||||||
|
This repository includes a flake for NixOS integration.
|
||||||
|
|
||||||
|
#### Installation Steps
|
||||||
|
|
||||||
|
Add the flake input and NixOS module to your `flake.nix`:
|
||||||
|
|
||||||
|
The module builds the package with your NixOS configuration's `pkgs`, so the
|
||||||
|
GlobalProtect GUI and the system use the same Nixpkgs dependency versions.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
# ... other inputs
|
||||||
|
globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, globalprotect-openconnect, ... }:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux"; # or "aarch64-linux" for ARM64
|
||||||
|
hostname = "<your-host>";
|
||||||
|
in {
|
||||||
|
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
globalprotect-openconnect.nixosModules.default
|
||||||
|
{
|
||||||
|
programs.globalprotect-openconnect.enable = true;
|
||||||
|
|
||||||
|
environment.systemPackages = [
|
||||||
|
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Apply:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo nixos-rebuild switch
|
||||||
|
loginctl terminate-user "$USER"
|
||||||
|
```
|
||||||
|
|
||||||
|
After logging back in to GNOME, enable AppIndicator support if needed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gnome-extensions enable [email protected]
|
||||||
|
```
|
||||||
|
|
||||||
|
NixOS does not run an imperative package-uninstall hook when a package is
|
||||||
|
removed from the system configuration. Remove an installed replacement VPN
|
||||||
|
script from the app settings before removing the package.
|
||||||
|
|
||||||
|
### Official Docker Image
|
||||||
|
|
||||||
|
The [official Docker image](https://hub.docker.com/r/yuezk/globalprotect-openconnect) provides the CLI tools on Alpine Linux:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull yuezk/globalprotect-openconnect:<version>
|
||||||
|
```
|
||||||
|
|
||||||
|
Release images are tagged as `vX.Y.Z`, `X.Y.Z`, and `latest`.
|
||||||
|
|
||||||
|
Run it with access to the TUN device:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||||
|
yuezk/globalprotect-openconnect:<version> \
|
||||||
|
connect <portal> --cookie-on-stdin
|
||||||
|
```
|
||||||
|
|
||||||
|
For browser authentication in a headless environment, use remote browser authentication:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||||
|
yuezk/globalprotect-openconnect:<version> \
|
||||||
|
connect <portal> --browser remote
|
||||||
|
```
|
||||||
|
|
||||||
|
On a host with multiple network interfaces, use `--browser-listen` to select the IP address reachable from the browser machine:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gpclient connect <portal> --browser remote --browser-listen 192.168.107.15
|
||||||
|
```
|
||||||
|
|
||||||
|
On a Linux host, add host networking if the VPN routes should affect the host network namespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --network host --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||||
|
yuezk/globalprotect-openconnect:<version> \
|
||||||
|
connect <portal> --browser remote
|
||||||
|
```
|
||||||
|
|
||||||
|
Without `--network host`, the VPN connection stays inside the container's network namespace. Docker Desktop on macOS and Windows does not make the host use the VPN through `--network host`; run `gpclient` on the host or use a container gateway setup for host traffic.
|
||||||
|
|
||||||
|
Alternatively, pipe `gpauth` remote-browser output into `gpclient`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --entrypoint gpauth yuezk/globalprotect-openconnect:<version> \
|
||||||
|
<portal> --browser remote 2>/dev/null \
|
||||||
|
| docker run --rm -i --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||||
|
yuezk/globalprotect-openconnect:<version> \
|
||||||
|
connect <portal> --cookie-on-stdin
|
||||||
|
```
|
||||||
|
|
||||||
|
The image includes `gpclient` and `gpauth` only. It does not include embedded webview authentication, `gpgui-helper`, or `gpgui`.
|
||||||
|
|
||||||
|
### Other Distributions
|
||||||
|
|
||||||
|
#### Manual Installation
|
||||||
|
|
||||||
|
1. **Install dependencies:**
|
||||||
|
- `webkit2gtk`
|
||||||
|
- `libsecret`
|
||||||
|
- `libayatana-appindicator` or `libappindicator-gtk3`
|
||||||
|
|
||||||
|
2. **Download and extract:**
|
||||||
|
Download `globalprotect-openconnect_${version}_${arch}.bin.tar.xz` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
|
||||||
|
```bash
|
||||||
|
tar -xJf globalprotect-openconnect_${version}_${arch}.bin.tar.xz
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Install:**
|
||||||
|
```bash
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building from Source
|
||||||
|
|
||||||
|
You can build the application from source using either a DevContainer (recommended) or a local development environment.
|
||||||
|
|
||||||
|
### Method 1: Using DevContainer (Recommended)
|
||||||
|
|
||||||
|
This project includes a DevContainer configuration that provides a consistent, reproducible build environment with all dependencies pre-installed.
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
- [Docker](https://docs.docker.com/get-docker/)
|
||||||
|
- [Visual Studio Code](https://code.visualstudio.com/) (optional, for IDE support)
|
||||||
|
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) (if using VS Code)
|
||||||
|
|
||||||
|
#### Build Steps
|
||||||
|
|
||||||
|
1. **Clone the repository:**
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/yuezk/GlobalProtect-openconnect.git
|
||||||
|
cd GlobalProtect-openconnect
|
||||||
|
git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Build the DevContainer image:**
|
||||||
|
```bash
|
||||||
|
docker build -t gpoc-devcontainer .devcontainer/
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Build the project:**
|
||||||
|
|
||||||
|
To build everything including the GUI helper run this command:
|
||||||
|
```bash
|
||||||
|
docker run --privileged --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||||
|
--tty -v "$(pwd)":/workspace -w /workspace gpoc-devcontainer \
|
||||||
|
bash -c "export PATH=/usr/local/cargo/bin:\$PATH && make build"
|
||||||
|
```
|
||||||
|
To build without the GUI helper run the same command as above, but with `BUILD_GUI_HELPER=0` passed as an argument to `make`.
|
||||||
|
|
||||||
|
5. **Locate build artifacts:**
|
||||||
|
|
||||||
|
The compiled binaries will be available in `target/release/`:
|
||||||
|
- `gpclient` – CLI client
|
||||||
|
- `gpservice` – Background service
|
||||||
|
- `gpauth` – Authentication helper
|
||||||
|
- `gpgui-helper` – GUI helper
|
||||||
|
|
||||||
|
#### Alternative: Using VS Code
|
||||||
|
|
||||||
|
1. Open the project in VS Code
|
||||||
|
2. When prompted, click "Reopen in Container" (or run **Dev Containers: Reopen in Container**)
|
||||||
|
3. Once the container is ready, open a terminal and run:
|
||||||
|
```bash
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Method 2: Local Development Build
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
- [Rust 1.91 or later](https://www.rust-lang.org/tools/install)
|
||||||
|
- [Tauri dependencies](https://tauri.app/start/prerequisites/)
|
||||||
|
- OpenConnect source-build dependencies: `autoconf`, `automake`, `autopoint`/`gettext`, `libtool`, `patch`, `pkg-config`, `libxml2`, `zlib`, `lz4`, `gnutls`, `p11-kit`, `nettle`, and `gmp` development packages
|
||||||
|
- `pkexec` and `gnome-keyring` (or `pam_kwallet` on KDE)
|
||||||
|
- `nodejs` and `pnpm` (optional)
|
||||||
|
|
||||||
|
#### Build Steps
|
||||||
|
|
||||||
|
1. **Download source code:**
|
||||||
|
|
||||||
|
Download `globalprotect-openconnect-${version}.tar.gz` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page.
|
||||||
|
|
||||||
|
2. **Extract and build:**
|
||||||
|
```bash
|
||||||
|
tar -xzf globalprotect-openconnect-${version}.tar.gz
|
||||||
|
cd globalprotect-openconnect-${version}
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Install:**
|
||||||
|
```bash
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** `DESTDIR` is not currently supported.
|
||||||
|
|
||||||
|
### Testing Your Build
|
||||||
|
|
||||||
|
Verify the CLI client is working correctly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./target/release/gpclient --help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build Options
|
||||||
|
|
||||||
|
- `BUILD_GUI_HELPER=0` – Build CLI components only (excludes GUI)
|
||||||
|
- `OFFLINE=1` – Build in offline mode using vendored dependencies
|
||||||
|
|
||||||
|
## Frequently Asked Questions
|
||||||
|
|
||||||
|
### Q: How do I resolve the "Secure Storage not ready" error?
|
||||||
|
|
||||||
|
**Solution 1:** Update to version 2.2.0 or later, which includes a file-based storage fallback.
|
||||||
|
|
||||||
|
**Solution 2:** Install the `gnome-keyring` package and restart your system.
|
||||||
|
|
||||||
|
See related issues: [#321](https://github.com/yuezk/GlobalProtect-openconnect/issues/321), [#316](https://github.com/yuezk/GlobalProtect-openconnect/issues/316)
|
||||||
|
|
||||||
|
### Q: How do I fix the "cannot open display" error when using CLI?
|
||||||
|
|
||||||
|
If you encounter `(gpauth:18869): Gtk-WARNING **: 10:33:37.566: cannot open display:`, try running the command with `sudo -E`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo -E gpclient connect <portal>
|
||||||
|
```
|
||||||
|
|
||||||
|
See related issue: [#316](https://github.com/yuezk/GlobalProtect-openconnect/issues/316)
|
||||||
|
|
||||||
|
## NetworkManager Integration
|
||||||
|
|
||||||
|
- [WMP/GlobalProtect-SAML-NetworkManager](https://github.com/WMP/GlobalProtect-SAML-NetworkManager) – NetworkManager VPN plugin with SAML/SSO support for GNOME and KDE Plasma
|
||||||
|
- [jdpipe/networkmanager-gpclient](https://github.com/jdpipe/networkmanager-gpclient) – NetworkManager VPN plugin that uses `gpclient`
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
### Trial and Pricing
|
||||||
|
|
||||||
|
The **CLI version** is completely free and open source.
|
||||||
|
The **GUI version** is a paid application with a **7-day trial period** after installation.
|
||||||
|
|
||||||
|
### Open Source Licenses
|
||||||
|
|
||||||
|
This project consists of multiple components, each with its own license:
|
||||||
|
|
||||||
|
| Component | Type | License |
|
||||||
|
|-----------|------|---------|
|
||||||
|
| [gpapi](./crates/gpapi) | Crate | [MIT](./crates/gpapi/LICENSE) |
|
||||||
|
| [openconnect](./crates/openconnect) | Rust wrapper crate | [MIT](./crates/openconnect/LICENSE) |
|
||||||
|
| [upstream OpenConnect](./crates/openconnect/deps/openconnect) | C library | [LGPL-2.1](./crates/openconnect/deps/openconnect/COPYING.LGPL) |
|
||||||
|
| [common](./crates/common) | Crate | [MIT](./crates/common/LICENSE) |
|
||||||
|
| [browser-launcher](./crates/browser-launcher) | Crate | [MIT](./crates/browser-launcher/LICENSE) |
|
||||||
|
| [auth](./crates/auth) | Crate | [GPL-3.0](./crates/auth/LICENSE) |
|
||||||
|
| [gpservice](./apps/gpservice) | Application | [GPL-3.0](./apps/gpservice/LICENSE) |
|
||||||
|
| [gpclient](./apps/gpclient) | Application | [GPL-3.0](./apps/gpclient/LICENSE) |
|
||||||
|
| [gpauth](./apps/gpauth) | Application | [GPL-3.0](./apps/gpauth/LICENSE) |
|
||||||
|
| [gpgui-helper](./apps/gpgui-helper) | Application | [GPL-3.0](./apps/gpgui-helper/LICENSE) |
|
||||||
@@ -1,23 +1,36 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gpauth"
|
name = "gpauth"
|
||||||
|
rust-version.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "1.5", features = [] }
|
tauri-build = { version = "2", features = [], optional = true }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpapi = { path = "../../crates/gpapi", features = ["tauri", "clap"] }
|
common = { path = "../../crates/common" }
|
||||||
|
gpapi = { path = "../../crates/gpapi", features = ["clap", "logger"] }
|
||||||
|
|
||||||
|
auth = { path = "../../crates/auth", features = ["browser-auth"] }
|
||||||
|
|
||||||
|
# Shared dependencies
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
env_logger.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
regex.workspace = true
|
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tokio.workspace = true
|
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||||
tokio-util.workspace = true
|
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
webkit2gtk = "0.18.2"
|
|
||||||
tauri = { workspace = true, features = ["http-all"] }
|
|
||||||
compile-time.workspace = true
|
compile-time.workspace = true
|
||||||
|
|
||||||
|
# Pin to specific version due to MSRV
|
||||||
|
home = "=0.5.11"
|
||||||
|
|
||||||
|
# webview auth dependencies
|
||||||
|
tauri = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["webview-auth"]
|
||||||
|
webview-auth = ["auth/webview-auth", "dep:tauri", "dep:tauri-build"]
|
||||||
|
release-devtools = ["auth/release-devtools"]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>LSUIElement</key>
|
||||||
|
<true/>
|
||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>GlobalProtect authentication callback</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>globalprotectcallback</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -1,3 +1,63 @@
|
|||||||
|
use std::{env, fs, path::PathBuf, process::Command};
|
||||||
|
|
||||||
|
const UNKNOWN_COMMIT: &str = "unknown";
|
||||||
|
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=GPAUTH_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||||
|
|
||||||
|
let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../..");
|
||||||
|
let source_commit = repo_root.join("SOURCE_COMMIT");
|
||||||
|
println!("cargo:rerun-if-changed={}", source_commit.display());
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=GPAUTH_GIT_COMMIT={}",
|
||||||
|
resolve_commit(&repo_root, &source_commit)
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
tauri_build::build()
|
tauri_build::build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String {
|
||||||
|
env_commit("GPAUTH_GIT_COMMIT")
|
||||||
|
.or_else(|| env_commit("SOURCE_GIT_COMMIT"))
|
||||||
|
.or_else(|| env_commit("GITHUB_SHA"))
|
||||||
|
.or_else(|| file_commit(source_commit))
|
||||||
|
.or_else(|| git_commit(repo_root))
|
||||||
|
.unwrap_or_else(|| UNKNOWN_COMMIT.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn env_commit(key: &str) -> Option<String> {
|
||||||
|
env::var(key).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn file_commit(path: &PathBuf) -> Option<String> {
|
||||||
|
fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn git_commit(repo_root: &PathBuf) -> Option<String> {
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args(["rev-parse", "--short=9", "HEAD"])
|
||||||
|
.current_dir(repo_root)
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
String::from_utf8(output.stdout)
|
||||||
|
.ok()
|
||||||
|
.and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normalize_commit(value: &str) -> Option<String> {
|
||||||
|
let value = value.trim();
|
||||||
|
if value.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(value.chars().take(DISPLAY_COMMIT_LEN).collect())
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 57 KiB |
@@ -1,486 +0,0 @@
|
|||||||
use std::{
|
|
||||||
rc::Rc,
|
|
||||||
sync::Arc,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::bail;
|
|
||||||
use gpapi::{
|
|
||||||
auth::SamlAuthData,
|
|
||||||
gp_params::GpParams,
|
|
||||||
portal::{prelogin, Prelogin},
|
|
||||||
utils::{redact::redact_uri, window::WindowExt},
|
|
||||||
};
|
|
||||||
use log::{info, warn};
|
|
||||||
use regex::Regex;
|
|
||||||
use tauri::{AppHandle, Window, WindowEvent, WindowUrl};
|
|
||||||
use tokio::sync::{mpsc, oneshot, RwLock};
|
|
||||||
use tokio_util::sync::CancellationToken;
|
|
||||||
use webkit2gtk::{
|
|
||||||
gio::Cancellable,
|
|
||||||
glib::{GString, TimeSpan},
|
|
||||||
LoadEvent, SettingsExt, TLSErrorsPolicy, URIResponse, URIResponseExt, WebContextExt, WebResource,
|
|
||||||
WebResourceExt, WebView, WebViewExt, WebsiteDataManagerExtManual, WebsiteDataTypes,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum AuthDataError {
|
|
||||||
/// Failed to load page due to TLS error
|
|
||||||
TlsError,
|
|
||||||
/// 1. Found auth data in headers/body but it's invalid
|
|
||||||
/// 2. Loaded an empty page, failed to load page. etc.
|
|
||||||
Invalid,
|
|
||||||
/// No auth data found in headers/body
|
|
||||||
NotFound,
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthResult = Result<SamlAuthData, AuthDataError>;
|
|
||||||
|
|
||||||
pub(crate) struct AuthWindow<'a> {
|
|
||||||
app_handle: AppHandle,
|
|
||||||
server: &'a str,
|
|
||||||
saml_request: &'a str,
|
|
||||||
user_agent: &'a str,
|
|
||||||
gp_params: Option<GpParams>,
|
|
||||||
clean: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> AuthWindow<'a> {
|
|
||||||
pub fn new(app_handle: AppHandle) -> Self {
|
|
||||||
Self {
|
|
||||||
app_handle,
|
|
||||||
server: "",
|
|
||||||
saml_request: "",
|
|
||||||
user_agent: "",
|
|
||||||
gp_params: None,
|
|
||||||
clean: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn server(mut self, server: &'a str) -> Self {
|
|
||||||
self.server = server;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn saml_request(mut self, saml_request: &'a str) -> Self {
|
|
||||||
self.saml_request = saml_request;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn user_agent(mut self, user_agent: &'a str) -> Self {
|
|
||||||
self.user_agent = user_agent;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gp_params(mut self, gp_params: GpParams) -> Self {
|
|
||||||
self.gp_params.replace(gp_params);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clean(mut self, clean: bool) -> Self {
|
|
||||||
self.clean = clean;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn open(&self) -> anyhow::Result<SamlAuthData> {
|
|
||||||
info!("Open auth window, user_agent: {}", self.user_agent);
|
|
||||||
|
|
||||||
let window = Window::builder(&self.app_handle, "auth_window", WindowUrl::default())
|
|
||||||
.title("GlobalProtect Login")
|
|
||||||
// .user_agent(self.user_agent)
|
|
||||||
.focused(true)
|
|
||||||
.visible(false)
|
|
||||||
.center()
|
|
||||||
.build()?;
|
|
||||||
|
|
||||||
let window = Arc::new(window);
|
|
||||||
|
|
||||||
let cancel_token = CancellationToken::new();
|
|
||||||
let cancel_token_clone = cancel_token.clone();
|
|
||||||
|
|
||||||
window.on_window_event(move |event| {
|
|
||||||
if let WindowEvent::CloseRequested { .. } = event {
|
|
||||||
cancel_token_clone.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let window_clone = Arc::clone(&window);
|
|
||||||
let timeout_secs = 15;
|
|
||||||
tokio::spawn(async move {
|
|
||||||
tokio::time::sleep(Duration::from_secs(timeout_secs)).await;
|
|
||||||
let visible = window_clone.is_visible().unwrap_or(false);
|
|
||||||
if !visible {
|
|
||||||
info!("Try to raise auth window after {} seconds", timeout_secs);
|
|
||||||
raise_window(&window_clone);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tokio::select! {
|
|
||||||
_ = cancel_token.cancelled() => {
|
|
||||||
bail!("Auth cancelled");
|
|
||||||
}
|
|
||||||
saml_result = self.auth_loop(&window) => {
|
|
||||||
window.close()?;
|
|
||||||
saml_result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn auth_loop(&self, window: &Arc<Window>) -> anyhow::Result<SamlAuthData> {
|
|
||||||
let saml_request = self.saml_request.to_string();
|
|
||||||
let (auth_result_tx, mut auth_result_rx) = mpsc::unbounded_channel::<AuthResult>();
|
|
||||||
let raise_window_cancel_token: Arc<RwLock<Option<CancellationToken>>> = Default::default();
|
|
||||||
let gp_params = self.gp_params.as_ref().unwrap();
|
|
||||||
let tls_err_policy = if gp_params.ignore_tls_errors() {
|
|
||||||
TLSErrorsPolicy::Ignore
|
|
||||||
} else {
|
|
||||||
TLSErrorsPolicy::Fail
|
|
||||||
};
|
|
||||||
|
|
||||||
if self.clean {
|
|
||||||
clear_webview_cookies(window).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let raise_window_cancel_token_clone = Arc::clone(&raise_window_cancel_token);
|
|
||||||
window.with_webview(move |wv| {
|
|
||||||
let wv = wv.inner();
|
|
||||||
|
|
||||||
if let Some(context) = wv.context() {
|
|
||||||
context.set_tls_errors_policy(tls_err_policy);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(settings) = wv.settings() {
|
|
||||||
let ua = settings.user_agent().unwrap_or("".into());
|
|
||||||
info!("Auth window user agent: {}", ua);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the initial SAML request
|
|
||||||
load_saml_request(&wv, &saml_request);
|
|
||||||
|
|
||||||
let auth_result_tx_clone = auth_result_tx.clone();
|
|
||||||
wv.connect_load_changed(move |wv, event| {
|
|
||||||
if event == LoadEvent::Started {
|
|
||||||
let Ok(mut cancel_token) = raise_window_cancel_token_clone.try_write() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cancel the raise window task
|
|
||||||
if let Some(cancel_token) = cancel_token.take() {
|
|
||||||
cancel_token.cancel();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if event != LoadEvent::Finished {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(main_resource) = wv.main_resource() {
|
|
||||||
let uri = main_resource.uri().unwrap_or("".into());
|
|
||||||
|
|
||||||
if uri.is_empty() {
|
|
||||||
warn!("Loaded an empty uri");
|
|
||||||
send_auth_result(&auth_result_tx_clone, Err(AuthDataError::Invalid));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
info!("Loaded uri: {}", redact_uri(&uri));
|
|
||||||
read_auth_data(&main_resource, auth_result_tx_clone.clone());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let auth_result_tx_clone = auth_result_tx.clone();
|
|
||||||
wv.connect_load_failed_with_tls_errors(move |_wv, uri, cert, err| {
|
|
||||||
let redacted_uri = redact_uri(uri);
|
|
||||||
warn!(
|
|
||||||
"Failed to load uri: {} with error: {}, cert: {}",
|
|
||||||
redacted_uri, err, cert
|
|
||||||
);
|
|
||||||
|
|
||||||
send_auth_result(&auth_result_tx_clone, Err(AuthDataError::TlsError));
|
|
||||||
true
|
|
||||||
});
|
|
||||||
|
|
||||||
wv.connect_load_failed(move |_wv, _event, uri, err| {
|
|
||||||
let redacted_uri = redact_uri(uri);
|
|
||||||
warn!("Failed to load uri: {} with error: {}", redacted_uri, err);
|
|
||||||
// NOTE: Don't send error here, since load_changed event will be triggered after this
|
|
||||||
// send_auth_result(&auth_result_tx, Err(AuthDataError::Invalid));
|
|
||||||
// true to stop other handlers from being invoked for the event. false to propagate the event further.
|
|
||||||
true
|
|
||||||
});
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let portal = self.server.to_string();
|
|
||||||
|
|
||||||
loop {
|
|
||||||
if let Some(auth_result) = auth_result_rx.recv().await {
|
|
||||||
match auth_result {
|
|
||||||
Ok(auth_data) => return Ok(auth_data),
|
|
||||||
Err(AuthDataError::TlsError) => {
|
|
||||||
return Err(anyhow::anyhow!("TLS error: certificate verify failed"))
|
|
||||||
}
|
|
||||||
Err(AuthDataError::NotFound) => {
|
|
||||||
info!("No auth data found, it may not be the /SAML20/SP/ACS endpoint");
|
|
||||||
|
|
||||||
// The user may need to interact with the auth window, raise it in 3 seconds
|
|
||||||
if !window.is_visible().unwrap_or(false) {
|
|
||||||
let window = Arc::clone(window);
|
|
||||||
let cancel_token = CancellationToken::new();
|
|
||||||
|
|
||||||
raise_window_cancel_token
|
|
||||||
.write()
|
|
||||||
.await
|
|
||||||
.replace(cancel_token.clone());
|
|
||||||
|
|
||||||
tokio::spawn(async move {
|
|
||||||
let delay_secs = 1;
|
|
||||||
|
|
||||||
info!("Raise window in {} second(s)", delay_secs);
|
|
||||||
tokio::select! {
|
|
||||||
_ = tokio::time::sleep(Duration::from_secs(delay_secs)) => {
|
|
||||||
raise_window(&window);
|
|
||||||
}
|
|
||||||
_ = cancel_token.cancelled() => {
|
|
||||||
info!("Raise window cancelled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(AuthDataError::Invalid) => {
|
|
||||||
info!("Got invalid auth data, retrying...");
|
|
||||||
|
|
||||||
window.with_webview(|wv| {
|
|
||||||
let wv = wv.inner();
|
|
||||||
wv.run_javascript(r#"
|
|
||||||
var loading = document.createElement("div");
|
|
||||||
loading.innerHTML = '<div style="position: absolute; width: 100%; text-align: center; font-size: 20px; font-weight: bold; top: 50%; left: 50%; transform: translate(-50%, -50%);">Got invalid token, retrying...</div>';
|
|
||||||
loading.style = "position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.85); z-index: 99999;";
|
|
||||||
document.body.appendChild(loading);
|
|
||||||
"#,
|
|
||||||
Cancellable::NONE,
|
|
||||||
|_| info!("Injected loading element successfully"),
|
|
||||||
);
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let saml_request = portal_prelogin(&portal, gp_params).await?;
|
|
||||||
window.with_webview(move |wv| {
|
|
||||||
let wv = wv.inner();
|
|
||||||
load_saml_request(&wv, &saml_request);
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn raise_window(window: &Arc<Window>) {
|
|
||||||
let visible = window.is_visible().unwrap_or(false);
|
|
||||||
if !visible {
|
|
||||||
if let Err(err) = window.raise() {
|
|
||||||
warn!("Failed to raise window: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn portal_prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result<String> {
|
|
||||||
info!("Portal prelogin...");
|
|
||||||
|
|
||||||
match prelogin(portal, gp_params).await? {
|
|
||||||
Prelogin::Saml(prelogin) => Ok(prelogin.saml_request().to_string()),
|
|
||||||
Prelogin::Standard(_) => Err(anyhow::anyhow!("Received non-SAML prelogin response")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send_auth_result(auth_result_tx: &mpsc::UnboundedSender<AuthResult>, auth_result: AuthResult) {
|
|
||||||
if let Err(err) = auth_result_tx.send(auth_result) {
|
|
||||||
warn!("Failed to send auth event: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn load_saml_request(wv: &Rc<WebView>, saml_request: &str) {
|
|
||||||
if saml_request.starts_with("http") {
|
|
||||||
info!("Load the SAML request as URI...");
|
|
||||||
wv.load_uri(saml_request);
|
|
||||||
} else {
|
|
||||||
info!("Load the SAML request as HTML...");
|
|
||||||
wv.load_html(saml_request, None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_auth_data_from_headers(response: &URIResponse) -> AuthResult {
|
|
||||||
response.http_headers().map_or_else(
|
|
||||||
|| {
|
|
||||||
info!("No headers found in response");
|
|
||||||
Err(AuthDataError::NotFound)
|
|
||||||
},
|
|
||||||
|mut headers| match headers.get("saml-auth-status") {
|
|
||||||
Some(status) if status == "1" => {
|
|
||||||
let username = headers.get("saml-username").map(GString::into);
|
|
||||||
let prelogin_cookie = headers.get("prelogin-cookie").map(GString::into);
|
|
||||||
let portal_userauthcookie = headers.get("portal-userauthcookie").map(GString::into);
|
|
||||||
|
|
||||||
if SamlAuthData::check(&username, &prelogin_cookie, &portal_userauthcookie) {
|
|
||||||
return Ok(SamlAuthData::new(
|
|
||||||
username.unwrap(),
|
|
||||||
prelogin_cookie,
|
|
||||||
portal_userauthcookie,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
info!("Found invalid auth data in headers");
|
|
||||||
Err(AuthDataError::Invalid)
|
|
||||||
}
|
|
||||||
Some(status) => {
|
|
||||||
info!("Found invalid SAML status: {} in headers", status);
|
|
||||||
Err(AuthDataError::Invalid)
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
info!("No saml-auth-status header found");
|
|
||||||
Err(AuthDataError::NotFound)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_auth_data_from_body<F>(main_resource: &WebResource, callback: F)
|
|
||||||
where
|
|
||||||
F: FnOnce(AuthResult) + Send + 'static,
|
|
||||||
{
|
|
||||||
main_resource.data(Cancellable::NONE, |data| match data {
|
|
||||||
Ok(data) => {
|
|
||||||
let html = String::from_utf8_lossy(&data);
|
|
||||||
callback(read_auth_data_from_html(&html));
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
info!("Failed to read response body: {}", err);
|
|
||||||
callback(Err(AuthDataError::Invalid))
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_auth_data_from_html(html: &str) -> AuthResult {
|
|
||||||
if html.contains("Temporarily Unavailable") {
|
|
||||||
info!("Found 'Temporarily Unavailable' in HTML, auth failed");
|
|
||||||
return Err(AuthDataError::Invalid);
|
|
||||||
}
|
|
||||||
|
|
||||||
match parse_xml_tag(html, "saml-auth-status") {
|
|
||||||
Some(saml_status) if saml_status == "1" => {
|
|
||||||
let username = parse_xml_tag(html, "saml-username");
|
|
||||||
let prelogin_cookie = parse_xml_tag(html, "prelogin-cookie");
|
|
||||||
let portal_userauthcookie = parse_xml_tag(html, "portal-userauthcookie");
|
|
||||||
|
|
||||||
if SamlAuthData::check(&username, &prelogin_cookie, &portal_userauthcookie) {
|
|
||||||
return Ok(SamlAuthData::new(
|
|
||||||
username.unwrap(),
|
|
||||||
prelogin_cookie,
|
|
||||||
portal_userauthcookie,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
info!("Found invalid auth data in HTML");
|
|
||||||
Err(AuthDataError::Invalid)
|
|
||||||
}
|
|
||||||
Some(status) => {
|
|
||||||
info!("Found invalid SAML status {} in HTML", status);
|
|
||||||
Err(AuthDataError::Invalid)
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
info!("No auth data found in HTML");
|
|
||||||
Err(AuthDataError::NotFound)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_auth_data(main_resource: &WebResource, auth_result_tx: mpsc::UnboundedSender<AuthResult>) {
|
|
||||||
if main_resource.response().is_none() {
|
|
||||||
info!("No response found in main resource");
|
|
||||||
send_auth_result(&auth_result_tx, Err(AuthDataError::Invalid));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let response = main_resource.response().unwrap();
|
|
||||||
info!("Trying to read auth data from response headers...");
|
|
||||||
|
|
||||||
match read_auth_data_from_headers(&response) {
|
|
||||||
Ok(auth_data) => {
|
|
||||||
info!("Got auth data from headers");
|
|
||||||
send_auth_result(&auth_result_tx, Ok(auth_data));
|
|
||||||
}
|
|
||||||
Err(AuthDataError::Invalid) => {
|
|
||||||
info!("Found invalid auth data in headers, trying to read from body...");
|
|
||||||
read_auth_data_from_body(main_resource, move |auth_result| {
|
|
||||||
// Since we have already found invalid auth data in headers, which means this could be the `/SAML20/SP/ACS` endpoint
|
|
||||||
// any error result from body should be considered as invalid, and trigger a retry
|
|
||||||
let auth_result = auth_result.map_err(|_| AuthDataError::Invalid);
|
|
||||||
send_auth_result(&auth_result_tx, auth_result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Err(AuthDataError::NotFound) => {
|
|
||||||
info!("No auth data found in headers, trying to read from body...");
|
|
||||||
read_auth_data_from_body(main_resource, move |auth_result| {
|
|
||||||
send_auth_result(&auth_result_tx, auth_result)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Err(AuthDataError::TlsError) => {
|
|
||||||
// NOTE: This is unreachable
|
|
||||||
info!("TLS error found in headers, trying to read from body...");
|
|
||||||
send_auth_result(&auth_result_tx, Err(AuthDataError::TlsError));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_xml_tag(html: &str, tag: &str) -> Option<String> {
|
|
||||||
let re = Regex::new(&format!("<{}>(.*)</{}>", tag, tag)).unwrap();
|
|
||||||
re.captures(html)
|
|
||||||
.and_then(|captures| captures.get(1))
|
|
||||||
.map(|m| m.as_str().to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn clear_webview_cookies(window: &Window) -> anyhow::Result<()> {
|
|
||||||
let (tx, rx) = oneshot::channel::<Result<(), String>>();
|
|
||||||
|
|
||||||
window.with_webview(|wv| {
|
|
||||||
let send_result = move |result: Result<(), String>| {
|
|
||||||
if let Err(err) = tx.send(result) {
|
|
||||||
info!("Failed to send result: {:?}", err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let wv = wv.inner();
|
|
||||||
let context = match wv.context() {
|
|
||||||
Some(context) => context,
|
|
||||||
None => {
|
|
||||||
send_result(Err("No webview context found".into()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let data_manager = match context.website_data_manager() {
|
|
||||||
Some(manager) => manager,
|
|
||||||
None => {
|
|
||||||
send_result(Err("No data manager found".into()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let now = Instant::now();
|
|
||||||
data_manager.clear(
|
|
||||||
WebsiteDataTypes::COOKIES,
|
|
||||||
TimeSpan(0),
|
|
||||||
Cancellable::NONE,
|
|
||||||
move |result| match result {
|
|
||||||
Err(err) => {
|
|
||||||
send_result(Err(err.to_string()));
|
|
||||||
}
|
|
||||||
Ok(_) => {
|
|
||||||
info!("Cookies cleared in {} ms", now.elapsed().as_millis());
|
|
||||||
send_result(Ok(()));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
})?;
|
|
||||||
|
|
||||||
rx.await?.map_err(|err| anyhow::anyhow!(err))
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
use std::{
|
||||||
|
sync::{
|
||||||
|
Arc,
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
|
use tauri::RunEvent;
|
||||||
|
|
||||||
|
pub fn run() -> anyhow::Result<()> {
|
||||||
|
let handled = Arc::new(AtomicBool::new(false));
|
||||||
|
let timeout_handled = Arc::clone(&handled);
|
||||||
|
let app = tauri::Builder::default()
|
||||||
|
.setup(move |app| {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
||||||
|
|
||||||
|
let app_handle = app.handle().clone();
|
||||||
|
tauri::async_runtime::spawn(async move {
|
||||||
|
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||||
|
if !timeout_handled.swap(true, Ordering::AcqRel) {
|
||||||
|
app_handle.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.build(crate::tauri_context::get())?;
|
||||||
|
|
||||||
|
app.run(move |app_handle, event| {
|
||||||
|
let RunEvent::Opened { urls } = event else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(callback) = urls
|
||||||
|
.into_iter()
|
||||||
|
.find(|url| url.scheme().eq_ignore_ascii_case("globalprotectcallback"))
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if handled.swap(true, Ordering::AcqRel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let app_handle = app_handle.clone();
|
||||||
|
tauri::async_runtime::spawn(async move {
|
||||||
|
let exit_code = match auth::forward_auth_callback(callback.as_str()).await {
|
||||||
|
Ok(()) => 0,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Failed to forward authentication callback: {err}");
|
||||||
|
1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
app_handle.exit(exit_code);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,90 +1,166 @@
|
|||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
use auth::forward_auth_callback;
|
||||||
|
use auth::{BrowserAuthenticator, auth_prelogin};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
use clap::Subcommand;
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
use gpapi::auth::AuthWindowTheme;
|
||||||
use gpapi::{
|
use gpapi::{
|
||||||
auth::{SamlAuthData, SamlAuthResult},
|
auth::{AuthenticationCancelled, SamlAuthData, SamlAuthResult},
|
||||||
clap::args::Os,
|
clap::{Args, InfoLevelVerbosity, args::Os, handle_error},
|
||||||
gp_params::{ClientOs, GpParams},
|
gp_params::GpParams,
|
||||||
|
log_format::LogFormat,
|
||||||
|
os_profile::{ClientOs, OsProfile},
|
||||||
utils::{normalize_server, openssl},
|
utils::{normalize_server, openssl},
|
||||||
GP_USER_AGENT,
|
|
||||||
};
|
};
|
||||||
use log::{info, LevelFilter};
|
use log::info;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tauri::{App, AppHandle, RunEvent};
|
use std::net::IpAddr;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
use crate::auth_window::{portal_prelogin, AuthWindow};
|
|
||||||
|
|
||||||
const VERSION: &str = concat!(
|
const VERSION: &str = concat!(
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
" (",
|
" (",
|
||||||
|
env!("GPAUTH_GIT_COMMIT"),
|
||||||
|
" ",
|
||||||
compile_time::date_str!(),
|
compile_time::date_str!(),
|
||||||
")"
|
")"
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Parser, Clone)]
|
#[derive(Parser)]
|
||||||
#[command(version = VERSION)]
|
#[command(
|
||||||
|
version = VERSION,
|
||||||
|
author,
|
||||||
|
about = "The authentication component for the GlobalProtect VPN client, supports the SSO authentication method.",
|
||||||
|
args_conflicts_with_subcommands = true,
|
||||||
|
subcommand_negates_reqs = true,
|
||||||
|
help_template = "\
|
||||||
|
{before-help}{name} {version}
|
||||||
|
{author}
|
||||||
|
|
||||||
|
{about}
|
||||||
|
|
||||||
|
{usage-heading} {usage}
|
||||||
|
|
||||||
|
{all-args}{after-help}
|
||||||
|
|
||||||
|
See 'gpauth -h' for more information.
|
||||||
|
"
|
||||||
|
)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
server: String,
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
#[arg(long)]
|
#[command(subcommand)]
|
||||||
|
command: Option<CliCommand>,
|
||||||
|
|
||||||
|
#[arg(required = true, help = "The portal server to authenticate")]
|
||||||
|
server: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Treating the server as a gateway")]
|
||||||
|
gateway: bool,
|
||||||
|
|
||||||
|
#[arg(long, help = "The SAML authentication request")]
|
||||||
saml_request: Option<String>,
|
saml_request: Option<String>,
|
||||||
#[arg(long, default_value = GP_USER_AGENT)]
|
|
||||||
user_agent: String,
|
#[arg(long, value_enum, default_value_t = Os::default())]
|
||||||
#[arg(long, default_value = "Linux")]
|
|
||||||
os: Os,
|
os: Os,
|
||||||
#[arg(long)]
|
|
||||||
os_version: Option<String>,
|
#[arg(long, help = "Use this runtime host ID when building the OS profile")]
|
||||||
#[arg(long)]
|
host_id: Option<String>,
|
||||||
hidpi: bool,
|
|
||||||
#[arg(long)]
|
#[arg(long, help = "Override the GlobalProtect client version reported to the server")]
|
||||||
|
client_version: Option<String>,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
short,
|
||||||
|
long,
|
||||||
|
help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format"
|
||||||
|
)]
|
||||||
|
certificate: Option<String>,
|
||||||
|
|
||||||
|
#[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")]
|
||||||
|
sslkey: Option<String>,
|
||||||
|
|
||||||
|
#[arg(short = 'p', long, help = "The key passphrase of the private key")]
|
||||||
|
key_password: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")]
|
||||||
fix_openssl: bool,
|
fix_openssl: bool,
|
||||||
#[arg(long)]
|
|
||||||
|
#[arg(long, help = "Ignore TLS errors")]
|
||||||
ignore_tls_errors: bool,
|
ignore_tls_errors: bool,
|
||||||
#[arg(long)]
|
|
||||||
clean: bool,
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_enum,
|
||||||
|
default_value_t = LogFormat::Text,
|
||||||
|
help = "Log output format. JSON is intended for non-interactive consumers; interactive prompts remain text."
|
||||||
|
)]
|
||||||
|
log_format: LogFormat,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "Use the default browser for authentication")]
|
||||||
|
default_browser: bool,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser or `remote` for headless servers.",
|
||||||
|
default_missing_value = "auto",
|
||||||
|
num_args=0..=1
|
||||||
|
)]
|
||||||
|
browser: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Listen on this IP address when using '--browser remote'")]
|
||||||
|
browser_listen: Option<IpAddr>,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "The HiDPI mode, useful for high-resolution screens")]
|
||||||
|
hidpi: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "Clean the cache of the embedded browser")]
|
||||||
|
pub clean: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "Set the embedded authentication window title")]
|
||||||
|
window_title: Option<String>,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, value_enum, default_value_t = AuthWindowTheme::default(), help = "Set the embedded authentication window appearance")]
|
||||||
|
window_theme: AuthWindowTheme,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
verbose: InfoLevelVerbosity,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
enum CliCommand {
|
||||||
|
#[command(hide = true)]
|
||||||
|
AuthCallback {
|
||||||
|
#[arg(help = "The globalprotectcallback URL to forward")]
|
||||||
|
callback: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Args for Cli {
|
||||||
|
fn fix_openssl(&self) -> bool {
|
||||||
|
self.fix_openssl
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ignore_tls_errors(&self) -> bool {
|
||||||
|
self.ignore_tls_errors
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log_format(&self) -> LogFormat {
|
||||||
|
self.log_format
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cli {
|
impl Cli {
|
||||||
async fn run(&mut self) -> anyhow::Result<()> {
|
|
||||||
if self.ignore_tls_errors {
|
|
||||||
info!("TLS errors will be ignored");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut openssl_conf = self.prepare_env()?;
|
|
||||||
|
|
||||||
self.server = normalize_server(&self.server)?;
|
|
||||||
let gp_params = self.build_gp_params();
|
|
||||||
|
|
||||||
// Get the initial SAML request
|
|
||||||
let saml_request = match self.saml_request {
|
|
||||||
Some(ref saml_request) => saml_request.clone(),
|
|
||||||
None => portal_prelogin(&self.server, &gp_params).await?,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.saml_request.replace(saml_request);
|
|
||||||
|
|
||||||
let app = create_app(self.clone())?;
|
|
||||||
|
|
||||||
app.run(move |_app_handle, event| {
|
|
||||||
if let RunEvent::Exit = event {
|
|
||||||
if let Some(file) = openssl_conf.take() {
|
|
||||||
if let Err(err) = file.close() {
|
|
||||||
info!("Error closing OpenSSL config file: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_env(&self) -> anyhow::Result<Option<NamedTempFile>> {
|
fn prepare_env(&self) -> anyhow::Result<Option<NamedTempFile>> {
|
||||||
std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1");
|
#[cfg(feature = "webview-auth")]
|
||||||
|
gpapi::utils::env_utils::patch_gui_runtime_env(self.hidpi);
|
||||||
if self.hidpi {
|
|
||||||
info!("Setting GDK_SCALE=2 and GDK_DPI_SCALE=0.5");
|
|
||||||
|
|
||||||
std::env::set_var("GDK_SCALE", "2");
|
|
||||||
std::env::set_var("GDK_DPI_SCALE", "0.5");
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.fix_openssl {
|
if self.fix_openssl {
|
||||||
info!("Fixing OpenSSL environment");
|
info!("Fixing OpenSSL environment");
|
||||||
@@ -96,69 +172,285 @@ impl Cli {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_gp_params(&self) -> GpParams {
|
async fn run(&self) -> anyhow::Result<()> {
|
||||||
let gp_params = GpParams::builder()
|
if self.browser_listen.is_some()
|
||||||
.user_agent(&self.user_agent)
|
&& !matches!(self.browser.as_deref(), Some(browser) if browser.eq_ignore_ascii_case("remote"))
|
||||||
.client_os(ClientOs::from(&self.os))
|
{
|
||||||
.os_version(self.os_version.clone())
|
anyhow::bail!("The '--browser-listen' option requires '--browser remote'");
|
||||||
.ignore_tls_errors(self.ignore_tls_errors)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
gp_params
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn saml_auth(&self, app_handle: AppHandle) -> anyhow::Result<SamlAuthData> {
|
if self.ignore_tls_errors {
|
||||||
let auth_window = AuthWindow::new(app_handle)
|
info!("TLS errors will be ignored");
|
||||||
.server(&self.server)
|
}
|
||||||
.user_agent(&self.user_agent)
|
|
||||||
.gp_params(self.build_gp_params())
|
|
||||||
.saml_request(self.saml_request.as_ref().unwrap())
|
|
||||||
.clean(self.clean);
|
|
||||||
|
|
||||||
auth_window.open().await
|
let openssl_conf = self.prepare_env()?;
|
||||||
|
|
||||||
|
let server = normalize_server(self.server.as_deref().expect("server is required for authentication"))?;
|
||||||
|
let gp_params = self.build_gp_params();
|
||||||
|
info!(
|
||||||
|
"gpauth auth host-id: {}",
|
||||||
|
gp_params.os_profile().host_identity().host_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
let auth_request = match self.saml_request.as_deref() {
|
||||||
|
Some(auth_request) => auth_request.to_string(),
|
||||||
|
None => auth_prelogin(&server, &gp_params, self.external_browser_requested(), self.gateway).await?,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
let browser = self
|
||||||
|
.browser
|
||||||
|
.as_deref()
|
||||||
|
.or_else(|| self.default_browser.then(|| "default"));
|
||||||
|
|
||||||
|
#[cfg(not(feature = "webview-auth"))]
|
||||||
|
let browser = self.browser.as_deref().or(Some("default"));
|
||||||
|
|
||||||
|
if let Some(browser) = browser {
|
||||||
|
let auth_host_id = gp_params.os_profile().host_identity().host_id().to_string();
|
||||||
|
let authenticator = BrowserAuthenticator::new(&auth_request, browser, self.browser_listen);
|
||||||
|
let auth_result = authenticator.authenticate().await;
|
||||||
|
|
||||||
|
print_auth_result(auth_result, Some(&auth_host_id));
|
||||||
|
|
||||||
|
// explicitly drop openssl_conf to avoid the unused variable warning
|
||||||
|
drop(openssl_conf);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
crate::webview_auth::authenticate(
|
||||||
|
server,
|
||||||
|
gp_params,
|
||||||
|
auth_request,
|
||||||
|
self.clean,
|
||||||
|
self.window_title.clone(),
|
||||||
|
self.window_theme,
|
||||||
|
openssl_conf,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_gp_params(&self) -> GpParams {
|
||||||
|
GpParams::builder(self.build_os_profile())
|
||||||
|
.ignore_tls_errors(self.ignore_tls_errors)
|
||||||
|
.certificate(self.certificate.clone())
|
||||||
|
.sslkey(self.sslkey.clone())
|
||||||
|
.key_password(self.key_password.clone())
|
||||||
|
.is_gateway(self.gateway)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_os_profile(&self) -> OsProfile {
|
||||||
|
let mut builder = OsProfile::builder(ClientOs::from(self.os));
|
||||||
|
if let Some(host_id) = self.host_id.as_deref() {
|
||||||
|
builder = builder.host_id_override(host_id);
|
||||||
|
}
|
||||||
|
if let Some(client_version) = self.client_version.as_deref() {
|
||||||
|
builder = builder.client_version(client_version);
|
||||||
|
}
|
||||||
|
builder.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn external_browser_requested(&self) -> bool {
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
{
|
||||||
|
self.default_browser || self.browser.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "webview-auth"))]
|
||||||
|
{
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_app(cli: Cli) -> anyhow::Result<App> {
|
fn init_logger(cli: &Cli) {
|
||||||
let app = tauri::Builder::default()
|
let Some(level) = cli.verbose.log_level_filter().to_level() else {
|
||||||
.setup(|app| {
|
log::set_max_level(log::LevelFilter::Off);
|
||||||
let app_handle = app.handle();
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
gpapi::logger::init(level, "com.yuezk.gpgui", "gpauth", cli.log_format);
|
||||||
let auth_result = match cli.saml_auth(app_handle.clone()).await {
|
}
|
||||||
Ok(auth_data) => SamlAuthResult::Success(auth_data),
|
|
||||||
|
pub async fn run() {
|
||||||
|
let cli = Cli::parse();
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
if let Some(CliCommand::AuthCallback { callback }) = &cli.command {
|
||||||
|
if let Err(err) = forward_auth_callback(callback).await {
|
||||||
|
eprintln!("Failed to forward authentication callback: {err}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
init_logger(&cli);
|
||||||
|
info!("gpauth started: {}", VERSION);
|
||||||
|
|
||||||
|
if let Err(err) = cli.run().await {
|
||||||
|
handle_error(err, &cli);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn print_auth_result(auth_result: anyhow::Result<SamlAuthData>, host_id: Option<&str>) {
|
||||||
|
let auth_result = match auth_result {
|
||||||
|
Ok(auth_data) => {
|
||||||
|
let auth_data = match host_id {
|
||||||
|
Some(host_id) => auth_data.with_host_id(host_id),
|
||||||
|
None => auth_data,
|
||||||
|
};
|
||||||
|
SamlAuthResult::Success(auth_data)
|
||||||
|
}
|
||||||
|
Err(err) if err.downcast_ref::<AuthenticationCancelled>().is_some() => SamlAuthResult::Cancelled,
|
||||||
Err(err) => SamlAuthResult::Failure(format!("{}", err)),
|
Err(err) => SamlAuthResult::Failure(format!("{}", err)),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{}", json!(auth_result));
|
println!("{}", json!(auth_result));
|
||||||
});
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.build(tauri::generate_context!())?;
|
|
||||||
|
|
||||||
Ok(app)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_logger() {
|
#[cfg(test)]
|
||||||
env_logger::builder().filter_level(LevelFilter::Info).init();
|
mod tests {
|
||||||
}
|
use super::*;
|
||||||
|
|
||||||
pub async fn run() {
|
/// gpauth's own result already goes to stdout as JSON; this makes its *logs*
|
||||||
let mut cli = Cli::parse();
|
/// readable the same way, so a caller driving it does not have to parse prose
|
||||||
|
/// on stderr to find out why an attempt failed.
|
||||||
|
#[test]
|
||||||
|
fn log_format_defaults_to_text() {
|
||||||
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
init_logger();
|
assert_eq!(cli.log_format, LogFormat::Text);
|
||||||
info!("gpauth started: {}", VERSION);
|
|
||||||
|
|
||||||
if let Err(err) = cli.run().await {
|
|
||||||
eprintln!("\nError: {}", err);
|
|
||||||
|
|
||||||
if err.to_string().contains("unsafe legacy renegotiation") && !cli.fix_openssl {
|
|
||||||
eprintln!("\nRe-run it with the `--fix-openssl` option to work around this issue, e.g.:\n");
|
|
||||||
// Print the command
|
|
||||||
let args = std::env::args().collect::<Vec<_>>();
|
|
||||||
eprintln!("{} --fix-openssl {}\n", args[0], args[1..].join(" "));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::process::exit(1);
|
#[test]
|
||||||
|
fn log_format_accepts_json() {
|
||||||
|
let cli =
|
||||||
|
Cli::try_parse_from(["gpauth", "portal.example.com", "--log-format", "json"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.log_format, LogFormat::Json);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn os_defaults_to_runtime_os() {
|
||||||
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.os, Os::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
fn callback_arguments_parse_separately() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpauth",
|
||||||
|
"auth-callback",
|
||||||
|
"globalprotectcallback:cas-as=1&[email protected]&token=token",
|
||||||
|
])
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
cli.command,
|
||||||
|
Some(CliCommand::AuthCallback { callback }) if callback.starts_with("globalprotectcallback:")
|
||||||
|
));
|
||||||
|
assert!(cli.server.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn host_id_arg_sets_profile_host_id_seed() {
|
||||||
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--host-id", "host-seed"])
|
||||||
|
.expect("gpauth args should parse");
|
||||||
|
let profile = cli.build_os_profile();
|
||||||
|
|
||||||
|
assert_eq!(profile.host_identity().host_id(), "host-seed");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_arg_requests_external_browser() {
|
||||||
|
let cli =
|
||||||
|
Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "firefox"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert!(cli.external_browser_requested());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_without_value_uses_auto_mode() {
|
||||||
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--browser"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.browser.as_deref(), Some("auto"));
|
||||||
|
assert!(cli.external_browser_requested());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_default_keeps_system_default_mode() {
|
||||||
|
let cli =
|
||||||
|
Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "default"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.browser.as_deref(), Some("default"));
|
||||||
|
assert!(cli.external_browser_requested());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_listen_accepts_ip_address() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpauth",
|
||||||
|
"portal.example.com",
|
||||||
|
"--browser",
|
||||||
|
"remote",
|
||||||
|
"--browser-listen",
|
||||||
|
"192.168.107.15",
|
||||||
|
])
|
||||||
|
.expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.browser_listen, Some("192.168.107.15".parse().unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn client_version_arg_sets_profile_client_version() {
|
||||||
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--client-version", "legacy-client"])
|
||||||
|
.expect("gpauth args should parse");
|
||||||
|
let profile = cli.build_os_profile();
|
||||||
|
|
||||||
|
assert_eq!(profile.client_version(), "legacy-client");
|
||||||
|
assert!(profile.user_agent().contains("legacy-client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn client_certificate_args_parse() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpauth",
|
||||||
|
"portal.example.com",
|
||||||
|
"--certificate",
|
||||||
|
"/tmp/client.pem",
|
||||||
|
"--sslkey",
|
||||||
|
"/tmp/client.key",
|
||||||
|
"--key-password",
|
||||||
|
"secret",
|
||||||
|
])
|
||||||
|
.expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.certificate.as_deref(), Some("/tmp/client.pem"));
|
||||||
|
assert_eq!(cli.sslkey.as_deref(), Some("/tmp/client.key"));
|
||||||
|
assert_eq!(cli.key_password.as_deref(), Some("secret"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[test]
|
||||||
|
fn auth_window_options_parse() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpauth",
|
||||||
|
"portal.example.com",
|
||||||
|
"--window-title",
|
||||||
|
"GP Connect Login",
|
||||||
|
"--window-theme",
|
||||||
|
"dark",
|
||||||
|
])
|
||||||
|
.expect("gpauth window options should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.window_title.as_deref(), Some("GP Connect Login"));
|
||||||
|
assert_eq!(cli.window_theme, AuthWindowTheme::Dark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,35 @@
|
|||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
mod auth_window;
|
|
||||||
mod cli;
|
mod cli;
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "macos", feature = "webview-auth"))]
|
||||||
|
mod callback_app;
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
mod tauri_context;
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
mod webview_auth;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
#[cfg(all(target_os = "macos", feature = "webview-auth"))]
|
||||||
|
if is_callback_app_launch() {
|
||||||
|
if let Err(err) = callback_app::run() {
|
||||||
|
eprintln!("Failed to handle authentication callback: {err}");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cli::run().await;
|
cli::run().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "macos", feature = "webview-auth"))]
|
||||||
|
fn is_callback_app_launch() -> bool {
|
||||||
|
std::env::args_os().len() == 1
|
||||||
|
&& std::env::current_exe().is_ok_and(|executable| {
|
||||||
|
executable
|
||||||
|
.ancestors()
|
||||||
|
.any(|path| path.extension().is_some_and(|extension| extension == "app"))
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
pub fn get() -> tauri::Context<tauri::Wry> {
|
||||||
|
tauri::generate_context!()
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
use auth::{WebviewAuthenticator, apply_auth_theme};
|
||||||
|
use gpapi::{auth::AuthWindowTheme, gp_params::GpParams};
|
||||||
|
use log::info;
|
||||||
|
use tauri::RunEvent;
|
||||||
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
use crate::cli::print_auth_result;
|
||||||
|
|
||||||
|
pub async fn authenticate(
|
||||||
|
server: String,
|
||||||
|
gp_params: GpParams,
|
||||||
|
auth_request: String,
|
||||||
|
clean: bool,
|
||||||
|
window_title: Option<String>,
|
||||||
|
window_theme: AuthWindowTheme,
|
||||||
|
mut openssl_conf: Option<NamedTempFile>,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let auth_host_id = gp_params.os_profile().host_identity().host_id().to_string();
|
||||||
|
|
||||||
|
tauri::Builder::default()
|
||||||
|
.setup(move |app| {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
||||||
|
|
||||||
|
apply_auth_theme(app.handle(), window_theme);
|
||||||
|
let app_handle = app.handle().clone();
|
||||||
|
|
||||||
|
tauri::async_runtime::spawn(async move {
|
||||||
|
let authenticator = WebviewAuthenticator::new(&server, &gp_params)
|
||||||
|
.with_auth_request(&auth_request)
|
||||||
|
.with_webview_user_agent(gp_params.os_profile().webview_user_agent())
|
||||||
|
.with_clean(clean)
|
||||||
|
.with_window_title(window_title.as_deref().unwrap_or("GlobalProtect Login"))
|
||||||
|
.with_window_theme(window_theme);
|
||||||
|
|
||||||
|
let auth_result = authenticator.authenticate(&app_handle).await;
|
||||||
|
print_auth_result(auth_result, Some(&auth_host_id));
|
||||||
|
|
||||||
|
// Ensure the app exits after the authentication process
|
||||||
|
app_handle.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.build(crate::tauri_context::get())?
|
||||||
|
.run(move |_app_handle, event| {
|
||||||
|
if let RunEvent::Exit = event {
|
||||||
|
if let Some(file) = openssl_conf.take() {
|
||||||
|
if let Err(err) = file.close() {
|
||||||
|
info!("Error closing OpenSSL config file: {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,47 +1,19 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://cdn.jsdelivr.net/gh/tauri-apps/tauri@tauri-v1.5.0/tooling/cli/schema.json",
|
"$schema": "https://cdn.jsdelivr.net/gh/tauri-apps/tauri@tauri-v2.1.1/crates/tauri-cli/config.schema.json",
|
||||||
"build": {
|
"build": {
|
||||||
"distDir": [
|
"frontendDist": ["index.html"],
|
||||||
"index.html"
|
|
||||||
],
|
|
||||||
"devPath": [
|
|
||||||
"index.html"
|
|
||||||
],
|
|
||||||
"beforeDevCommand": "",
|
"beforeDevCommand": "",
|
||||||
"beforeBuildCommand": "",
|
"beforeBuildCommand": ""
|
||||||
"withGlobalTauri": false
|
|
||||||
},
|
},
|
||||||
"package": {
|
"identifier": "com.yuezk.gpauth",
|
||||||
"productName": "gpauth",
|
"productName": "GP Connect Login",
|
||||||
"version": "0.0.0"
|
"app": {
|
||||||
},
|
"withGlobalTauri": false,
|
||||||
"tauri": {
|
"security": {
|
||||||
"allowlist": {
|
"csp": null
|
||||||
"all": false,
|
|
||||||
"http": {
|
|
||||||
"all": true,
|
|
||||||
"request": true,
|
|
||||||
"scope": [
|
|
||||||
"http://**",
|
|
||||||
"https://**"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"active": true,
|
"icon": ["icons/icon.png"]
|
||||||
"targets": "deb",
|
|
||||||
"identifier": "com.yuezk.gpauth",
|
|
||||||
"icon": [
|
|
||||||
"icons/32x32.png",
|
|
||||||
"icons/128x128.png",
|
|
||||||
"icons/[email protected]",
|
|
||||||
"icons/icon.icns",
|
|
||||||
"icons/icon.ico"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"security": {
|
|
||||||
"csp": null
|
|
||||||
},
|
|
||||||
"windows": []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,33 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
|
rust-version.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
common = { path = "../../crates/common" }
|
||||||
gpapi = { path = "../../crates/gpapi", features = ["clap"] }
|
gpapi = { path = "../../crates/gpapi", features = ["clap"] }
|
||||||
|
gphip = { path = "../../crates/gphip" }
|
||||||
openconnect = { path = "../../crates/openconnect" }
|
openconnect = { path = "../../crates/openconnect" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
inquire = "0.6.2"
|
inquire = "0.9"
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
tokio.workspace = true
|
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||||
sysinfo.workspace = true
|
sysinfo.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
whoami.workspace = true
|
whoami.workspace = true
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
directories = "5.0"
|
directories.workspace = true
|
||||||
compile-time.workspace = true
|
compile-time.workspace = true
|
||||||
|
uzers.workspace = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["webview-auth"]
|
||||||
|
webview-auth = ["gpapi/webview-auth"]
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
use std::{env, fs, path::PathBuf, process::Command};
|
||||||
|
|
||||||
|
const UNKNOWN_COMMIT: &str = "unknown";
|
||||||
|
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=GPCLIENT_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||||
|
|
||||||
|
let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../..");
|
||||||
|
let source_commit = repo_root.join("SOURCE_COMMIT");
|
||||||
|
println!("cargo:rerun-if-changed={}", source_commit.display());
|
||||||
|
|
||||||
|
let commit = env_commit("GPCLIENT_GIT_COMMIT")
|
||||||
|
.or_else(|| env_commit("SOURCE_GIT_COMMIT"))
|
||||||
|
.or_else(|| env_commit("GITHUB_SHA"))
|
||||||
|
.or_else(|| file_commit(&source_commit))
|
||||||
|
.or_else(|| git_commit(&repo_root))
|
||||||
|
.unwrap_or_else(|| UNKNOWN_COMMIT.to_string());
|
||||||
|
|
||||||
|
println!("cargo:rustc-env=GPCLIENT_GIT_COMMIT={commit}");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn env_commit(key: &str) -> Option<String> {
|
||||||
|
env::var(key).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn file_commit(path: &PathBuf) -> Option<String> {
|
||||||
|
fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn git_commit(repo_root: &PathBuf) -> Option<String> {
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args(["rev-parse", "--short=12", "HEAD"])
|
||||||
|
.current_dir(repo_root)
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
String::from_utf8(output.stdout)
|
||||||
|
.ok()
|
||||||
|
.and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normalize_commit(value: &str) -> Option<String> {
|
||||||
|
let value = value.trim();
|
||||||
|
if value.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(value.chars().take(DISPLAY_COMMIT_LEN).collect())
|
||||||
|
}
|
||||||
@@ -1,34 +1,55 @@
|
|||||||
|
use std::{
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
|
use anyhow::bail;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use gpapi::utils::openssl;
|
use gpapi::{
|
||||||
use log::{info, LevelFilter};
|
clap::{Args, InfoLevelVerbosity, handle_error},
|
||||||
|
log_format::{LogFormat, write_json_record},
|
||||||
|
utils::openssl,
|
||||||
|
};
|
||||||
|
use log::info;
|
||||||
|
use sysinfo::{Pid, System};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
use tokio::fs;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
GP_CLIENT_LOCK_FILE,
|
||||||
connect::{ConnectArgs, ConnectHandler},
|
connect::{ConnectArgs, ConnectHandler},
|
||||||
disconnect::DisconnectHandler,
|
disconnect::{DisconnectArgs, DisconnectHandler},
|
||||||
|
hip::{HipArgs, HipHandler},
|
||||||
launch_gui::{LaunchGuiArgs, LaunchGuiHandler},
|
launch_gui::{LaunchGuiArgs, LaunchGuiHandler},
|
||||||
};
|
};
|
||||||
|
|
||||||
const VERSION: &str = concat!(
|
const VERSION: &str = concat!(
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
" (",
|
" (",
|
||||||
|
env!("GPCLIENT_GIT_COMMIT"),
|
||||||
|
" ",
|
||||||
compile_time::date_str!(),
|
compile_time::date_str!(),
|
||||||
")"
|
")"
|
||||||
);
|
);
|
||||||
|
|
||||||
pub(crate) struct SharedArgs {
|
pub(crate) struct SharedArgs<'a> {
|
||||||
pub(crate) fix_openssl: bool,
|
pub(crate) fix_openssl: bool,
|
||||||
pub(crate) ignore_tls_errors: bool,
|
pub(crate) ignore_tls_errors: bool,
|
||||||
|
pub(crate) lock_file: &'a Path,
|
||||||
|
pub(crate) verbose: &'a InfoLevelVerbosity,
|
||||||
|
pub(crate) log_format: LogFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum CliCommand {
|
enum CliCommand {
|
||||||
#[command(about = "Connect to a portal server")]
|
#[command(about = "Connect to a portal server")]
|
||||||
Connect(ConnectArgs),
|
Connect(Box<ConnectArgs>),
|
||||||
#[command(about = "Disconnect from the server")]
|
#[command(about = "Disconnect from the server")]
|
||||||
Disconnect,
|
Disconnect(DisconnectArgs),
|
||||||
#[command(about = "Launch the GUI")]
|
#[command(about = "Launch the GUI")]
|
||||||
LaunchGui(LaunchGuiArgs),
|
LaunchGui(LaunchGuiArgs),
|
||||||
|
#[command(about = "Generate HIP report")]
|
||||||
|
Hip(HipArgs),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
@@ -55,14 +76,74 @@ struct Cli {
|
|||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "Get around the OpenSSL `unsafe legacy renegotiation` error"
|
help = "Uses extended compatibility mode for OpenSSL operations to support a broader range of systems and formats."
|
||||||
)]
|
)]
|
||||||
fix_openssl: bool,
|
fix_openssl: bool,
|
||||||
#[arg(long, help = "Ignore the TLS errors")]
|
#[arg(long, help = "Ignore the TLS errors")]
|
||||||
ignore_tls_errors: bool,
|
ignore_tls_errors: bool,
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
global = true,
|
||||||
|
default_value = GP_CLIENT_LOCK_FILE,
|
||||||
|
help = "Path to the gpclient PID lock file"
|
||||||
|
)]
|
||||||
|
lock_file: PathBuf,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_enum,
|
||||||
|
default_value_t = LogFormat::Text,
|
||||||
|
help = "Log output format. JSON is intended for non-interactive consumers; interactive prompts remain text."
|
||||||
|
)]
|
||||||
|
log_format: LogFormat,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
verbose: InfoLevelVerbosity,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Args for Cli {
|
||||||
|
fn fix_openssl(&self) -> bool {
|
||||||
|
self.fix_openssl
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ignore_tls_errors(&self) -> bool {
|
||||||
|
self.ignore_tls_errors
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log_format(&self) -> LogFormat {
|
||||||
|
self.log_format
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cli {
|
impl Cli {
|
||||||
|
fn can_run_alongside_client(&self) -> bool {
|
||||||
|
match &self.command {
|
||||||
|
CliCommand::Disconnect(_) => true,
|
||||||
|
CliCommand::Hip(_) => true,
|
||||||
|
CliCommand::LaunchGui(args) => args.is_auth_callback(),
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn is_running(&self) -> bool {
|
||||||
|
let Ok(c) = fs::read_to_string(&self.lock_file).await else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(pid) = Pid::from_str(c.trim()) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let s = System::new_all();
|
||||||
|
let Some(p) = s.process(pid) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
p.exe()
|
||||||
|
.map(|exe| exe.to_string_lossy().contains("gpclient"))
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
fn fix_openssl(&self) -> anyhow::Result<Option<NamedTempFile>> {
|
fn fix_openssl(&self) -> anyhow::Result<Option<NamedTempFile>> {
|
||||||
if self.fix_openssl {
|
if self.fix_openssl {
|
||||||
let file = openssl::fix_openssl_env()?;
|
let file = openssl::fix_openssl_env()?;
|
||||||
@@ -73,12 +154,20 @@ impl Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn run(&self) -> anyhow::Result<()> {
|
async fn run(&self) -> anyhow::Result<()> {
|
||||||
|
// check if an instance is running
|
||||||
|
if !self.can_run_alongside_client() && self.is_running().await {
|
||||||
|
bail!("Another instance of the client is already running");
|
||||||
|
}
|
||||||
|
|
||||||
// The temp file will be dropped automatically when the file handle is dropped
|
// The temp file will be dropped automatically when the file handle is dropped
|
||||||
// So, declare it here to ensure it's not dropped
|
// So, declare it here to ensure it's not dropped
|
||||||
let _file = self.fix_openssl()?;
|
let _file = self.fix_openssl()?;
|
||||||
let shared_args = SharedArgs {
|
let shared_args = SharedArgs {
|
||||||
fix_openssl: self.fix_openssl,
|
fix_openssl: self.fix_openssl,
|
||||||
ignore_tls_errors: self.ignore_tls_errors,
|
ignore_tls_errors: self.ignore_tls_errors,
|
||||||
|
lock_file: &self.lock_file,
|
||||||
|
verbose: &self.verbose,
|
||||||
|
log_format: self.log_format,
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.ignore_tls_errors {
|
if self.ignore_tls_errors {
|
||||||
@@ -87,43 +176,217 @@ impl Cli {
|
|||||||
|
|
||||||
match &self.command {
|
match &self.command {
|
||||||
CliCommand::Connect(args) => ConnectHandler::new(args, &shared_args).handle().await,
|
CliCommand::Connect(args) => ConnectHandler::new(args, &shared_args).handle().await,
|
||||||
CliCommand::Disconnect => DisconnectHandler::new().handle(),
|
CliCommand::Disconnect(args) => DisconnectHandler::new(args, shared_args.lock_file).handle().await,
|
||||||
CliCommand::LaunchGui(args) => LaunchGuiHandler::new(args).handle().await,
|
CliCommand::LaunchGui(args) => LaunchGuiHandler::new(args).handle().await,
|
||||||
|
CliCommand::Hip(args) => HipHandler::new(args).handle().await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_logger() {
|
fn build_logger(cli: &Cli) -> env_logger::Builder {
|
||||||
env_logger::builder().filter_level(LevelFilter::Info).init();
|
let mut builder = env_logger::builder();
|
||||||
|
builder.filter_level(cli.verbose.log_level_filter());
|
||||||
|
|
||||||
|
// Text is env_logger's own format, so leave it untouched rather than
|
||||||
|
// reimplementing it.
|
||||||
|
if cli.log_format == LogFormat::Json {
|
||||||
|
builder.format(write_json_record);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn run() {
|
pub(crate) async fn run() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
|
|
||||||
init_logger();
|
build_logger(&cli).init();
|
||||||
|
|
||||||
info!("gpclient started: {}", VERSION);
|
info!("gpclient started: {}", VERSION);
|
||||||
|
|
||||||
if let Err(err) = cli.run().await {
|
if let Err(err) = cli.run().await {
|
||||||
eprintln!("\nError: {}", err);
|
handle_error(err, &cli);
|
||||||
|
|
||||||
let err = err.to_string();
|
|
||||||
|
|
||||||
if err.contains("unsafe legacy renegotiation") && !cli.fix_openssl {
|
|
||||||
eprintln!("\nRe-run it with the `--fix-openssl` option to work around this issue, e.g.:\n");
|
|
||||||
// Print the command
|
|
||||||
let args = std::env::args().collect::<Vec<_>>();
|
|
||||||
eprintln!("{} --fix-openssl {}\n", args[0], args[1..].join(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
if err.contains("certificate verify failed") && !cli.ignore_tls_errors {
|
|
||||||
eprintln!(
|
|
||||||
"\nRe-run it with the `--ignore-tls-errors` option to ignore the certificate error, e.g.:\n"
|
|
||||||
);
|
|
||||||
// Print the command
|
|
||||||
let args = std::env::args().collect::<Vec<_>>();
|
|
||||||
eprintln!("{} --ignore-tls-errors {}\n", args[0], args[1..].join(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::{
|
||||||
|
io::Write,
|
||||||
|
sync::{Arc, Mutex},
|
||||||
|
};
|
||||||
|
|
||||||
|
use log::Log;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn lock_file_defaults_to_standard_path() {
|
||||||
|
let cli = Cli::try_parse_from(["gpclient", "connect", "portal.example.com"]).expect("cli should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.lock_file, PathBuf::from(GP_CLIENT_LOCK_FILE));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn lock_file_can_be_overridden_after_subcommand() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpclient",
|
||||||
|
"connect",
|
||||||
|
"portal.example.com",
|
||||||
|
"--lock-file",
|
||||||
|
"/tmp/gpclient-portal.lock",
|
||||||
|
])
|
||||||
|
.expect("global lock file option should parse after subcommand");
|
||||||
|
|
||||||
|
assert_eq!(cli.lock_file, PathBuf::from("/tmp/gpclient-portal.lock"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hip_can_run_alongside_connected_client() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpclient",
|
||||||
|
"hip",
|
||||||
|
"--client-version",
|
||||||
|
"6.2.4-49",
|
||||||
|
"--client-os",
|
||||||
|
"Mac",
|
||||||
|
"--cookie",
|
||||||
|
"user=alice",
|
||||||
|
"--md5",
|
||||||
|
"test",
|
||||||
|
])
|
||||||
|
.expect("HIP arguments should parse");
|
||||||
|
|
||||||
|
assert!(cli.can_run_alongside_client());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
fn launch_gui_accepts_auth_callback() {
|
||||||
|
let cli = Cli::try_parse_from([
|
||||||
|
"gpclient",
|
||||||
|
"launch-gui",
|
||||||
|
"globalprotectcallback:cas-as=1&[email protected]&token=token",
|
||||||
|
])
|
||||||
|
.expect("authentication callback should parse");
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
&cli.command,
|
||||||
|
CliCommand::LaunchGui(args) if args.is_auth_callback()
|
||||||
|
));
|
||||||
|
assert!(cli.can_run_alongside_client());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
fn launch_gui_rejects_callback_with_minimized() {
|
||||||
|
assert!(Cli::try_parse_from(["gpclient", "launch-gui", "globalprotectcallback:token", "--minimized",]).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
fn launch_gui_rejects_non_callback_positional() {
|
||||||
|
assert!(Cli::try_parse_from(["gpclient", "launch-gui", "https://example.com/callback"]).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_cli(args: &[&str]) -> Cli {
|
||||||
|
Cli::try_parse_from(args).expect("arguments should parse")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Text stays the default: a plain `gpclient connect` must keep the output it
|
||||||
|
/// has always had, or every existing user's terminal changes under them.
|
||||||
|
#[test]
|
||||||
|
fn log_format_defaults_to_text() {
|
||||||
|
assert_eq!(parse_cli(&["gpclient", "disconnect"]).log_format, LogFormat::Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn log_format_accepts_json() {
|
||||||
|
assert_eq!(
|
||||||
|
parse_cli(&["gpclient", "--log-format", "json", "disconnect"]).log_format,
|
||||||
|
LogFormat::Json
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An unknown value is a mistake worth reporting rather than silently
|
||||||
|
/// falling back to text, which would leave a caller parsing prose.
|
||||||
|
#[test]
|
||||||
|
fn log_format_rejects_an_unknown_value() {
|
||||||
|
// `.err()` rather than `unwrap_err()`: the Ok side is `Cli`, which is not
|
||||||
|
// `Debug`, and it is not worth deriving it just to print an error we expect.
|
||||||
|
let err = Cli::try_parse_from(["gpclient", "--log-format", "yaml", "disconnect"])
|
||||||
|
.err()
|
||||||
|
.expect("an unknown log format should be rejected");
|
||||||
|
let msg = err.to_string();
|
||||||
|
assert!(msg.contains("yaml"), "error should name the input: {msg}");
|
||||||
|
assert!(msg.contains("json"), "error should list the valid values: {msg}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A `Write` that keeps what was written, so the logger can be driven for
|
||||||
|
/// real instead of asserting on how it was configured.
|
||||||
|
#[derive(Clone, Default)]
|
||||||
|
struct Captured(Arc<Mutex<Vec<u8>>>);
|
||||||
|
|
||||||
|
impl Captured {
|
||||||
|
fn contents(&self) -> String {
|
||||||
|
String::from_utf8(self.0.lock().unwrap().clone()).expect("log output should be UTF-8")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for Captured {
|
||||||
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||||
|
self.0.lock().unwrap().extend_from_slice(buf);
|
||||||
|
Ok(buf.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flush(&mut self) -> std::io::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log_one_record(args: &[&str]) -> String {
|
||||||
|
let captured = Captured::default();
|
||||||
|
let logger = build_logger(&parse_cli(args))
|
||||||
|
.target(env_logger::Target::Pipe(Box::new(captured.clone())))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Drive the logger directly: `init()` installs a global that a second test
|
||||||
|
// could not replace.
|
||||||
|
logger.log(
|
||||||
|
&log::Record::builder()
|
||||||
|
.level(log::Level::Info)
|
||||||
|
.target("gpclient")
|
||||||
|
.args(format_args!("connected to {}", "vpn.example.com"))
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
logger.flush();
|
||||||
|
|
||||||
|
captured.contents()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The point of the flag: with `json`, a caller gets fields, and gets them one
|
||||||
|
/// record per line so the stream can be read incrementally.
|
||||||
|
#[test]
|
||||||
|
fn json_format_emits_one_json_object_per_record() {
|
||||||
|
let out = log_one_record(&["gpclient", "--log-format", "json", "disconnect"]);
|
||||||
|
|
||||||
|
let lines: Vec<_> = out.lines().collect();
|
||||||
|
assert_eq!(lines.len(), 1, "expected exactly one line, got: {out:?}");
|
||||||
|
|
||||||
|
let v: serde_json::Value = serde_json::from_str(lines[0]).unwrap_or_else(|e| panic!("not JSON: {out:?} ({e})"));
|
||||||
|
assert_eq!(v["level"], "INFO");
|
||||||
|
assert_eq!(v["target"], "gpclient");
|
||||||
|
assert_eq!(v["message"], "connected to vpn.example.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn text_format_is_left_alone() {
|
||||||
|
let out = log_one_record(&["gpclient", "disconnect"]);
|
||||||
|
|
||||||
|
assert!(out.contains("connected to vpn.example.com"), "message missing: {out:?}");
|
||||||
|
assert!(
|
||||||
|
serde_json::from_str::<serde_json::Value>(out.trim()).is_err(),
|
||||||
|
"text output should not be JSON: {out:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
use std::{fs, sync::Arc};
|
|
||||||
|
|
||||||
use clap::Args;
|
|
||||||
use gpapi::{
|
|
||||||
clap::args::Os,
|
|
||||||
credential::{Credential, PasswordCredential},
|
|
||||||
gateway::gateway_login,
|
|
||||||
gp_params::{ClientOs, GpParams},
|
|
||||||
portal::{prelogin, retrieve_config, Prelogin},
|
|
||||||
process::auth_launcher::SamlAuthLauncher,
|
|
||||||
utils::{self, shutdown_signal},
|
|
||||||
GP_USER_AGENT,
|
|
||||||
};
|
|
||||||
use inquire::{Password, PasswordDisplayMode, Select, Text};
|
|
||||||
use log::info;
|
|
||||||
use openconnect::Vpn;
|
|
||||||
|
|
||||||
use crate::{cli::SharedArgs, GP_CLIENT_LOCK_FILE};
|
|
||||||
|
|
||||||
#[derive(Args)]
|
|
||||||
pub(crate) struct ConnectArgs {
|
|
||||||
#[arg(help = "The portal server to connect to")]
|
|
||||||
server: String,
|
|
||||||
#[arg(
|
|
||||||
short,
|
|
||||||
long,
|
|
||||||
help = "The gateway to connect to, it will prompt if not specified"
|
|
||||||
)]
|
|
||||||
gateway: Option<String>,
|
|
||||||
#[arg(
|
|
||||||
short,
|
|
||||||
long,
|
|
||||||
help = "The username to use, it will prompt if not specified"
|
|
||||||
)]
|
|
||||||
user: Option<String>,
|
|
||||||
#[arg(long, short, help = "The VPNC script to use")]
|
|
||||||
script: Option<String>,
|
|
||||||
#[arg(long, default_value = GP_USER_AGENT, help = "The user agent to use")]
|
|
||||||
user_agent: String,
|
|
||||||
#[arg(long, default_value = "Linux")]
|
|
||||||
os: Os,
|
|
||||||
#[arg(long)]
|
|
||||||
os_version: Option<String>,
|
|
||||||
#[arg(long, help = "The HiDPI mode, useful for high resolution screens")]
|
|
||||||
hidpi: bool,
|
|
||||||
#[arg(long, help = "Do not reuse the remembered authentication cookie")]
|
|
||||||
clean: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ConnectArgs {
|
|
||||||
fn os_version(&self) -> String {
|
|
||||||
if let Some(os_version) = &self.os_version {
|
|
||||||
return os_version.to_owned();
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.os {
|
|
||||||
Os::Linux => format!("Linux {}", whoami::distro()),
|
|
||||||
Os::Windows => String::from("Microsoft Windows 11 Pro , 64-bit"),
|
|
||||||
Os::Mac => String::from("Apple Mac OS X 13.4.0"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct ConnectHandler<'a> {
|
|
||||||
args: &'a ConnectArgs,
|
|
||||||
shared_args: &'a SharedArgs,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ConnectHandler<'a> {
|
|
||||||
pub(crate) fn new(args: &'a ConnectArgs, shared_args: &'a SharedArgs) -> Self {
|
|
||||||
Self { args, shared_args }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_gp_params(&self) -> GpParams {
|
|
||||||
GpParams::builder()
|
|
||||||
.user_agent(&self.args.user_agent)
|
|
||||||
.client_os(ClientOs::from(&self.args.os))
|
|
||||||
.os_version(self.args.os_version())
|
|
||||||
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
|
||||||
let portal = utils::normalize_server(self.args.server.as_str())?;
|
|
||||||
let gp_params = self.build_gp_params();
|
|
||||||
|
|
||||||
let prelogin = prelogin(&portal, &gp_params).await?;
|
|
||||||
let portal_credential = self.obtain_credential(&prelogin).await?;
|
|
||||||
let mut portal_config = retrieve_config(&portal, &portal_credential, &gp_params).await?;
|
|
||||||
|
|
||||||
let selected_gateway = match &self.args.gateway {
|
|
||||||
Some(gateway) => portal_config
|
|
||||||
.find_gateway(gateway)
|
|
||||||
.ok_or_else(|| anyhow::anyhow!("Cannot find gateway {}", gateway))?,
|
|
||||||
None => {
|
|
||||||
portal_config.sort_gateways(prelogin.region());
|
|
||||||
let gateways = portal_config.gateways();
|
|
||||||
|
|
||||||
if gateways.len() > 1 {
|
|
||||||
Select::new("Which gateway do you want to connect to?", gateways)
|
|
||||||
.with_vim_mode(true)
|
|
||||||
.prompt()?
|
|
||||||
} else {
|
|
||||||
gateways[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let gateway = selected_gateway.server();
|
|
||||||
let cred = portal_config.auth_cookie().into();
|
|
||||||
|
|
||||||
let token = match gateway_login(gateway, &cred, &gp_params).await {
|
|
||||||
Ok(token) => token,
|
|
||||||
Err(_) => {
|
|
||||||
info!("Gateway login failed, retrying with prelogin");
|
|
||||||
self.gateway_login_with_prelogin(gateway).await?
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let vpn = Vpn::builder(gateway, &token)
|
|
||||||
.user_agent(self.args.user_agent.clone())
|
|
||||||
.script(self.args.script.clone())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let vpn = Arc::new(vpn);
|
|
||||||
let vpn_clone = vpn.clone();
|
|
||||||
|
|
||||||
// Listen for the interrupt signal in the background
|
|
||||||
tokio::spawn(async move {
|
|
||||||
shutdown_signal().await;
|
|
||||||
info!("Received the interrupt signal, disconnecting...");
|
|
||||||
vpn_clone.disconnect();
|
|
||||||
});
|
|
||||||
|
|
||||||
vpn.connect(write_pid_file);
|
|
||||||
|
|
||||||
if fs::metadata(GP_CLIENT_LOCK_FILE).is_ok() {
|
|
||||||
info!("Removing PID file");
|
|
||||||
fs::remove_file(GP_CLIENT_LOCK_FILE)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn gateway_login_with_prelogin(&self, gateway: &str) -> anyhow::Result<String> {
|
|
||||||
let mut gp_params = self.build_gp_params();
|
|
||||||
gp_params.set_is_gateway(true);
|
|
||||||
|
|
||||||
let prelogin = prelogin(gateway, &gp_params).await?;
|
|
||||||
let cred = self.obtain_credential(&prelogin).await?;
|
|
||||||
|
|
||||||
gateway_login(gateway, &cred, &gp_params).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn obtain_credential(&self, prelogin: &Prelogin) -> anyhow::Result<Credential> {
|
|
||||||
match prelogin {
|
|
||||||
Prelogin::Saml(prelogin) => {
|
|
||||||
SamlAuthLauncher::new(&self.args.server)
|
|
||||||
.saml_request(prelogin.saml_request())
|
|
||||||
.user_agent(&self.args.user_agent)
|
|
||||||
.os(self.args.os.as_str())
|
|
||||||
.os_version(Some(&self.args.os_version()))
|
|
||||||
.hidpi(self.args.hidpi)
|
|
||||||
.fix_openssl(self.shared_args.fix_openssl)
|
|
||||||
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
|
|
||||||
.clean(self.args.clean)
|
|
||||||
.launch()
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
Prelogin::Standard(prelogin) => {
|
|
||||||
println!("{}", prelogin.auth_message());
|
|
||||||
|
|
||||||
let user = self.args.user.as_ref().map_or_else(
|
|
||||||
|| Text::new(&format!("{}:", prelogin.label_username())).prompt(),
|
|
||||||
|user| Ok(user.to_owned()),
|
|
||||||
)?;
|
|
||||||
let password = Password::new(&format!("{}:", prelogin.label_password()))
|
|
||||||
.without_confirmation()
|
|
||||||
.with_display_mode(PasswordDisplayMode::Masked)
|
|
||||||
.prompt()?;
|
|
||||||
|
|
||||||
let password_cred = PasswordCredential::new(&user, &password);
|
|
||||||
|
|
||||||
Ok(password_cred.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_pid_file() {
|
|
||||||
let pid = std::process::id();
|
|
||||||
|
|
||||||
fs::write(GP_CLIENT_LOCK_FILE, pid.to_string()).unwrap();
|
|
||||||
info!("Wrote PID {} to {}", pid, GP_CLIENT_LOCK_FILE);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,448 @@
|
|||||||
|
use clap::Args;
|
||||||
|
use gpapi::{
|
||||||
|
clap::args::Os,
|
||||||
|
cookie_store,
|
||||||
|
gp_params::CscMode,
|
||||||
|
os_profile::{ClientOs, OsProfile},
|
||||||
|
};
|
||||||
|
use log::warn;
|
||||||
|
use std::{net::IpAddr, path::PathBuf};
|
||||||
|
|
||||||
|
#[derive(Args)]
|
||||||
|
pub(crate) struct ConnectArgs {
|
||||||
|
#[arg(help = "The portal server to connect to")]
|
||||||
|
pub(super) server: String,
|
||||||
|
|
||||||
|
#[arg(short, long, help = "The gateway to connect to, it will prompt if not specified")]
|
||||||
|
pub(super) gateway: Option<String>,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
conflicts_with = "gateway",
|
||||||
|
help = "Automatically try gateways in priority order until gateway auth/config succeeds, without prompting"
|
||||||
|
)]
|
||||||
|
pub(super) auto_gateway: bool,
|
||||||
|
|
||||||
|
#[arg(short, long, help = "The username to use, it will prompt if not specified")]
|
||||||
|
pub(super) user: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Read the password from standard input")]
|
||||||
|
pub(super) passwd_on_stdin: bool,
|
||||||
|
|
||||||
|
#[arg(long, help = "Read the gpauth authentication result from standard input")]
|
||||||
|
pub(super) cookie_on_stdin: bool,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
help = "Read and write the portal cookie cache, optionally specify the cache file path",
|
||||||
|
default_missing_value = "",
|
||||||
|
num_args=0..=1
|
||||||
|
)]
|
||||||
|
pub(super) cookie_cache: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, short, help = "The VPNC script to use", required_if_eq("script_tun", "true"))]
|
||||||
|
pub(super) script: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, short, help = "The IFNAME for tunnel interface")]
|
||||||
|
pub(super) interface: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, short = 'S', help = "Pass traffic to '--script' program, not tun")]
|
||||||
|
pub(super) script_tun: bool,
|
||||||
|
|
||||||
|
#[arg(long, help = "Connect the server as a gateway, instead of a portal")]
|
||||||
|
pub(super) as_gateway: bool,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
help = "Use HIP (Host Integrity Protection) extension, optionally specify the HIP script path",
|
||||||
|
default_missing_value = "",
|
||||||
|
num_args=0..=1
|
||||||
|
)]
|
||||||
|
pub(super) hip: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "The user used to run the HIP script")]
|
||||||
|
pub(super) hip_user: Option<String>,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
short,
|
||||||
|
long,
|
||||||
|
help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format"
|
||||||
|
)]
|
||||||
|
pub(super) certificate: Option<String>,
|
||||||
|
|
||||||
|
#[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")]
|
||||||
|
pub(super) sslkey: Option<String>,
|
||||||
|
|
||||||
|
#[arg(short = 'p', long, help = "The key passphrase of the private key")]
|
||||||
|
pub(super) key_password: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, hide = true)]
|
||||||
|
pub(super) csd_user: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, hide = true)]
|
||||||
|
pub(super) csd_wrapper: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, default_value = "300", help = "Reconnection retry timeout in seconds")]
|
||||||
|
pub(super) reconnect_timeout: u32,
|
||||||
|
|
||||||
|
#[arg(short, long, help = "Request MTU from server (legacy servers only)")]
|
||||||
|
pub(super) mtu: Option<u32>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Do not ask for IPv6 connectivity")]
|
||||||
|
pub(super) disable_ipv6: bool,
|
||||||
|
|
||||||
|
#[arg(long = "user-agent", hide = true)]
|
||||||
|
pub(super) deprecated_user_agent: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long = "os-version", hide = true)]
|
||||||
|
pub(super) deprecated_os_version: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Override the client version reported to the server, e.g., '6.2.4-49'")]
|
||||||
|
pub(super) client_version: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, value_enum, default_value_t = Os::default())]
|
||||||
|
pub(super) os: Os,
|
||||||
|
|
||||||
|
#[arg(long, value_enum, default_value_t = CscMode::Auto, help = "CSC support mode: auto, yes, or no")]
|
||||||
|
pub(super) csc: CscMode,
|
||||||
|
|
||||||
|
#[arg(long, help = "Disable DTLS and ESP")]
|
||||||
|
pub(super) no_dtls: bool,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long = "local-hostname",
|
||||||
|
help = "Same as the '--local-hostname' option in the openconnect command"
|
||||||
|
)]
|
||||||
|
pub(super) local_hostname: Option<String>,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long = "force-dpd",
|
||||||
|
help = "Same as the '--force-dpd' option in the openconnect command"
|
||||||
|
)]
|
||||||
|
pub(super) dpd_interval: Option<u32>,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long = "no-xmlpost",
|
||||||
|
help = "Same as the '--no-xmlpost' option in the openconnect command"
|
||||||
|
)]
|
||||||
|
pub(super) no_xmlpost: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "The HiDPI mode, useful for high-resolution screens")]
|
||||||
|
pub(super) hidpi: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "Do not reuse the remembered authentication cookie")]
|
||||||
|
pub(super) clean: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
#[arg(long, help = "Deprecated: Use the `--browser` option instead")]
|
||||||
|
pub(super) default_browser: bool,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser or `remote` for headless servers.",
|
||||||
|
default_missing_value = "auto",
|
||||||
|
num_args=0..=1
|
||||||
|
)]
|
||||||
|
pub(super) browser: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Listen on this IP address when using '--browser remote'")]
|
||||||
|
pub(super) browser_listen: Option<IpAddr>,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
help = "Authenticate and print the gateway cookie to stdout, then exit without starting the \
|
||||||
|
VPN tunnel. Outputs two lines: COOKIE='<value>' and HOST='<gateway>'. Combine with \
|
||||||
|
--cookie-cache to avoid re-authenticating when the portal session is still valid."
|
||||||
|
)]
|
||||||
|
pub(super) cookie_only: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn build_os_profile(args: &ConnectArgs) -> OsProfile {
|
||||||
|
build_os_profile_with_host_id(args, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn build_os_profile_with_host_id(args: &ConnectArgs, host_id: Option<&str>) -> OsProfile {
|
||||||
|
let mut builder = OsProfile::builder(ClientOs::from(args.os));
|
||||||
|
if let Some(client_version) = args.client_version.as_deref() {
|
||||||
|
builder = builder.client_version(client_version.to_string());
|
||||||
|
}
|
||||||
|
if let Some(local_hostname) = args.local_hostname.as_deref() {
|
||||||
|
builder = builder.computer_name_override(local_hostname.to_string());
|
||||||
|
}
|
||||||
|
if let Some(host_id) = host_id {
|
||||||
|
builder = builder.host_id_override(host_id);
|
||||||
|
}
|
||||||
|
builder.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn cookie_cache_path(args: &ConnectArgs) -> Option<PathBuf> {
|
||||||
|
args.cookie_cache.as_deref().map(|path| {
|
||||||
|
let custom = (!path.is_empty()).then_some(path);
|
||||||
|
cookie_store::cookie_path(custom)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn warn_deprecated_connect_args(args: &ConnectArgs) {
|
||||||
|
if args.csd_user.is_some() {
|
||||||
|
warn!("Deprecated option --csd-user will be removed; use --hip-user instead");
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.csd_wrapper.is_some() {
|
||||||
|
warn!("Deprecated option --csd-wrapper will be removed; use --hip instead");
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.deprecated_user_agent.is_some() {
|
||||||
|
warn!("Deprecated option --user-agent is ignored; user agent is derived from --os");
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.deprecated_os_version.is_some() {
|
||||||
|
warn!("Deprecated option --os-version is ignored; OS version is derived from --os");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(clap::Parser)]
|
||||||
|
struct ConnectArgsTestCli {
|
||||||
|
#[command(flatten)]
|
||||||
|
args: ConnectArgs,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parses_csc_mode_values() {
|
||||||
|
use clap::ValueEnum;
|
||||||
|
|
||||||
|
assert_eq!(CscMode::from_str("auto", false), Ok(CscMode::Auto));
|
||||||
|
assert_eq!(CscMode::from_str("yes", false), Ok(CscMode::Yes));
|
||||||
|
assert_eq!(CscMode::from_str("no", false), Ok(CscMode::No));
|
||||||
|
assert!(CscMode::from_str("maybe", false).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn auto_gateway_flag_parses() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--auto-gateway"])
|
||||||
|
.expect("--auto-gateway alone should parse");
|
||||||
|
|
||||||
|
assert!(cli.args.auto_gateway);
|
||||||
|
assert!(cli.args.gateway.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn auto_gateway_help_describes_auth_config_retry() {
|
||||||
|
use clap::CommandFactory;
|
||||||
|
|
||||||
|
let help = ConnectArgsTestCli::command().render_long_help().to_string();
|
||||||
|
|
||||||
|
assert!(help.contains("--auto-gateway"));
|
||||||
|
assert!(help.contains("Automatically try gateways in priority order until gateway auth/config succeeds"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gateway_flag_alone_parses() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--gateway", "gw1"])
|
||||||
|
.expect("--gateway alone should parse");
|
||||||
|
|
||||||
|
assert!(!cli.args.auto_gateway);
|
||||||
|
assert_eq!(cli.args.gateway.as_deref(), Some("gw1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_without_value_uses_auto_mode() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--browser"])
|
||||||
|
.expect("--browser without value should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.browser.as_deref(), Some("auto"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_default_keeps_system_default_mode() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--browser", "default"])
|
||||||
|
.expect("--browser default should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.browser.as_deref(), Some("default"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_listen_accepts_ip_address() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from([
|
||||||
|
"test",
|
||||||
|
"portal.example.com",
|
||||||
|
"--browser",
|
||||||
|
"remote",
|
||||||
|
"--browser-listen",
|
||||||
|
"192.168.107.15",
|
||||||
|
])
|
||||||
|
.expect("connect args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.browser_listen, Some("192.168.107.15".parse().unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn os_defaults_to_runtime_os() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com"]).expect("connect args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.os, Os::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deprecated_profile_override_flags_still_parse() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from([
|
||||||
|
"test",
|
||||||
|
"portal.example.com",
|
||||||
|
"--user-agent",
|
||||||
|
"legacy-agent",
|
||||||
|
"--os-version",
|
||||||
|
"legacy-os",
|
||||||
|
"--client-version",
|
||||||
|
"legacy-client",
|
||||||
|
])
|
||||||
|
.expect("deprecated profile override flags should remain parse-compatible");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.deprecated_user_agent.as_deref(), Some("legacy-agent"));
|
||||||
|
assert_eq!(cli.args.deprecated_os_version.as_deref(), Some("legacy-os"));
|
||||||
|
assert_eq!(cli.args.client_version.as_deref(), Some("legacy-client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deprecated_profile_override_flags_do_not_affect_os_profile() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from([
|
||||||
|
"test",
|
||||||
|
"portal.example.com",
|
||||||
|
"--os",
|
||||||
|
"Linux",
|
||||||
|
"--user-agent",
|
||||||
|
"legacy-agent",
|
||||||
|
"--os-version",
|
||||||
|
"legacy-os",
|
||||||
|
"--client-version",
|
||||||
|
"legacy-client",
|
||||||
|
])
|
||||||
|
.expect("deprecated profile override flags should remain parse-compatible");
|
||||||
|
|
||||||
|
let profile = build_os_profile(&cli.args);
|
||||||
|
|
||||||
|
assert_ne!(profile.user_agent(), "legacy-agent");
|
||||||
|
assert_ne!(profile.os_version(), "legacy-os");
|
||||||
|
assert_eq!(profile.client_version(), "legacy-client");
|
||||||
|
assert!(profile.user_agent().contains("legacy-client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdin_host_id_sets_profile_runtime_identity_seed() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--os", "Linux"])
|
||||||
|
.expect("connect args should parse");
|
||||||
|
|
||||||
|
let profile = build_os_profile_with_host_id(&cli.args, Some("auth-host-id"));
|
||||||
|
|
||||||
|
assert_eq!(profile.host_identity().host_id(), "auth-host-id");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cookie_cache_is_disabled_by_default() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com"]).expect("connect args should parse");
|
||||||
|
|
||||||
|
assert!(cli.args.cookie_cache.is_none());
|
||||||
|
assert!(cookie_cache_path(&cli.args).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cookie_cache_accepts_default_path_without_value() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--cookie-cache"])
|
||||||
|
.expect("--cookie-cache without value should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.cookie_cache.as_deref(), Some(""));
|
||||||
|
assert!(cookie_cache_path(&cli.args).is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cookie_cache_accepts_custom_path() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli =
|
||||||
|
ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--cookie-cache", "/tmp/gp-cookie.json"])
|
||||||
|
.expect("--cookie-cache with value should parse");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
cookie_cache_path(&cli.args).as_deref(),
|
||||||
|
Some(std::path::Path::new("/tmp/gp-cookie.json"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deprecated_hip_alias_flags_still_parse() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from([
|
||||||
|
"test",
|
||||||
|
"portal.example.com",
|
||||||
|
"--csd-user",
|
||||||
|
"legacy-user",
|
||||||
|
"--csd-wrapper",
|
||||||
|
"/tmp/legacy-hip.sh",
|
||||||
|
])
|
||||||
|
.expect("deprecated HIP alias flags should remain parse-compatible");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.csd_user.as_deref(), Some("legacy-user"));
|
||||||
|
assert_eq!(cli.args.csd_wrapper.as_deref(), Some("/tmp/legacy-hip.sh"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn auto_gateway_and_gateway_are_mutually_exclusive() {
|
||||||
|
use clap::Parser;
|
||||||
|
use clap::error::ErrorKind;
|
||||||
|
|
||||||
|
let result =
|
||||||
|
ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--gateway", "gw1", "--auto-gateway"]);
|
||||||
|
|
||||||
|
let err = match result {
|
||||||
|
Ok(_) => panic!("--gateway and --auto-gateway must conflict"),
|
||||||
|
Err(err) => err,
|
||||||
|
};
|
||||||
|
assert_eq!(err.kind(), ErrorKind::ArgumentConflict);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cookie_only_flag_parses() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--cookie-only"])
|
||||||
|
.expect("--cookie-only should parse");
|
||||||
|
|
||||||
|
assert!(cli.args.cookie_only);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cookie_only_is_disabled_by_default() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com"]).expect("connect args should parse");
|
||||||
|
|
||||||
|
assert!(!cli.args.cookie_only);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,273 @@
|
|||||||
|
use anyhow::{Context, bail};
|
||||||
|
use gpapi::{
|
||||||
|
auth::SamlAuthResult,
|
||||||
|
clap::ToVerboseArg,
|
||||||
|
credential::{Credential, PasswordCredential},
|
||||||
|
portal::{Prelogin, StandardPrelogin},
|
||||||
|
process::auth_launcher::SamlAuthLauncher,
|
||||||
|
};
|
||||||
|
use inquire::{Password, PasswordDisplayMode, Text};
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
use super::ConnectHandler;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub(super) struct CleanAuthState {
|
||||||
|
requested: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CleanAuthState {
|
||||||
|
pub(super) fn new(requested: bool) -> Self {
|
||||||
|
Self { requested }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn consume_for_webview(&mut self, webview_auth: bool) -> bool {
|
||||||
|
if !webview_auth || !self.requested {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.requested = false;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ConnectHandler<'_> {
|
||||||
|
pub(super) fn prepare_cookie_from_stdin(&self) -> anyhow::Result<()> {
|
||||||
|
if !self.args.cookie_on_stdin || self.cookie_from_stdin.borrow().is_some() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let auth_result = self.read_auth_result_from_stdin()?;
|
||||||
|
log_stdin_host_id(auth_result.host_id());
|
||||||
|
self.apply_stdin_host_id(auth_result.host_id());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) async fn obtain_credential(
|
||||||
|
&self,
|
||||||
|
prelogin: &Prelogin,
|
||||||
|
server: &str,
|
||||||
|
gateway_browser_auth_allowed: bool,
|
||||||
|
) -> anyhow::Result<Credential> {
|
||||||
|
if should_read_stdin_credential(self.args.cookie_on_stdin, self.args.as_gateway, prelogin.is_gateway()) {
|
||||||
|
return self.read_cookie_from_stdin();
|
||||||
|
}
|
||||||
|
|
||||||
|
let is_gateway = prelogin.is_gateway();
|
||||||
|
|
||||||
|
match prelogin {
|
||||||
|
Prelogin::Saml(prelogin) => {
|
||||||
|
let external_browser_supported = can_use_external_browser_auth(
|
||||||
|
prelogin.support_default_browser(),
|
||||||
|
is_gateway,
|
||||||
|
gateway_browser_auth_allowed,
|
||||||
|
);
|
||||||
|
let browser = if external_browser_supported {
|
||||||
|
self.args.browser.as_deref()
|
||||||
|
} else if !cfg!(feature = "webview-auth") {
|
||||||
|
bail!(
|
||||||
|
"The server does not support authentication via the default browser and the gpclient is not built with the `webview-auth` feature"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let verbose = self.shared_args.verbose.to_verbose_arg();
|
||||||
|
let os_profile = self.os_profile.borrow().clone();
|
||||||
|
let key_password = self.latest_key_password.borrow().clone();
|
||||||
|
let auth_launcher = SamlAuthLauncher::new(server)
|
||||||
|
.gateway(is_gateway)
|
||||||
|
.saml_request(prelogin.saml_request())
|
||||||
|
.os_profile(&os_profile)
|
||||||
|
.fix_openssl(self.shared_args.fix_openssl)
|
||||||
|
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
|
||||||
|
.certificate(self.args.certificate.as_deref())
|
||||||
|
.sslkey(self.args.sslkey.as_deref())
|
||||||
|
.key_password(key_password.as_deref())
|
||||||
|
.browser(browser)
|
||||||
|
.browser_listen(self.args.browser_listen)
|
||||||
|
.log_format(self.shared_args.log_format)
|
||||||
|
.verbose(verbose);
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
let use_default_browser = external_browser_supported && self.args.default_browser;
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
let browser_kind = if browser.is_some() || use_default_browser {
|
||||||
|
"external"
|
||||||
|
} else {
|
||||||
|
"embedded"
|
||||||
|
};
|
||||||
|
#[cfg(not(feature = "webview-auth"))]
|
||||||
|
let browser_kind = "external";
|
||||||
|
|
||||||
|
let clean_auth = self
|
||||||
|
.clean_auth_state
|
||||||
|
.borrow_mut()
|
||||||
|
.consume_for_webview(browser_kind == "embedded");
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"SAML auth launch: gateway={}, clean={}, browser={}",
|
||||||
|
is_gateway, clean_auth, browser_kind
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
let auth_launcher = auth_launcher
|
||||||
|
.hidpi(self.args.hidpi)
|
||||||
|
.clean(clean_auth)
|
||||||
|
.default_browser(use_default_browser);
|
||||||
|
|
||||||
|
let cred = auth_launcher.launch().await?;
|
||||||
|
Ok(cred)
|
||||||
|
}
|
||||||
|
|
||||||
|
Prelogin::Standard(prelogin) => {
|
||||||
|
let prefix = if is_gateway { "Gateway" } else { "Portal" };
|
||||||
|
println!("{} ({}: {})", prelogin.auth_message(), prefix, server);
|
||||||
|
|
||||||
|
let user = self.args.user.as_ref().map_or_else(
|
||||||
|
|| Text::new(&format!("{}:", prelogin.label_username())).prompt(),
|
||||||
|
|user| Ok(user.to_owned()),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let password = self.obtain_password(prelogin)?;
|
||||||
|
let password_cred = PasswordCredential::new(&user, &password);
|
||||||
|
|
||||||
|
Ok(password_cred.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_cookie_from_stdin(&self) -> anyhow::Result<Credential> {
|
||||||
|
if let Some(cookie) = self.cookie_from_stdin.borrow().as_ref() {
|
||||||
|
info!("Reusing the cookie read from standard input");
|
||||||
|
return Credential::try_from(serde_json::from_str::<SamlAuthResult>(cookie)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
let auth_result = self.read_auth_result_from_stdin()?;
|
||||||
|
log_stdin_host_id(auth_result.host_id());
|
||||||
|
self.apply_stdin_host_id(auth_result.host_id());
|
||||||
|
Credential::try_from(auth_result)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_auth_result_from_stdin(&self) -> anyhow::Result<SamlAuthResult> {
|
||||||
|
info!("Reading cookie from standard input");
|
||||||
|
|
||||||
|
let mut cookie = String::new();
|
||||||
|
std::io::stdin().read_line(&mut cookie)?;
|
||||||
|
|
||||||
|
self.cookie_from_stdin.replace(Some(cookie.trim_end().to_owned()));
|
||||||
|
|
||||||
|
let auth_result = serde_json::from_str::<SamlAuthResult>(cookie.trim_end()).context("Failed to parse auth data")?;
|
||||||
|
Ok(auth_result)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn obtain_password(&self, prelogin: &StandardPrelogin) -> anyhow::Result<String> {
|
||||||
|
let password = if self.args.passwd_on_stdin {
|
||||||
|
if let Some(password) = self.password_from_stdin.borrow().as_ref() {
|
||||||
|
info!("Reusing the password read from standard input");
|
||||||
|
return Ok(password.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Reading password from standard input");
|
||||||
|
let mut input = String::new();
|
||||||
|
std::io::stdin().read_line(&mut input)?;
|
||||||
|
let password = input.trim_end().to_owned();
|
||||||
|
self.password_from_stdin.replace(Some(password.clone()));
|
||||||
|
|
||||||
|
password
|
||||||
|
} else {
|
||||||
|
Password::new(&format!("{}:", prelogin.label_password()))
|
||||||
|
.without_confirmation()
|
||||||
|
.with_display_mode(PasswordDisplayMode::Masked)
|
||||||
|
.prompt()?
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(password)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn should_read_stdin_credential(cookie_on_stdin: bool, as_gateway: bool, prelogin_is_gateway: bool) -> bool {
|
||||||
|
cookie_on_stdin && (!prelogin_is_gateway || as_gateway)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn can_use_external_browser_auth(
|
||||||
|
saml_support_default_browser: bool,
|
||||||
|
is_gateway: bool,
|
||||||
|
gateway_browser_auth_allowed: bool,
|
||||||
|
) -> bool {
|
||||||
|
saml_support_default_browser && (!is_gateway || gateway_browser_auth_allowed)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log_stdin_host_id(host_id: Option<&str>) {
|
||||||
|
match host_id {
|
||||||
|
Some(host_id) => info!("stdin auth result host-id: {}", host_id),
|
||||||
|
None => info!("stdin auth result host-id: <none>"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn clean_auth_state_is_consumed_once_for_webview() {
|
||||||
|
let mut state = CleanAuthState::new(true);
|
||||||
|
|
||||||
|
assert!(state.consume_for_webview(true));
|
||||||
|
assert!(!state.consume_for_webview(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn clean_auth_state_is_not_consumed_by_external_browser() {
|
||||||
|
let mut state = CleanAuthState::new(true);
|
||||||
|
|
||||||
|
assert!(!state.consume_for_webview(false));
|
||||||
|
assert!(state.consume_for_webview(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn clean_auth_state_remains_false_when_not_requested() {
|
||||||
|
let mut state = CleanAuthState::new(false);
|
||||||
|
|
||||||
|
assert!(!state.consume_for_webview(true));
|
||||||
|
assert!(!state.consume_for_webview(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdin_credential_is_allowed_for_portal_auth() {
|
||||||
|
assert!(should_read_stdin_credential(true, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdin_credential_is_allowed_for_direct_gateway_auth() {
|
||||||
|
assert!(should_read_stdin_credential(true, true, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdin_credential_is_not_reused_for_gateway_fallback_auth() {
|
||||||
|
assert!(!should_read_stdin_credential(true, false, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdin_credential_is_not_used_when_flag_is_disabled() {
|
||||||
|
assert!(!should_read_stdin_credential(false, false, false));
|
||||||
|
assert!(!should_read_stdin_credential(false, true, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn portal_saml_can_use_default_browser_when_supported() {
|
||||||
|
assert!(can_use_external_browser_auth(true, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gateway_saml_requires_gateway_browser_auth_allowance() {
|
||||||
|
assert!(!can_use_external_browser_auth(true, true, false));
|
||||||
|
assert!(can_use_external_browser_auth(true, true, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn default_browser_auth_requires_saml_support() {
|
||||||
|
assert!(!can_use_external_browser_auth(false, false, true));
|
||||||
|
assert!(!can_use_external_browser_auth(false, true, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,576 @@
|
|||||||
|
use std::{
|
||||||
|
fs,
|
||||||
|
path::Path,
|
||||||
|
sync::{
|
||||||
|
Arc, Mutex,
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
use gpapi::{
|
||||||
|
clap::report,
|
||||||
|
cookie_store,
|
||||||
|
credential::{AuthCookieCredential, Credential},
|
||||||
|
gateway::{GatewayLogin, GatewayLoginContext, SessionExtensionAuth, gateway_login, gateway_login_with_context},
|
||||||
|
gp_params::GpParams,
|
||||||
|
os_profile::OsProfile,
|
||||||
|
portal::prelogin,
|
||||||
|
process::users::get_user_by_name,
|
||||||
|
utils::shutdown_signal,
|
||||||
|
};
|
||||||
|
use inquire::Text;
|
||||||
|
use log::{Level, info, warn};
|
||||||
|
use openconnect::{Vpn, VpnBuilder};
|
||||||
|
use tokio::{runtime::Handle, task::JoinHandle};
|
||||||
|
|
||||||
|
use crate::session::{
|
||||||
|
SessionContextInput, build_session_context, session_info_from_vpn, spawn_session_runtime_with_info,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::{ConnectHandler, args::cookie_cache_path};
|
||||||
|
|
||||||
|
const OPENCONNECT_INTERRUPTED_EXIT_CODE: i32 = -4;
|
||||||
|
|
||||||
|
struct GatewayLoginSession {
|
||||||
|
cookie: String,
|
||||||
|
extension_auth: SessionExtensionAuth,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum GatewayConnectFailureStage {
|
||||||
|
BeforeTunnel,
|
||||||
|
AfterTunnel,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(super) struct GatewayConnectError {
|
||||||
|
stage: GatewayConnectFailureStage,
|
||||||
|
error: anyhow::Error,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GatewayConnectError {
|
||||||
|
fn before_tunnel(error: anyhow::Error) -> Self {
|
||||||
|
Self {
|
||||||
|
stage: GatewayConnectFailureStage::BeforeTunnel,
|
||||||
|
error,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn after_tunnel(error: anyhow::Error) -> Self {
|
||||||
|
Self {
|
||||||
|
stage: GatewayConnectFailureStage::AfterTunnel,
|
||||||
|
error,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn is_before_tunnel(&self) -> bool {
|
||||||
|
self.stage == GatewayConnectFailureStage::BeforeTunnel
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn as_error(&self) -> &anyhow::Error {
|
||||||
|
&self.error
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn into_error(self) -> anyhow::Error {
|
||||||
|
self.error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ConnectHandler<'_> {
|
||||||
|
pub(super) async fn try_cached_cookie(&self, server: &str) -> Option<()> {
|
||||||
|
let path = cookie_cache_path(self.args)?;
|
||||||
|
let host_id = self.os_profile.borrow().host_identity().host_id().to_string();
|
||||||
|
let stored = cookie_store::load(&path, server, &host_id)?;
|
||||||
|
|
||||||
|
if !stored.auth_cookie.can_authenticate_gateway() {
|
||||||
|
warn!(
|
||||||
|
"Cached portal cookie for {} is not usable for gateway authentication. Clearing cache.",
|
||||||
|
stored.server
|
||||||
|
);
|
||||||
|
cookie_store::clear(&path);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Using cached portal cookie for {} (saved_at={}, gateway={})",
|
||||||
|
stored.server, stored.saved_at, stored.last_gateway
|
||||||
|
);
|
||||||
|
|
||||||
|
let cred: Credential = (&stored.auth_cookie).into();
|
||||||
|
let mut gp_params = self.build_gp_params();
|
||||||
|
gp_params.set_is_gateway(true);
|
||||||
|
|
||||||
|
let login_session = match self.login_gateway(&stored.last_gateway, &cred, &gp_params, None).await {
|
||||||
|
Ok(session) => session,
|
||||||
|
Err(err) => {
|
||||||
|
warn!(
|
||||||
|
"Cached portal cookie rejected by gateway {}: {}. Clearing cache and falling back to portal auth.",
|
||||||
|
stored.last_gateway, err
|
||||||
|
);
|
||||||
|
cookie_store::clear(&path);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match self
|
||||||
|
.connect_gateway(
|
||||||
|
server,
|
||||||
|
&stored.last_gateway,
|
||||||
|
&login_session.cookie,
|
||||||
|
false,
|
||||||
|
login_session.extension_auth,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(()) => Some(()),
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Gateway connect failed after cached-cookie login: {}", err.as_error());
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) async fn connect_gateway_with_prelogin(
|
||||||
|
&self,
|
||||||
|
portal: &str,
|
||||||
|
gateway: &str,
|
||||||
|
allow_extend_session: bool,
|
||||||
|
gateway_context: Option<GatewayLoginContext>,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
info!("Performing the gateway authentication...");
|
||||||
|
|
||||||
|
let mut gp_params = self.build_gp_params();
|
||||||
|
gp_params.set_is_gateway(true);
|
||||||
|
|
||||||
|
let gateway_browser_auth_allowed = true;
|
||||||
|
let prelogin = prelogin(gateway, &gp_params, self.direct_gateway_prelogin_options()).await?;
|
||||||
|
let cred = self
|
||||||
|
.obtain_credential(&prelogin, gateway, gateway_browser_auth_allowed)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let login_session = self
|
||||||
|
.login_gateway(gateway, &cred, &gp_params, gateway_context.as_ref())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
self
|
||||||
|
.connect_gateway(
|
||||||
|
portal,
|
||||||
|
gateway,
|
||||||
|
&login_session.cookie,
|
||||||
|
allow_extend_session,
|
||||||
|
login_session.extension_auth,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(GatewayConnectError::into_error)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Connect to a gateway using the official client's auth flow:
|
||||||
|
///
|
||||||
|
/// 1. Call gateway prelogin and retain the response (SAML data is held as a fallback).
|
||||||
|
/// 2. If the portal provided auth cookies, attempt gateway login using them.
|
||||||
|
/// 3. If that login succeeds, proceed directly to the VPN connection.
|
||||||
|
/// 4. If no portal auth cookies exist or portal-cookie login fails, use the retained gateway prelogin response to authenticate
|
||||||
|
/// against the gateway (SAML or username/password) and obtain a gateway-issued
|
||||||
|
/// credential.
|
||||||
|
/// 5. Retry gateway login with the gateway credential (now carrying the gateway's
|
||||||
|
/// `prelogin-cookie`) and connect on success.
|
||||||
|
pub(super) async fn connect_gateway_with_fallback(
|
||||||
|
&self,
|
||||||
|
portal: &str,
|
||||||
|
gateway: &str,
|
||||||
|
portal_cred: &AuthCookieCredential,
|
||||||
|
allow_extend_session: bool,
|
||||||
|
portal_config_default_browser: bool,
|
||||||
|
gateway_context: GatewayLoginContext,
|
||||||
|
) -> Result<(), GatewayConnectError> {
|
||||||
|
info!("Connecting to gateway with portal-cookie first, gateway prelogin fallback...");
|
||||||
|
|
||||||
|
let mut gp_params = self.build_gp_params();
|
||||||
|
gp_params.set_is_gateway(true);
|
||||||
|
let gateway_browser_auth_allowed = self.gateway_browser_auth_allowed(portal_config_default_browser);
|
||||||
|
|
||||||
|
let gateway_prelogin = prelogin(gateway, &gp_params, self.prelogin_options(gateway_browser_auth_allowed))
|
||||||
|
.await
|
||||||
|
.map_err(GatewayConnectError::before_tunnel)?;
|
||||||
|
|
||||||
|
if portal_cred.can_authenticate_gateway() {
|
||||||
|
let portal_cred_for_login: Credential = portal_cred.into();
|
||||||
|
match self
|
||||||
|
.login_gateway(gateway, &portal_cred_for_login, &gp_params, Some(&gateway_context))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(login_session) => {
|
||||||
|
info!("Gateway login with portal auth cookies succeeded");
|
||||||
|
self.save_cookie_cache(portal, gateway, portal_cred);
|
||||||
|
return self
|
||||||
|
.connect_gateway(
|
||||||
|
portal,
|
||||||
|
gateway,
|
||||||
|
&login_session.cookie,
|
||||||
|
allow_extend_session,
|
||||||
|
login_session.extension_auth,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
info!("Gateway login with portal auth cookies failed: {}", err);
|
||||||
|
info!("Falling back to gateway prelogin authentication...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("Portal config did not provide gateway auth cookies; using gateway prelogin flow");
|
||||||
|
}
|
||||||
|
|
||||||
|
let gateway_cred = match self
|
||||||
|
.obtain_credential(&gateway_prelogin, gateway, gateway_browser_auth_allowed)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(cred) => cred,
|
||||||
|
Err(err) => {
|
||||||
|
self.print_direct_gateway_recommendation(gateway);
|
||||||
|
return Err(GatewayConnectError::before_tunnel(err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let login_session = match self
|
||||||
|
.login_gateway(gateway, &gateway_cred, &gp_params, Some(&gateway_context))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(login_session) => login_session,
|
||||||
|
Err(err) => {
|
||||||
|
self.print_direct_gateway_recommendation(gateway);
|
||||||
|
return Err(GatewayConnectError::before_tunnel(err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self
|
||||||
|
.connect_gateway(
|
||||||
|
portal,
|
||||||
|
gateway,
|
||||||
|
&login_session.cookie,
|
||||||
|
allow_extend_session,
|
||||||
|
login_session.extension_auth,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
fn save_cookie_cache(&self, portal: &str, gateway: &str, auth_cookie: &AuthCookieCredential) {
|
||||||
|
let Some(path) = cookie_cache_path(self.args) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if !auth_cookie.can_authenticate_gateway() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let stored = cookie_store::StoredCookie::new(
|
||||||
|
portal.to_string(),
|
||||||
|
auth_cookie.username().to_string(),
|
||||||
|
self.os_profile.borrow().host_identity().host_id().to_string(),
|
||||||
|
gateway.to_string(),
|
||||||
|
auth_cookie.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
match cookie_store::save(&path, &stored) {
|
||||||
|
Ok(()) => info!("Saved portal cookie cache to {}", path.display()),
|
||||||
|
Err(err) => warn!("Failed to save portal cookie cache to {}: {}", path.display(), err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_direct_gateway_recommendation(&self, gateway: &str) {
|
||||||
|
if !self.args.cookie_on_stdin {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let format = self.shared_args.log_format;
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Warn,
|
||||||
|
"\nNOTE: Gateway authentication failed after portal login.",
|
||||||
|
);
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Warn,
|
||||||
|
"NOTE: If this server also accepts direct gateway login, try:",
|
||||||
|
);
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Warn,
|
||||||
|
&format!("NOTE: {}", direct_gateway_command(gateway)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn login_gateway(
|
||||||
|
&self,
|
||||||
|
gateway: &str,
|
||||||
|
cred: &Credential,
|
||||||
|
gp_params: &GpParams,
|
||||||
|
gateway_context: Option<&GatewayLoginContext>,
|
||||||
|
) -> anyhow::Result<GatewayLoginSession> {
|
||||||
|
let mut gp_params = gp_params.clone();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let login = match gateway_context {
|
||||||
|
Some(context) => gateway_login_with_context(gateway, cred, &gp_params, context).await?,
|
||||||
|
None => gateway_login(gateway, cred, &gp_params).await?,
|
||||||
|
};
|
||||||
|
|
||||||
|
match login {
|
||||||
|
GatewayLogin::Cookie(cookie) => {
|
||||||
|
return Ok(GatewayLoginSession {
|
||||||
|
cookie,
|
||||||
|
extension_auth: SessionExtensionAuth::new(cred.clone(), gp_params),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
GatewayLogin::Mfa(message, input_str) => {
|
||||||
|
let otp = Text::new(&message).prompt()?;
|
||||||
|
gp_params.set_input_str(&input_str);
|
||||||
|
gp_params.set_otp(&otp);
|
||||||
|
|
||||||
|
info!("Retrying gateway login with MFA...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn connect_gateway(
|
||||||
|
&self,
|
||||||
|
portal: &str,
|
||||||
|
gateway: &str,
|
||||||
|
cookie: &str,
|
||||||
|
allow_extend_session: bool,
|
||||||
|
extension_auth: SessionExtensionAuth,
|
||||||
|
) -> Result<(), GatewayConnectError> {
|
||||||
|
// --cookie-only: print the gateway cookie and exit without opening a tunnel.
|
||||||
|
// No tun device is allocated, no root is required, and no logout is issued
|
||||||
|
// against the gateway — the cookie remains valid for subsequent use.
|
||||||
|
// Output format matches openconnect --authenticate for easy shell consumption.
|
||||||
|
if self.args.cookie_only {
|
||||||
|
println!("COOKIE='{}'", cookie);
|
||||||
|
println!("HOST='{}'", gateway);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let mtu = self.args.mtu.unwrap_or(0);
|
||||||
|
let (hip, csd_wrapper) = self.determine_hip_script();
|
||||||
|
let hip_user = self.determine_hip_user();
|
||||||
|
let csd_uid = get_uid(&hip_user).map_err(GatewayConnectError::before_tunnel)?;
|
||||||
|
let os_profile = self.os_profile.borrow().clone();
|
||||||
|
|
||||||
|
let session_ctx = build_session_context(SessionContextInput {
|
||||||
|
portal: portal.to_string(),
|
||||||
|
gateway: gateway.to_string(),
|
||||||
|
cookie: cookie.to_string(),
|
||||||
|
os_profile: os_profile.clone(),
|
||||||
|
certificate: self.args.certificate.clone(),
|
||||||
|
sslkey: self.args.sslkey.clone(),
|
||||||
|
key_password: self.latest_key_password.borrow().clone(),
|
||||||
|
disable_ipv6: self.args.disable_ipv6,
|
||||||
|
extension_auth: Some(extension_auth),
|
||||||
|
});
|
||||||
|
let vpn_builder = Vpn::builder(gateway, cookie)
|
||||||
|
.script(self.args.script.clone())
|
||||||
|
.interface(self.args.interface.clone())
|
||||||
|
.script_tun(self.args.script_tun)
|
||||||
|
.certificate(self.args.certificate.clone())
|
||||||
|
.sslkey(self.args.sslkey.clone())
|
||||||
|
.key_password(self.latest_key_password.borrow().clone())
|
||||||
|
.hip(hip)
|
||||||
|
.csd_uid(csd_uid)
|
||||||
|
.csd_wrapper(csd_wrapper)
|
||||||
|
.reconnect_timeout(self.args.reconnect_timeout)
|
||||||
|
.mtu(mtu)
|
||||||
|
.disable_ipv6(self.args.disable_ipv6)
|
||||||
|
.no_dtls(self.args.no_dtls)
|
||||||
|
.local_hostname(self.args.local_hostname.clone())
|
||||||
|
.dpd_interval(self.args.dpd_interval.unwrap_or(0))
|
||||||
|
.no_xmlpost(self.args.no_xmlpost);
|
||||||
|
let vpn = apply_os_profile(vpn_builder, &os_profile)
|
||||||
|
.build()
|
||||||
|
.map_err(|err| GatewayConnectError::before_tunnel(err.into()))?;
|
||||||
|
|
||||||
|
let vpn = Arc::new(vpn);
|
||||||
|
let vpn_clone = vpn.clone();
|
||||||
|
let runtime_handle = Handle::current();
|
||||||
|
let session_ctx = Arc::new(Mutex::new(Some(session_ctx)));
|
||||||
|
let session_task: Arc<Mutex<Option<JoinHandle<()>>>> = Arc::new(Mutex::new(None));
|
||||||
|
let session_task_on_connect = Arc::clone(&session_task);
|
||||||
|
let session_ctx_on_connect = Arc::clone(&session_ctx);
|
||||||
|
let tunnel_established = Arc::new(AtomicBool::new(false));
|
||||||
|
let tunnel_established_on_connect = Arc::clone(&tunnel_established);
|
||||||
|
let disconnect_requested = Arc::new(AtomicBool::new(false));
|
||||||
|
let disconnect_requested_on_signal = Arc::clone(&disconnect_requested);
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
|
shutdown_signal().await;
|
||||||
|
info!("Received the interrupt signal, disconnecting...");
|
||||||
|
disconnect_requested_on_signal.store(true, Ordering::SeqCst);
|
||||||
|
vpn_clone.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
let lock_file = self.shared_args.lock_file.to_path_buf();
|
||||||
|
let lock_file_on_connect = lock_file.clone();
|
||||||
|
let log_format = self.shared_args.log_format;
|
||||||
|
let connect_result = vpn.connect(move |vpn_session_info| {
|
||||||
|
tunnel_established_on_connect.store(true, Ordering::SeqCst);
|
||||||
|
write_pid_file(&lock_file_on_connect);
|
||||||
|
|
||||||
|
let Some(session_ctx) = session_ctx_on_connect.lock().unwrap().take() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let session_info = session_info_from_vpn(vpn_session_info, allow_extend_session);
|
||||||
|
info!("VPN session info: {}", session_info.log_summary());
|
||||||
|
|
||||||
|
let task = spawn_session_runtime_with_info(&runtime_handle, session_ctx, session_info, log_format);
|
||||||
|
session_task_on_connect.lock().unwrap().replace(task);
|
||||||
|
});
|
||||||
|
let tunnel_established = tunnel_established.load(Ordering::SeqCst);
|
||||||
|
|
||||||
|
if let Some(task) = session_task.lock().unwrap().take() {
|
||||||
|
task.abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
if fs::metadata(&lock_file).is_ok() {
|
||||||
|
info!("Removing PID file");
|
||||||
|
fs::remove_file(&lock_file).map_err(|err| GatewayConnectError::after_tunnel(err.into()))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let disconnect_requested = disconnect_requested.load(Ordering::SeqCst);
|
||||||
|
classify_openconnect_result(connect_result, tunnel_established, disconnect_requested)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn determine_hip_script(&self) -> (bool, Option<String>) {
|
||||||
|
if let Some(hip) = &self.args.hip {
|
||||||
|
return if hip.is_empty() {
|
||||||
|
(true, None)
|
||||||
|
} else {
|
||||||
|
(true, Some(hip.clone()))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
(self.args.csd_wrapper.is_some(), self.args.csd_wrapper.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn determine_hip_user(&self) -> Option<String> {
|
||||||
|
if let Some(hip_user) = &self.args.hip_user {
|
||||||
|
return Some(hip_user.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
self.args.csd_user.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn classify_openconnect_result(
|
||||||
|
exit_code: i32,
|
||||||
|
tunnel_established: bool,
|
||||||
|
disconnect_requested: bool,
|
||||||
|
) -> Result<(), GatewayConnectError> {
|
||||||
|
if exit_code == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if disconnect_requested && exit_code == OPENCONNECT_INTERRUPTED_EXIT_CODE {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code);
|
||||||
|
if tunnel_established {
|
||||||
|
Err(GatewayConnectError::after_tunnel(error))
|
||||||
|
} else {
|
||||||
|
Err(GatewayConnectError::before_tunnel(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn direct_gateway_command(gateway: &str) -> String {
|
||||||
|
format!("gpauth --gateway {gateway} | sudo gpclient connect {gateway} --as-gateway --cookie-on-stdin")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_pid_file(lock_file: &Path) {
|
||||||
|
let pid = std::process::id();
|
||||||
|
|
||||||
|
if let Err(err) = fs::write(lock_file, pid.to_string()) {
|
||||||
|
warn!("Failed to write PID file: {}", err);
|
||||||
|
} else {
|
||||||
|
info!("Wrote PID {} to {}", pid, lock_file.display());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_uid(user: &Option<String>) -> anyhow::Result<u32> {
|
||||||
|
if let Some(user) = user {
|
||||||
|
get_user_by_name(user).map(|user| user.uid())
|
||||||
|
} else {
|
||||||
|
Ok(uzers::get_effective_uid())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_os_profile(builder: VpnBuilder, profile: &OsProfile) -> VpnBuilder {
|
||||||
|
builder
|
||||||
|
.os(Some(profile.client_os().to_openconnect_os().to_string()))
|
||||||
|
.os_version(Some(profile.os_version().to_string()))
|
||||||
|
.client_version(Some(profile.client_version().to_string()))
|
||||||
|
.host_id(Some(profile.host_identity().host_id().to_string()))
|
||||||
|
.user_agent(Some(profile.user_agent().to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hip_script_defaults_to_process_effective_uid() {
|
||||||
|
assert_eq!(get_uid(&None).unwrap(), uzers::get_effective_uid());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn explicit_hip_user_must_exist() {
|
||||||
|
assert!(get_uid(&Some("gpclient-nonexistent-hip-user".to_string())).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn explicit_hip_user_resolves_to_the_selected_account() {
|
||||||
|
let current = uzers::get_user_by_uid(uzers::get_effective_uid()).unwrap();
|
||||||
|
let name = current.name().to_string_lossy().into_owned();
|
||||||
|
assert_eq!(get_uid(&Some(name)).unwrap(), current.uid());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn openconnect_success_is_not_a_gateway_failure() {
|
||||||
|
assert!(classify_openconnect_result(0, false, false).is_ok());
|
||||||
|
assert!(classify_openconnect_result(0, true, false).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn openconnect_failure_before_callback_is_retryable_gateway_failure() {
|
||||||
|
let err = classify_openconnect_result(1, false, false).expect_err("nonzero exit should fail");
|
||||||
|
|
||||||
|
assert!(err.is_before_tunnel());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn openconnect_failure_after_callback_is_terminal_gateway_failure() {
|
||||||
|
let err = classify_openconnect_result(1, true, false).expect_err("nonzero exit should fail");
|
||||||
|
|
||||||
|
assert!(!err.is_before_tunnel());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn interrupted_exit_after_requested_disconnect_is_success() {
|
||||||
|
assert!(classify_openconnect_result(OPENCONNECT_INTERRUPTED_EXIT_CODE, true, true).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn interrupted_exit_without_requested_disconnect_is_failure() {
|
||||||
|
let err = classify_openconnect_result(OPENCONNECT_INTERRUPTED_EXIT_CODE, true, false)
|
||||||
|
.expect_err("unexpected interrupt should fail");
|
||||||
|
|
||||||
|
assert!(!err.is_before_tunnel());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn direct_gateway_recommendation_uses_gateway_server() {
|
||||||
|
assert_eq!(
|
||||||
|
direct_gateway_command("gateway.example.test"),
|
||||||
|
"gpauth --gateway gateway.example.test | sudo gpclient connect gateway.example.test --as-gateway --cookie-on-stdin"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
mod args;
|
||||||
|
mod credential;
|
||||||
|
mod gateway;
|
||||||
|
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use anyhow::bail;
|
||||||
|
use gpapi::{
|
||||||
|
clap::report,
|
||||||
|
error::PortalError,
|
||||||
|
gateway::{GatewayLoginContext, GatewaySelection},
|
||||||
|
gp_params::GpParams,
|
||||||
|
os_profile::OsProfile,
|
||||||
|
portal::{PreloginOptions, prelogin, retrieve_config},
|
||||||
|
utils::request::RequestIdentityError,
|
||||||
|
};
|
||||||
|
use inquire::{Password, PasswordDisplayMode, Select};
|
||||||
|
use log::{Level, info, warn};
|
||||||
|
|
||||||
|
use crate::cli::SharedArgs;
|
||||||
|
|
||||||
|
pub(crate) use args::ConnectArgs;
|
||||||
|
use args::{build_os_profile, build_os_profile_with_host_id, warn_deprecated_connect_args};
|
||||||
|
use credential::CleanAuthState;
|
||||||
|
use gateway::GatewayConnectError;
|
||||||
|
|
||||||
|
pub(crate) struct ConnectHandler<'a> {
|
||||||
|
args: &'a ConnectArgs,
|
||||||
|
shared_args: &'a SharedArgs<'a>,
|
||||||
|
os_profile: RefCell<OsProfile>,
|
||||||
|
latest_key_password: RefCell<Option<String>>,
|
||||||
|
password_from_stdin: RefCell<Option<String>>,
|
||||||
|
cookie_from_stdin: RefCell<Option<String>>,
|
||||||
|
clean_auth_state: RefCell<CleanAuthState>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ConnectHandler<'a> {
|
||||||
|
pub(crate) fn new(args: &'a ConnectArgs, shared_args: &'a SharedArgs) -> Self {
|
||||||
|
warn_deprecated_connect_args(args);
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
let clean_auth = args.clean;
|
||||||
|
#[cfg(not(feature = "webview-auth"))]
|
||||||
|
let clean_auth = false;
|
||||||
|
|
||||||
|
Self {
|
||||||
|
args,
|
||||||
|
shared_args,
|
||||||
|
os_profile: RefCell::new(build_os_profile(args)),
|
||||||
|
latest_key_password: Default::default(),
|
||||||
|
password_from_stdin: Default::default(),
|
||||||
|
cookie_from_stdin: Default::default(),
|
||||||
|
clean_auth_state: RefCell::new(CleanAuthState::new(clean_auth)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_gp_params(&self) -> GpParams {
|
||||||
|
let mut builder = GpParams::builder(self.os_profile.borrow().clone());
|
||||||
|
builder
|
||||||
|
.csc_mode(self.args.csc)
|
||||||
|
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
|
||||||
|
.certificate(self.args.certificate.clone())
|
||||||
|
.sslkey(self.args.sslkey.clone())
|
||||||
|
.key_password(self.latest_key_password.borrow().clone());
|
||||||
|
|
||||||
|
builder.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn prelogin_options(&self, gateway_browser_auth_allowed: bool) -> PreloginOptions {
|
||||||
|
PreloginOptions::default()
|
||||||
|
.external_browser_requested(self.external_browser_requested())
|
||||||
|
.gateway_external_browser_allowed(gateway_browser_auth_allowed)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn direct_gateway_prelogin_options(&self) -> PreloginOptions {
|
||||||
|
self.prelogin_options(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn gateway_browser_auth_allowed(&self, portal_config_default_browser: bool) -> bool {
|
||||||
|
gateway_browser_auth_allowed(portal_config_default_browser, self.external_browser_requested())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn external_browser_requested(&self) -> bool {
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
{
|
||||||
|
self.args.default_browser || self.args.browser.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "webview-auth"))]
|
||||||
|
{
|
||||||
|
self.args.browser.is_some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
||||||
|
if self.args.browser_listen.is_some()
|
||||||
|
&& !matches!(self.args.browser.as_deref(), Some(browser) if browser.eq_ignore_ascii_case("remote"))
|
||||||
|
{
|
||||||
|
bail!("The '--browser-listen' option requires '--browser remote'");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webview-auth")]
|
||||||
|
if self.args.default_browser && self.args.browser.is_some() {
|
||||||
|
bail!("Cannot use `--default-browser` and `--browser` options at the same time");
|
||||||
|
}
|
||||||
|
|
||||||
|
self.latest_key_password.replace(self.args.key_password.clone());
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let Err(err) = self.handle_impl().await else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(root_cause) = err.root_cause().downcast_ref::<RequestIdentityError>() else {
|
||||||
|
return Err(err);
|
||||||
|
};
|
||||||
|
|
||||||
|
match root_cause {
|
||||||
|
RequestIdentityError::NoKey => {
|
||||||
|
let format = self.shared_args.log_format;
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Error,
|
||||||
|
"ERROR: No private key found in the certificate file",
|
||||||
|
);
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Error,
|
||||||
|
"ERROR: Please provide the private key file using the `-k` option",
|
||||||
|
);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
RequestIdentityError::NoPassphrase(cert_type) | RequestIdentityError::DecryptError(cert_type) => {
|
||||||
|
let message = format!("Enter the {} passphrase:", cert_type);
|
||||||
|
let password = Password::new(&message)
|
||||||
|
.without_confirmation()
|
||||||
|
.with_display_mode(PasswordDisplayMode::Masked)
|
||||||
|
.prompt()?;
|
||||||
|
|
||||||
|
self.latest_key_password.replace(Some(password));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn handle_impl(&self) -> anyhow::Result<()> {
|
||||||
|
let server = self.args.server.as_str();
|
||||||
|
let as_gateway = self.args.as_gateway;
|
||||||
|
|
||||||
|
self.prepare_cookie_from_stdin()?;
|
||||||
|
|
||||||
|
if as_gateway {
|
||||||
|
info!("Treating the server as a gateway");
|
||||||
|
return self.connect_gateway_with_prelogin(server, server, false, None).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self.args.cookie_on_stdin {
|
||||||
|
if let Some(()) = self.try_cached_cookie(server).await {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let Err(err) = self.connect_portal_with_prelogin(server).await else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
|
warn!("Failed to connect portal with prelogin: {}", err);
|
||||||
|
if err.root_cause().downcast_ref::<PortalError>().is_some() {
|
||||||
|
info!("Trying the gateway authentication workflow...");
|
||||||
|
self.connect_gateway_with_prelogin(server, server, false, None).await?;
|
||||||
|
|
||||||
|
let format = self.shared_args.log_format;
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Warn,
|
||||||
|
"\nNOTE: the server may be a gateway, not a portal.",
|
||||||
|
);
|
||||||
|
report(
|
||||||
|
format,
|
||||||
|
Level::Warn,
|
||||||
|
"NOTE: try to use the `--as-gateway` option if you were authenticated twice.",
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn connect_portal_with_prelogin(&self, portal: &str) -> anyhow::Result<()> {
|
||||||
|
let gp_params = self.build_gp_params();
|
||||||
|
|
||||||
|
let prelogin = prelogin(portal, &gp_params, self.prelogin_options(false)).await?;
|
||||||
|
|
||||||
|
let cred = self.obtain_credential(&prelogin, portal, false).await?;
|
||||||
|
let mut portal_config = retrieve_config(portal, &cred, &gp_params).await?;
|
||||||
|
|
||||||
|
portal_config.sort_gateways(prelogin.region());
|
||||||
|
|
||||||
|
let auth_cookie = match cred.password() {
|
||||||
|
Some(password) => portal_config.auth_cookie().clone().with_password(password),
|
||||||
|
None => portal_config.auth_cookie().clone(),
|
||||||
|
};
|
||||||
|
let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false);
|
||||||
|
let portal_config_default_browser = portal_config.default_browser().unwrap_or(false);
|
||||||
|
info!("Portal config default-browser: {}", portal_config_default_browser);
|
||||||
|
|
||||||
|
if self.args.auto_gateway {
|
||||||
|
let gateways = portal_config.gateways();
|
||||||
|
if gateways.is_empty() {
|
||||||
|
bail!("No gateways available in portal config for auto-gateway selection");
|
||||||
|
}
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Auto-gateway mode: trying {} gateway(s) in priority order",
|
||||||
|
gateways.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut last_err: Option<anyhow::Error> = None;
|
||||||
|
for gateway in &gateways {
|
||||||
|
info!("Auto-gateway: attempting gateway {}", gateway);
|
||||||
|
let gateway_context =
|
||||||
|
GatewayLoginContext::new(gateway, GatewaySelection::Auto).with_connect_method(portal_config.connect_method());
|
||||||
|
|
||||||
|
match self
|
||||||
|
.connect_gateway_with_fallback(
|
||||||
|
portal,
|
||||||
|
gateway.server(),
|
||||||
|
&auth_cookie,
|
||||||
|
allow_extend_session,
|
||||||
|
portal_config_default_browser,
|
||||||
|
gateway_context,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(()) => return Ok(()),
|
||||||
|
Err(err) => {
|
||||||
|
if !err.is_before_tunnel() {
|
||||||
|
return Err(err.into_error());
|
||||||
|
}
|
||||||
|
warn!(
|
||||||
|
"Auto-gateway: gateway {} failed before tunnel setup: {}",
|
||||||
|
gateway,
|
||||||
|
err.as_error()
|
||||||
|
);
|
||||||
|
last_err = Some(err.into_error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let detail = last_err
|
||||||
|
.map(|e| e.to_string())
|
||||||
|
.unwrap_or_else(|| "unknown error".to_string());
|
||||||
|
bail!(
|
||||||
|
"Auto-gateway: all {} gateway(s) failed to connect; last error: {}",
|
||||||
|
gateways.len(),
|
||||||
|
detail
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let gateway_selection = if self.args.gateway.is_some() {
|
||||||
|
GatewaySelection::Manual
|
||||||
|
} else {
|
||||||
|
GatewaySelection::Auto
|
||||||
|
};
|
||||||
|
let selected_gateway = match &self.args.gateway {
|
||||||
|
Some(gateway) => portal_config
|
||||||
|
.find_gateway(gateway)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("Cannot find gateway specified: {}", gateway))?,
|
||||||
|
None => {
|
||||||
|
let gateways = portal_config.gateways();
|
||||||
|
|
||||||
|
if gateways.len() > 1 {
|
||||||
|
let gateway = Select::new("Which gateway do you want to connect to?", gateways)
|
||||||
|
.with_vim_mode(true)
|
||||||
|
.prompt()?;
|
||||||
|
info!("Connecting to the selected gateway: {}", gateway);
|
||||||
|
gateway
|
||||||
|
} else {
|
||||||
|
info!("Connecting to the only available gateway: {}", gateways[0]);
|
||||||
|
gateways[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let gateway = selected_gateway.server();
|
||||||
|
let gateway_context =
|
||||||
|
GatewayLoginContext::new(selected_gateway, gateway_selection).with_connect_method(portal_config.connect_method());
|
||||||
|
|
||||||
|
self
|
||||||
|
.connect_gateway_with_fallback(
|
||||||
|
portal,
|
||||||
|
gateway,
|
||||||
|
&auth_cookie,
|
||||||
|
allow_extend_session,
|
||||||
|
portal_config_default_browser,
|
||||||
|
gateway_context,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(GatewayConnectError::into_error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_stdin_host_id(&self, host_id: Option<&str>) {
|
||||||
|
let Some(host_id) = host_id else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
self
|
||||||
|
.os_profile
|
||||||
|
.replace(build_os_profile_with_host_id(self.args, Some(host_id)));
|
||||||
|
info!(
|
||||||
|
"connect profile host-id: {}",
|
||||||
|
self.os_profile.borrow().host_identity().host_id()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gateway_browser_auth_allowed(portal_config_default_browser: bool, external_browser_requested: bool) -> bool {
|
||||||
|
portal_config_default_browser || external_browser_requested
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::gateway_browser_auth_allowed;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gateway_browser_auth_is_allowed_by_portal_config() {
|
||||||
|
assert!(gateway_browser_auth_allowed(true, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gateway_browser_auth_is_allowed_by_explicit_browser_request() {
|
||||||
|
assert!(gateway_browser_auth_allowed(false, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gateway_browser_auth_is_disabled_without_portal_config_or_user_request() {
|
||||||
|
assert!(!gateway_browser_auth_allowed(false, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,63 @@
|
|||||||
use crate::GP_CLIENT_LOCK_FILE;
|
use clap::Args;
|
||||||
|
use gpapi::utils::lock_file::gpservice_lock_info;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use std::fs;
|
use std::{fs, path::Path, str::FromStr, thread, time::Duration};
|
||||||
use sysinfo::{Pid, ProcessExt, Signal, System, SystemExt};
|
use sysinfo::{Pid, Signal, System};
|
||||||
|
|
||||||
pub(crate) struct DisconnectHandler;
|
#[derive(Args)]
|
||||||
|
pub struct DisconnectArgs {
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
required = false,
|
||||||
|
help = "The time in seconds to wait for the VPN connection to disconnect"
|
||||||
|
)]
|
||||||
|
wait: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
impl DisconnectHandler {
|
pub struct DisconnectHandler<'a> {
|
||||||
pub(crate) fn new() -> Self {
|
args: &'a DisconnectArgs,
|
||||||
Self
|
lock_file: &'a Path,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> DisconnectHandler<'a> {
|
||||||
|
pub fn new(args: &'a DisconnectArgs, lock_file: &'a Path) -> Self {
|
||||||
|
Self { args, lock_file }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn handle(&self) -> anyhow::Result<()> {
|
pub async fn handle(&self) -> anyhow::Result<()> {
|
||||||
if fs::metadata(GP_CLIENT_LOCK_FILE).is_err() {
|
// Try to disconnect the CLI client
|
||||||
warn!("PID file not found, maybe the client is not running");
|
if let Ok(c) = fs::read_to_string(self.lock_file) {
|
||||||
return Ok(());
|
send_signal(c.trim(), Signal::Interrupt).unwrap_or_else(|err| {
|
||||||
|
warn!("Failed to send signal to client: {}", err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Try to disconnect the GUI service
|
||||||
|
if let Ok(c) = gpservice_lock_info().await {
|
||||||
|
send_signal(&c.pid.to_string(), Signal::User1).unwrap_or_else(|err| {
|
||||||
|
warn!("Failed to send signal to service: {}", err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// sleep, to give the client and service time to disconnect
|
||||||
|
if let Some(wait) = self.args.wait {
|
||||||
|
thread::sleep(Duration::from_secs(wait));
|
||||||
}
|
}
|
||||||
|
|
||||||
let pid = fs::read_to_string(GP_CLIENT_LOCK_FILE)?;
|
Ok(())
|
||||||
let pid = pid.trim().parse::<usize>()?;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_signal(pid: &str, signal: Signal) -> anyhow::Result<()> {
|
||||||
let s = System::new_all();
|
let s = System::new_all();
|
||||||
|
let pid = Pid::from_str(pid)?;
|
||||||
|
|
||||||
if let Some(process) = s.process(Pid::from(pid)) {
|
if let Some(process) = s.process(pid) {
|
||||||
info!("Found process {}, killing...", pid);
|
info!("Found process {}, sending signal...", pid);
|
||||||
if process.kill_with(Signal::Interrupt).is_none() {
|
|
||||||
|
if process.kill_with(signal).is_none() {
|
||||||
warn!("Failed to kill process {}", pid);
|
warn!("Failed to kill process {}", pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
use clap::Args;
|
||||||
|
use gpapi::{
|
||||||
|
clap::args::Os,
|
||||||
|
os_profile::{ClientOs, OsProfileBuilder},
|
||||||
|
};
|
||||||
|
use gphip::{ReportContext, ReportInput, generate_report};
|
||||||
|
|
||||||
|
#[derive(Args)]
|
||||||
|
pub(crate) struct HipArgs {
|
||||||
|
#[arg(long, help = "The GP client version, e.g., 6.2.4-49")]
|
||||||
|
client_version: String,
|
||||||
|
|
||||||
|
#[arg(long, value_enum, help = "The client OS")]
|
||||||
|
client_os: Os,
|
||||||
|
|
||||||
|
#[arg(long, hide = true)]
|
||||||
|
os_version: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "Use this runtime host ID when building the OS profile")]
|
||||||
|
host_id: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "The authentication cookie")]
|
||||||
|
cookie: String,
|
||||||
|
|
||||||
|
#[arg(long, help = "The client IPv4 address")]
|
||||||
|
client_ip: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "The client IPv6 address")]
|
||||||
|
client_ipv6: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help = "The MD5 digest to encode into the HIP report")]
|
||||||
|
md5: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct HipHandler<'a> {
|
||||||
|
args: &'a HipArgs,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> HipHandler<'a> {
|
||||||
|
pub(crate) fn new(args: &'a HipArgs) -> Self {
|
||||||
|
Self { args }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
||||||
|
let client_os = ClientOs::from(self.args.client_os);
|
||||||
|
let mut builder = OsProfileBuilder::new(client_os).client_version(self.args.client_version.clone());
|
||||||
|
if let Some(host_id) = self.args.host_id.as_deref() {
|
||||||
|
builder = builder.host_id_override(host_id);
|
||||||
|
}
|
||||||
|
let input = ReportInput {
|
||||||
|
profile: builder.build(),
|
||||||
|
context: ReportContext::Connected {
|
||||||
|
cookie: self.args.cookie.clone(),
|
||||||
|
client_ip: self.args.client_ip.clone(),
|
||||||
|
client_ipv6: self.args.client_ipv6.clone(),
|
||||||
|
md5: self.args.md5.clone(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
println!("{}", generate_report(&input)?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,48 @@
|
|||||||
use std::{collections::HashMap, fs, path::PathBuf};
|
use std::{collections::HashMap, fs, path::PathBuf};
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
|
||||||
|
use std::process::{Command, ExitStatus};
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
use anyhow::Context;
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
|
||||||
|
use anyhow::bail;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
|
||||||
|
use common::binary_paths;
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use gpapi::{
|
use gpapi::{
|
||||||
process::service_launcher::ServiceLauncher,
|
process::service_launcher::ServiceLauncher,
|
||||||
utils::{endpoint::http_endpoint, env_file, shutdown_signal},
|
utils::{endpoint::http_endpoint, env_utils, shutdown_signal},
|
||||||
};
|
};
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub(crate) struct LaunchGuiArgs {
|
pub(crate) struct LaunchGuiArgs {
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
#[arg(
|
#[arg(
|
||||||
required = false,
|
required = false,
|
||||||
help = "The authentication data, used for the default browser authentication"
|
conflicts_with = "minimized",
|
||||||
|
value_parser = parse_auth_callback,
|
||||||
|
help = "The external-browser authentication callback URL"
|
||||||
)]
|
)]
|
||||||
auth_data: Option<String>,
|
callback: Option<String>,
|
||||||
#[arg(long, help = "Launch the GUI minimized")]
|
#[arg(long, help = "Launch the GUI minimized")]
|
||||||
minimized: bool,
|
minimized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl LaunchGuiArgs {
|
||||||
|
pub(crate) fn is_auth_callback(&self) -> bool {
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
{
|
||||||
|
return self.callback.is_some();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) struct LaunchGuiHandler<'a> {
|
pub(crate) struct LaunchGuiHandler<'a> {
|
||||||
args: &'a LaunchGuiArgs,
|
args: &'a LaunchGuiArgs,
|
||||||
}
|
}
|
||||||
@@ -30,15 +54,14 @@ impl<'a> LaunchGuiHandler<'a> {
|
|||||||
|
|
||||||
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
||||||
// `launch-gui`cannot be run as root
|
// `launch-gui`cannot be run as root
|
||||||
let user = whoami::username();
|
let user = whoami::username().map_err(|err| anyhow::anyhow!("Failed to resolve current user: {err}"))?;
|
||||||
if user == "root" {
|
if user == "root" {
|
||||||
anyhow::bail!("`launch-gui` cannot be run as root");
|
anyhow::bail!("`launch-gui` cannot be run as root");
|
||||||
}
|
}
|
||||||
|
|
||||||
let auth_data = self.args.auth_data.as_deref().unwrap_or_default();
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
if !auth_data.is_empty() {
|
if let Some(callback) = &self.args.callback {
|
||||||
// Process the authentication data, its format is `globalprotectcallback:<data>`
|
return forward_auth_callback(callback);
|
||||||
return feed_auth_data(auth_data).await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if try_active_gui().await.is_ok() {
|
if try_active_gui().await.is_ok() {
|
||||||
@@ -60,7 +83,7 @@ impl<'a> LaunchGuiHandler<'a> {
|
|||||||
extra_envs.insert("GP_LOG_FILE".into(), log_file_path.clone());
|
extra_envs.insert("GP_LOG_FILE".into(), log_file_path.clone());
|
||||||
|
|
||||||
// Persist the environment variables to a file
|
// Persist the environment variables to a file
|
||||||
let env_file = env_file::persist_env_vars(Some(extra_envs))?;
|
let env_file = env_utils::persist_env_vars(Some(extra_envs))?;
|
||||||
let env_file = env_file.into_temp_path();
|
let env_file = env_file.into_temp_path();
|
||||||
let env_file_path = env_file.to_string_lossy().to_string();
|
let env_file_path = env_file.to_string_lossy().to_string();
|
||||||
|
|
||||||
@@ -77,19 +100,38 @@ impl<'a> LaunchGuiHandler<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn feed_auth_data(auth_data: &str) -> anyhow::Result<()> {
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
let service_endpoint = http_endpoint().await?;
|
fn forward_auth_callback(callback: &str) -> anyhow::Result<()> {
|
||||||
|
let status = auth_callback_command(callback)
|
||||||
|
.status()
|
||||||
|
.context("Failed to start the authentication callback handler")?;
|
||||||
|
ensure_auth_callback_succeeded(status)
|
||||||
|
}
|
||||||
|
|
||||||
reqwest::Client::default()
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
|
||||||
.post(format!("{}/auth-data", service_endpoint))
|
fn auth_callback_command(callback: &str) -> Command {
|
||||||
.json(&auth_data)
|
let mut command = Command::new(binary_paths::gpauth());
|
||||||
.send()
|
command.args(["auth-callback", callback]);
|
||||||
.await?
|
command
|
||||||
.error_for_status()?;
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
|
||||||
|
fn ensure_auth_callback_succeeded(status: ExitStatus) -> anyhow::Result<()> {
|
||||||
|
if !status.success() {
|
||||||
|
bail!("Authentication callback handler exited with {status}");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
|
||||||
|
fn parse_auth_callback(callback: &str) -> Result<String, String> {
|
||||||
|
callback
|
||||||
|
.starts_with("globalprotectcallback:")
|
||||||
|
.then(|| callback.to_owned())
|
||||||
|
.ok_or_else(|| "callback URL must use the globalprotectcallback scheme".to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
async fn try_active_gui() -> anyhow::Result<()> {
|
async fn try_active_gui() -> anyhow::Result<()> {
|
||||||
let service_endpoint = http_endpoint().await?;
|
let service_endpoint = http_endpoint().await?;
|
||||||
|
|
||||||
@@ -102,7 +144,7 @@ async fn try_active_gui() -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_log_file() -> anyhow::Result<PathBuf> {
|
fn get_log_file() -> anyhow::Result<PathBuf> {
|
||||||
let dirs = ProjectDirs::from("com.yuezk", "GlobalProtect-openconnect", "gpclient")
|
let dirs = ProjectDirs::from("com.yuezk", "GlobalProtect-openconnect", "gpclient")
|
||||||
.ok_or_else(|| anyhow::anyhow!("Failed to get project dirs"))?;
|
.ok_or_else(|| anyhow::anyhow!("Failed to get project dirs"))?;
|
||||||
|
|
||||||
@@ -110,3 +152,34 @@ pub fn get_log_file() -> anyhow::Result<PathBuf> {
|
|||||||
|
|
||||||
Ok(dirs.data_dir().join("gpclient.log"))
|
Ok(dirs.data_dir().join("gpclient.log"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(test, unix))]
|
||||||
|
mod tests {
|
||||||
|
use std::os::unix::process::ExitStatusExt;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
const CALLBACK: &str = "globalprotectcallback:cas-as=1&[email protected]&token=token";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn callback_command_preserves_callback_argument() {
|
||||||
|
let command = auth_callback_command(CALLBACK);
|
||||||
|
let args = command
|
||||||
|
.get_args()
|
||||||
|
.map(|argument| argument.to_str().unwrap())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(args, ["auth-callback", CALLBACK]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn callback_command_status_is_propagated() {
|
||||||
|
assert!(ensure_auth_callback_succeeded(ExitStatus::from_raw(0)).is_ok());
|
||||||
|
assert!(ensure_auth_callback_succeeded(ExitStatus::from_raw(1 << 8)).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rejects_non_callback_url() {
|
||||||
|
assert!(parse_auth_callback("https://example.com/callback").is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
mod cli;
|
mod cli;
|
||||||
mod connect;
|
mod connect;
|
||||||
mod disconnect;
|
mod disconnect;
|
||||||
|
mod hip;
|
||||||
mod launch_gui;
|
mod launch_gui;
|
||||||
|
mod session;
|
||||||
|
|
||||||
pub(crate) const GP_CLIENT_LOCK_FILE: &str = "/var/run/gpclient.lock";
|
pub(crate) const GP_CLIENT_LOCK_FILE: &str = "/var/run/gpclient.lock";
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,254 @@
|
|||||||
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
|
use gpapi::{
|
||||||
|
clap::report,
|
||||||
|
gateway::{SessionContext, SessionExtensionAuth, extend_session},
|
||||||
|
log_format::LogFormat,
|
||||||
|
os_profile::OsProfile,
|
||||||
|
session::{SessionInfo, SessionRequestArgs, SessionWarning},
|
||||||
|
};
|
||||||
|
use log::{Level, info, warn};
|
||||||
|
use openconnect::VpnSessionInfo;
|
||||||
|
use tokio::{runtime::Handle, task::JoinHandle};
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
struct SessionWarningSchedule {
|
||||||
|
delay: Duration,
|
||||||
|
message: String,
|
||||||
|
should_auto_extend: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct SessionContextInput {
|
||||||
|
pub(crate) portal: String,
|
||||||
|
pub(crate) gateway: String,
|
||||||
|
pub(crate) cookie: String,
|
||||||
|
pub(crate) os_profile: OsProfile,
|
||||||
|
pub(crate) certificate: Option<String>,
|
||||||
|
pub(crate) sslkey: Option<String>,
|
||||||
|
pub(crate) key_password: Option<String>,
|
||||||
|
pub(crate) disable_ipv6: bool,
|
||||||
|
pub(crate) extension_auth: Option<SessionExtensionAuth>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn build_session_context(input: SessionContextInput) -> SessionContext {
|
||||||
|
let session_args = SessionRequestArgs::new(input.cookie)
|
||||||
|
.with_user_agent(input.os_profile.user_agent().to_string())
|
||||||
|
.with_certificate(input.certificate)
|
||||||
|
.with_sslkey(input.sslkey)
|
||||||
|
.with_key_password(input.key_password)
|
||||||
|
.with_disable_ipv6(input.disable_ipv6);
|
||||||
|
|
||||||
|
let ctx = SessionContext::new(input.gateway, input.portal, session_args);
|
||||||
|
match input.extension_auth {
|
||||||
|
Some(extension_auth) => ctx.with_extension_auth(extension_auth),
|
||||||
|
None => ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn session_info_from_vpn(vpn_session_info: VpnSessionInfo, allow_extend_session: bool) -> SessionInfo {
|
||||||
|
SessionInfo::from_vpn_session_fields(
|
||||||
|
vpn_session_info.lifetime_secs,
|
||||||
|
vpn_session_info.user_expires,
|
||||||
|
vpn_session_info.lifetime_warning.map(|warning| SessionWarning {
|
||||||
|
prior_secs: warning.prior_secs,
|
||||||
|
message: warning.message,
|
||||||
|
}),
|
||||||
|
allow_extend_session,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn spawn_session_runtime_with_info(
|
||||||
|
handle: &Handle,
|
||||||
|
session_ctx: SessionContext,
|
||||||
|
session_info: SessionInfo,
|
||||||
|
log_format: LogFormat,
|
||||||
|
) -> JoinHandle<()> {
|
||||||
|
handle.spawn(run_session_runtime(session_ctx, session_info, log_format))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run_session_runtime(session_ctx: SessionContext, mut session_info: SessionInfo, log_format: LogFormat) {
|
||||||
|
loop {
|
||||||
|
let Some(schedule) = build_session_warning_schedule(&session_info) else {
|
||||||
|
info!("No session warning schedule provided by the gateway");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
tokio::time::sleep(schedule.delay).await;
|
||||||
|
|
||||||
|
report(log_format, Level::Warn, &format!("\nWARNING: {}", schedule.message));
|
||||||
|
|
||||||
|
if !schedule.should_auto_extend {
|
||||||
|
info!("Session extension is not allowed by the gateway");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Attempting to extend the session");
|
||||||
|
match extend_session(&session_ctx).await {
|
||||||
|
Ok(()) => {
|
||||||
|
let Some(next_session_info) = session_info.rescheduled_after_extension() else {
|
||||||
|
info!("Session extended, but no lifetime is available to schedule another warning");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
report(log_format, Level::Info, "Session extended.");
|
||||||
|
session_info = next_session_info;
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Failed to extend session: {}", err);
|
||||||
|
report(
|
||||||
|
log_format,
|
||||||
|
Level::Warn,
|
||||||
|
&format!("WARNING: Failed to extend session: {}", err),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_session_warning_schedule(session_info: &SessionInfo) -> Option<SessionWarningSchedule> {
|
||||||
|
let warning = session_info.lifetime_warning.as_ref()?;
|
||||||
|
let warning_secs = if let Some(user_expires) = session_info.user_expires {
|
||||||
|
let now = unix_timestamp();
|
||||||
|
user_expires.saturating_sub(warning.prior_secs).saturating_sub(now)
|
||||||
|
} else if let Some(lifetime_secs) = session_info.lifetime_secs {
|
||||||
|
lifetime_secs.saturating_sub(warning.prior_secs)
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(SessionWarningSchedule {
|
||||||
|
delay: Duration::from_secs(warning_secs as u64),
|
||||||
|
message: warning.message.clone(),
|
||||||
|
should_auto_extend: session_info.allow_extend_session,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unix_timestamp() -> u32 {
|
||||||
|
SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs() as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn sample_session_info(user_expires: Option<u32>, allow_extend_session: bool) -> SessionInfo {
|
||||||
|
SessionInfo {
|
||||||
|
user_expires,
|
||||||
|
lifetime_warning: Some(SessionWarning {
|
||||||
|
prior_secs: 1800,
|
||||||
|
message: "Session expires soon".to_string(),
|
||||||
|
}),
|
||||||
|
allow_extend_session,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn builds_warning_schedule_for_auto_extend() {
|
||||||
|
let session_info = sample_session_info(Some(unix_timestamp() + 1830), true);
|
||||||
|
|
||||||
|
let schedule = build_session_warning_schedule(&session_info).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(schedule.message, "Session expires soon");
|
||||||
|
assert!(schedule.delay <= Duration::from_secs(30));
|
||||||
|
assert!(schedule.should_auto_extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn builds_warning_schedule_without_auto_extend() {
|
||||||
|
let session_info = sample_session_info(Some(unix_timestamp() + 1830), false);
|
||||||
|
|
||||||
|
let schedule = build_session_warning_schedule(&session_info).unwrap();
|
||||||
|
|
||||||
|
assert!(!schedule.should_auto_extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn schedules_next_warning_after_extension_from_lifetime() {
|
||||||
|
let mut session_info = sample_session_info(Some(unix_timestamp() + 1830), true);
|
||||||
|
session_info.lifetime_secs = Some(7200);
|
||||||
|
|
||||||
|
let next_session_info = session_info.rescheduled_after_extension().unwrap();
|
||||||
|
let schedule = build_session_warning_schedule(&next_session_info).unwrap();
|
||||||
|
|
||||||
|
assert!(schedule.delay <= Duration::from_secs(5400));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn builds_session_context_from_os_profile() {
|
||||||
|
let profile = OsProfile::builder(gpapi::os_profile::ClientOs::Mac)
|
||||||
|
.client_version("6.3.1-12".to_string())
|
||||||
|
.build();
|
||||||
|
let expected_user_agent = profile.user_agent().to_string();
|
||||||
|
|
||||||
|
let ctx = build_session_context(SessionContextInput {
|
||||||
|
portal: "portal.example.com".to_string(),
|
||||||
|
gateway: "vpn.example.com".to_string(),
|
||||||
|
cookie: "authcookie=AUTH".to_string(),
|
||||||
|
os_profile: profile,
|
||||||
|
certificate: Some("/tmp/client.pem".to_string()),
|
||||||
|
sslkey: Some("/tmp/client.key".to_string()),
|
||||||
|
key_password: Some("secret".to_string()),
|
||||||
|
disable_ipv6: true,
|
||||||
|
extension_auth: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(ctx.portal(), "portal.example.com");
|
||||||
|
assert_eq!(ctx.server(), "vpn.example.com");
|
||||||
|
assert_eq!(ctx.session_args().cookie(), "authcookie=AUTH");
|
||||||
|
assert_eq!(
|
||||||
|
ctx.session_args().user_agent().as_deref(),
|
||||||
|
Some(expected_user_agent.as_str())
|
||||||
|
);
|
||||||
|
assert_eq!(ctx.session_args().certificate().as_deref(), Some("/tmp/client.pem"));
|
||||||
|
assert_eq!(ctx.session_args().sslkey().as_deref(), Some("/tmp/client.key"));
|
||||||
|
assert_eq!(ctx.session_args().key_password().as_deref(), Some("secret"));
|
||||||
|
assert!(ctx.session_args().disable_ipv6());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn maps_openconnect_session_metadata_to_runtime_session_info() {
|
||||||
|
let info = session_info_from_vpn(
|
||||||
|
VpnSessionInfo {
|
||||||
|
lifetime_secs: Some(43_200),
|
||||||
|
user_expires: Some(1_776_828_409),
|
||||||
|
lifetime_warning: Some(openconnect::VpnSessionWarning {
|
||||||
|
prior_secs: 1_800,
|
||||||
|
message: "Session expires soon".to_string(),
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(info.lifetime_secs, Some(43_200));
|
||||||
|
assert_eq!(info.user_expires, Some(1_776_828_409));
|
||||||
|
assert_eq!(info.lifetime_warning.unwrap().prior_secs, 1_800);
|
||||||
|
assert!(info.allow_extend_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn direct_gateway_session_info_does_not_allow_extension_without_portal_policy() {
|
||||||
|
let info = session_info_from_vpn(
|
||||||
|
VpnSessionInfo {
|
||||||
|
lifetime_secs: Some(43_200),
|
||||||
|
user_expires: Some(1_776_828_409),
|
||||||
|
lifetime_warning: Some(openconnect::VpnSessionWarning {
|
||||||
|
prior_secs: 1_800,
|
||||||
|
message: "Session expires soon".to_string(),
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(info.lifetime_secs, Some(43_200));
|
||||||
|
assert_eq!(info.user_expires, Some(1_776_828_409));
|
||||||
|
assert_eq!(info.lifetime_warning.unwrap().prior_secs, 1_800);
|
||||||
|
assert!(!info.allow_extend_session);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es2021: true,
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:react/jsx-runtime",
|
||||||
|
"plugin:react-hooks/recommended",
|
||||||
|
"prettier",
|
||||||
|
],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
files: [".eslintrc.{js,cjs}"],
|
||||||
|
parserOptions: {
|
||||||
|
sourceType: "script",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
plugins: ["@typescript-eslint", "react"],
|
||||||
|
rules: {
|
||||||
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
"react-hooks/exhaustive-deps": "error",
|
||||||
|
"@typescript-eslint/no-unused-vars": "warn",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
.vite
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Tauri + React + Typescript
|
||||||
|
|
||||||
|
This template should help get you started developing with Tauri, React and Typescript in Vite.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="ocean" x1="245" y1="170" x2="770" y2="770" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#579bc1"/>
|
||||||
|
<stop offset=".52" stop-color="#438fbd"/>
|
||||||
|
<stop offset="1" stop-color="#2f719e"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="land" x1="260" y1="190" x2="750" y2="735" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#56c78a"/>
|
||||||
|
<stop offset=".55" stop-color="#3bbf78"/>
|
||||||
|
<stop offset="1" stop-color="#279b5d"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="lock" x1="385" y1="400" x2="650" y2="700" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#f3b84c"/>
|
||||||
|
<stop offset=".55" stop-color="#e8a12f"/>
|
||||||
|
<stop offset="1" stop-color="#d4871e"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="globe-clip">
|
||||||
|
<circle cx="512" cy="455" r="315"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<g transform="translate(512 512) scale(1.3) translate(-512 -455)">
|
||||||
|
<circle cx="512" cy="455" r="315" fill="url(#ocean)"/>
|
||||||
|
<g clip-path="url(#globe-clip)" fill="url(#land)">
|
||||||
|
<path d="M177 326c74-121 177-185 302-190-13 51-49 84-105 98-4 45-32 79-86 101-37 17-75 14-111-9Z"/>
|
||||||
|
<path d="M564 135c129 18 229 103 273 220-69-3-121 15-157 54-51-14-83-50-95-107-38-36-45-92-21-167Z"/>
|
||||||
|
<path d="M189 467c63-39 125-34 187 16 57 25 73 73 48 144-45 90-108 146-189 166-58-88-73-197-46-326Z"/>
|
||||||
|
<path d="M612 572c78-38 157-18 238 59-45 89-122 144-231 164-20-67-22-122-7-165-22-17-22-36 0-58Z"/>
|
||||||
|
</g>
|
||||||
|
<circle cx="512" cy="455" r="308" fill="none" stroke="#9ccde2" stroke-width="11" stroke-opacity=".4"/>
|
||||||
|
|
||||||
|
<g transform="translate(512 490) scale(.82) translate(-512 -490)">
|
||||||
|
<path d="M405 429v-75c0-142 214-142 214 0v75" fill="none" stroke="#eef1f2" stroke-width="58" stroke-linecap="round"/>
|
||||||
|
<rect x="340" y="403" width="344" height="278" rx="62" fill="url(#lock)"/>
|
||||||
|
<rect x="346" y="409" width="332" height="266" rx="56" fill="none" stroke="#f7cb75" stroke-width="10" stroke-opacity=".45"/>
|
||||||
|
<g fill="#85500f" opacity=".85">
|
||||||
|
<path d="M501 538h22l16 69h-54Z"/>
|
||||||
|
<circle cx="512" cy="521" r="27"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var t=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function ee(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,x||(x=!0,ie());else{var t=n(l);t!==null&&se(ee,t.startTime-e)}}}var x=!1,te=-1,ne=5,S=-1;function re(){return g?!0:!(e.unstable_now()-S<ne)}function C(){if(g=!1,x){var t=e.unstable_now();S=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(te),te=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&re());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&se(ee,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ie():x=!1}}}var ie;if(typeof y==`function`)ie=function(){y(C)};else if(typeof MessageChannel<`u`){var ae=new MessageChannel,oe=ae.port2;ae.port1.onmessage=C,ie=function(){oe.postMessage(null)}}else ie=function(){_(C,0)};function se(t,n){te=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ne=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(te),te=-1):h=!0,se(ee,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,x||(x=!0,ie()))),r},e.unstable_shouldYield=re,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),n=e(((e,n)=>{n.exports=t()})),r=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){Line truncated
|
||||||
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
||||||
|
`+ze+e+Be}var He=!1;function Ue(e,t){if(!e||He)return``;He=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
||||||
|
`),l=s.split(`
|
||||||
|
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
||||||
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{He=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ve(n):``}function We(e,t){switch(e.tag){case 26:case 27:case 5:return Ve(e.type);case 16:return Ve(`Lazy`);case 13:return e.child!==t&&t!==null?Ve(`Suspense Fallback`):Ve(`Suspense`);case 19:return Ve(`SuspenseList`);case 0:case 15:return Ue(e.type,!1);case 11:return Ue(e.type.render,!1);case 1:return Ue(e.type,!0);case 31:return Ve(`Activity`);case 30:return Ve(`ViewTransition`);default:return``}}function Ge(e){try{var t=``,n=null;do t+=We(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
||||||
|
Error generating stack: `+e.message+`
|
||||||
|
`+e.stack}}var Ke=Object.prototype.hasOwnProperty,qe=t.unstable_scheduleCallback,Je=t.unstable_cancelCallback,Ye=t.unstable_shouldYield,Xe=t.unstable_requestPaint,Ze=t.unstable_now,Qe=t.unstable_getCurrentPriorityLevel,$e=t.unstable_ImmediatePriority,et=t.unstable_UserBlockingPriority,tt=t.unstable_NormalPriority,nt=t.unstable_LowPriority,rt=t.unstable_IdlePriority,it=t.log,at=t.unstable_setDisableYieldValue,ot=null,st=null;function ct(e){if(typeof it==`function`&&at(e),st&&typeof st.setStrictMode==`function`)try{st.setStrictMode(ot,e)}catch{}}var lt=Math.clz32?Math.clz32:ft,ut=Math.log,dt=Math.LN2;function ft(e){return e>>>=0,e===0?32:31-(ut(e)/dt|0)|0}var pt=256,mt=262144,ht=4194304;function gt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function _t(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=gt(n))):i=gt(o):i=gt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=gt(n))):i=gt(o)):i=gt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function vt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function yt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-lt(n),i=1<<r;t|=e[r],n&=~i}return t}function bt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function xt(){var e=ht;return ht<<=1,!(ht&62914560)&&(ht=4194304),e}function St(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ct(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function wt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-lt(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Tt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Tt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-lt(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Et(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-lt(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Dt(e,t){var n=t&-t;return n=n&42?1:Ot(n),(n&(e.suspendedLanes|t))===0?n:0}function Ot(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function kt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function At(){var e=E.p;return e===0?(e=window.event,e===void 0?32:Ch(e.type)):e}function jt(e,t){var n=E.p;try{return E.p=e,t()}finally{E.p=n}}var Mt=Math.random().toString(36).slice(2),Nt=`__reactFiber$`+Mt,Pt=`__reactProps$`+Mt,Ft=`__reactContainer$`+Mt,It=`__reactEvents$`+Mt,Lt=`__reactListeners$`+Mt,Rt=`__reactHandles$`+Mt,zt=`__reactResources$`+Mt,Bt=`__reactMarker$`+Mt,Vt=`__reactLoad$`+Mt;function Ht(e){delete e[Nt],delete e[Pt],delete e[Lt],delete e[Rt]}function Ut(e){var t;if(t=e[Nt])return t;for(var n=e.parentNode;n;){if(t=n[Ft]||n[Nt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=fm(e);e!==null;){if(n=e[Nt])return n;e=fm(e)}return t}e=n,n=e.parentNode}return null}function Wt(e){if(e=e[Nt]||e[Ft]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Gt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(s(33))}function Kt(e){var t=e[zt];return t||=e[zt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function qt(e){e[Bt]=!0}function Jt(e){e[Vt]=void 0}var Yt=new Set,Xt={};function Zt(e,t){Qt(e,t),Qt(e+`Capture`,t)}function Qt(e,t){for(Xt[e]=t,e=0;e<t.le
Line truncated
|
||||||
|
`).replace(Qf,``)}function ep(e,t){return t=$f(t),$f(e)===t}function $(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||xn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&xn(e,``+r);else return;break;case`className`:on(e,`class`,r);break;case`tabIndex`:on(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:on(e,n,r);break;case`style`:wn(e,r,a);return;case`data`:if(t!==`object`){on(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=On(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,i.name,i,null),$(e,t,`formEncType`,i.formEncType,i,null),$(e,t,`formMethod`,i.formMethod,i,null),$(e,t,`formTarget`,i.formTarget,i,null)):($(e,t,`encType`,i.encType,i,null),$(e,t,`method`,i.method,i,null),$(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=On(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=kn);return;case`onScroll`:r!=null&&Q(`scroll`,e);return;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(s(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(s(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=On(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),an(e,`popover`,r);break;case`xlinkActuate`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:sn(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:sn(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:sn(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:sn(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:an(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=En.get(n)||n,an(e,n,r);else return}O=!0}function tp(e,t,n,r,i,a){switch(n){case`style`:wn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(s(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(s(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)xn(e,r);else if(typeof r==`number`||typeof r==`bigint`)xn(e,``+r);else return;break;case`onScroll`:r!=null&&Q(`scroll`,e);return;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=k
Line truncated
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
html,body,#root{box-sizing:border-box;-webkit-user-select:none;user-select:none;cursor:default;height:100%;margin:0;padding:0;overflow:hidden}body{color:#2e3436;background:#f6f5f4;font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}button{font:inherit}.update-window{box-sizing:border-box;background:#f6f5f4;align-items:center;gap:15px;width:100%;height:100%;padding:16px 18px;display:flex}.update-logo{flex:none;width:48px;height:48px}.update-content,.update-status{width:100%;min-width:0}.update-title{color:#2e3436;letter-spacing:-.01em;margin:0;font-size:16px;font-weight:600;line-height:1.25}.update-description{color:#5e5c64;margin:3px 0 0;font-size:12px;line-height:1.4}.progress-summary{justify-content:space-between;align-items:baseline;gap:12px;margin-top:3px;display:flex}.progress-summary .update-description{margin:0}.progress-bar{background-color:#d5d3d1;border-radius:3px;width:100%;height:6px;margin-top:9px;position:relative;overflow:hidden}.progress-fill{background:#3584e4;border-radius:3px;height:100%;transition:width .18s ease-out}.progress-bar-indeterminate .progress-fill{width:35%;animation:1.4s ease-in-out infinite progress-indeterminate}@keyframes progress-indeterminate{0%{transform:translate(-110%)}to{transform:translate(300%)}}@media (prefers-reduced-motion:reduce){.progress-fill{transition:none}.progress-bar-indeterminate .progress-fill{animation:none;transform:translate(90%)}}.progress-label{color:#3d3846;font-variant-numeric:tabular-nums;text-align:right;white-space:nowrap;flex:none;font-size:12px;font-weight:500}.error-status{justify-content:space-between;align-items:center;gap:16px;display:flex}.error-status .update-title{color:#9c2f2f}.error-copy{min-width:0}.retry-button{color:#fff;cursor:pointer;background:#1c71d8;border:0;border-radius:8px;min-width:68px;padding:4px 14px;font-size:12px;font-weight:600;line-height:1.5}.retry-button:hover{background:#1a5fb4}.retry-button:active{background:#174a8b}.retry-button:focus-visible{outline-offset:2px;outline:2px solid #1a5fb4}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/assets/icon-small-BO4dlTNl.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>GPGUI Downloader</title>
|
||||||
|
<script type="module" crossorigin src="/assets/main-B7u6_mhO.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="/assets/main-DiWGniCh.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
/* workaround to webview font size auto scaling */
|
||||||
|
var htmlFontSize = getComputedStyle(document.documentElement).fontSize;
|
||||||
|
var ratio = parseInt(htmlFontSize, 10) / 16;
|
||||||
|
document.documentElement.style.fontSize = 16 / ratio + "px";
|
||||||
|
</script>
|
||||||
|
<div id="root" data-tauri-drag-region></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/src/assets/icon-small.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>GPGUI Downloader</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
/* workaround to webview font size auto scaling */
|
||||||
|
var htmlFontSize = getComputedStyle(document.documentElement).fontSize;
|
||||||
|
var ratio = parseInt(htmlFontSize, 10) / 16;
|
||||||
|
document.documentElement.style.fontSize = 16 / ratio + "px";
|
||||||
|
</script>
|
||||||
|
<div id="root" data-tauri-drag-region></div>
|
||||||
|
<script type="module" src="/src/pages/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"name": "gpgui",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"tauri": "tauri"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@tauri-apps/api": "^2.12.0",
|
||||||
|
"react": "^19.3.0",
|
||||||
|
"react-dom": "^19.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tauri-apps/cli": "^2.12.0",
|
||||||
|
"@types/node": "^26.6.3",
|
||||||
|
"@types/react": "^19.3.0",
|
||||||
|
"@types/react-dom": "^19.3.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.71.0",
|
||||||
|
"@typescript-eslint/parser": "^8.71.0",
|
||||||
|
"@vitejs/plugin-react": "^6.1.1",
|
||||||
|
"eslint": "^9.39.5",
|
||||||
|
"eslint-config-prettier": "^10.1.8",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
|
"prettier": "3.9.9",
|
||||||
|
"typescript": "^6.0.3",
|
||||||
|
"vite": "^8.3.1"
|
||||||
|
},
|
||||||
|
"packageManager": "[email protected]"
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
[package]
|
||||||
|
name = "gpgui-helper"
|
||||||
|
rust-version.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
gpapi = { path = "../../../crates/gpapi", features = ["tauri", "clap"] }
|
||||||
|
tauri.workspace = true
|
||||||
|
|
||||||
|
tokio.workspace = true
|
||||||
|
anyhow.workspace = true
|
||||||
|
log.workspace = true
|
||||||
|
clap.workspace = true
|
||||||
|
compile-time.workspace = true
|
||||||
|
env_logger.workspace = true
|
||||||
|
futures-util.workspace = true
|
||||||
|
uuid.workspace = true
|
||||||
|
zeroize.workspace = true
|
||||||
|
tokio-tungstenite = "0.30"
|
||||||
|
tempfile.workspace = true
|
||||||
|
reqwest = { workspace = true, features = ["stream"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["tauri/custom-protocol"]
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
use std::{env, fs, path::PathBuf, process::Command};
|
||||||
|
|
||||||
|
const UNKNOWN_COMMIT: &str = "unknown";
|
||||||
|
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=GPGUI_HELPER_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||||
|
|
||||||
|
let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../../..");
|
||||||
|
let source_commit = repo_root.join("SOURCE_COMMIT");
|
||||||
|
println!("cargo:rerun-if-changed={}", source_commit.display());
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=GPGUI_HELPER_GIT_COMMIT={}",
|
||||||
|
resolve_commit(&repo_root, &source_commit)
|
||||||
|
);
|
||||||
|
|
||||||
|
tauri_build::build()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String {
|
||||||
|
env_commit("GPGUI_HELPER_GIT_COMMIT")
|
||||||
|
.or_else(|| env_commit("SOURCE_GIT_COMMIT"))
|
||||||
|
.or_else(|| env_commit("GITHUB_SHA"))
|
||||||
|
.or_else(|| file_commit(source_commit))
|
||||||
|
.or_else(|| git_commit(repo_root))
|
||||||
|
.unwrap_or_else(|| UNKNOWN_COMMIT.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn env_commit(key: &str) -> Option<String> {
|
||||||
|
env::var(key).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn file_commit(path: &PathBuf) -> Option<String> {
|
||||||
|
fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn git_commit(repo_root: &PathBuf) -> Option<String> {
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args(["rev-parse", "--short=9", "HEAD"])
|
||||||
|
.current_dir(repo_root)
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
String::from_utf8(output.stdout)
|
||||||
|
.ok()
|
||||||
|
.and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normalize_commit(value: &str) -> Option<String> {
|
||||||
|
let value = value.trim();
|
||||||
|
if value.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(value.chars().take(DISPLAY_COMMIT_LEN).collect())
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
"identifier": "default",
|
||||||
|
"description": "Capability for the main window",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": [
|
||||||
|
"core:window:allow-start-dragging",
|
||||||
|
"core:event:allow-listen",
|
||||||
|
"core:event:allow-emit",
|
||||||
|
"core:event:allow-unlisten"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 57 KiB |
@@ -0,0 +1,51 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="ocean" x1="245" y1="170" x2="770" y2="770" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#579bc1"/>
|
||||||
|
<stop offset=".52" stop-color="#438fbd"/>
|
||||||
|
<stop offset="1" stop-color="#2f719e"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="land" x1="260" y1="190" x2="750" y2="735" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#56c78a"/>
|
||||||
|
<stop offset=".55" stop-color="#3bbf78"/>
|
||||||
|
<stop offset="1" stop-color="#279b5d"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="lock" x1="385" y1="400" x2="650" y2="700" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#f3b84c"/>
|
||||||
|
<stop offset=".55" stop-color="#e8a12f"/>
|
||||||
|
<stop offset="1" stop-color="#d4871e"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="globe-clip">
|
||||||
|
<circle cx="512" cy="455" r="315"/>
|
||||||
|
</clipPath>
|
||||||
|
<filter id="globe-shadow" x="150" y="90" width="730" height="760" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feDropShadow dx="0" dy="18" stdDeviation="22" flood-color="#174d6f" flood-opacity=".14"/>
|
||||||
|
</filter>
|
||||||
|
<filter id="lock-shadow" x="280" y="210" width="470" height="540" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feDropShadow dx="0" dy="18" stdDeviation="18" flood-color="#70430c" flood-opacity=".2"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<g transform="translate(512 512) scale(1.3) translate(-512 -455)">
|
||||||
|
<g filter="url(#globe-shadow)">
|
||||||
|
<circle cx="512" cy="455" r="315" fill="url(#ocean)"/>
|
||||||
|
<g clip-path="url(#globe-clip)" fill="url(#land)">
|
||||||
|
<path d="M177 326c74-121 177-185 302-190-13 51-49 84-105 98-4 45-32 79-86 101-37 17-75 14-111-9Z"/>
|
||||||
|
<path d="M564 135c129 18 229 103 273 220-69-3-121 15-157 54-51-14-83-50-95-107-38-36-45-92-21-167Z"/>
|
||||||
|
<path d="M189 467c63-39 125-34 187 16 57 25 73 73 48 144-45 90-108 146-189 166-58-88-73-197-46-326Z"/>
|
||||||
|
<path d="M612 572c78-38 157-18 238 59-45 89-122 144-231 164-20-67-22-122-7-165-22-17-22-36 0-58Z"/>
|
||||||
|
</g>
|
||||||
|
<circle cx="512" cy="455" r="308" fill="none" stroke="#9ccde2" stroke-width="11" stroke-opacity=".24"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<g transform="translate(512 490) scale(.82) translate(-512 -490)" filter="url(#lock-shadow)">
|
||||||
|
<path d="M405 429v-75c0-142 214-142 214 0v75" fill="none" stroke="#eef1f2" stroke-width="58" stroke-linecap="round"/>
|
||||||
|
<rect x="340" y="403" width="344" height="278" rx="62" fill="url(#lock)"/>
|
||||||
|
<rect x="346" y="409" width="332" height="266" rx="56" fill="none" stroke="#f7cb75" stroke-width="10" stroke-opacity=".3"/>
|
||||||
|
<g fill="#85500f" opacity=".78">
|
||||||
|
<path d="M501 538h22l16 69h-54Z"/>
|
||||||
|
<circle cx="512" cy="521" r="27"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,75 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use gpapi::service::transport::SessionCredential;
|
||||||
|
use log::info;
|
||||||
|
use tauri::{Listener, Manager};
|
||||||
|
use tokio::sync::watch;
|
||||||
|
|
||||||
|
use crate::updater::{GuiUpdater, Installer, ProgressNotifier};
|
||||||
|
|
||||||
|
pub struct App {
|
||||||
|
credential: Arc<SessionCredential>,
|
||||||
|
credential_lease: watch::Receiver<bool>,
|
||||||
|
gui_version: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl App {
|
||||||
|
pub fn new(credential: Arc<SessionCredential>, credential_lease: watch::Receiver<bool>, gui_version: &str) -> Self {
|
||||||
|
Self {
|
||||||
|
credential,
|
||||||
|
credential_lease,
|
||||||
|
gui_version: gui_version.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(&self) -> anyhow::Result<()> {
|
||||||
|
let gui_version = self.gui_version.clone();
|
||||||
|
let credential = Arc::clone(&self.credential);
|
||||||
|
let credential_lease = self.credential_lease.clone();
|
||||||
|
|
||||||
|
tauri::Builder::default()
|
||||||
|
.setup(move |app| {
|
||||||
|
let win = app.get_webview_window("main").expect("no main window");
|
||||||
|
let _ = win.hide_menu();
|
||||||
|
|
||||||
|
let notifier = ProgressNotifier::new(win.clone());
|
||||||
|
let installer = Installer::new(credential, credential_lease.clone());
|
||||||
|
let updater = Arc::new(GuiUpdater::new(gui_version, notifier, installer));
|
||||||
|
|
||||||
|
let app_handle = app.handle().clone();
|
||||||
|
let mut app_credential_lease = credential_lease;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
while *app_credential_lease.borrow() {
|
||||||
|
if app_credential_lease.changed().await.is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info!("Service credential lease ended");
|
||||||
|
app_handle.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
let win_clone = win.clone();
|
||||||
|
app.listen_any("app://update-done", move |_event| {
|
||||||
|
info!("Update done");
|
||||||
|
let _ = win_clone.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for the update event
|
||||||
|
win.listen("app://update", move |_event| {
|
||||||
|
let updater = Arc::clone(&updater);
|
||||||
|
if updater.is_in_progress() {
|
||||||
|
info!("Update already in progress");
|
||||||
|
updater.notify_progress();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tokio::spawn(async move { updater.update().await });
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.run(tauri::generate_context!())?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
use clap::Parser;
|
||||||
|
use std::{io::Read, sync::Arc};
|
||||||
|
|
||||||
|
use anyhow::{Context, bail};
|
||||||
|
use gpapi::{
|
||||||
|
clap::InfoLevelVerbosity,
|
||||||
|
service::transport::{MAX_CREDENTIAL_FRAME, SessionCredential},
|
||||||
|
utils::env_utils,
|
||||||
|
};
|
||||||
|
use log::info;
|
||||||
|
use tokio::sync::watch;
|
||||||
|
use zeroize::Zeroizing;
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
|
|
||||||
|
const VERSION: &str = concat!(
|
||||||
|
env!("CARGO_PKG_VERSION"),
|
||||||
|
" (",
|
||||||
|
env!("GPGUI_HELPER_GIT_COMMIT"),
|
||||||
|
" ",
|
||||||
|
compile_time::date_str!(),
|
||||||
|
")"
|
||||||
|
);
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[command(version = VERSION)]
|
||||||
|
struct Cli {
|
||||||
|
#[arg(long, help = "Read the service credential from stdin")]
|
||||||
|
service_credential_on_stdin: bool,
|
||||||
|
|
||||||
|
#[arg(long, default_value = env!("CARGO_PKG_VERSION"), help = "The version of the GUI")]
|
||||||
|
gui_version: String,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
verbose: InfoLevelVerbosity,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cli {
|
||||||
|
fn run(&self) -> anyhow::Result<()> {
|
||||||
|
let credential = self.read_credential()?;
|
||||||
|
let credential_lease = monitor_credential_lease().context("Failed to monitor service credential lifetime")?;
|
||||||
|
let app = App::new(Arc::new(credential), credential_lease, &self.gui_version);
|
||||||
|
|
||||||
|
env_utils::patch_gui_runtime_env(false);
|
||||||
|
|
||||||
|
app.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_credential(&self) -> anyhow::Result<SessionCredential> {
|
||||||
|
if !self.service_credential_on_stdin {
|
||||||
|
bail!("Service credential must be provided via --service-credential-on-stdin");
|
||||||
|
}
|
||||||
|
let stdin = std::io::stdin();
|
||||||
|
let mut input = stdin.lock();
|
||||||
|
let mut header = [0_u8; 2];
|
||||||
|
input
|
||||||
|
.read_exact(&mut header)
|
||||||
|
.context("Failed to read service credential header")?;
|
||||||
|
let payload_len = u16::from_be_bytes(header) as usize;
|
||||||
|
if payload_len == 0 || payload_len + header.len() > MAX_CREDENTIAL_FRAME {
|
||||||
|
bail!("Invalid service credential length");
|
||||||
|
}
|
||||||
|
let mut frame = Zeroizing::new(Vec::with_capacity(payload_len + header.len()));
|
||||||
|
frame.extend_from_slice(&header);
|
||||||
|
frame.resize(payload_len + header.len(), 0);
|
||||||
|
input
|
||||||
|
.read_exact(&mut frame[header.len()..])
|
||||||
|
.context("Failed to read service credential")?;
|
||||||
|
SessionCredential::decode_frame(&frame).context("Invalid service credential")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn monitor_credential_lease() -> std::io::Result<watch::Receiver<bool>> {
|
||||||
|
let (lease_tx, lease_rx) = watch::channel(true);
|
||||||
|
std::thread::Builder::new()
|
||||||
|
.name("credential-lease".to_owned())
|
||||||
|
.spawn(move || {
|
||||||
|
let stdin = std::io::stdin();
|
||||||
|
close_credential_lease_at_eof(stdin.lock(), lease_tx);
|
||||||
|
})?;
|
||||||
|
Ok(lease_rx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn close_credential_lease_at_eof(mut input: impl Read, lease_tx: watch::Sender<bool>) {
|
||||||
|
let mut buffer = [0_u8; 256];
|
||||||
|
while matches!(input.read(&mut buffer), Ok(len) if len > 0) {}
|
||||||
|
let _ = lease_tx.send(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_logger(cli: &Cli) {
|
||||||
|
env_logger::builder()
|
||||||
|
.filter_level(cli.verbose.log_level_filter())
|
||||||
|
.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
let cli = Cli::parse();
|
||||||
|
|
||||||
|
init_logger(&cli);
|
||||||
|
info!("gpgui-helper started: {}", VERSION);
|
||||||
|
|
||||||
|
if let Err(e) = cli.run() {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::io::Cursor;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn credential_lease_closes_at_eof() {
|
||||||
|
let (lease_tx, lease_rx) = watch::channel(true);
|
||||||
|
close_credential_lease_at_eof(Cursor::new(b"ignored lease bytes"), lease_tx);
|
||||||
|
assert!(!*lease_rx.borrow());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
use anyhow::bail;
|
||||||
|
use futures_util::StreamExt;
|
||||||
|
use log::info;
|
||||||
|
use tempfile::NamedTempFile;
|
||||||
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
type OnProgress = Box<dyn Fn(Option<f64>) + Send + Sync + 'static>;
|
||||||
|
|
||||||
|
pub struct FileDownloader<'a> {
|
||||||
|
url: &'a str,
|
||||||
|
on_progress: RwLock<Option<OnProgress>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> FileDownloader<'a> {
|
||||||
|
pub fn new(url: &'a str) -> Self {
|
||||||
|
Self {
|
||||||
|
url,
|
||||||
|
on_progress: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn on_progress<T>(&self, on_progress: T)
|
||||||
|
where
|
||||||
|
T: Fn(Option<f64>) + Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
if let Ok(mut guard) = self.on_progress.try_write() {
|
||||||
|
*guard = Some(Box::new(on_progress));
|
||||||
|
} else {
|
||||||
|
info!("Failed to acquire on_progress lock");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn download(&self) -> anyhow::Result<NamedTempFile> {
|
||||||
|
let res = reqwest::get(self.url).await?.error_for_status()?;
|
||||||
|
let content_length = res.content_length().unwrap_or(0);
|
||||||
|
|
||||||
|
info!("Content length: {}", content_length);
|
||||||
|
|
||||||
|
let mut current_length = 0;
|
||||||
|
let mut stream = res.bytes_stream();
|
||||||
|
|
||||||
|
let mut file = NamedTempFile::new()?;
|
||||||
|
|
||||||
|
while let Some(item) = stream.next().await {
|
||||||
|
let chunk = item?;
|
||||||
|
let chunk_size = chunk.len() as u64;
|
||||||
|
|
||||||
|
file.write_all(&chunk)?;
|
||||||
|
|
||||||
|
current_length += chunk_size;
|
||||||
|
let progress = current_length as f64 / content_length as f64 * 100.0;
|
||||||
|
|
||||||
|
if let Some(on_progress) = &*self.on_progress.read().await {
|
||||||
|
let progress = if content_length > 0 { Some(progress) } else { None };
|
||||||
|
|
||||||
|
on_progress(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if content_length > 0 && current_length != content_length {
|
||||||
|
bail!("Download incomplete");
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Downloaded to: {:?}", file.path());
|
||||||
|
|
||||||
|
Ok(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ChecksumFetcher<'a> {
|
||||||
|
url: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ChecksumFetcher<'a> {
|
||||||
|
pub fn new(url: &'a str) -> Self {
|
||||||
|
Self { url }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn fetch(&self) -> anyhow::Result<String> {
|
||||||
|
let res = reqwest::get(self.url).await?.error_for_status()?;
|
||||||
|
let checksum = res.text().await?.trim().to_string();
|
||||||
|
|
||||||
|
Ok(checksum)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
pub(crate) mod app;
|
||||||
|
pub(crate) mod downloader;
|
||||||
|
pub(crate) mod updater;
|
||||||
|
|
||||||
|
pub mod cli;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
use gpgui_helper::cli;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
cli::run()
|
||||||
|
}
|
||||||
@@ -0,0 +1,672 @@
|
|||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
fmt::{self, Display, Formatter},
|
||||||
|
sync::{Arc, RwLock},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
|
use anyhow::{Context, bail};
|
||||||
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
use gpapi::{
|
||||||
|
service::{
|
||||||
|
request::{UpdateGuiRequest, WsRequest},
|
||||||
|
transport::{
|
||||||
|
ClientMessage, ClientPrelude, MAX_WS_MESSAGE, NoiseInitiator, NoiseTransport, ServerMessage, ServerPrelude,
|
||||||
|
ServiceResult, SessionCredential,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
utils::{checksum::verify_checksum, endpoint::ws_endpoint},
|
||||||
|
};
|
||||||
|
use log::{info, warn};
|
||||||
|
use tauri::{Emitter, WebviewWindow};
|
||||||
|
use tokio::net::TcpStream;
|
||||||
|
use tokio::sync::{mpsc, oneshot, watch};
|
||||||
|
use tokio_tungstenite::{
|
||||||
|
MaybeTlsStream, WebSocketStream, connect_async_with_config,
|
||||||
|
tungstenite::{Message, protocol::WebSocketConfig},
|
||||||
|
};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::downloader::{ChecksumFetcher, FileDownloader};
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
const SNAPSHOT: &str = match option_env!("SNAPSHOT") {
|
||||||
|
Some(val) => val,
|
||||||
|
None => "false",
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(target_env = "musl")]
|
||||||
|
const GUI_LIBC_SUFFIX: &str = "-musl";
|
||||||
|
|
||||||
|
#[cfg(not(target_env = "musl"))]
|
||||||
|
const GUI_LIBC_SUFFIX: &str = "";
|
||||||
|
|
||||||
|
fn gui_asset_name() -> Option<String> {
|
||||||
|
gui_asset_name_for(std::env::consts::OS, std::env::consts::ARCH, GUI_LIBC_SUFFIX)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gui_asset_name_for(os: &str, arch: &str, libc_suffix: &str) -> Option<String> {
|
||||||
|
let name = match (os, arch) {
|
||||||
|
("linux", "x86_64" | "aarch64") => format!("gpgui_{arch}{libc_suffix}.bin.tar.xz"),
|
||||||
|
("freebsd", "x86_64") => "gpgui_freebsd_amd64.bin.tar.xz".to_owned(),
|
||||||
|
("freebsd", "aarch64") => "gpgui_freebsd_arm64.bin.tar.xz".to_owned(),
|
||||||
|
("openbsd", "x86_64") => "gpgui_openbsd_amd64.bin.tar.xz".to_owned(),
|
||||||
|
("openbsd", "aarch64") => "gpgui_openbsd_arm64.bin.tar.xz".to_owned(),
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
Some(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ProgressNotifier {
|
||||||
|
win: WebviewWindow,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProgressNotifier {
|
||||||
|
pub fn new(win: WebviewWindow) -> Self {
|
||||||
|
Self { win }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notify(&self, progress: Option<f64>) {
|
||||||
|
let _ = self.win.emit("app://update-progress", progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notify_error(&self) {
|
||||||
|
let _ = self.win.emit("app://update-error", ());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notify_done(&self) {
|
||||||
|
let _ = self.win.emit("app://update-done", ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Installer {
|
||||||
|
command_tx: mpsc::Sender<InstallCommand>,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct InstallCommand {
|
||||||
|
request: UpdateGuiRequest,
|
||||||
|
reply: oneshot::Sender<anyhow::Result<()>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Installer {
|
||||||
|
pub fn new(credential: Arc<SessionCredential>, credential_lease: watch::Receiver<bool>) -> Self {
|
||||||
|
let (command_tx, command_rx) = mpsc::channel(1);
|
||||||
|
tokio::spawn(async move {
|
||||||
|
run_installer(credential, credential_lease, command_rx).await;
|
||||||
|
});
|
||||||
|
Self { command_tx }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn install(&self, path: &str, checksum: &str) -> anyhow::Result<()> {
|
||||||
|
let request = UpdateGuiRequest {
|
||||||
|
path: path.to_string(),
|
||||||
|
checksum: checksum.to_string(),
|
||||||
|
};
|
||||||
|
let (reply, result) = oneshot::channel();
|
||||||
|
self
|
||||||
|
.command_tx
|
||||||
|
.send(InstallCommand { request, reply })
|
||||||
|
.await
|
||||||
|
.context("Authenticated GUI installer is unavailable")?;
|
||||||
|
tokio::time::timeout(Duration::from_secs(60), result)
|
||||||
|
.await
|
||||||
|
.context("Service update request timed out")?
|
||||||
|
.context("Authenticated GUI installer stopped before replying")?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Socket = WebSocketStream<MaybeTlsStream<TcpStream>>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct TerminalConnectError(String);
|
||||||
|
|
||||||
|
impl Display for TerminalConnectError {
|
||||||
|
fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
|
||||||
|
formatter.write_str(&self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for TerminalConnectError {}
|
||||||
|
|
||||||
|
async fn run_installer(
|
||||||
|
credential: Arc<SessionCredential>,
|
||||||
|
mut credential_lease: watch::Receiver<bool>,
|
||||||
|
mut commands: mpsc::Receiver<InstallCommand>,
|
||||||
|
) {
|
||||||
|
let mut pending = None;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if !*credential_lease.borrow() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let connection = tokio::select! {
|
||||||
|
changed = credential_lease.changed() => {
|
||||||
|
if changed.is_err() || !*credential_lease.borrow() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result = tokio::time::timeout(Duration::from_secs(5), connect_installer(&credential)) => {
|
||||||
|
match result {
|
||||||
|
Ok(result) => result,
|
||||||
|
Err(_) => Err(anyhow::anyhow!("Authenticated GUI installer handshake timed out")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match connection {
|
||||||
|
Ok((mut socket, mut noise)) => {
|
||||||
|
info!("Authenticated GUI installer connected");
|
||||||
|
match run_installer_connection(
|
||||||
|
&mut socket,
|
||||||
|
&mut noise,
|
||||||
|
&mut credential_lease,
|
||||||
|
&mut commands,
|
||||||
|
&mut pending,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(ConnectionEnd::CredentialLeaseEnded | ConnectionEnd::CommandsClosed) => return,
|
||||||
|
Err(err) => warn!("Authenticated GUI installer connection lost: {err}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) if err.is::<TerminalConnectError>() => {
|
||||||
|
warn!("Authenticated GUI installer stopped: {err}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Err(err) => warn!("Authenticated GUI installer connection failed: {err}"),
|
||||||
|
}
|
||||||
|
|
||||||
|
tokio::select! {
|
||||||
|
changed = credential_lease.changed() => {
|
||||||
|
if changed.is_err() || !*credential_lease.borrow() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = tokio::time::sleep(Duration::from_millis(100)) => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ConnectionEnd {
|
||||||
|
CredentialLeaseEnded,
|
||||||
|
CommandsClosed,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run_installer_connection(
|
||||||
|
socket: &mut Socket,
|
||||||
|
noise: &mut NoiseTransport,
|
||||||
|
credential_lease: &mut watch::Receiver<bool>,
|
||||||
|
commands: &mut mpsc::Receiver<InstallCommand>,
|
||||||
|
pending: &mut Option<InstallCommand>,
|
||||||
|
) -> anyhow::Result<ConnectionEnd> {
|
||||||
|
if pending.as_ref().is_some_and(|command| command.reply.is_closed()) {
|
||||||
|
pending.take();
|
||||||
|
}
|
||||||
|
let mut pending_id = match pending.as_ref() {
|
||||||
|
Some(command) => Some(send_install_command(socket, noise, command).await?),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
changed = credential_lease.changed() => {
|
||||||
|
if changed.is_err() || !*credential_lease.borrow() {
|
||||||
|
return Ok(ConnectionEnd::CredentialLeaseEnded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command = commands.recv() => {
|
||||||
|
let Some(command) = command else { return Ok(ConnectionEnd::CommandsClosed) };
|
||||||
|
if command.reply.is_closed() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if pending.is_some() {
|
||||||
|
let _ = command.reply.send(Err(anyhow::anyhow!("GUI installation is already pending")));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*pending = Some(command);
|
||||||
|
pending_id = Some(send_install_command(socket, noise, pending.as_ref().unwrap()).await?);
|
||||||
|
}
|
||||||
|
frame = socket.next() => {
|
||||||
|
match frame.context("Service closed the authenticated GUI installer")?? {
|
||||||
|
Message::Binary(data) => match noise.decrypt::<ServerMessage>(&data)? {
|
||||||
|
ServerMessage::Reply { id, result } => {
|
||||||
|
if pending_id != Some(id) {
|
||||||
|
bail!("Service sent a mismatched GUI installation reply");
|
||||||
|
}
|
||||||
|
let Some(command) = pending.take() else {
|
||||||
|
bail!("Service sent an unexpected GUI installation reply");
|
||||||
|
};
|
||||||
|
pending_id = None;
|
||||||
|
let result = match result {
|
||||||
|
ServiceResult::Accepted => Ok(()),
|
||||||
|
ServiceResult::Rejected(rejection) => Err(anyhow::anyhow!(
|
||||||
|
"Service rejected GUI installation ({:?}): {}",
|
||||||
|
rejection.code(),
|
||||||
|
rejection.message()
|
||||||
|
)),
|
||||||
|
_ => Err(anyhow::anyhow!("Service sent an unexpected GUI installation reply")),
|
||||||
|
};
|
||||||
|
let _ = command.reply.send(result);
|
||||||
|
}
|
||||||
|
ServerMessage::Event { .. } | ServerMessage::Snapshot { .. } => {}
|
||||||
|
ServerMessage::Attached { .. } => bail!("Service sent a duplicate attach response"),
|
||||||
|
},
|
||||||
|
Message::Ping(data) => socket.send(Message::Pong(data)).await?,
|
||||||
|
Message::Pong(_) => {}
|
||||||
|
Message::Close(_) => bail!("Service closed the authenticated GUI installer"),
|
||||||
|
_ => bail!("Service sent an unexpected WebSocket frame"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send_install_command(
|
||||||
|
socket: &mut Socket,
|
||||||
|
noise: &mut NoiseTransport,
|
||||||
|
command: &InstallCommand,
|
||||||
|
) -> anyhow::Result<Uuid> {
|
||||||
|
let id = Uuid::new_v4();
|
||||||
|
send_client_message(
|
||||||
|
socket,
|
||||||
|
noise,
|
||||||
|
&ClientMessage::Request {
|
||||||
|
id,
|
||||||
|
request: WsRequest::UpdateGui(command.request.clone()),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn connect_installer(credential: &SessionCredential) -> anyhow::Result<(Socket, NoiseTransport)> {
|
||||||
|
let endpoint = ws_endpoint().await?;
|
||||||
|
connect_installer_at(credential, &endpoint).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn connect_installer_at(
|
||||||
|
credential: &SessionCredential,
|
||||||
|
endpoint: &str,
|
||||||
|
) -> anyhow::Result<(Socket, NoiseTransport)> {
|
||||||
|
if credential.product_version() != env!("CARGO_PKG_VERSION") {
|
||||||
|
return Err(TerminalConnectError("Service credential version does not match gpgui-helper".to_owned()).into());
|
||||||
|
}
|
||||||
|
let config = WebSocketConfig::default()
|
||||||
|
.max_message_size(Some(MAX_WS_MESSAGE))
|
||||||
|
.max_frame_size(Some(MAX_WS_MESSAGE));
|
||||||
|
let (mut socket, _) = connect_async_with_config(endpoint, Some(config), false).await?;
|
||||||
|
let prelude = ClientPrelude {
|
||||||
|
product_version: credential.product_version().to_owned(),
|
||||||
|
hip_protocol_version: gpapi::service::transport::HIP_PROTOCOL_VERSION,
|
||||||
|
service_instance_id: credential.service_instance_id(),
|
||||||
|
session_id: credential.session_id(),
|
||||||
|
};
|
||||||
|
socket.send(Message::Binary(prelude.encode()?.into())).await?;
|
||||||
|
let server_prelude = ServerPrelude::decode(&receive_binary(&mut socket).await?)
|
||||||
|
.map_err(|err| TerminalConnectError(format!("Service sent an invalid update-session response: {err}")))?;
|
||||||
|
match server_prelude {
|
||||||
|
ServerPrelude::Ready => {}
|
||||||
|
ServerPrelude::Rejected(reason) => {
|
||||||
|
return Err(TerminalConnectError(format!("Service rejected the update session: {reason:?}")).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut initiator = NoiseInitiator::new(
|
||||||
|
credential.product_version(),
|
||||||
|
credential.service_instance_id(),
|
||||||
|
credential.session_id(),
|
||||||
|
credential.secret(),
|
||||||
|
)?;
|
||||||
|
socket.send(Message::Binary(initiator.write_first()?.into())).await?;
|
||||||
|
let mut noise = initiator.read_response(&receive_binary(&mut socket).await?)?;
|
||||||
|
send_client_message(
|
||||||
|
&mut socket,
|
||||||
|
&mut noise,
|
||||||
|
&ClientMessage::Attach {
|
||||||
|
last_event_revision: None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
if !matches!(
|
||||||
|
receive_server_message(&mut socket, &mut noise).await?,
|
||||||
|
ServerMessage::Attached { .. }
|
||||||
|
) {
|
||||||
|
bail!("Service did not attach the update session");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok((socket, noise))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send_client_message(
|
||||||
|
socket: &mut Socket,
|
||||||
|
noise: &mut NoiseTransport,
|
||||||
|
message: &ClientMessage,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
socket.send(Message::Binary(noise.encrypt(message)?.into())).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn receive_server_message(socket: &mut Socket, noise: &mut NoiseTransport) -> anyhow::Result<ServerMessage> {
|
||||||
|
Ok(noise.decrypt(&receive_binary(socket).await?)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn receive_binary(socket: &mut Socket) -> anyhow::Result<Vec<u8>> {
|
||||||
|
match socket.next().await {
|
||||||
|
Some(Ok(Message::Binary(data))) => Ok(data.to_vec()),
|
||||||
|
Some(Ok(_)) => bail!("Service sent an unexpected handshake frame"),
|
||||||
|
Some(Err(err)) => Err(err.into()),
|
||||||
|
None => bail!("Service closed during handshake"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct GuiUpdater {
|
||||||
|
version: String,
|
||||||
|
notifier: Arc<ProgressNotifier>,
|
||||||
|
installer: Installer,
|
||||||
|
in_progress: RwLock<bool>,
|
||||||
|
progress: Arc<RwLock<Option<f64>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GuiUpdater {
|
||||||
|
pub fn new(version: String, notifier: ProgressNotifier, installer: Installer) -> Self {
|
||||||
|
Self {
|
||||||
|
version,
|
||||||
|
notifier: Arc::new(notifier),
|
||||||
|
installer,
|
||||||
|
in_progress: Default::default(),
|
||||||
|
progress: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update(&self) {
|
||||||
|
let Some(asset_name) = gui_asset_name() else {
|
||||||
|
info!("GUI updates are not supported on this platform.");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
info!("Update GUI, version: {}", self.version);
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
let release_tag = "snapshot";
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
let release_tag = if SNAPSHOT == "true" {
|
||||||
|
String::from("snapshot")
|
||||||
|
} else {
|
||||||
|
format!("v{}", self.version)
|
||||||
|
};
|
||||||
|
|
||||||
|
let file_url =
|
||||||
|
format!("https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{release_tag}/{asset_name}");
|
||||||
|
let checksum_url = format!("{}.sha256", file_url);
|
||||||
|
|
||||||
|
info!("Downloading file: {}", file_url);
|
||||||
|
|
||||||
|
let dl = FileDownloader::new(&file_url);
|
||||||
|
let cf = ChecksumFetcher::new(&checksum_url);
|
||||||
|
let notifier = Arc::clone(&self.notifier);
|
||||||
|
|
||||||
|
let progress_ref = Arc::clone(&self.progress);
|
||||||
|
dl.on_progress(move |progress| {
|
||||||
|
// Save progress to shared state so that it can be notified to the UI when needed
|
||||||
|
if let Ok(mut guard) = progress_ref.try_write() {
|
||||||
|
*guard = progress;
|
||||||
|
}
|
||||||
|
notifier.notify(progress);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.set_in_progress(true);
|
||||||
|
let res = tokio::try_join!(dl.download(), cf.fetch());
|
||||||
|
|
||||||
|
let (file, checksum) = match res {
|
||||||
|
Ok((file, checksum)) => (file, checksum),
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Download error: {}", err);
|
||||||
|
self.notify_error();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let path = file.into_temp_path();
|
||||||
|
let file_path = path.to_string_lossy();
|
||||||
|
|
||||||
|
if let Err(err) = verify_checksum(&file_path, &checksum) {
|
||||||
|
warn!("Checksum error: {}", err);
|
||||||
|
self.notify_error();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Checksum success");
|
||||||
|
|
||||||
|
if let Err(err) = self.installer.install(&file_path, &checksum).await {
|
||||||
|
warn!("Install error: {}", err);
|
||||||
|
self.notify_error();
|
||||||
|
} else {
|
||||||
|
info!("Install success");
|
||||||
|
self.notify_done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_in_progress(&self) -> bool {
|
||||||
|
if let Ok(guard) = self.in_progress.try_read() {
|
||||||
|
*guard
|
||||||
|
} else {
|
||||||
|
info!("Failed to acquire in_progress lock");
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_in_progress(&self, in_progress: bool) {
|
||||||
|
if let Ok(mut guard) = self.in_progress.try_write() {
|
||||||
|
*guard = in_progress;
|
||||||
|
} else {
|
||||||
|
info!("Failed to acquire in_progress lock");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notify_error(&self) {
|
||||||
|
self.set_in_progress(false);
|
||||||
|
self.notifier.notify_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notify_done(&self) {
|
||||||
|
self.set_in_progress(false);
|
||||||
|
self.notifier.notify_done();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn notify_progress(&self) {
|
||||||
|
let progress = if let Ok(guard) = self.progress.try_read() {
|
||||||
|
*guard
|
||||||
|
} else {
|
||||||
|
info!("Failed to acquire progress lock");
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
self.notifier.notify(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use gpapi::{
|
||||||
|
os_profile::HostIdentity,
|
||||||
|
service::{
|
||||||
|
transport::{ClientPrelude, NoiseResponder},
|
||||||
|
vpn_env::{HostInfo, VpnEnv},
|
||||||
|
vpn_state::VpnState,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use tokio::net::TcpListener;
|
||||||
|
use tokio_tungstenite::accept_async;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn selects_platform_specific_gui_assets() {
|
||||||
|
assert_eq!(
|
||||||
|
gui_asset_name_for("linux", "x86_64", ""),
|
||||||
|
Some("gpgui_x86_64.bin.tar.xz".to_owned())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
gui_asset_name_for("linux", "aarch64", "-musl"),
|
||||||
|
Some("gpgui_aarch64-musl.bin.tar.xz".to_owned())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
gui_asset_name_for("freebsd", "x86_64", ""),
|
||||||
|
Some("gpgui_freebsd_amd64.bin.tar.xz".to_owned())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
gui_asset_name_for("openbsd", "aarch64", ""),
|
||||||
|
Some("gpgui_openbsd_arm64.bin.tar.xz".to_owned())
|
||||||
|
);
|
||||||
|
assert_eq!(gui_asset_name_for("macos", "aarch64", ""), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn pending_install_reconnects_with_a_fresh_handshake() {
|
||||||
|
let credential = Arc::new(SessionCredential::generate(Uuid::new_v4(), env!("CARGO_PKG_VERSION")).unwrap());
|
||||||
|
let (command_tx, mut commands) = mpsc::channel(1);
|
||||||
|
let (reply_tx, reply_rx) = oneshot::channel();
|
||||||
|
command_tx
|
||||||
|
.send(InstallCommand {
|
||||||
|
request: UpdateGuiRequest {
|
||||||
|
path: "/tmp/gpgui-update".to_owned(),
|
||||||
|
checksum: "checksum".to_owned(),
|
||||||
|
},
|
||||||
|
reply: reply_tx,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let (_lease_tx, mut credential_lease) = watch::channel(true);
|
||||||
|
let mut pending = None;
|
||||||
|
|
||||||
|
let (first_endpoint, first_service) = spawn_test_service(Arc::clone(&credential), false).await;
|
||||||
|
let (mut socket, mut noise) = connect_installer_at(&credential, &first_endpoint).await.unwrap();
|
||||||
|
assert!(
|
||||||
|
run_installer_connection(
|
||||||
|
&mut socket,
|
||||||
|
&mut noise,
|
||||||
|
&mut credential_lease,
|
||||||
|
&mut commands,
|
||||||
|
&mut pending,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
first_service.await.unwrap();
|
||||||
|
assert!(pending.is_some());
|
||||||
|
|
||||||
|
let (second_endpoint, second_service) = spawn_test_service(Arc::clone(&credential), true).await;
|
||||||
|
let (mut socket, mut noise) = connect_installer_at(&credential, &second_endpoint).await.unwrap();
|
||||||
|
assert!(
|
||||||
|
run_installer_connection(
|
||||||
|
&mut socket,
|
||||||
|
&mut noise,
|
||||||
|
&mut credential_lease,
|
||||||
|
&mut commands,
|
||||||
|
&mut pending,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
second_service.await.unwrap();
|
||||||
|
assert!(pending.is_none());
|
||||||
|
assert!(reply_rx.await.unwrap().is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn credential_version_mismatch_is_terminal() {
|
||||||
|
let credential = SessionCredential::generate(Uuid::new_v4(), "different-version").unwrap();
|
||||||
|
let Err(err) = connect_installer_at(&credential, "ws://127.0.0.1:1/ws").await else {
|
||||||
|
panic!("version mismatch should fail before connecting");
|
||||||
|
};
|
||||||
|
assert!(err.is::<TerminalConnectError>());
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn spawn_test_service(
|
||||||
|
credential: Arc<SessionCredential>,
|
||||||
|
reply: bool,
|
||||||
|
) -> (String, tokio::task::JoinHandle<()>) {
|
||||||
|
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||||
|
let endpoint = format!("ws://{}/ws", listener.local_addr().unwrap());
|
||||||
|
let service = tokio::spawn(async move {
|
||||||
|
let (stream, _) = listener.accept().await.unwrap();
|
||||||
|
let mut socket = accept_async(stream).await.unwrap();
|
||||||
|
let prelude = match socket.next().await.unwrap().unwrap() {
|
||||||
|
Message::Binary(data) => ClientPrelude::decode(&data).unwrap(),
|
||||||
|
frame => panic!("unexpected prelude frame: {frame:?}"),
|
||||||
|
};
|
||||||
|
assert_eq!(prelude.service_instance_id, credential.service_instance_id());
|
||||||
|
assert_eq!(prelude.session_id, credential.session_id());
|
||||||
|
socket
|
||||||
|
.send(Message::Binary(ServerPrelude::Ready.encode().unwrap().into()))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut responder = NoiseResponder::new(
|
||||||
|
credential.product_version(),
|
||||||
|
credential.service_instance_id(),
|
||||||
|
credential.session_id(),
|
||||||
|
credential.secret(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let first = match socket.next().await.unwrap().unwrap() {
|
||||||
|
Message::Binary(data) => data,
|
||||||
|
frame => panic!("unexpected handshake frame: {frame:?}"),
|
||||||
|
};
|
||||||
|
responder.read_first(&first).unwrap();
|
||||||
|
let (response, mut noise) = responder.write_response().unwrap();
|
||||||
|
socket.send(Message::Binary(response.into())).await.unwrap();
|
||||||
|
|
||||||
|
let attach = match socket.next().await.unwrap().unwrap() {
|
||||||
|
Message::Binary(data) => data,
|
||||||
|
frame => panic!("unexpected attach frame: {frame:?}"),
|
||||||
|
};
|
||||||
|
assert!(matches!(
|
||||||
|
noise.decrypt::<ClientMessage>(&attach).unwrap(),
|
||||||
|
ClientMessage::Attach { .. }
|
||||||
|
));
|
||||||
|
let attached = ServerMessage::Attached {
|
||||||
|
connection_id: Uuid::new_v4(),
|
||||||
|
current_revision: 0,
|
||||||
|
snapshot: VpnEnv {
|
||||||
|
vpn_state: VpnState::Disconnected,
|
||||||
|
vpnc_script: None,
|
||||||
|
auth_executable: String::new(),
|
||||||
|
host_info: HostInfo {
|
||||||
|
host_identity: HostIdentity::collect(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket
|
||||||
|
.send(Message::Binary(noise.encrypt(&attached).unwrap().into()))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let request = match socket.next().await.unwrap().unwrap() {
|
||||||
|
Message::Binary(data) => noise.decrypt::<ClientMessage>(&data).unwrap(),
|
||||||
|
frame => panic!("unexpected request frame: {frame:?}"),
|
||||||
|
};
|
||||||
|
let ClientMessage::Request {
|
||||||
|
id,
|
||||||
|
request: WsRequest::UpdateGui(update),
|
||||||
|
} = request
|
||||||
|
else {
|
||||||
|
panic!("unexpected installer request");
|
||||||
|
};
|
||||||
|
assert_eq!(update.path, "/tmp/gpgui-update");
|
||||||
|
if reply {
|
||||||
|
let message = ServerMessage::Reply {
|
||||||
|
id,
|
||||||
|
result: ServiceResult::Accepted,
|
||||||
|
};
|
||||||
|
socket
|
||||||
|
.send(Message::Binary(noise.encrypt(&message).unwrap().into()))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
socket.close(None).await.unwrap();
|
||||||
|
});
|
||||||
|
(endpoint, service)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "pnpm dev",
|
||||||
|
"beforeBuildCommand": "pnpm build",
|
||||||
|
"devUrl": "http://localhost:1421",
|
||||||
|
"frontendDist": "../dist"
|
||||||
|
},
|
||||||
|
"identifier": "com.yuezk.gpgui-helper",
|
||||||
|
"productName": "gpgui-helper",
|
||||||
|
"app": {
|
||||||
|
"withGlobalTauri": false,
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
},
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "GPGUI Downloader",
|
||||||
|
"center": true,
|
||||||
|
"resizable": true,
|
||||||
|
"width": 460,
|
||||||
|
"height": 104,
|
||||||
|
"minWidth": 460,
|
||||||
|
"minHeight": 104,
|
||||||
|
"maxWidth": 460,
|
||||||
|
"maxHeight": 104,
|
||||||
|
"label": "main",
|
||||||
|
"decorations": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": false,
|
||||||
|
"targets": "deb",
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/[email protected]",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="ocean" x1="245" y1="170" x2="770" y2="770" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#579bc1"/>
|
||||||
|
<stop offset=".52" stop-color="#438fbd"/>
|
||||||
|
<stop offset="1" stop-color="#2f719e"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="land" x1="260" y1="190" x2="750" y2="735" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#56c78a"/>
|
||||||
|
<stop offset=".55" stop-color="#3bbf78"/>
|
||||||
|
<stop offset="1" stop-color="#279b5d"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="lock" x1="385" y1="400" x2="650" y2="700" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#f3b84c"/>
|
||||||
|
<stop offset=".55" stop-color="#e8a12f"/>
|
||||||
|
<stop offset="1" stop-color="#d4871e"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="globe-clip">
|
||||||
|
<circle cx="512" cy="455" r="315"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<g transform="translate(512 512) scale(1.3) translate(-512 -455)">
|
||||||
|
<circle cx="512" cy="455" r="315" fill="url(#ocean)"/>
|
||||||
|
<g clip-path="url(#globe-clip)" fill="url(#land)">
|
||||||
|
<path d="M177 326c74-121 177-185 302-190-13 51-49 84-105 98-4 45-32 79-86 101-37 17-75 14-111-9Z"/>
|
||||||
|
<path d="M564 135c129 18 229 103 273 220-69-3-121 15-157 54-51-14-83-50-95-107-38-36-45-92-21-167Z"/>
|
||||||
|
<path d="M189 467c63-39 125-34 187 16 57 25 73 73 48 144-45 90-108 146-189 166-58-88-73-197-46-326Z"/>
|
||||||
|
<path d="M612 572c78-38 157-18 238 59-45 89-122 144-231 164-20-67-22-122-7-165-22-17-22-36 0-58Z"/>
|
||||||
|
</g>
|
||||||
|
<circle cx="512" cy="455" r="308" fill="none" stroke="#9ccde2" stroke-width="11" stroke-opacity=".4"/>
|
||||||
|
|
||||||
|
<g transform="translate(512 490) scale(.82) translate(-512 -490)">
|
||||||
|
<path d="M405 429v-75c0-142 214-142 214 0v75" fill="none" stroke="#eef1f2" stroke-width="58" stroke-linecap="round"/>
|
||||||
|
<rect x="340" y="403" width="344" height="278" rx="62" fill="url(#lock)"/>
|
||||||
|
<rect x="346" y="409" width="332" height="266" rx="56" fill="none" stroke="#f7cb75" stroke-width="10" stroke-opacity=".45"/>
|
||||||
|
<g fill="#85500f" opacity=".85">
|
||||||
|
<path d="M501 538h22l16 69h-54Z"/>
|
||||||
|
<circle cx="512" cy="521" r="27"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,117 @@
|
|||||||
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
import logo from "../../assets/icon-small.svg";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import "./styles.css";
|
||||||
|
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const [error, setError] = useState(false);
|
||||||
|
const [progress, setProgress] = useState<number | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const unlisteners: Array<() => void> = [];
|
||||||
|
let disposed = false;
|
||||||
|
|
||||||
|
const startUpdate = async () => {
|
||||||
|
const progressUnlisten = await appWindow.listen("app://update-progress", (event) => {
|
||||||
|
setProgress(event.payload as number);
|
||||||
|
});
|
||||||
|
const errorUnlisten = await appWindow.listen("app://update-error", () => {
|
||||||
|
setError(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (disposed) {
|
||||||
|
progressUnlisten();
|
||||||
|
errorUnlisten();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlisteners.push(progressUnlisten, errorUnlisten);
|
||||||
|
await appWindow.emit("app://update");
|
||||||
|
};
|
||||||
|
|
||||||
|
void startUpdate();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disposed = true;
|
||||||
|
unlisteners.forEach((unlisten) => unlisten());
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleRetry = () => {
|
||||||
|
setError(false);
|
||||||
|
setProgress(null);
|
||||||
|
appWindow.emit("app://update");
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="update-window" data-tauri-drag-region>
|
||||||
|
<img src={logo} alt="" className="update-logo" data-tauri-drag-region />
|
||||||
|
<div className="update-content" data-tauri-drag-region>
|
||||||
|
{error ? (
|
||||||
|
<DownloadFailed onRetry={handleRetry} />
|
||||||
|
) : (
|
||||||
|
<DownloadIndicator progress={progress} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DownloadIndicator({ progress }: { progress: number | null }) {
|
||||||
|
return (
|
||||||
|
<div className="update-status" data-tauri-drag-region>
|
||||||
|
<h1 className="update-title" data-tauri-drag-region>
|
||||||
|
Getting GP Connect ready
|
||||||
|
</h1>
|
||||||
|
<DownloadProgress value={progress} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DownloadFailed({ onRetry }: { onRetry: () => void }) {
|
||||||
|
return (
|
||||||
|
<div className="update-status error-status" data-tauri-drag-region>
|
||||||
|
<div className="error-copy" role="alert" data-tauri-drag-region>
|
||||||
|
<h1 className="update-title" data-tauri-drag-region>
|
||||||
|
Couldn’t get GP Connect ready
|
||||||
|
</h1>
|
||||||
|
<p className="update-description" data-tauri-drag-region>
|
||||||
|
Please try again.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" onClick={onRetry} className="retry-button">
|
||||||
|
Retry
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DownloadProgress({ value }: { value: number | null }) {
|
||||||
|
const isDeterminate = value !== null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="progress-summary" data-tauri-drag-region>
|
||||||
|
<p className="update-description" data-tauri-drag-region>
|
||||||
|
This should only take a moment.
|
||||||
|
</p>
|
||||||
|
<span className="progress-label" aria-hidden="true">
|
||||||
|
{isDeterminate ? `${Math.round(value)}%` : "In progress"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={`progress-bar${isDeterminate ? "" : " progress-bar-indeterminate"}`}
|
||||||
|
role="progressbar"
|
||||||
|
aria-label="Update progress"
|
||||||
|
aria-valuemin={isDeterminate ? 0 : undefined}
|
||||||
|
aria-valuemax={isDeterminate ? 100 : undefined}
|
||||||
|
aria-valuenow={isDeterminate ? Math.round(value) : undefined}
|
||||||
|
>
|
||||||
|
<div className="progress-fill" style={isDeterminate ? { width: `${value}%` } : undefined} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root {
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #f6f5f4;
|
||||||
|
color: #2e3436;
|
||||||
|
font-family:
|
||||||
|
Inter,
|
||||||
|
ui-sans-serif,
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-window {
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 16px 18px;
|
||||||
|
gap: 15px;
|
||||||
|
background: #f6f5f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-logo {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-content,
|
||||||
|
.update-status {
|
||||||
|
min-width: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-title {
|
||||||
|
margin: 0;
|
||||||
|
color: #2e3436;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.25;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-description {
|
||||||
|
margin: 3px 0 0;
|
||||||
|
color: #5e5c64;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-summary {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-summary .update-description {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 6px;
|
||||||
|
margin-top: 9px;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #d5d3d1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-fill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: #3584e4;
|
||||||
|
transition: width 180ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar-indeterminate .progress-fill {
|
||||||
|
width: 35%;
|
||||||
|
animation: progress-indeterminate 1.4s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes progress-indeterminate {
|
||||||
|
from {
|
||||||
|
transform: translateX(-110%);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
transform: translateX(300%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.progress-fill {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar-indeterminate .progress-fill {
|
||||||
|
animation: none;
|
||||||
|
transform: translateX(90%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-label {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: #3d3846;
|
||||||
|
font-size: 12px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: right;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-status .update-title {
|
||||||
|
color: #9c2f2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-copy {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-button {
|
||||||
|
min-width: 68px;
|
||||||
|
padding: 4px 14px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #1c71d8;
|
||||||
|
color: #ffffff;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-button:hover {
|
||||||
|
background: #1a5fb4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-button:active {
|
||||||
|
background: #174a8b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-button:focus-visible {
|
||||||
|
outline: 2px solid #1a5fb4;
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { createRoot } from "react-dom/client"
|
||||||
|
import App from "../components/App/App";
|
||||||
|
|
||||||
|
const rootApp = createRoot(document.getElementById('root') as HTMLElement);
|
||||||
|
|
||||||
|
rootApp.render(<App />);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import react from "@vitejs/plugin-react";
|
||||||
|
import { resolve } from "path";
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig(async () => {
|
||||||
|
return {
|
||||||
|
plugins: [react()],
|
||||||
|
|
||||||
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||||
|
//
|
||||||
|
// 1. prevent vite from obscuring rust errors
|
||||||
|
clearScreen: false,
|
||||||
|
// 2. tauri expects a fixed port, fail if that port is not available
|
||||||
|
server: {
|
||||||
|
port: 1421,
|
||||||
|
strictPort: true,
|
||||||
|
},
|
||||||
|
// 3. to make use of `TAURI_DEBUG` and other env variables
|
||||||
|
// https://tauri.app/v1/api/config#buildconfig.beforedevcommand
|
||||||
|
envPrefix: ["VITE_", "TAURI_"],
|
||||||
|
build: {
|
||||||
|
rolldownOptions: {
|
||||||
|
input: {
|
||||||
|
main: resolve(import.meta.dirname, "index.html"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -5,15 +5,34 @@ edition.workspace = true
|
|||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpapi = { path = "../../crates/gpapi" }
|
common = { path = "../../crates/common" }
|
||||||
|
gpapi = { path = "../../crates/gpapi", features = ["clap", "logger"] }
|
||||||
|
gphip = { path = "../../crates/gphip" }
|
||||||
|
base64.workspace = true
|
||||||
|
sha256.workspace = true
|
||||||
openconnect = { path = "../../crates/openconnect" }
|
openconnect = { path = "../../crates/openconnect" }
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
tokio.workspace = true
|
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||||
tokio-util.workspace = true
|
tokio-util.workspace = true
|
||||||
axum = { workspace = true, features = ["ws"] }
|
axum = { workspace = true, features = ["ws"] }
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
compile-time.workspace = true
|
compile-time.workspace = true
|
||||||
|
xz2 = "0.1"
|
||||||
|
tar = "0.4"
|
||||||
|
thiserror.workspace = true
|
||||||
|
uuid = { workspace = true, features = ["v4"] }
|
||||||
|
zeroize.workspace = true
|
||||||
|
tempfile.workspace = true
|
||||||
|
getrandom = "0.4"
|
||||||
|
mac_address = "1"
|
||||||
|
|
||||||
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
nix = { version = "0.31", features = ["fs", "socket", "user"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tokio-tungstenite = "0.29"
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
use std::{env, fs, path::PathBuf, process::Command};
|
||||||
|
|
||||||
|
const UNKNOWN_COMMIT: &str = "unknown";
|
||||||
|
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=GPSERVICE_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
||||||
|
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||||
|
|
||||||
|
let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../..");
|
||||||
|
let source_commit = repo_root.join("SOURCE_COMMIT");
|
||||||
|
println!("cargo:rerun-if-changed={}", source_commit.display());
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=GPSERVICE_GIT_COMMIT={}",
|
||||||
|
resolve_commit(&repo_root, &source_commit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String {
|
||||||
|
env_commit("GPSERVICE_GIT_COMMIT")
|
||||||
|
.or_else(|| env_commit("SOURCE_GIT_COMMIT"))
|
||||||
|
.or_else(|| env_commit("GITHUB_SHA"))
|
||||||
|
.or_else(|| file_commit(source_commit))
|
||||||
|
.or_else(|| git_commit(repo_root))
|
||||||
|
.unwrap_or_else(|| UNKNOWN_COMMIT.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn env_commit(key: &str) -> Option<String> {
|
||||||
|
env::var(key).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn file_commit(path: &PathBuf) -> Option<String> {
|
||||||
|
fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn git_commit(repo_root: &PathBuf) -> Option<String> {
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args(["rev-parse", "--short=9", "HEAD"])
|
||||||
|
.current_dir(repo_root)
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
String::from_utf8(output.stdout)
|
||||||
|
.ok()
|
||||||
|
.and_then(|value| normalize_commit(&value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normalize_commit(value: &str) -> Option<String> {
|
||||||
|
let value = value.trim();
|
||||||
|
if value.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(value.chars().take(DISPLAY_COMMIT_LEN).collect())
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
use std::{
|
||||||
|
env, fs,
|
||||||
|
io::{self, Write},
|
||||||
|
};
|
||||||
|
|
||||||
|
use anyhow::{Context, ensure};
|
||||||
|
use clap::Parser;
|
||||||
|
use gpapi::{
|
||||||
|
clap::args::Os,
|
||||||
|
os_profile::{ClientOs, OsProfileBuilder},
|
||||||
|
};
|
||||||
|
use gphip::{ReportContext, ReportInput, generate_report, refresh_edited_report};
|
||||||
|
use gpservice::hip_runner_state::{MAX_STATE_BYTES, RunnerReport, STATE_NAME, validate_root_owned_path};
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct Args {
|
||||||
|
#[arg(long)]
|
||||||
|
client_version: String,
|
||||||
|
#[arg(long, value_enum)]
|
||||||
|
client_os: Os,
|
||||||
|
#[arg(long)]
|
||||||
|
os_version: Option<String>,
|
||||||
|
#[arg(long)]
|
||||||
|
host_id: Option<String>,
|
||||||
|
#[arg(long)]
|
||||||
|
cookie: Option<String>,
|
||||||
|
#[arg(long)]
|
||||||
|
client_ip: Option<String>,
|
||||||
|
#[arg(long)]
|
||||||
|
client_ipv6: Option<String>,
|
||||||
|
#[arg(long)]
|
||||||
|
md5: Option<String>,
|
||||||
|
#[arg(long)]
|
||||||
|
preview: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if let Err(err) = run() {
|
||||||
|
eprintln!("HIP report generation failed: {err:#}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run() -> anyhow::Result<()> {
|
||||||
|
let args = Args::parse();
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
let original_args: Vec<_> = env::args_os().skip(1).collect();
|
||||||
|
let executable = env::current_exe().context("Cannot locate HIP runner")?;
|
||||||
|
validate_root_owned_path(&executable, true)?;
|
||||||
|
let state = executable
|
||||||
|
.parent()
|
||||||
|
.context("HIP runner has no parent")?
|
||||||
|
.join(STATE_NAME);
|
||||||
|
let metadata = fs::symlink_metadata(&state).context("Cannot inspect HIP report state")?;
|
||||||
|
ensure!(
|
||||||
|
metadata.is_file() && !metadata.file_type().is_symlink(),
|
||||||
|
"Invalid HIP report state"
|
||||||
|
);
|
||||||
|
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
||||||
|
ensure!(
|
||||||
|
metadata.uid() == 0 && metadata.permissions().mode() & 0o077 == 0,
|
||||||
|
"HIP report state is not private"
|
||||||
|
);
|
||||||
|
ensure!(
|
||||||
|
metadata.len() <= MAX_STATE_BYTES as u64,
|
||||||
|
"HIP report state is too large"
|
||||||
|
);
|
||||||
|
let bytes = fs::read(&state).context("Cannot read HIP report state")?;
|
||||||
|
ensure!(bytes.len() <= MAX_STATE_BYTES, "HIP report state is too large");
|
||||||
|
let report: RunnerReport = serde_json::from_slice(&bytes).context("Invalid HIP report state")?;
|
||||||
|
|
||||||
|
// This binary is single-threaded. Clear the VPN and desktop environment
|
||||||
|
// before host collectors invoke any external system utilities.
|
||||||
|
for (key, _) in env::vars_os() {
|
||||||
|
unsafe { env::remove_var(key) };
|
||||||
|
}
|
||||||
|
unsafe {
|
||||||
|
env::set_var("PATH", "/usr/bin:/bin:/usr/sbin:/sbin");
|
||||||
|
env::set_var("LC_ALL", "C");
|
||||||
|
env::set_var(
|
||||||
|
"HOME",
|
||||||
|
if cfg!(target_os = "macos") {
|
||||||
|
"/var/root"
|
||||||
|
} else {
|
||||||
|
"/root"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let report = match report {
|
||||||
|
RunnerReport::ApprovedRootScript { approval_id, owner_uid } => {
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
{
|
||||||
|
let approved = gpservice::hip_approval::resolve(&approval_id, owner_uid)?;
|
||||||
|
let script_args = original_args.into_iter().filter(|arg| arg != "--preview");
|
||||||
|
let status = std::process::Command::new(approved.path)
|
||||||
|
.args(script_args)
|
||||||
|
.status()
|
||||||
|
.context("Approved HIP script did not start")?;
|
||||||
|
ensure!(status.success(), "Approved HIP script failed");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
|
||||||
|
{
|
||||||
|
let _ = (approval_id, owner_uid);
|
||||||
|
anyhow::bail!("Root HIP script approvals are unavailable on this platform");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
report => report,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut builder = OsProfileBuilder::new(ClientOs::from(args.client_os)).client_version(args.client_version);
|
||||||
|
if let Some(host_id) = args.host_id {
|
||||||
|
builder = builder.host_id_override(host_id);
|
||||||
|
}
|
||||||
|
let context = if args.preview {
|
||||||
|
ReportContext::Preview
|
||||||
|
} else {
|
||||||
|
ReportContext::Connected {
|
||||||
|
cookie: args.cookie.context("Missing HIP cookie")?,
|
||||||
|
client_ip: args.client_ip,
|
||||||
|
client_ipv6: args.client_ipv6,
|
||||||
|
md5: args.md5.context("Missing HIP digest")?,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let input = ReportInput {
|
||||||
|
profile: builder.build(),
|
||||||
|
context,
|
||||||
|
};
|
||||||
|
let xml = match report {
|
||||||
|
RunnerReport::Generated => generate_report(&input)?,
|
||||||
|
RunnerReport::Edited { xml } => refresh_edited_report(&xml, &input)?,
|
||||||
|
RunnerReport::ApprovedRootScript { .. } => unreachable!("approved script returned before report generation"),
|
||||||
|
};
|
||||||
|
io::stdout().write_all(xml.as_bytes())?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
#[path = "privileged_unix.rs"]
|
||||||
|
mod platform;
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
|
||||||
|
#[path = "unsupported.rs"]
|
||||||
|
mod platform;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
platform::run();
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
use anyhow::{Context, ensure};
|
||||||
|
use clap::{Parser, Subcommand};
|
||||||
|
use gpservice::hip_approval::{self, InstallRequest};
|
||||||
|
use nix::unistd::Uid;
|
||||||
|
|
||||||
|
const MAX_INSTALL_REQUEST_SIZE: u64 = 2 * 1024 * 1024;
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct Cli {
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Command,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
enum Command {
|
||||||
|
Install,
|
||||||
|
Revoke { approval_id: String },
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_run() -> anyhow::Result<()> {
|
||||||
|
ensure!(Uid::effective().is_root(), "HIP script installer must run as root");
|
||||||
|
let approving_uid = std::env::var("PKEXEC_UID")
|
||||||
|
.context("HIP script installer requires pkexec authorization")?
|
||||||
|
.parse::<u32>()
|
||||||
|
.context("Invalid pkexec user identity")?;
|
||||||
|
ensure!(approving_uid != 0, "HIP script installer requires a desktop user");
|
||||||
|
|
||||||
|
match Cli::parse().command {
|
||||||
|
Command::Install => {
|
||||||
|
let mut input = Vec::new();
|
||||||
|
std::io::stdin()
|
||||||
|
.lock()
|
||||||
|
.take(MAX_INSTALL_REQUEST_SIZE + 1)
|
||||||
|
.read_to_end(&mut input)?;
|
||||||
|
ensure!(
|
||||||
|
input.len() as u64 <= MAX_INSTALL_REQUEST_SIZE,
|
||||||
|
"HIP install request is too large"
|
||||||
|
);
|
||||||
|
let request: InstallRequest = serde_json::from_slice(&input).context("Invalid HIP install request")?;
|
||||||
|
let info = hip_approval::install(request, approving_uid)?;
|
||||||
|
serde_json::to_writer(std::io::stdout().lock(), &info)?;
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
Command::Revoke { approval_id } => hip_approval::revoke(&approval_id, approving_uid)?,
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn run() {
|
||||||
|
if let Err(err) = try_run() {
|
||||||
|
eprintln!("HIP approval failed: {err:#}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
pub(super) fn run() {
|
||||||
|
eprintln!("Root HIP script approvals are unavailable on this platform");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
|
#[path = "privileged_unix.rs"]
|
||||||
|
mod platform;
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
|
||||||
|
#[path = "unsupported.rs"]
|
||||||
|
mod platform;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
platform::run();
|
||||||
|
}
|
||||||