mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
feat(windows): support gpclient authentication and VPN connections
This commit is contained in:
49 files changed
+1888
-390
No files matched your search
@@ -22,7 +22,7 @@ $info = Get-Content (Join-Path $destination 'build-info.json') -Raw | ConvertFro
|
||||
if ($info.architecture -ne $Architecture -or [string]$info.build_version -ne $Build) { throw 'The installed package identity does not match.' }
|
||||
if ($env:WINDOWS_SIGNING_PUBLISHER) {
|
||||
$signed = @($Installer)
|
||||
foreach ($name in @('gpgui.exe', 'gpauth.exe', 'gpservice.exe', 'gp-posture.exe', 'libopenconnect-5.dll', 'uninstall.exe')) {
|
||||
foreach ($name in @('gpgui.exe', 'gpauth.exe', 'gpservice.exe', 'gp-posture.exe', 'libopenconnect-5.dll', 'uninstall.exe', 'bin\gpclient.exe', 'bin\libopenconnect-5.dll')) {
|
||||
$signed += Join-Path $destination $name
|
||||
}
|
||||
& (Join-Path $PSScriptRoot 'test-windows-signature.ps1') -Files $signed -Publisher $env:WINDOWS_SIGNING_PUBLISHER
|
||||
@@ -41,6 +41,18 @@ foreach ($name in @('gpgui.exe', 'gpauth.exe')) {
|
||||
$process = Start-Process (Join-Path $destination $name) -ArgumentList '--version' -PassThru -Wait
|
||||
if ($process.ExitCode -ne 0) { throw "The installed $name cannot start." }
|
||||
}
|
||||
$cli = Join-Path $destination 'bin\gpclient.exe'
|
||||
Push-Location $env:TEMP
|
||||
try {
|
||||
$version = & $cli --version
|
||||
if ($LASTEXITCODE -ne 0 -or $version -notmatch "^gpclient $([regex]::Escape($info.version))\s") {
|
||||
throw 'The installed CLI failed its version check.'
|
||||
}
|
||||
$help = & $cli connect --help | Out-String
|
||||
if ($LASTEXITCODE -ne 0 -or $help -notmatch '--cookie-only' -or $help -match '--background') {
|
||||
throw 'The installed Windows CLI failed its connect help check.'
|
||||
}
|
||||
} finally { Pop-Location }
|
||||
$helper = Join-Path $destination 'gp-posture.exe'
|
||||
$output = Join-Path $env:TEMP 'gp-posture-install-test.json'
|
||||
$process = Start-Process $helper -PassThru -Wait -RedirectStandardOutput $output
|
||||
@@ -52,7 +64,8 @@ $state = Join-Path $env:LOCALAPPDATA 'GP Connect\config\protected-state'
|
||||
New-Item -ItemType Directory -Force $state | Out-Null
|
||||
$marker = Join-Path $state 'ci-install-retention'
|
||||
[IO.File]::WriteAllText($marker, 'retain user settings')
|
||||
$process = Start-Process (Join-Path $destination 'uninstall.exe') -ArgumentList '/S' -PassThru -Wait
|
||||
# Start-Process otherwise uses the executable's directory, which the uninstaller must move.
|
||||
$process = Start-Process (Join-Path $destination 'uninstall.exe') -WorkingDirectory (Split-Path $destination) -ArgumentList '/S' -PassThru -Wait
|
||||
if ($process.ExitCode -ne 0) { throw 'The uninstaller failed.' }
|
||||
if ((Get-Service GPConnect -ErrorAction SilentlyContinue) -or (Test-Path $destination) -or (Test-Path ($destination + '.previous'))) {
|
||||
throw 'The uninstaller left service registration or runtime files.'
|
||||
@@ -62,4 +75,4 @@ if ((Test-Path $shortcut) -or (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\Curre
|
||||
}
|
||||
if ([IO.File]::ReadAllText($marker) -ne 'retain user settings') { throw 'The uninstaller changed user state.' }
|
||||
Remove-Item $marker
|
||||
Write-Host "Installed $Architecture runtime and service, launched both applications, and uninstalled successfully."
|
||||
Write-Host "Installed $Architecture runtime and service, launched the desktop, authenticator and CLI, and uninstalled successfully."
|
||||
@@ -130,24 +130,31 @@ class OBSTests(unittest.TestCase):
|
||||
|
||||
|
||||
class CoprTests(unittest.TestCase):
|
||||
def test_migrated_repository_matches_exact_build_manifest(self):
|
||||
def test_public_repository_must_match_the_selected_builds_signed_rpm(self):
|
||||
checker = publication.Copr(arguments(build_id=42))
|
||||
build = {"ownername": "yuezk", "projectname": "globalprotect-openconnect",
|
||||
"state": "succeeded", "source_package": {"name": "globalprotect-openconnect", "version": "3.0.1-1"},
|
||||
"chroots": ["fedora-44-x86_64"], "repo_url": "https://repo"}
|
||||
status = {"state": "succeeded", "result_url": "https://results/42/"}
|
||||
package = {"name": "globalprotect-openconnect", "version": "3.0.1", "release": "1.fc44", "arch": "x86_64"}
|
||||
primary = ET.fromstring('''<metadata xmlns="http://linux.duke.edu/metadata/common"><package>
|
||||
<name>globalprotect-openconnect</name><arch>x86_64</arch><version ver="3.0.1" rel="1.fc44"/>
|
||||
<location href="Packages/g/globalprotect-openconnect-3.0.1-1.fc44.x86_64.rpm"/></package></metadata>''')
|
||||
with patch.object(publication, "api", side_effect=[build, status, {"packages": [package]}]), \
|
||||
patch.object(publication, "rpm_packages", return_value=primary):
|
||||
self.assertIn("1 targets built and published", checker.check())
|
||||
package["release"] = "1.fc45"
|
||||
with patch.object(publication, "api", side_effect=[build, status, {"packages": [package]}]), \
|
||||
patch.object(publication, "rpm_packages", return_value=primary):
|
||||
with self.assertRaisesRegex(publication.Pending, "Waiting for Copr build 42"):
|
||||
checker.check()
|
||||
digest = "a" * 64
|
||||
artifacts = {"count": 1, "results": [{"release": "1.fc44", "sha256": digest}]}
|
||||
for release, published_digest, matches in [
|
||||
("1.fc44", digest, True),
|
||||
("1.fc44", "b" * 64, False),
|
||||
("1.fc45", digest, False)]:
|
||||
with self.subTest(release=release, published_digest=published_digest):
|
||||
primary = ET.fromstring(f'''<metadata xmlns="http://linux.duke.edu/metadata/common"><package>
|
||||
<name>globalprotect-openconnect</name><arch>x86_64</arch><version ver="3.0.1" rel="{release}"/>
|
||||
<checksum type="sha256">{published_digest}</checksum>
|
||||
<location href="Packages/g/globalprotect-openconnect-3.0.1-1.fc44.x86_64.rpm"/></package></metadata>''')
|
||||
with patch.object(publication, "api", side_effect=[build, status, artifacts]) as api, \
|
||||
patch.object(publication, "rpm_packages", return_value=primary):
|
||||
if matches:
|
||||
self.assertIn("1 targets built and published", checker.check())
|
||||
else:
|
||||
with self.assertRaisesRegex(publication.Pending, "Waiting for Copr build 42"):
|
||||
checker.check()
|
||||
self.assertEqual(api.call_args.kwargs["pulp_label_select"], "build_id=42,chroot=fedora-44-x86_64")
|
||||
|
||||
def test_unselected_chroot_cannot_be_hidden_by_verification(self):
|
||||
checker = publication.Copr(arguments(build_id=42, chroots=["fedora-44-x86_64"]))
|
||||
|
||||
@@ -66,7 +66,7 @@ class WindowsFeedTests(unittest.TestCase):
|
||||
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), f"windows-{payload.architecture}")
|
||||
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}installerArguments"), "/UPDATE")
|
||||
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0")
|
||||
minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041"
|
||||
minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.17763"
|
||||
self.assertEqual(item.findtext(f"{{{feed.SPARKLE}}}minimumSystemVersion"), minimum)
|
||||
self.assertEqual(json.loads((args.output / "latest.json").read_text())["stable"]["platforms"], ["windows"])
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ def rpm_packages(base_url):
|
||||
return ET.fromstring(unpack(content, location))
|
||||
|
||||
|
||||
def rpm_present(base_url, package, version, arch, release_matches):
|
||||
def rpm_present(base_url, package, version, arch, release_matches, *, sha256=None):
|
||||
namespace = {"rpm": "http://linux.duke.edu/metadata/common"}
|
||||
for entry in rpm_packages(base_url).findall("rpm:package", namespace):
|
||||
info = entry.find("rpm:version", namespace)
|
||||
@@ -92,6 +92,10 @@ def rpm_present(base_url, package, version, arch, release_matches):
|
||||
entry.findtext("rpm:arch", namespaces=namespace) != arch or
|
||||
info.get("ver") != version or not release_matches(info.get("rel", ""))):
|
||||
continue
|
||||
if sha256 is not None:
|
||||
digest = entry.find("rpm:checksum[@type='sha256']", namespace)
|
||||
if digest is None or digest.text != sha256:
|
||||
continue
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -251,16 +255,23 @@ class Copr:
|
||||
raise Pending(f"Copr {chroot}: {status['state']}; {link}")
|
||||
base = build["repo_url"].rstrip("/") + "/" + chroot
|
||||
arch = chroot.rsplit("-", 1)[1]
|
||||
packages = api(urljoin(status["result_url"], "results.json"))["packages"]
|
||||
package = next((item for item in packages
|
||||
if item["name"] == args.package and item["version"] == args.version
|
||||
and item["arch"] == arch
|
||||
and (item["release"] == args.revision
|
||||
or item["release"].startswith(args.revision + "."))), None)
|
||||
if package is None:
|
||||
raise Failed(f"Copr build {args.build_id} has no requested package for {chroot}")
|
||||
# Pulp labels the signed RPM with the producing build and chroot.
|
||||
artifacts = api("https://packages.redhat.com/api/pulp/public-copr/api/v3/content/rpm/packages/",
|
||||
pulp_label_select=f"build_id={args.build_id},chroot={chroot}",
|
||||
name=args.package, version=args.version, arch=arch, fields="release,sha256")
|
||||
if not artifacts["count"]:
|
||||
raise Pending(f"Waiting for the signed RPM from Copr build {args.build_id} for {chroot}")
|
||||
if artifacts["count"] != 1:
|
||||
raise Failed(f"Ambiguous RPMs from Copr build {args.build_id} for {chroot}")
|
||||
artifact = artifacts["results"][0]
|
||||
release = artifact["release"]
|
||||
if release != args.revision and not release.startswith(args.revision + "."):
|
||||
raise Failed(f"Copr build {args.build_id} has an unexpected RPM revision for {chroot}")
|
||||
digest = artifact["sha256"]
|
||||
if not digest or not re.fullmatch(r"[0-9a-f]{64}", digest):
|
||||
raise Failed(f"Missing signed RPM checksum for Copr build {args.build_id} for {chroot}")
|
||||
if not rpm_present(base, args.package, args.version, arch,
|
||||
lambda release: release == package["release"]):
|
||||
lambda value: value == release, sha256=digest):
|
||||
raise Pending(f"Waiting for Copr build {args.build_id} in {base}")
|
||||
return f"Copr build {args.build_id}: {len(build['chroots'])} targets built and published; {link}"
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ def generate(args: argparse.Namespace) -> None:
|
||||
item = ET.SubElement(channel, "item")
|
||||
ET.SubElement(item, "title").text = f"GP Connect {display_version}"
|
||||
ET.SubElement(item, "description").text = "\n".join(release["highlights"])
|
||||
minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041"
|
||||
minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.17763"
|
||||
ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = minimum
|
||||
ET.SubElement(item, "enclosure", {
|
||||
"url": payload.installer_url, "length": str(length), "type": "application/octet-stream",
|
||||
|
||||
Reference in new issue
Block a user