Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 392e7553c4 | |||
| 19f76f4d9d | |||
| 7dcbff8ece | |||
| 8952589efd | |||
| bcc0d40413 | |||
| 1af72deb16 | |||
| 11168b22df | |||
| 653623b9f0 | |||
| 74288e1dfc | |||
| 73a11e70e0 | |||
| fc0b42040e | |||
| 0d8b9a4d94 | |||
| 945febbe96 | |||
| 6b75d2ab01 | |||
| 0d582f2fda | |||
| 7c55c99e48 | |||
| 5b5791f52f |
BIN
.a0proj/audit.db
BIN
.a0proj/audit.db
Binary file not shown.
@ -171,6 +171,10 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get -f install -y
|
||||
sudo apt-get install -y build-essential debhelper pkg-config libsystemd-dev libssl-dev
|
||||
- name: Clean previous build artifacts
|
||||
run: |
|
||||
cargo clean
|
||||
rm -f ../linux-patch-api_*.deb
|
||||
- name: Build Debian package
|
||||
run: |
|
||||
sudo dpkg-buildpackage -us -uc -b -d
|
||||
@ -204,6 +208,10 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get -f install -y
|
||||
sudo apt-get install -y build-essential debhelper pkg-config libsystemd-dev libssl-dev
|
||||
- name: Clean previous build artifacts
|
||||
run: |
|
||||
cargo clean
|
||||
rm -f ../linux-patch-api_*.deb
|
||||
- name: Build Debian package
|
||||
run: |
|
||||
sudo dpkg-buildpackage -us -uc -b -d
|
||||
|
||||
@ -909,6 +909,7 @@ Enrollment endpoints enable new hosts to register with the Patch Manager and rec
|
||||
| `fqdn` | string | Yes | Fully qualified domain name of the host |
|
||||
| `ip_address` | string | Yes | Primary non-loopback IPv4 address |
|
||||
| `os_details` | object | Yes | OS metadata (free-form JSON object) |
|
||||
| `hostname` | string | No | Short hostname (without domain). Used by the manager to populate `display_name` on approval. If omitted, the manager falls back to the FQDN. |
|
||||
|
||||
**`os_details` common fields:**
|
||||
|
||||
@ -933,7 +934,8 @@ curl -X POST https://manager.example.com/api/v1/enroll \
|
||||
"version_id": "12",
|
||||
"kernel": "6.1.0-kali9-amd64",
|
||||
"id_like": "debian"
|
||||
}
|
||||
},
|
||||
"hostname": "host-01"
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Linux Patch API - Package Build Guide
|
||||
|
||||
This document provides comprehensive instructions for building production-ready Debian (.deb) and RPM (.rpm) packages for the Linux Patch API.
|
||||
This document provides comprehensive instructions for building production-ready packages for the Linux Patch API across all supported platforms: Debian/Ubuntu (.deb), RHEL/CentOS/Fedora (.rpm), Arch Linux (.pkg.tar.zst), and Alpine Linux (.apk).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@ -173,6 +173,152 @@ rpm -ql linux-patch-api
|
||||
rpm -e linux-patch-api
|
||||
```
|
||||
|
||||
## Building Arch Package (.pkg.tar.zst)
|
||||
|
||||
### Quick Build
|
||||
|
||||
```bash
|
||||
cd /path/to/linux_patch_api
|
||||
|
||||
# Build release binary
|
||||
cargo build --release
|
||||
|
||||
# Build Arch package
|
||||
chmod +x build-arch.sh
|
||||
SKIP_CARGO_BUILD=1 ./build-arch.sh
|
||||
|
||||
# Package will be created in releases/
|
||||
ls -la releases/*.pkg.tar.zst
|
||||
```
|
||||
|
||||
### Detailed Build Process
|
||||
|
||||
```bash
|
||||
# 1. Install build dependencies (Arch Linux)
|
||||
sudo pacman -Syu --noconfirm rust cargo systemd git base-devel gcc
|
||||
|
||||
# 2. Build release binary
|
||||
cargo build --release
|
||||
|
||||
# 3. Run build script
|
||||
chmod +x build-arch.sh
|
||||
./build-arch.sh
|
||||
|
||||
# 4. Verify package contents
|
||||
bsdtar -tf releases/linux-patch-api-*.pkg.tar.zst
|
||||
|
||||
# 5. Verify package info
|
||||
pacman -Qi releases/linux-patch-api-*.pkg.tar.zst
|
||||
```
|
||||
|
||||
### Install Script Hooks
|
||||
|
||||
The Arch package includes an `.install` file (`configs/linux-patch-api.install`) that runs automatically on install:
|
||||
|
||||
- **post_install**: Creates directories, copies example configs, enables systemd service
|
||||
- **post_upgrade**: Reloads systemd daemon
|
||||
- **pre_remove**: Stops and disables service
|
||||
- **post_remove**: Cleans up empty directories
|
||||
|
||||
### Installation Test
|
||||
|
||||
```bash
|
||||
# Install the package
|
||||
sudo pacman -U ./releases/linux-patch-api-*.pkg.tar.zst
|
||||
|
||||
# Verify installation
|
||||
systemctl status linux-patch-api
|
||||
linux-patch-api --version
|
||||
|
||||
# Check installed files
|
||||
pacman -Ql linux-patch-api
|
||||
|
||||
# Verify config files exist
|
||||
ls -la /etc/linux_patch_api/
|
||||
|
||||
# Remove package
|
||||
sudo pacman -R linux-patch-api
|
||||
```
|
||||
|
||||
**Note:** The build script creates a `builduser` for `makepkg` when running as root (typical in CI environments). The `.install` hook handles directory creation, config copying, and service enablement.
|
||||
|
||||
## Building Alpine Package (.apk)
|
||||
|
||||
### Quick Build
|
||||
|
||||
```bash
|
||||
cd /path/to/linux_patch_api
|
||||
|
||||
# Build release binary (MUSL target for Alpine)
|
||||
cargo build --release --target x86_64-unknown-linux-musl
|
||||
|
||||
# Build Alpine package
|
||||
chmod +x build-alpine.sh
|
||||
SKIP_CARGO_BUILD=1 ./build-alpine.sh
|
||||
|
||||
# Package will be created in releases/
|
||||
ls -la releases/*.apk
|
||||
```
|
||||
|
||||
### Detailed Build Process
|
||||
|
||||
```bash
|
||||
# 1. Install build dependencies (Alpine Linux)
|
||||
apk add --no-cache alpine-sdk rust cargo openssl openssl-dev elogind-dev musl-dev abuild gcc
|
||||
|
||||
# 2. Add Rust MUSL target
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
|
||||
# 3. Build release binary
|
||||
cargo build --release --target x86_64-unknown-linux-musl
|
||||
|
||||
# 4. Run build script
|
||||
chmod +x build-alpine.sh
|
||||
./build-alpine.sh
|
||||
|
||||
# 5. Verify package contents
|
||||
apk verify releases/*.apk
|
||||
|
||||
# 6. List package contents
|
||||
tar -tzf releases/*.apk
|
||||
```
|
||||
|
||||
### Install Script Hooks
|
||||
|
||||
The Alpine package includes an install script (`configs/linux-patch-api.apk-install`) that runs automatically on install:
|
||||
|
||||
- **pre_install**: Creates directories, sets ownership and permissions
|
||||
- **post_install**: Copies example configs, adds service to default runlevel
|
||||
- **pre_deinstall**: Stops and removes service from runlevel
|
||||
- **post_deinstall**: Cleans up empty directories
|
||||
|
||||
### Installation Test
|
||||
|
||||
```bash
|
||||
# Install the package
|
||||
sudo apk add --allow-unstable ./releases/linux-patch-api-*.apk
|
||||
|
||||
# Verify installation
|
||||
rc-service linux-patch-api status
|
||||
linux-patch-api --version
|
||||
|
||||
# Check installed files
|
||||
apk info -L linux-patch-api
|
||||
|
||||
# Verify config files exist
|
||||
ls -la /etc/linux_patch_api/
|
||||
|
||||
# Remove package
|
||||
sudo apk del linux-patch-api
|
||||
```
|
||||
|
||||
**Important:** Alpine uses **OpenRC** instead of systemd. Key differences:
|
||||
- Start service: `rc-service linux-patch-api start`
|
||||
- Stop service: `rc-service linux-patch-api stop`
|
||||
- Check status: `rc-service linux-patch-api status`
|
||||
- Service init script: `/etc/init.d/linux-patch-api`
|
||||
- The `abuild` tool generates signing keys automatically for CI builds
|
||||
|
||||
## Using the Interactive Installer
|
||||
|
||||
For manual deployment without package managers:
|
||||
@ -209,15 +355,17 @@ The installer will:
|
||||
| `/var/lib/linux_patch_api/` | Data directory | 755 |
|
||||
| `/var/log/linux_patch_api/` | Log directory | 755 |
|
||||
|
||||
### System User/Group
|
||||
### Service Account
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| User | linux-patch-api |
|
||||
| Group | linux-patch-api |
|
||||
| User | root |
|
||||
| Group | root |
|
||||
| Home | /var/lib/linux_patch_api |
|
||||
| Shell | /usr/sbin/nologin |
|
||||
| Type | System account |
|
||||
| Shell | N/A (systemd service) |
|
||||
| Type | Runs as root (required for package management) |
|
||||
|
||||
**Note:** The service runs as root because package management operations (apt, dnf, apk, pacman) require root privileges. Security is provided by mTLS + IP whitelist, not process isolation.
|
||||
|
||||
## Supported Distributions
|
||||
|
||||
@ -240,6 +388,19 @@ The installer will:
|
||||
| AlmaLinux | 8, 9 | ✅ Supported |
|
||||
| Rocky Linux | 8, 9 | ✅ Supported |
|
||||
|
||||
### Arch Package (.pkg.tar.zst)
|
||||
|
||||
| Distribution | Versions | Status |
|
||||
|--------------|----------|--------|
|
||||
| Arch Linux | Rolling | ✅ Supported |
|
||||
| Manjaro | Rolling | ✅ Supported |
|
||||
|
||||
### Alpine Package (.apk)
|
||||
|
||||
| Distribution | Versions | Status |
|
||||
|--------------|----------|--------|
|
||||
| Alpine Linux | 3.18+ | ✅ Supported |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Debian Package Issues
|
||||
@ -276,9 +437,62 @@ cat ~/rpmbuild/BUILDROOT/*/var/log/rpmbuild.log
|
||||
dnf install -y systemd-devel pkgconfig
|
||||
```
|
||||
|
||||
### Arch Package Issues
|
||||
|
||||
**Error: `makepkg: cannot run as root`**
|
||||
```bash
|
||||
# The build script handles this automatically by creating builduser
|
||||
# If running manually:
|
||||
useradd -m builduser
|
||||
su - builduser -c "cd /path/to/repo && makepkg -f --noconfirm"
|
||||
```
|
||||
|
||||
**Error: `install script not found`**
|
||||
```bash
|
||||
# Ensure linux-patch-api.install is in the same directory as PKGBUILD
|
||||
ls -la configs/linux-patch-api.install
|
||||
# The build script copies it automatically
|
||||
```
|
||||
|
||||
**Error: `Permission denied` on config files**
|
||||
```bash
|
||||
# Verify ownership is root:root
|
||||
ls -la /etc/linux_patch_api/
|
||||
# Fix if needed:
|
||||
sudo chown -R root:root /etc/linux_patch_api/
|
||||
sudo chmod 750 /etc/linux_patch_api /etc/linux_patch_api/certs
|
||||
```
|
||||
|
||||
### Alpine Package Issues
|
||||
|
||||
**Error: `abuild: UNTRUSTED signature`**
|
||||
```bash
|
||||
# The build script handles key generation automatically
|
||||
# If running manually:
|
||||
abuild-keygen -a -n
|
||||
cp /root/.abuild/*.rsa.pub /etc/apk/keys/
|
||||
```
|
||||
|
||||
**Error: `apk add: ERROR: failed to create directory`**
|
||||
```bash
|
||||
# Verify the install script ran correctly
|
||||
ls -la /etc/linux_patch_api/
|
||||
ls -la /var/lib/linux_patch_api/
|
||||
# Manually create if needed:
|
||||
sudo mkdir -p /etc/linux_patch_api/certs /var/lib/linux_patch_api /var/log/linux_patch_api
|
||||
```
|
||||
|
||||
**Error: `rc-service: service not found`**
|
||||
```bash
|
||||
# Verify the init script exists
|
||||
ls -la /etc/init.d/linux-patch-api
|
||||
# Re-add to default runlevel
|
||||
sudo rc-update add linux-patch-api default
|
||||
```
|
||||
|
||||
### Service Issues
|
||||
|
||||
**Service fails to start:**
|
||||
**Service fails to start (systemd):**
|
||||
```bash
|
||||
# Check service status
|
||||
systemctl status linux-patch-api
|
||||
@ -293,6 +507,22 @@ linux-patch-api --config /etc/linux_patch_api/config.yaml --check
|
||||
ls -la /etc/linux_patch_api/certs/
|
||||
```
|
||||
|
||||
**Service fails to start (OpenRC/Alpine):**
|
||||
```bash
|
||||
# Check service status
|
||||
rc-service linux-patch-api status
|
||||
|
||||
# View logs
|
||||
cat /var/log/linux_patch_api/linux-patch-api.log
|
||||
cat /var/log/linux_patch_api/linux-patch-api.err
|
||||
|
||||
# Check configuration
|
||||
linux-patch-api --config /etc/linux_patch_api/config.yaml --check
|
||||
|
||||
# Verify certificates
|
||||
ls -la /etc/linux_patch_api/certs/
|
||||
```
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
### GitHub Actions Example
|
||||
@ -383,7 +613,7 @@ jobs:
|
||||
- Packages are signed with maintainer GPG key for production deployments
|
||||
- All maintainer scripts run with `set -e` for fail-fast behavior
|
||||
- Configuration files are marked as conffiles to preserve user modifications
|
||||
- System user has minimal privileges (nologin shell, no home directory)
|
||||
- Service runs as root (required for package management operations)
|
||||
- Directory permissions follow principle of least privilege
|
||||
- TLS certificates should be replaced with CA-signed certs in production
|
||||
|
||||
|
||||
205
Cargo.lock
generated
205
Cargo.lock
generated
@ -821,26 +821,6 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
@ -1193,15 +1173,6 @@ version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-shared 0.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.5.0"
|
||||
@ -1209,7 +1180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
|
||||
dependencies = [
|
||||
"foreign-types-macros",
|
||||
"foreign-types-shared 0.3.1",
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1223,12 +1194,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.3.1"
|
||||
@ -1606,22 +1571,6 @@ dependencies = [
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.20"
|
||||
@ -1640,11 +1589,9 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"socket2 0.6.3",
|
||||
"system-configuration",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"windows-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1969,7 +1916,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "linux-patch-api"
|
||||
version = "0.3.12"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"actix",
|
||||
"actix-rt",
|
||||
@ -2123,23 +2070,6 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"openssl",
|
||||
"openssl-probe",
|
||||
"openssl-sys",
|
||||
"schannel",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.30.1"
|
||||
@ -2270,49 +2200,6 @@ version = "11.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a45fa2aa886c42762255da344f0a0d313e254066c46aad76f300c3d3da62d967"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"cfg-if",
|
||||
"foreign-types 0.3.2",
|
||||
"libc",
|
||||
"openssl-macros",
|
||||
"openssl-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.116"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f28a22dc7140cda5f096e5e7724a6962ca81a7f8bfd2979f9b18c11af56318c4"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-multimap"
|
||||
version = "0.7.3"
|
||||
@ -2755,20 +2642,15 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
"h2 0.4.13",
|
||||
"http 1.4.0",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-tls",
|
||||
"hyper-util",
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime",
|
||||
"native-tls",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"quinn",
|
||||
@ -2779,7 +2661,6 @@ dependencies = [
|
||||
"serde_urlencoded",
|
||||
"sync_wrapper",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tokio-rustls",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@ -2941,15 +2822,6 @@ dependencies = [
|
||||
"sdd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
@ -2962,29 +2834,6 @@ version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca"
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "3.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"core-foundation 0.10.1",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"security-framework-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "2.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
@ -3260,27 +3109,6 @@ dependencies = [
|
||||
"windows 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"core-foundation 0.9.4",
|
||||
"system-configuration-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration-sys"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "systemd"
|
||||
version = "0.10.1"
|
||||
@ -3288,7 +3116,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01e9d1976a15b86245def55d20d52b5818e1a1e81aa030b6a608d3ce57709423"
|
||||
dependencies = [
|
||||
"cstr-argument",
|
||||
"foreign-types 0.5.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"libsystemd-sys",
|
||||
"log",
|
||||
@ -3461,16 +3289,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.26.4"
|
||||
@ -3823,12 +3641,6 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
@ -4129,17 +3941,6 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-registry"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.4.1"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "linux-patch-api"
|
||||
version = "0.3.12"
|
||||
version = "1.1.9"
|
||||
edition = "2021"
|
||||
authors = ["Echo <echo@moon-dragon.us>"]
|
||||
description = "Secure remote package management API for Linux systems"
|
||||
|
||||
164
README.md
164
README.md
@ -185,6 +185,13 @@ For detailed enrollment procedures, see [DEPLOYMENT_GUIDE.md - Self-Enrollment D
|
||||
|
||||
### Package Installation
|
||||
|
||||
All platform packages produce identical installation results:
|
||||
- Creates `/etc/linux_patch_api/`, `/etc/linux_patch_api/certs/`, `/var/lib/linux_patch_api/`, `/var/log/linux_patch_api/`
|
||||
- Copies example configs to live configs if not already present
|
||||
- Enables the service (does not start automatically)
|
||||
- Sets correct permissions (750 on config dirs, 755 on data/log dirs)
|
||||
- Ownership: root:root (service runs as root)
|
||||
|
||||
#### Debian/Ubuntu (.deb)
|
||||
|
||||
```bash
|
||||
@ -197,52 +204,173 @@ apt-get install -f -y
|
||||
# Verify installation
|
||||
systemctl status linux-patch-api
|
||||
linux-patch-api --version
|
||||
|
||||
# Check installed files
|
||||
dpkg -L linux-patch-api
|
||||
|
||||
# Remove package (keeping configs)
|
||||
dpkg -r linux-patch-api
|
||||
|
||||
# Purge package (removing all configs)
|
||||
dpkg -P linux-patch-api
|
||||
```
|
||||
|
||||
**Prerequisites:** `systemd`, `libsystemd0`
|
||||
|
||||
**Post-install:** The package automatically copies example configs, enables the service, and prints next steps. Configure `/etc/linux_patch_api/config.yaml` and place TLS certificates in `/etc/linux_patch_api/certs/` before starting.
|
||||
|
||||
#### RHEL/CentOS/Fedora (.rpm)
|
||||
|
||||
```bash
|
||||
# Install the package
|
||||
rpm -ivh linux-patch-api-1.0.0-1.x86_64.rpm
|
||||
# Install the package (recommended - resolves dependencies automatically)
|
||||
dnf install -y ./linux-patch-api-1.0.0-1.el9.x86_64.rpm
|
||||
|
||||
# Or with yum
|
||||
yum install -y ./linux-patch-api-1.0.0-1.el9.x86_64.rpm
|
||||
|
||||
# Or with rpm (does NOT resolve dependencies)
|
||||
rpm -ivh linux-patch-api-1.0.0-1.el9.x86_64.rpm
|
||||
|
||||
# Verify installation
|
||||
systemctl status linux-patch-api
|
||||
linux-patch-api --version
|
||||
|
||||
# Check installed files
|
||||
rpm -ql linux-patch-api
|
||||
|
||||
# Remove package
|
||||
rpm -e linux-patch-api
|
||||
```
|
||||
|
||||
**Prerequisites (auto-resolved with dnf/yum):** `systemd`, `libsystemd`, `openssl-libs`, `ca-certificates`
|
||||
|
||||
**Post-install:** The package automatically creates directories, copies example configs, enables the service, and prints next steps. Configure `/etc/linux_patch_api/config.yaml` and place TLS certificates in `/etc/linux_patch_api/certs/` before starting.
|
||||
|
||||
**Note:** Use `dnf install` or `yum install` instead of `rpm -ivh` to automatically resolve dependencies. The `rpm -ivh` command will fail if required packages are not already installed.
|
||||
|
||||
#### Arch Linux (.pkg.tar.zst)
|
||||
|
||||
```bash
|
||||
# Install the package
|
||||
sudo pacman -U ./linux-patch-api-1.0.0-1-x86_64.pkg.tar.zst
|
||||
|
||||
# Verify installation
|
||||
systemctl status linux-patch-api
|
||||
linux-patch-api --version
|
||||
|
||||
# Check installed files
|
||||
pacman -Ql linux-patch-api
|
||||
|
||||
# Remove package
|
||||
sudo pacman -R linux-patch-api
|
||||
```
|
||||
|
||||
**Prerequisites:** `systemd` (included by default on Arch)
|
||||
|
||||
**Post-install:** The package automatically creates directories, copies example configs, enables the service, and prints next steps. Configure `/etc/linux_patch_api/config.yaml` and place TLS certificates in `/etc/linux_patch_api/certs/` before starting.
|
||||
|
||||
**Note:** Arch uses systemd by default. The install hook runs `systemctl enable` but does not start the service. You must configure before starting.
|
||||
|
||||
#### Alpine Linux (.apk)
|
||||
|
||||
```bash
|
||||
# Install the package
|
||||
sudo apk add --allow-unstable ./linux-patch-api-1.0.0-r0.apk
|
||||
|
||||
# Verify installation
|
||||
rc-service linux-patch-api status
|
||||
linux-patch-api --version
|
||||
|
||||
# Check installed files
|
||||
apk info -L linux-patch-api
|
||||
|
||||
# Remove package
|
||||
sudo apk del linux-patch-api
|
||||
```
|
||||
|
||||
**Prerequisites:** `openrc` (included by default on Alpine)
|
||||
|
||||
**Post-install:** The package automatically creates directories, copies example configs, adds the service to the default runlevel, and prints next steps. Configure `/etc/linux_patch_api/config.yaml` and place TLS certificates in `/etc/linux_patch_api/certs/` before starting.
|
||||
|
||||
**Important differences from systemd-based systems:**
|
||||
- Alpine uses **OpenRC** instead of systemd. Use `rc-service` commands instead of `systemctl`
|
||||
- Start service: `rc-service linux-patch-api start`
|
||||
- Stop service: `rc-service linux-patch-api stop`
|
||||
- Check status: `rc-service linux-patch-api status`
|
||||
- The service is added to the `default` runlevel automatically on install
|
||||
- Service init script: `/etc/init.d/linux-patch-api`
|
||||
|
||||
### Manual Installation
|
||||
|
||||
For systems without package manager support:
|
||||
|
||||
```bash
|
||||
# Run interactive installer (requires root)
|
||||
./install.sh
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
The installer will:
|
||||
- Detect operating system
|
||||
- Create system user and group
|
||||
- Set up directory structure
|
||||
- Install binary and configuration files
|
||||
- Create directory structure (`/etc/linux_patch_api/`, `/var/lib/linux_patch_api/`, `/var/log/linux_patch_api/`)
|
||||
- Install binary to `/usr/bin/linux-patch-api`
|
||||
- Install example configs
|
||||
- Configure systemd service
|
||||
- Set correct permissions
|
||||
|
||||
### Building from Source
|
||||
|
||||
#### Prerequisites (all platforms)
|
||||
|
||||
- Rust toolchain (stable channel, 1.75+)
|
||||
- OpenSSL development headers
|
||||
- systemd development headers
|
||||
- C compiler (gcc)
|
||||
|
||||
#### Build Debian Package (.deb)
|
||||
|
||||
```bash
|
||||
# Clone repository
|
||||
git clone https://gitea.internal/linux-patch-api.git
|
||||
cd linux-patch-api
|
||||
|
||||
# Build release binary
|
||||
cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
# Build Debian package
|
||||
dpkg-buildpackage -us -uc -b
|
||||
|
||||
# Or build RPM package
|
||||
rpmbuild -ba linux-patch-api.spec
|
||||
# On Debian/Ubuntu
|
||||
apt-get install -y build-essential debhelper pkg-config libsystemd-dev libssl-dev cargo rustc
|
||||
cargo build --release
|
||||
sudo dpkg-buildpackage -us -uc -b
|
||||
```
|
||||
|
||||
#### Build RPM Package (.rpm)
|
||||
|
||||
```bash
|
||||
# On Fedora/RHEL/CentOS
|
||||
dnf install -y rpm-build cargo rust gcc openssl-devel systemd-devel pkgconfig
|
||||
cargo build --release --target x86_64-unknown-linux-gnu
|
||||
chmod +x build-rpm.sh
|
||||
./build-rpm.sh
|
||||
```
|
||||
|
||||
**Note:** The RPM spec includes `BuildRequires` for native RPM build environments. When building in CI containers (where deps are pre-installed via apt-get), these are informational only.
|
||||
|
||||
#### Build Arch Package (.pkg.tar.zst)
|
||||
|
||||
```bash
|
||||
# On Arch Linux/Manjaro
|
||||
pacman -Syu --noconfirm rust cargo systemd git base-devel gcc
|
||||
cargo build --release
|
||||
chmod +x build-arch.sh
|
||||
SKIP_CARGO_BUILD=1 ./build-arch.sh
|
||||
```
|
||||
|
||||
**Note:** The build script creates a `builduser` for `makepkg` when running as root (typical in CI). The `.install` hook handles directory creation, config copying, and service enablement.
|
||||
|
||||
#### Build Alpine Package (.apk)
|
||||
|
||||
```bash
|
||||
# On Alpine Linux 3.18+
|
||||
apk add --no-cache alpine-sdk rust cargo openssl openssl-dev elogind-dev musl-dev abuild gcc
|
||||
cargo build --release --target x86_64-unknown-linux-musl
|
||||
chmod +x build-alpine.sh
|
||||
SKIP_CARGO_BUILD=1 ./build-alpine.sh
|
||||
```
|
||||
|
||||
**Important:** Alpine requires the `x86_64-unknown-linux-musl` target for static linking. The build script handles `abuild` key generation and runs as a `builduser` when executed as root.
|
||||
|
||||
See [BUILD_PACKAGES.md](./BUILD_PACKAGES.md) for detailed build instructions.
|
||||
|
||||
---
|
||||
|
||||
2
SPEC.md
2
SPEC.md
@ -169,7 +169,7 @@ The enrollment flow runs before mTLS server startup. On success, the daemon proc
|
||||
### Phase 1: Registration Request
|
||||
- **Identity Extraction:**
|
||||
- `/etc/machine-id` (fallback: `/var/lib/dbus/machine-id`)
|
||||
- FQDN from `/etc/hostname` → `hostname -f` → `hostname` → `localhost`
|
||||
- FQDN from `hostname -f` (validated contains `.`) → `hostname` + `hostname -d` → `/etc/hostname` → `hostname` → `localhost`
|
||||
- Non-loopback IPv4 addresses via network interface enumeration
|
||||
- OS details from `/etc/os-release` (distro, version, id_like, codename) + kernel version (`uname -r`)
|
||||
- **Submission:** Unauthenticated `POST /api/v1/enroll` to manager with identity payload
|
||||
|
||||
@ -44,27 +44,48 @@ else
|
||||
echo "Skipping cargo build (SKIP_CARGO_BUILD is set)"
|
||||
fi
|
||||
|
||||
# Create package directory in /home/builduser (accessible by builduser)
|
||||
PKGDIR=/home/builduser/apk-package
|
||||
mkdir -p "$PKGDIR"/usr/bin
|
||||
mkdir -p "$PKGDIR"/etc/linux_patch_api
|
||||
mkdir -p "$PKGDIR"/etc/init.d
|
||||
# Get version from Cargo.toml
|
||||
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*=.*"\([^"]*\)".*/\1/')
|
||||
|
||||
# Copy files
|
||||
# Create package directory structure
|
||||
PKGDIR=$(pwd)/apk-package
|
||||
rm -rf "$PKGDIR"
|
||||
mkdir -p "$PKGDIR"/usr/bin
|
||||
mkdir -p "$PKGDIR"/etc/linux_patch_api/certs
|
||||
mkdir -p "$PKGDIR"/etc/init.d
|
||||
mkdir -p "$PKGDIR"/var/lib/linux_patch_api
|
||||
mkdir -p "$PKGDIR"/var/log/linux_patch_api
|
||||
|
||||
# Copy binary
|
||||
chmod 755 target/x86_64-unknown-linux-musl/release/linux-patch-api
|
||||
cp target/x86_64-unknown-linux-musl/release/linux-patch-api "$PKGDIR"/usr/bin/
|
||||
chmod 755 "$PKGDIR"/usr/bin/linux-patch-api
|
||||
|
||||
# Copy OpenRC init script
|
||||
cp configs/linux-patch-api-openrc "$PKGDIR"/etc/init.d/linux-patch-api
|
||||
chmod 755 "$PKGDIR"/etc/init.d/linux-patch-api
|
||||
cp configs/whitelist.yaml.example "$PKGDIR"/etc/linux_patch_api/whitelist.yaml
|
||||
|
||||
# Use /home/builduser as workspace for APKBUILD
|
||||
WORKSPACE_DIR=/home/builduser
|
||||
# Copy example configs (as .example files - install script creates live configs)
|
||||
cp configs/config.yaml.example "$PKGDIR"/etc/linux_patch_api/config.yaml.example
|
||||
cp configs/whitelist.yaml.example "$PKGDIR"/etc/linux_patch_api/whitelist.yaml.example
|
||||
|
||||
# Create APKBUILD
|
||||
# Prepare workspace for abuild
|
||||
WORKSPACE_DIR=/home/builduser/repo
|
||||
mkdir -p "$WORKSPACE_DIR"
|
||||
|
||||
# Copy install script to workspace (must be co-located with APKBUILD)
|
||||
cp configs/linux-patch-api.apk-install "$WORKSPACE_DIR"/linux-patch-api.apk-install
|
||||
|
||||
# Copy package directory to workspace
|
||||
cp -r "$PKGDIR" "$WORKSPACE_DIR"/apk-package
|
||||
|
||||
# Copy entire repo to workspace for source references
|
||||
cp -r . "$WORKSPACE_DIR"/src/
|
||||
|
||||
# Create APKBUILD in workspace directory (co-located with install script)
|
||||
echo "Creating APKBUILD..."
|
||||
cat > APKBUILD << EOF
|
||||
cat > "$WORKSPACE_DIR"/APKBUILD << EOF
|
||||
pkgname=linux-patch-api
|
||||
pkgver=1.0.0
|
||||
pkgver=${VERSION}
|
||||
pkgrel=1
|
||||
pkgdesc="Secure remote package management API for Linux systems"
|
||||
url="https://gitea.moon-dragon.us/echo/linux_patch_api"
|
||||
@ -72,21 +93,24 @@ arch="x86_64"
|
||||
license="MIT"
|
||||
makedepends=""
|
||||
depends="openrc"
|
||||
install="linux-patch-api.apk-install"
|
||||
subpackages=""
|
||||
source=""
|
||||
|
||||
package() {
|
||||
install -d "\$pkgdir"/usr/bin
|
||||
install -d "\$pkgdir"/etc/linux_patch_api
|
||||
install -d "\$pkgdir"/etc/linux_patch_api/certs
|
||||
install -d "\$pkgdir"/etc/init.d
|
||||
cp -r ${WORKSPACE_DIR}/apk-package/usr/bin/* "\$pkgdir"/usr/bin/
|
||||
cp -r ${WORKSPACE_DIR}/apk-package/etc/linux_patch_api/* "\$pkgdir"/etc/linux_patch_api/
|
||||
cp -r ${WORKSPACE_DIR}/apk-package/etc/init.d/* "\$pkgdir"/etc/init.d/
|
||||
install -d "\$pkgdir"/var/lib/linux_patch_api
|
||||
install -d "\$pkgdir"/var/log/linux_patch_api
|
||||
|
||||
install -Dm755 "\$startdir"/apk-package/usr/bin/linux-patch-api "\$pkgdir"/usr/bin/linux-patch-api
|
||||
install -Dm755 "\$startdir"/apk-package/etc/init.d/linux-patch-api "\$pkgdir"/etc/init.d/linux-patch-api
|
||||
install -Dm644 "\$startdir"/apk-package/etc/linux_patch_api/config.yaml.example "\$pkgdir"/etc/linux_patch_api/config.yaml.example
|
||||
install -Dm644 "\$startdir"/apk-package/etc/linux_patch_api/whitelist.yaml.example "\$pkgdir"/etc/linux_patch_api/whitelist.yaml.example
|
||||
}
|
||||
EOF
|
||||
|
||||
# Generate checksums for APKBUILD sources
|
||||
echo "Generating checksums..."
|
||||
|
||||
# Build APK package
|
||||
echo "Building APK package..."
|
||||
|
||||
@ -96,10 +120,8 @@ if [ "$(id -u)" = "0" ]; then
|
||||
adduser -D -s /bin/sh builduser 2>/dev/null || true
|
||||
addgroup builduser abuild 2>/dev/null || usermod -aG abuild builduser
|
||||
|
||||
# Copy repo contents to builduser home (accessible directory)
|
||||
cp -r . /home/builduser/repo/
|
||||
chown -R builduser:builduser /home/builduser/repo/
|
||||
chown -R builduser:builduser /home/builduser/apk-package/
|
||||
# Set ownership of workspace
|
||||
chown -R builduser:builduser "$WORKSPACE_DIR"
|
||||
|
||||
# Set up builduser home directory for abuild
|
||||
mkdir -p /home/builduser/.abuild
|
||||
@ -115,32 +137,25 @@ if [ "$(id -u)" = "0" ]; then
|
||||
echo "PACKAGER_PRIVKEY=\"$KEYFILE\"" > /home/builduser/.abuild/abuild.conf
|
||||
chown builduser:builduser /home/builduser/.abuild/abuild.conf
|
||||
|
||||
# Copy APKBUILD and checksums to builduser home for abuild
|
||||
cp APKBUILD /home/builduser/
|
||||
cp .checksums /home/builduser/ 2>/dev/null || true
|
||||
|
||||
# Install public key BEFORE abuild (fixes UNTRUSTED signature)
|
||||
cp /home/builduser/.abuild/*.rsa.pub /etc/apk/keys/ 2>/dev/null || true
|
||||
|
||||
# Run abuild as builduser in /home/builduser where APKBUILD exists
|
||||
# Run abuild as builduser in workspace directory
|
||||
# Use || true because index update may fail but APK is still created
|
||||
su - builduser -c "cd /home/builduser && abuild checksum && abuild -d -F" || true
|
||||
su - builduser -c "cd $WORKSPACE_DIR && abuild checksum && abuild -d -F" || true
|
||||
|
||||
# Copy APK from builduser packages to releases
|
||||
mkdir -p releases
|
||||
cp /home/builduser/packages/x86_64/*.apk releases/ 2>/dev/null || cp /home/builduser/packages/*.apk releases/ 2>/dev/null || find /home/builduser/packages -name "*.apk" -exec cp {} releases/ \; 2>/dev/null || true
|
||||
else
|
||||
cd "$WORKSPACE_DIR"
|
||||
abuild checksum
|
||||
abuild -F -r
|
||||
cd -
|
||||
mkdir -p releases
|
||||
cp ~/packages/x86_64/*.apk releases/ 2>/dev/null || cp ~/packages/*.apk releases/ 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Copy to releases directory (fallback for non-root builds)
|
||||
echo ""
|
||||
echo "Copying package to releases/..."
|
||||
mkdir -p releases
|
||||
cp ~/packages/x86_64/*.apk releases/ 2>/dev/null || cp ~/packages/*.apk releases/ 2>/dev/null || find ~/packages -name "*.apk" -exec cp {} releases/ \; 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "=== Build Complete ==="
|
||||
echo "Package: releases/linux-patch-api-*.apk"
|
||||
|
||||
@ -22,43 +22,68 @@ else
|
||||
echo "Skipping cargo build (SKIP_CARGO_BUILD is set)"
|
||||
fi
|
||||
|
||||
# Create package directory
|
||||
# Create package directory structure
|
||||
PKGDIR=$(pwd)/arch-package
|
||||
rm -rf "$PKGDIR"
|
||||
mkdir -p "$PKGDIR"/usr/bin
|
||||
mkdir -p "$PKGDIR"/etc/linux_patch_api
|
||||
mkdir -p "$PKGDIR"/etc/linux_patch_api/certs
|
||||
mkdir -p "$PKGDIR"/usr/lib/systemd/system
|
||||
mkdir -p "$PKGDIR"/var/lib/linux_patch_api
|
||||
mkdir -p "$PKGDIR"/var/log/linux_patch_api
|
||||
|
||||
# Copy files
|
||||
# Copy binary
|
||||
chmod 755 target/release/linux-patch-api
|
||||
cp target/release/linux-patch-api "$PKGDIR"/usr/bin/
|
||||
chmod 755 "$PKGDIR"/usr/bin/linux-patch-api
|
||||
|
||||
# Copy systemd service
|
||||
cp configs/linux-patch-api.service "$PKGDIR"/usr/lib/systemd/system/
|
||||
cp configs/config.yaml.example "$PKGDIR"/etc/linux_patch_api/config.yaml
|
||||
cp configs/whitelist.yaml.example "$PKGDIR"/etc/linux_patch_api/whitelist.yaml
|
||||
|
||||
# Copy example configs (as .example files - install script creates live configs)
|
||||
cp configs/config.yaml.example "$PKGDIR"/etc/linux_patch_api/config.yaml.example
|
||||
cp configs/whitelist.yaml.example "$PKGDIR"/etc/linux_patch_api/whitelist.yaml.example
|
||||
|
||||
# Copy install script to current directory (must be co-located with PKGBUILD)
|
||||
cp configs/linux-patch-api.install linux-patch-api.install
|
||||
|
||||
# Get version from Cargo.toml
|
||||
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*=.*"\([^"]*\)".*/\1/')
|
||||
|
||||
# Create PKGBUILD with quoted heredoc to prevent $pkgdir expansion
|
||||
# $pkgdir must be literal for makepkg to expand at runtime
|
||||
echo "Creating PKGBUILD..."
|
||||
cat > PKGBUILD << 'EOF'
|
||||
pkgname=linux-patch-api
|
||||
pkgver=1.0.0
|
||||
pkgver=VERSION_PLACEHOLDER
|
||||
pkgrel=1
|
||||
pkgdesc="Secure remote package management API for Linux systems"
|
||||
url="https://gitea.moon-dragon.us/echo/linux_patch_api"
|
||||
arch=('x86_64')
|
||||
license=('MIT')
|
||||
depends=('systemd')
|
||||
install=linux-patch-api.install
|
||||
source=()
|
||||
backup=(
|
||||
'etc/linux_patch_api/config.yaml'
|
||||
'etc/linux_patch_api/whitelist.yaml'
|
||||
)
|
||||
|
||||
package() {
|
||||
cp -r /home/builduser/repo/arch-package/* "$pkgdir"/
|
||||
# Use $startdir because arch-package is co-located with PKGBUILD, not in sources
|
||||
cp -r "$startdir"/arch-package/* "$pkgdir"/
|
||||
|
||||
# Ensure directories exist with proper structure
|
||||
mkdir -p "$pkgdir"/etc/linux_patch_api/certs
|
||||
mkdir -p "$pkgdir"/var/lib/linux_patch_api
|
||||
mkdir -p "$pkgdir"/var/log/linux_patch_api
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create .SRCINFO
|
||||
echo "Creating .SRCINFO..."
|
||||
# Replace version placeholder with actual version
|
||||
sed -i "s/VERSION_PLACEHOLDER/$VERSION/" PKGBUILD
|
||||
|
||||
echo "PKGBUILD version: $VERSION"
|
||||
|
||||
# Build package
|
||||
echo "Building Arch package..."
|
||||
|
||||
# For CI environments where we may run as root
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
echo "Running as root - creating build user for makepkg..."
|
||||
@ -69,12 +94,22 @@ if [ "$(id -u)" = "0" ]; then
|
||||
cp -r . /home/builduser/repo/
|
||||
chown -R builduser:builduser /home/builduser/repo/
|
||||
|
||||
# Create source tarball for makepkg
|
||||
# makepkg expects sources to be in $srcdir after extraction
|
||||
# We create a tarball of arch-package so %autosetup or prepare can extract it
|
||||
cd /home/builduser/repo
|
||||
|
||||
su - builduser -c "cd /home/builduser/repo && makepkg --printsrcinfo > .SRCINFO"
|
||||
su - builduser -c "cd /home/builduser/repo && makepkg -f --noconfirm"
|
||||
|
||||
# Copy package to releases
|
||||
mkdir -p /home/builduser/repo/releases
|
||||
cp /home/builduser/repo/*.pkg.tar.zst /home/builduser/repo/releases/ 2>/dev/null || true
|
||||
cd -
|
||||
|
||||
# Copy releases back to original directory
|
||||
mkdir -p releases
|
||||
cp /home/builduser/repo/*.pkg.tar.zst releases/
|
||||
cp /home/builduser/repo/releases/*.pkg.tar.zst releases/ 2>/dev/null || true
|
||||
else
|
||||
makepkg --printsrcinfo > .SRCINFO
|
||||
makepkg -f --noconfirm
|
||||
|
||||
19
build-rpm.sh
Executable file → Normal file
19
build-rpm.sh
Executable file → Normal file
@ -21,27 +21,38 @@ if ! command -v rpmbuild &> /dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get version from Cargo.toml
|
||||
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*=.*"\([^"]*\)".*/\1/')
|
||||
echo "Building version: $VERSION"
|
||||
|
||||
# Setup RPM build directory structure
|
||||
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
|
||||
|
||||
# Create source tarball (required by %autosetup in spec file)
|
||||
echo "Creating source tarball..."
|
||||
VERSION="1.0.0"
|
||||
TMPDIR=$(mktemp -d)
|
||||
mkdir -p "$TMPDIR/linux-patch-api-${VERSION}"
|
||||
# Copy files excluding unwanted directories using find
|
||||
|
||||
# Copy files excluding unnecessary directories
|
||||
cp -r . "$TMPDIR/linux-patch-api-${VERSION}/"
|
||||
|
||||
# Remove unnecessary directories from tarball
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/target"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.git"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/releases"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.github"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/debian"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/arch-package"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.abuild"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/apk-package"
|
||||
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.a0proj"
|
||||
|
||||
tar -czf ~/rpmbuild/SOURCES/linux-patch-api-${VERSION}.tar.gz -C "$TMPDIR" "linux-patch-api-${VERSION}"
|
||||
rm -rf "$TMPDIR"
|
||||
|
||||
# Copy spec file
|
||||
# Prepare spec file with dynamic version
|
||||
echo "Preparing spec file..."
|
||||
cp linux-patch-api.spec ~/rpmbuild/SPECS/
|
||||
sed "s/VERSION_PLACEHOLDER/$VERSION/" linux-patch-api.spec > ~/rpmbuild/SPECS/linux-patch-api.spec
|
||||
|
||||
# Build RPM
|
||||
echo "Building RPM package..."
|
||||
|
||||
@ -1,54 +1,5 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIJtTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQOJY6BZQMTvXCEBl6
|
||||
Rv+0fQICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEJwoQf7hSIurtiBM
|
||||
nm+YEhwEgglQiyNTxNNkeZ8hikGe3m+2cfXtAituVJYgs4V+bgTJXnrJVaFyPoRw
|
||||
Nde/m9vJU4EGaRwS7Sb89XsjFK+Qbc6+2mvBqhkoBIjXBjYsiqNlLStLUIf1IPdU
|
||||
HHHxrOSnkNIXaiEojEIb4SLHYsmwSGbHPCmr+sIvzRDo/tuc0ugTDJFoS4lhDy6r
|
||||
VsPuDsV3XTnyPTWlHgROr1DmwqhTa87PXkpiomFxw1/Jy+2D0tQ+PuhTlGh87q2r
|
||||
T+ZHOLf8GLMKxKL7Elup/ugT+qfK0FekKJV+1Pw8EL+vWmJMLvhk+tlO9b4WxOlD
|
||||
UiW98mf6ospzpbmVf/AkaI5mkeAaikp7XMim57bUDBbNT3YQWBgwjVR01n7nCKk/
|
||||
2hYcaDEJGv6KuU3utlVhSIF1OuIJR42q7AJuOmM22yAHJ7KOkcoXFcNsJuVqAeDc
|
||||
BcVMMEgrHuLdnlHTzUy+0ETFAiTTQE/8+RYHPi0t0LOgalJBVZN4kR8OvCXiTrfw
|
||||
J6Ex7BvRM7MisS9lNfzCoMaN84/tEdwVTc0USEYvY4mQGV5xINN9ehNgfnw5leMW
|
||||
n0+oFtNXeslV84xVVz/X0pSD5G4NiyOAVBD44jHowRHJqPMaWs38xFVNStjCyThX
|
||||
L6lq8ZcFMOLzswvPjBKpb+XlSwETDMGEXbhiOop/CYT2YLwjWH7Vu7rZ1kL553pp
|
||||
DUOmGRgSfeabKZeyePxh3Pz5uqmKtuX3WGmyeCX/bneDXVASJwCAe+HGFC0cy5JL
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9
|
||||
F6P1SXfoeE8DtUpBhu5XlJyIwcWANkstATrXxyZLA7IdLLgSPZXSwAWxLwCN0ypM
|
||||
Jnscfvkr2SW8OwpJ8/mA/SX88ZC28Uvp1egsgnM1k9Z7Oinxgk9a7LNUv0qxBc7k
|
||||
SuooMBJvuiqHOzTr3IJvpCkZykvbnYbDgtypxVOeWO257yxer/ora9NVX84pfprU
|
||||
7JbOpBGMY6FUAcONmBYikGyGeNsF9zsPcdSOdUKP7tlrncYughORsb/FkNq7LSbo
|
||||
ll+tRCu/7Xb+VEctDQhk1fJ+ojFzC0P9duRWcskIVWFbSj6r21hzdhKOMX6bXLhA
|
||||
NcNpSk3EHqDij4rMbaAqSs5W2Q4JTUJ6L0/OOy9aeckbXw/j31OdYnR5wM7nvXrH
|
||||
tv89sXX/ObNJFD5uPRMPvoACv2oTsgWtm4sNkapAeiOcovPCWSroyzc=
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg46Ewu04V/qVbFIaW
|
||||
ll6hUNA1ocfdND68cRv6GiOBikyhRANCAARORR0UUR6G6ndxeefpKai+82eH58ud
|
||||
sW5qox3Ed4I0WF12RcSwioAPrt5WNB+ptw0wvzx78wH8CdkqjyUb7Koc
|
||||
-----END PRIVATE KEY-----
|
||||
|
||||
@ -1,31 +1,12 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFVzCCAz+gAwIBAgIUO/u3nWWJUG+i/cwM8o/1fkLzfbAwDQYJKoZIhvcNAQEL
|
||||
BQAwOzEZMBcGA1UEAwwQTGludXhQYXRjaEFQSSBDQTERMA8GA1UECgwISW50ZXJu
|
||||
YWwxCzAJBgNVBAYTAlVTMB4XDTI2MDQwOTIwMTM1MloXDTM2MDQwNjIwMTM1Mlow
|
||||
OzEZMBcGA1UEAwwQTGludXhQYXRjaEFQSSBDQTERMA8GA1UECgwISW50Z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yUb7Koco0MwQTAP
|
||||
BgNVHQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBTcLRFILwfBbjqUm3fT8AzIAN5mQDAP
|
||||
BgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMCA0gAMEUCIQDMHR7n6plBEz7tP9Si
|
||||
Cs6Rk8m2gt9CL6qHlkeWiDJmtgIgVXrj2Lmqn1dEuKbVu9LaxPyvXU4/t2etWHgJ
|
||||
lfK+SS8=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
@ -1 +1 @@
|
||||
790CDB9FA2002BF59B3EE88AF326CB060353D111
|
||||
790CDB9FA2002BF59B3EE88AF326CB060353D113
|
||||
|
||||
@ -1,16 +1,8 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICeTCCAWECAQAwNDESMBAGA1UEAwwJY2xpZW50MDAxMREwDwYDVQQKDAhJbnRl
|
||||
cm5hbDELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
|
||||
AQC9Tida4so5qerRjEQXQQJb/W4jCsRwZg6lSvvd9qEtqWuwxX+SFfNbcpDOOZTh
|
||||
+CWmmCq9v5ZO+XyO/s9xKLnyudnkT/nymB6KFN3XywfDE2iiGshNVNd5d0B4nF7e
|
||||
nXeoF938GF5/ny4dkGgg+HoXXrQJ1WGjODXJsXtiiMZPI08kZL4vuYW64VojHvUf
|
||||
AQdEjGqlIZzNW909g0uaQEizpZwJvH7YGvWuQDx9ywbWrs1t3hHu2ahA+myVXL3Y
|
||||
C7+jAmROQ61FHW2F4swS+uRQDTEr9qQs256JCryzHCTma8IWmYqphM9wn18f5Tm7
|
||||
EXw4EHCz5FVL7HPL1vZnQdsrAgMBAAGgADANBgkqhkiG9w0BAQsFAAOCAQEAH46n
|
||||
SxI9O21jO1q2cmFlZano5JWAo3eb424+3jCYgAJDBUtlzTLfdkADvttaTtAjI8sh
|
||||
GqbUFsCtO4UlPD5SWFnPdUQqJ+zv1lXDyef0D694mUjgrjtdB27l9wmTnHZVwgcL
|
||||
GEr8nfuhqNNjARmWUJUv629slt0RDZxGm0IXGJBrx39t31oh0q1ll4rPvd9TEiLZ
|
||||
sP8r5WdC2PdFLh13J6erLkoMOOLmM/mXj1egz+ivgqo2uXDX1crBlNH0H1KM05ot
|
||||
c5wJo3mzbRC/3PWLLJHKwQ6ObI88AviGEMevIw54jdz2UHXPv0aK2SSoIDr6GhUi
|
||||
0OBKrqsjBII7l+w+Rw==
|
||||
MIH7MIGhAgEAMD8xHTAbBgNVBAMMFHBhdGNoLW1hbmFnZXItY2xpZW50MREwDwYD
|
||||
VQQKDAhJbnRlcm5hbDELMAkGA1UEBhMCVVMwWTATBgcqhkjOPQIBBggqhkjOPQMB
|
||||
BwNCAAQauACwaR4SyVoHEPviQgV0I4fbyFuGoHiQExzpYf9Ta025dy88T/a6qG6G
|
||||
TYJMtbRSjP/piLWfZ/2ze2AdbmczoAAwCgYIKoZIzj0EAwIDSQAwRgIhAJ/BBYsB
|
||||
aIhKjdwRr0vTqtYPKeeyO2rzHuyRnSvKKkdOAiEA94zCvG0FzkFiqGKT1oHGCVf9
|
||||
qZdkjkodRAUk6/4S2AU=
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
|
||||
@ -1,28 +1,5 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC9Tida4so5qerR
|
||||
jEQXQQJb/W4jCsRwZg6lSvvd9qEtqWuwxX+SFfNbcpDOOZTh+CWmmCq9v5ZO+XyO
|
||||
/s9xKLnyudnkT/nymB6KFN3XywfDE2iiGshNVNd5d0B4nF7enXeoF938GF5/ny4d
|
||||
kGgg+HoXXrQJ1WGjODXJsXtiiMZPI08kZL4vuYW64VojHvUfAQdEjGqlIZzNW909
|
||||
g0uaQEizpZwJvH7YGvWuQDx9ywbWrs1t3hHu2ahA+myVXL3YC7+jAmROQ61FHW2F
|
||||
4swS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W46lJt30/AMyADeZkAwCgYIKoZIzj0EAwIDSAAwRQIhAJ4jy8W2hbqK
|
||||
kiTI9aYS+xwMJlxH6cFJaKplrA+a5Ay8AiANPJdJN9ucgCsq/N3Ai6kO89rcXy8Z
|
||||
60kvNNc3Zg/Oog==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
@ -57,3 +57,17 @@ package_manager:
|
||||
# # Maximum number of polling attempts before giving up
|
||||
# # Default: 1440 (24 hours at 60s intervals = 86400 seconds total)
|
||||
# max_poll_attempts: 1440
|
||||
# # Network interface whose IPv4 address is reported to the manager.
|
||||
# # Overrides auto-detection when the wrong IP is selected (e.g., Docker bridge).
|
||||
# # Example: "eth0", "ens192", "enp0s3"
|
||||
# report_interface: "eth0"
|
||||
# # Explicit IPv4 address reported to the manager.
|
||||
# # Highest priority — overrides both report_interface and route-based selection.
|
||||
# # Useful when the host has multiple IPs or runs inside a container.
|
||||
# report_ip: "192.168.3.36"
|
||||
# # Route-based IP selection is enabled by default when manager_url is set.
|
||||
# The agent resolves the manager hostname to an IP, then uses `ip route get <manager_ip>`
|
||||
# to determine which local source IP the kernel would use to reach the manager.
|
||||
# This is the most accurate method for multi-homed hosts because it queries
|
||||
# the kernel routing table directly.
|
||||
# Priority order: report_ip > report_interface > route-based > auto-detect
|
||||
|
||||
81
configs/linux-patch-api.apk-install
Normal file
81
configs/linux-patch-api.apk-install
Normal file
@ -0,0 +1,81 @@
|
||||
#!/bin/sh
|
||||
# Alpine Linux install hooks for linux-patch-api
|
||||
# Matches Debian preinst/postinst behavior: no system user, root:root ownership
|
||||
# Alpine APKBUILD install script format: pre-install, post-install, pre-deinstall, post-deinstall
|
||||
|
||||
# Pre-install: Create directories before files are laid down
|
||||
pre_install() {
|
||||
# Create required directories
|
||||
mkdir -p /etc/linux_patch_api/certs
|
||||
mkdir -p /var/lib/linux_patch_api
|
||||
mkdir -p /var/log/linux_patch_api
|
||||
|
||||
# Set proper ownership (service runs as root)
|
||||
chown -R root:root /var/lib/linux_patch_api
|
||||
chown -R root:root /var/log/linux_patch_api
|
||||
|
||||
# Set secure permissions
|
||||
chmod 750 /etc/linux_patch_api
|
||||
chmod 750 /etc/linux_patch_api/certs
|
||||
chmod 755 /var/lib/linux_patch_api
|
||||
chmod 755 /var/log/linux_patch_api
|
||||
|
||||
echo "Pre-installation setup completed"
|
||||
}
|
||||
|
||||
# Post-install: Copy example configs, enable service
|
||||
post_install() {
|
||||
# Copy example configs if they don't exist
|
||||
if [ ! -f "/etc/linux_patch_api/config.yaml" ]; then
|
||||
if [ -f "/etc/linux_patch_api/config.yaml.example" ]; then
|
||||
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
||||
chmod 640 /etc/linux_patch_api/config.yaml
|
||||
chown root:root /etc/linux_patch_api/config.yaml
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
||||
if [ -f "/etc/linux_patch_api/whitelist.yaml.example" ]; then
|
||||
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
||||
chmod 640 /etc/linux_patch_api/whitelist.yaml
|
||||
chown root:root /etc/linux_patch_api/whitelist.yaml
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable the service (but don't start automatically - admin should configure first)
|
||||
rc-update add linux-patch-api default
|
||||
|
||||
echo ""
|
||||
echo "linux-patch-api installed successfully!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Configure /etc/linux_patch_api/config.yaml with your settings"
|
||||
echo " 2. Place TLS certificates in /etc/linux_patch_api/certs/"
|
||||
echo " 3. Configure IP whitelist in /etc/linux_patch_api/whitelist.yaml"
|
||||
echo " 4. Start the service: rc-service linux-patch-api start"
|
||||
echo " 5. Check status: rc-service linux-patch-api status"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Pre-deinstall: Stop and disable service before files are removed
|
||||
pre_deinstall() {
|
||||
# Stop the service if running
|
||||
if rc-service linux-patch-api status >/dev/null 2>&1; then
|
||||
rc-service linux-patch-api stop
|
||||
echo "Service stopped"
|
||||
else
|
||||
echo "Service was not running"
|
||||
fi
|
||||
|
||||
# Disable the service
|
||||
rc-update del linux-patch-api default 2>/dev/null || true
|
||||
}
|
||||
|
||||
# Post-deinstall: Clean up on removal
|
||||
post_deinstall() {
|
||||
# Remove directories only if empty (preserve user data on reinstall)
|
||||
rmdir /var/lib/linux_patch_api 2>/dev/null || true
|
||||
rmdir /var/log/linux_patch_api 2>/dev/null || true
|
||||
|
||||
echo "linux-patch-api removed"
|
||||
}
|
||||
81
configs/linux-patch-api.install
Normal file
81
configs/linux-patch-api.install
Normal file
@ -0,0 +1,81 @@
|
||||
# Arch Linux install hooks for linux-patch-api
|
||||
# Matches Debian preinst/postinst behavior: no system user, root:root ownership
|
||||
|
||||
post_install() {
|
||||
# Create required directories
|
||||
mkdir -p /etc/linux_patch_api/certs
|
||||
mkdir -p /var/lib/linux_patch_api
|
||||
mkdir -p /var/log/linux_patch_api
|
||||
|
||||
# Set proper ownership (service runs as root)
|
||||
chown -R root:root /var/lib/linux_patch_api
|
||||
chown -R root:root /var/log/linux_patch_api
|
||||
|
||||
# Set secure permissions
|
||||
chmod 750 /etc/linux_patch_api
|
||||
chmod 750 /etc/linux_patch_api/certs
|
||||
chmod 755 /var/lib/linux_patch_api
|
||||
chmod 755 /var/log/linux_patch_api
|
||||
|
||||
# Copy example configs if they don't exist
|
||||
if [ ! -f "/etc/linux_patch_api/config.yaml" ]; then
|
||||
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
||||
chmod 640 /etc/linux_patch_api/config.yaml
|
||||
chown root:root /etc/linux_patch_api/config.yaml
|
||||
fi
|
||||
|
||||
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
||||
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
||||
chmod 640 /etc/linux_patch_api/whitelist.yaml
|
||||
chown root:root /etc/linux_patch_api/whitelist.yaml
|
||||
fi
|
||||
|
||||
# Reload systemd daemon
|
||||
systemctl daemon-reload
|
||||
|
||||
# Enable the service (but don't start automatically - admin should configure first)
|
||||
systemctl enable linux-patch-api.service
|
||||
|
||||
echo ""
|
||||
echo "linux-patch-api installed successfully!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Configure /etc/linux_patch_api/config.yaml with your settings"
|
||||
echo " 2. Place TLS certificates in /etc/linux_patch_api/certs/"
|
||||
echo " 3. Configure IP whitelist in /etc/linux_patch_api/whitelist.yaml"
|
||||
echo " 4. Start the service: systemctl start linux-patch-api"
|
||||
echo " 5. Check status: systemctl status linux-patch-api"
|
||||
echo ""
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
# Reload systemd daemon on upgrade
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
pre_remove() {
|
||||
# Stop the service before removal
|
||||
if systemctl is-active --quiet linux-patch-api.service; then
|
||||
systemctl stop linux-patch-api.service
|
||||
echo "Service stopped successfully"
|
||||
else
|
||||
echo "Service was not running"
|
||||
fi
|
||||
|
||||
# Disable the service
|
||||
if systemctl is-enabled --quiet linux-patch-api.service 2>/dev/null; then
|
||||
systemctl disable linux-patch-api.service
|
||||
echo "Service disabled"
|
||||
fi
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
# Reload systemd to remove service file
|
||||
systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
# Remove directories only if empty (preserve user data on upgrade/reinstall)
|
||||
rmdir --ignore-fail-on-non-empty /var/lib/linux_patch_api 2>/dev/null || true
|
||||
rmdir --ignore-fail-on-non-empty /var/log/linux_patch_api 2>/dev/null || true
|
||||
|
||||
echo "linux-patch-api removed"
|
||||
}
|
||||
46
debian/changelog
vendored
46
debian/changelog
vendored
@ -1,3 +1,49 @@
|
||||
linux-patch-api (1.1.9-1) unstable; urgency=low
|
||||
|
||||
* Fix non-Ubuntu packages: align Arch, RPM, Alpine with Debian baseline
|
||||
* Remove system user creation (service runs as root)
|
||||
* Fix ownership to root:root across all platforms
|
||||
* Fix Alpine: co-locate install script with APKBUILD
|
||||
* Fix Arch: correct $startdir path in PKGBUILD
|
||||
* Fix RPM: add runtime deps, comment BuildRequires for CI
|
||||
* Add comprehensive installation docs for all platforms
|
||||
|
||||
-- Echo <echo@moon-dragon.us> Tue, 19 May 2026 21:54:00 -0500
|
||||
|
||||
linux-patch-api (1.1.8-1) unstable; urgency=low
|
||||
|
||||
* Fix FQDN resolution: prioritize hostname -f over /etc/hostname for full domain
|
||||
* Fix display_name blank: add hostname field to enrollment request
|
||||
* Fix Arch package: add install scripts, user creation, directory creation
|
||||
* Fix Alpine package: add install scripts, user creation, missing config.yaml
|
||||
* Fix RPM package: dynamic version, config handling, tarball exclusions
|
||||
|
||||
-- Echo <echo@moon-dragon.us> Mon, 18 May 2026 19:34:00 -0500
|
||||
|
||||
linux-patch-api (1.1.7-1) unstable; urgency=low
|
||||
|
||||
* Fix CI pipeline: add cargo clean and remove old .deb artifacts before packaging
|
||||
* Bump version to 1.1.7 to ensure clean build with correct binary
|
||||
|
||||
-- Echo <echo@moon-dragon.us> Mon, 18 May 2026 12:20:00 -0500
|
||||
|
||||
linux-patch-api (1.1.6-1) unstable; urgency=low
|
||||
|
||||
* Fix rustls CryptoProvider initialization panic on server startup
|
||||
* Add explicit CryptoProvider::install_default() for aws-lc-rs
|
||||
|
||||
-- Echo <echo@moon-dragon.us> Mon, 18 May 2026 08:45:00 -0500
|
||||
|
||||
linux-patch-api (1.1.5-1) unstable; urgency=low
|
||||
|
||||
* Fix enrollment IP detection: filter Docker bridge subnets (172.16.0.0/12)
|
||||
* Fix enrollment IP detection: filter link-local addresses (169.254.0.0/16)
|
||||
* Add report_interface and report_ip config options for explicit IP override
|
||||
* Add route-based IP selection using kernel routing table
|
||||
* Fix package versioning to derive from Cargo.toml
|
||||
|
||||
-- Echo <echo@moon-dragon.us> Sun, 18 May 2026 02:00:00 -0500
|
||||
|
||||
linux-patch-api (0.3.12-1) unstable; urgency=low
|
||||
|
||||
* Fix socket activation detection to use resolved service name
|
||||
|
||||
0
debian/rules
vendored
Normal file → Executable file
0
debian/rules
vendored
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
%global debug_package %{nil}
|
||||
|
||||
Name: linux-patch-api
|
||||
Version: 1.0.0
|
||||
Version: VERSION_PLACEHOLDER
|
||||
Release: 1%{?dist}
|
||||
Summary: Secure remote package management API for Linux systems
|
||||
License: MIT
|
||||
@ -10,19 +10,22 @@ Source0: linux-patch-api-%{version}.tar.gz
|
||||
BuildArch: x86_64
|
||||
|
||||
# Build requirements
|
||||
# NOTE: Building in Debian container (node:18) - apt packages don't register in RPM db
|
||||
# Build tools ARE available (installed via apt-get in ci.yml), just won't validate
|
||||
# NOTE: CI uses rustup to install cargo/rust, so they are NOT available as RPM packages.
|
||||
# Only uncomment BuildRequires for native RPM build environments where cargo/rust
|
||||
# are installed via dnf/yum package manager.
|
||||
# BuildRequires: cargo >= 1.75
|
||||
# BuildRequires: rust >= 1.75
|
||||
# BuildRequires: systemd-rpm-macros # Handling systemd manually
|
||||
# BuildRequires: pkgconfig(systemd)
|
||||
# BuildRequires: gcc
|
||||
# BuildRequires: openssl-devel
|
||||
# BuildRequires: systemd-devel
|
||||
# BuildRequires: pkgconfig(systemd)
|
||||
|
||||
# Runtime requirements
|
||||
Requires: systemd
|
||||
Requires: libsystemd
|
||||
Requires: openssl-libs
|
||||
Requires: ca-certificates
|
||||
|
||||
# Description
|
||||
%description
|
||||
Linux Patch API provides a secure, mTLS-authenticated REST API for
|
||||
remote package management operations including:
|
||||
@ -69,28 +72,16 @@ cp configs/config.yaml.example %{buildroot}/etc/linux_patch_api/config.yaml.exam
|
||||
cp configs/whitelist.yaml.example %{buildroot}/etc/linux_patch_api/whitelist.yaml.example
|
||||
chmod 644 %{buildroot}/etc/linux_patch_api/*.example
|
||||
|
||||
# Pre-installation script
|
||||
# Pre-installation script - create directories (matches Debian preinst)
|
||||
%pre
|
||||
# Create system group
|
||||
getent group linux-patch-api > /dev/null || groupadd --system linux-patch-api
|
||||
|
||||
# Create system user
|
||||
getent passwd linux-patch-api > /dev/null || useradd --system \
|
||||
--gid linux-patch-api \
|
||||
--home-dir /var/lib/linux_patch_api \
|
||||
--no-create-home \
|
||||
--shell /usr/sbin/nologin \
|
||||
--comment "Linux Patch API Service" \
|
||||
linux-patch-api
|
||||
|
||||
# Create required directories
|
||||
mkdir -p /etc/linux_patch_api/certs
|
||||
mkdir -p /var/lib/linux_patch_api
|
||||
mkdir -p /var/log/linux_patch_api
|
||||
|
||||
# Set proper ownership
|
||||
chown -R linux-patch-api:linux-patch-api /var/lib/linux_patch_api
|
||||
chown -R linux-patch-api:linux-patch-api /var/log/linux_patch_api
|
||||
# Set proper ownership (service runs as root)
|
||||
chown -R root:root /var/lib/linux_patch_api
|
||||
chown -R root:root /var/log/linux_patch_api
|
||||
|
||||
# Set secure permissions
|
||||
chmod 750 /etc/linux_patch_api
|
||||
@ -98,19 +89,19 @@ chmod 750 /etc/linux_patch_api/certs
|
||||
chmod 755 /var/lib/linux_patch_api
|
||||
chmod 755 /var/log/linux_patch_api
|
||||
|
||||
# Post-installation script
|
||||
# Post-installation script - copy configs, enable service (matches Debian postinst)
|
||||
%post
|
||||
# Copy example configs if they don't exist
|
||||
if [ ! -f "/etc/linux_patch_api/config.yaml" ]; then
|
||||
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
||||
chmod 640 /etc/linux_patch_api/config.yaml
|
||||
chown linux-patch-api:linux-patch-api /etc/linux_patch_api/config.yaml
|
||||
chown root:root /etc/linux_patch_api/config.yaml
|
||||
fi
|
||||
|
||||
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
||||
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
||||
chmod 640 /etc/linux_patch_api/whitelist.yaml
|
||||
chown linux-patch-api:linux-patch-api /etc/linux_patch_api/whitelist.yaml
|
||||
chown root:root /etc/linux_patch_api/whitelist.yaml
|
||||
fi
|
||||
|
||||
# Reload systemd daemon
|
||||
@ -162,6 +153,8 @@ fi
|
||||
/lib/systemd/system/linux-patch-api.service
|
||||
%config(noreplace) /etc/linux_patch_api/config.yaml.example
|
||||
%config(noreplace) /etc/linux_patch_api/whitelist.yaml.example
|
||||
%ghost %config(noreplace) /etc/linux_patch_api/config.yaml
|
||||
%ghost %config(noreplace) /etc/linux_patch_api/whitelist.yaml
|
||||
%dir /etc/linux_patch_api
|
||||
%dir /etc/linux_patch_api/certs
|
||||
%dir /var/lib/linux_patch_api
|
||||
@ -169,7 +162,27 @@ fi
|
||||
|
||||
# Changelog
|
||||
%changelog
|
||||
* Thu Apr 09 2026 Echo <echo@moon-dragon.us> - 1.0.0-1
|
||||
* Tue May 19 2026 Echo <echo@moon-dragon.us> - 1.1.9-1
|
||||
- Fix non-Ubuntu packages: align Arch, RPM, Alpine with Debian baseline
|
||||
- Remove system user creation (service runs as root)
|
||||
- Fix ownership to root:root across all platforms
|
||||
- Fix Alpine: co-locate install script with APKBUILD
|
||||
- Fix Arch: correct $startdir path in PKGBUILD
|
||||
- Fix RPM: add runtime deps, comment BuildRequires for CI
|
||||
- Add comprehensive installation docs for all platforms
|
||||
|
||||
* Tue May 19 2026 Echo <echo@moon-dragon.us> - 1.1.8-1
|
||||
- Fix RPM packaging: runtime deps, match Debian install behavior, comment BuildRequires for CI
|
||||
- Remove system user creation (service runs as root per systemd unit)
|
||||
- Fix ownership to root:root matching Debian package
|
||||
- Add openssl-libs and ca-certificates runtime dependencies
|
||||
|
||||
* Mon May 18 2026 Echo <echo@moon-dragon.us> - 1.1.8-1
|
||||
- Fix FQDN resolution: prioritize hostname -f over /etc/hostname
|
||||
- Fix display_name blank: add hostname field to enrollment request
|
||||
- Fix Arch/Alpine/RPM packaging: install scripts, user creation, directory creation
|
||||
|
||||
* Thu Apr 09 2026 Echo <echo@moon-dragon.us> - 1.1.7-1
|
||||
- Initial production release
|
||||
- Secure mTLS-authenticated REST API for remote package management
|
||||
- 15 API endpoints for package install/remove, patch application, system management
|
||||
|
||||
@ -114,6 +114,14 @@ pub struct EnrollmentConfig {
|
||||
pub polling_interval_seconds: u64,
|
||||
#[serde(default = "default_max_poll_attempts")]
|
||||
pub max_poll_attempts: u32,
|
||||
/// Network interface whose IPv4 address is reported to the manager.
|
||||
/// Overrides auto-detection. Example: `"eth0"`, `"ens192"`.
|
||||
#[serde(default)]
|
||||
pub report_interface: Option<String>,
|
||||
/// Explicit IPv4 address reported to the manager.
|
||||
/// Highest priority — overrides both `report_interface` and auto-detect.
|
||||
#[serde(default)]
|
||||
pub report_ip: Option<String>,
|
||||
}
|
||||
|
||||
fn default_polling_interval() -> u64 {
|
||||
@ -187,7 +195,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_config_load_valid_yaml() {
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml");
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml", false);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Failed to load valid config: {:?}",
|
||||
@ -204,7 +212,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_config_load_missing_file() {
|
||||
let result = AppConfig::load("/nonexistent/path/config.yaml");
|
||||
let result = AppConfig::load("/nonexistent/path/config.yaml", false);
|
||||
assert!(result.is_err(), "Should fail for missing file");
|
||||
let err = result.unwrap_err();
|
||||
assert!(err.to_string().contains("Failed to read config file"));
|
||||
@ -215,7 +223,7 @@ mod tests {
|
||||
let invalid_path = "/tmp/invalid_config_test.yaml";
|
||||
std::fs::write(invalid_path, "invalid: yaml: content: [").unwrap();
|
||||
|
||||
let result = AppConfig::load(invalid_path);
|
||||
let result = AppConfig::load(invalid_path, false);
|
||||
assert!(result.is_err(), "Should fail for invalid yaml");
|
||||
|
||||
std::fs::remove_file(invalid_path).unwrap();
|
||||
@ -223,7 +231,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_config_validation_port_range() {
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml");
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml", false);
|
||||
assert!(result.is_ok());
|
||||
let config = result.unwrap();
|
||||
assert!(config.server.port >= 1);
|
||||
@ -231,7 +239,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_config_validation_bind_address() {
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml");
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml", false);
|
||||
assert!(result.is_ok());
|
||||
let config = result.unwrap();
|
||||
assert!(!config.server.bind.is_empty());
|
||||
@ -239,7 +247,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_config_validation_max_concurrent() {
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml");
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml", false);
|
||||
assert!(result.is_ok());
|
||||
let config = result.unwrap();
|
||||
assert!(config.jobs.max_concurrent > 0);
|
||||
@ -247,7 +255,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_config_validation_timeout() {
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml");
|
||||
let result = AppConfig::load("tests/fixtures/valid_config.yaml", false);
|
||||
assert!(result.is_ok());
|
||||
let config = result.unwrap();
|
||||
assert!(config.jobs.timeout_minutes >= 1 && config.jobs.timeout_minutes <= 1440);
|
||||
|
||||
@ -18,6 +18,10 @@ pub struct EnrollmentRequest {
|
||||
pub fqdn: String,
|
||||
pub ip_address: String,
|
||||
pub os_details: serde_json::Value,
|
||||
/// Short hostname (from /etc/hostname or hostname command).
|
||||
/// Used by the manager to populate `display_name` on approval.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub hostname: Option<String>,
|
||||
}
|
||||
|
||||
/// Response from `POST /api/v1/enroll` (HTTP 202).
|
||||
@ -77,6 +81,10 @@ pub struct EnrollmentClient {
|
||||
pub manager_url: String,
|
||||
/// Pre-configured reqwest client with insecure TLS and timeout.
|
||||
http_client: reqwest::Client,
|
||||
/// Network interface whose IP is reported to the manager (overrides auto-detect).
|
||||
report_interface: Option<String>,
|
||||
/// Explicit IPv4 address reported to the manager (highest priority override).
|
||||
report_ip: Option<String>,
|
||||
}
|
||||
|
||||
impl EnrollmentClient {
|
||||
@ -91,6 +99,21 @@ impl EnrollmentClient {
|
||||
/// contains a valid host component. Rejects dangerous schemes like `file://`,
|
||||
/// `gopher://`, or URLs without a host.
|
||||
pub fn new(manager_url: &str) -> Self {
|
||||
Self::with_ip_overrides(manager_url, None, None)
|
||||
}
|
||||
|
||||
/// Create a new enrollment client with optional IP reporting overrides.
|
||||
///
|
||||
/// See [`identity::get_primary_ip`] for resolution priority:
|
||||
/// 1. `report_ip` — explicit IP (highest priority)
|
||||
/// 2. `report_interface` — IP from named interface
|
||||
/// 3. Route-based — IP from kernel routing table for reaching the manager
|
||||
/// 4. Auto-detect — first routable IP (container bridge subnets filtered)
|
||||
pub fn with_ip_overrides(
|
||||
manager_url: &str,
|
||||
report_interface: Option<String>,
|
||||
report_ip: Option<String>,
|
||||
) -> Self {
|
||||
// SECURITY: Validate URL scheme before building HTTP client.
|
||||
// Only http and https are permitted to prevent path traversal, SSRF,
|
||||
// or local file access via dangerous schemes (file://, gopher://, etc.).
|
||||
@ -124,6 +147,8 @@ impl EnrollmentClient {
|
||||
Self {
|
||||
manager_url: manager_url.to_string(),
|
||||
http_client,
|
||||
report_interface,
|
||||
report_ip,
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,28 +207,35 @@ impl EnrollmentClient {
|
||||
/// - `Ok(EnrollmentResponse)` with the polling token on HTTP 202
|
||||
/// - Error on 429 (rate limited), 5xx (server error), or network failure
|
||||
pub async fn register(&self) -> Result<EnrollmentResponse> {
|
||||
// 1. Collect identity data
|
||||
// 1. Resolve manager IP for route-based IP selection
|
||||
let route_target = self.manager_ip().await.ok();
|
||||
|
||||
// 2. Collect identity data
|
||||
let machine_id = identity::get_machine_id()
|
||||
.context("Failed to read machine-id — host cannot enroll without identity")?;
|
||||
let fqdn = identity::get_fqdn()
|
||||
.context("Failed to determine FQDN — check hostname configuration")?;
|
||||
let ip_addresses = identity::get_ip_addresses()
|
||||
.context("Failed to enumerate network interfaces — check network configuration")?;
|
||||
let ip_address = identity::get_primary_ip(
|
||||
self.report_interface.as_deref(),
|
||||
self.report_ip.as_deref(),
|
||||
route_target.as_deref(),
|
||||
)
|
||||
.context("Failed to determine reportable IP address — check network configuration or set report_interface/report_ip in config")?;
|
||||
let os_details = identity::get_os_details()
|
||||
.context("Failed to collect OS details — /etc/os-release may be missing")?;
|
||||
|
||||
// Use first non-loopback IP (manager expects single string)
|
||||
let ip_address = ip_addresses
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "127.0.0.1".to_string());
|
||||
// 2. Collect short hostname for display_name on manager
|
||||
let hostname = identity::get_hostname()
|
||||
.map_err(|e| tracing::warn!(error = %e, "Failed to determine hostname — display_name will use FQDN fallback"))
|
||||
.ok();
|
||||
|
||||
// 2. Build EnrollmentRequest struct
|
||||
// 3. Build EnrollmentRequest struct
|
||||
let request = EnrollmentRequest {
|
||||
machine_id,
|
||||
fqdn,
|
||||
ip_address,
|
||||
os_details,
|
||||
hostname,
|
||||
};
|
||||
|
||||
tracing::info!(
|
||||
@ -480,6 +512,7 @@ mod tests {
|
||||
fqdn: "node.example.com".into(),
|
||||
ip_address: "192.168.1.10".into(),
|
||||
os_details: serde_json::json!({"distro": "Debian", "version": "12"}),
|
||||
hostname: Some("node".into()),
|
||||
};
|
||||
let json = serde_json::to_string(&request).expect("Failed to serialize EnrollmentRequest");
|
||||
assert!(json.contains("machine_id"));
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use std::fs;
|
||||
use std::net::IpAddr;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::process::Command;
|
||||
|
||||
/// Read the D-Bus machine identifier from `/etc/machine-id`.
|
||||
@ -31,40 +31,120 @@ pub fn get_machine_id() -> Result<String> {
|
||||
}
|
||||
|
||||
/// Resolve the fully-qualified domain name.
|
||||
/// Strategy: `gethostname` via std → fallback to `hostname` CLI → "localhost".
|
||||
///
|
||||
/// Strategy (in priority order):
|
||||
/// 1. `hostname -f` → if result contains `.`, it's a real FQDN
|
||||
/// 2. `hostname` + `hostname -d` → combine short hostname + domain
|
||||
/// 3. `/etc/hostname` → short hostname fallback
|
||||
/// 4. `hostname` command → last resort
|
||||
/// 5. `"localhost"` → final fallback
|
||||
pub fn get_fqdn() -> Result<String> {
|
||||
// Try reading from hostname file first (common on systemd systems)
|
||||
// 1. Try `hostname -f` — returns FQDN on properly configured systems
|
||||
if let Ok(output) = Command::new("hostname").arg("-f").output() {
|
||||
if output.status.success() {
|
||||
let name = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !name.is_empty() && name.contains('.') && name != "(none)" {
|
||||
tracing::debug!(fqdn = %name, "Resolved FQDN via hostname -f");
|
||||
return Ok(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Try combining short hostname + domain from `hostname -d`
|
||||
if let Ok(short_output) = Command::new("hostname").output() {
|
||||
if short_output.status.success() {
|
||||
let short = String::from_utf8_lossy(&short_output.stdout)
|
||||
.trim()
|
||||
.to_string();
|
||||
if !short.is_empty() && short != "(none)" {
|
||||
if let Ok(domain_output) = Command::new("hostname").arg("-d").output() {
|
||||
if domain_output.status.success() {
|
||||
let domain = String::from_utf8_lossy(&domain_output.stdout)
|
||||
.trim()
|
||||
.to_string();
|
||||
if !domain.is_empty() {
|
||||
let fqdn = format!("{}.{}", short, domain);
|
||||
tracing::debug!(fqdn = %fqdn, "Resolved FQDN via hostname + hostname -d");
|
||||
return Ok(fqdn);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Domain not available — fall through to try other methods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Try reading from /etc/hostname (common on systemd systems, usually short hostname)
|
||||
if let Ok(name) = fs::read_to_string("/etc/hostname") {
|
||||
let trimmed = name.trim().to_string();
|
||||
if !trimmed.is_empty() && trimmed != "(none)" {
|
||||
tracing::debug!(hostname = %trimmed, "Resolved hostname via /etc/hostname (may be short)");
|
||||
return Ok(trimmed);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to hostname command
|
||||
if let Ok(output) = Command::new("hostname").arg("-f").output() {
|
||||
if output.status.success() {
|
||||
let name = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !name.is_empty() {
|
||||
return Ok(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to plain hostname
|
||||
// 4. Fallback to plain hostname command
|
||||
if let Ok(output) = Command::new("hostname").output() {
|
||||
if output.status.success() {
|
||||
let name = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !name.is_empty() {
|
||||
tracing::debug!(hostname = %name, "Resolved hostname via hostname command");
|
||||
return Ok(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Final fallback
|
||||
tracing::warn!("Could not determine hostname — falling back to localhost");
|
||||
Ok("localhost".into())
|
||||
}
|
||||
|
||||
/// Resolve the short hostname (without domain).
|
||||
///
|
||||
/// Strategy: `/etc/hostname` → `hostname` command → split FQDN on `.` → `"localhost"`.
|
||||
pub fn get_hostname() -> Result<String> {
|
||||
// Try reading from /etc/hostname (usually contains the short hostname)
|
||||
if let Ok(name) = fs::read_to_string("/etc/hostname") {
|
||||
let trimmed = name.trim().to_string();
|
||||
if !trimmed.is_empty() && trimmed != "(none)" {
|
||||
// If it contains a dot, take just the first component
|
||||
let short = trimmed.split('.').next().unwrap_or(&trimmed).to_string();
|
||||
tracing::debug!(hostname = %short, "Resolved short hostname via /etc/hostname");
|
||||
return Ok(short);
|
||||
}
|
||||
}
|
||||
|
||||
// Try hostname command
|
||||
if let Ok(output) = Command::new("hostname").output() {
|
||||
if output.status.success() {
|
||||
let name = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !name.is_empty() {
|
||||
// If it contains a dot, take just the first component
|
||||
let short = name.split('.').next().unwrap_or(&name).to_string();
|
||||
tracing::debug!(hostname = %short, "Resolved short hostname via hostname command");
|
||||
return Ok(short);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try splitting FQDN from get_fqdn()
|
||||
if let Ok(fqdn) = get_fqdn() {
|
||||
if fqdn != "localhost" && fqdn.contains('.') {
|
||||
let short = fqdn.split('.').next().unwrap_or(&fqdn).to_string();
|
||||
tracing::debug!(hostname = %short, "Resolved short hostname by splitting FQDN");
|
||||
return Ok(short);
|
||||
}
|
||||
}
|
||||
|
||||
// Final fallback
|
||||
tracing::warn!("Could not determine short hostname — falling back to localhost");
|
||||
Ok("localhost".into())
|
||||
}
|
||||
|
||||
/// Collect all non-loopback IPv4 addresses from network interfaces.
|
||||
///
|
||||
/// Filters out container bridge subnets (Docker 172.16.0.0/12) and
|
||||
/// link-local addresses (169.254.0.0/16) that are not routable from the manager.
|
||||
pub fn get_ip_addresses() -> Result<Vec<String>> {
|
||||
let ifaces = if_addrs::get_if_addrs().context("Failed to enumerate network interfaces")?;
|
||||
|
||||
@ -75,7 +155,17 @@ pub fn get_ip_addresses() -> Result<Vec<String>> {
|
||||
return None;
|
||||
}
|
||||
match &iface.ip() {
|
||||
IpAddr::V4(addr) => Some(addr.to_string()),
|
||||
IpAddr::V4(addr) => {
|
||||
// Filter container bridge and link-local subnets
|
||||
if is_container_bridge(addr) || is_link_local(addr) {
|
||||
tracing::debug!(
|
||||
ip = %addr,
|
||||
"Excluding container bridge or link-local IP from enrollment report"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
Some(addr.to_string())
|
||||
}
|
||||
IpAddr::V6(_) => None,
|
||||
}
|
||||
})
|
||||
@ -86,6 +176,189 @@ pub fn get_ip_addresses() -> Result<Vec<String>> {
|
||||
Ok(addrs)
|
||||
}
|
||||
|
||||
/// Check if an IPv4 address is in a container bridge subnet.
|
||||
///
|
||||
/// Filters the `172.16.0.0/12` range (172.16.0.0 – 172.31.255.255), which is
|
||||
/// Docker's default bridge network allocation.
|
||||
///
|
||||
/// Note: `10.0.0.0/8` is NOT filtered because it is widely used for legitimate
|
||||
/// LAN addressing. If a deployment uses a custom Docker bridge subnet outside
|
||||
/// `172.16.0.0/12`, use `report_interface` or `report_ip` config to override.
|
||||
pub fn is_container_bridge(addr: &Ipv4Addr) -> bool {
|
||||
// 172.16.0.0/12 = 172.16.0.0 – 172.31.255.255
|
||||
// Binary: 10101100.0001xxxx.xxxxxxxx.xxxxxxxx
|
||||
let octets = addr.octets();
|
||||
octets[0] == 172 && (octets[1] & 0xF0) == 0x10
|
||||
}
|
||||
|
||||
/// Check if an IPv4 address is link-local (`169.254.0.0/16`).
|
||||
///
|
||||
/// Link-local addresses are auto-assigned when no DHCP is available and
|
||||
/// are never routable across networks.
|
||||
pub fn is_link_local(addr: &Ipv4Addr) -> bool {
|
||||
let octets = addr.octets();
|
||||
octets[0] == 169 && octets[1] == 254
|
||||
}
|
||||
|
||||
/// Determine the local source IP that would be used to reach a target IP.
|
||||
/// Uses the kernel routing table via `ip route get <target>`.
|
||||
///
|
||||
/// This is the most accurate way to select the correct local IP because it
|
||||
/// queries the kernel routing table directly, which accounts for all routing
|
||||
/// rules, interface priorities, and source address selection.
|
||||
pub fn get_route_source_ip(target_ip: &str) -> Result<String> {
|
||||
let output = Command::new("ip")
|
||||
.args(["route", "get", target_ip])
|
||||
.output()
|
||||
.context("Failed to execute 'ip route get' — is iproute2 installed?")?;
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
return Err(anyhow!(
|
||||
"'ip route get {}' failed: {}",
|
||||
target_ip,
|
||||
stderr.trim()
|
||||
));
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
// Parse output like: "192.168.3.36 via 192.168.1.1 dev eth0 src 192.168.3.36 uid ..."
|
||||
// We want the 'src' field value
|
||||
let mut found_src = false;
|
||||
for part in stdout.split_whitespace() {
|
||||
if found_src {
|
||||
// Validate it's a valid IPv4 address
|
||||
if part.parse::<Ipv4Addr>().is_ok() {
|
||||
let addr = part.parse::<Ipv4Addr>().unwrap();
|
||||
if !addr.is_loopback() && !is_container_bridge(&addr) && !is_link_local(&addr) {
|
||||
tracing::info!(
|
||||
target_ip = target_ip,
|
||||
source_ip = part,
|
||||
"Route-based IP selection: local source IP for reaching target"
|
||||
);
|
||||
return Ok(part.to_string());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if part == "src" {
|
||||
found_src = true;
|
||||
}
|
||||
}
|
||||
|
||||
Err(anyhow!(
|
||||
"Could not determine source IP for route to '{}' — 'ip route get' output: {}",
|
||||
target_ip,
|
||||
stdout.trim()
|
||||
))
|
||||
}
|
||||
|
||||
/// Get the IPv4 address of a specific network interface by name.
|
||||
///
|
||||
/// Returns the first non-loopback IPv4 address on the named interface.
|
||||
/// Useful when the admin knows which interface faces the manager network.
|
||||
pub fn get_ip_for_interface(interface_name: &str) -> Result<String> {
|
||||
let ifaces = if_addrs::get_if_addrs()
|
||||
.with_context(|| "Failed to enumerate network interfaces for interface lookup")?;
|
||||
|
||||
for iface in &ifaces {
|
||||
if iface.name != interface_name {
|
||||
continue;
|
||||
}
|
||||
if let IpAddr::V4(addr) = iface.ip() {
|
||||
if !iface.is_loopback() {
|
||||
tracing::info!(
|
||||
interface = interface_name,
|
||||
ip = %addr,
|
||||
"Resolved IP from configured interface"
|
||||
);
|
||||
return Ok(addr.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(anyhow!(
|
||||
"No non-loopback IPv4 address found on interface '{}'",
|
||||
interface_name
|
||||
))
|
||||
}
|
||||
|
||||
/// Determine the primary IP address to report to the manager.
|
||||
///
|
||||
/// Resolution priority:
|
||||
/// 1. `report_ip` — explicit IP from config (highest priority)
|
||||
/// 2. `report_interface` — IP from a named interface
|
||||
/// 3. `route_target` — route-based selection using kernel routing table
|
||||
/// 4. Auto-detect — first IP from `get_ip_addresses()` (bridge subnets already filtered)
|
||||
pub fn get_primary_ip(
|
||||
report_interface: Option<&str>,
|
||||
report_ip: Option<&str>,
|
||||
route_target: Option<&str>,
|
||||
) -> Result<String> {
|
||||
// Priority 1: Explicit IP override
|
||||
if let Some(ip) = report_ip {
|
||||
// Validate it parses as IPv4
|
||||
if let Ok(addr) = ip.parse::<Ipv4Addr>() {
|
||||
if !addr.is_loopback() {
|
||||
tracing::info!(ip = ip, "Using explicitly configured report_ip");
|
||||
return Ok(ip.to_string());
|
||||
}
|
||||
tracing::warn!(
|
||||
ip = ip,
|
||||
"Configured report_ip is a loopback address — ignoring"
|
||||
);
|
||||
} else {
|
||||
tracing::warn!(
|
||||
ip = ip,
|
||||
"Configured report_ip is not a valid IPv4 address — falling back to auto-detect"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Priority 2: Interface name override
|
||||
if let Some(iface) = report_interface {
|
||||
match get_ip_for_interface(iface) {
|
||||
Ok(ip) => return Ok(ip),
|
||||
Err(e) => {
|
||||
tracing::warn!(
|
||||
interface = iface,
|
||||
error = %e,
|
||||
"Configured report_interface lookup failed — falling back to route-based or auto-detect"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Priority 3: Route-based selection using kernel routing table
|
||||
if let Some(target) = route_target {
|
||||
match get_route_source_ip(target) {
|
||||
Ok(ip) => {
|
||||
tracing::info!(
|
||||
target = target,
|
||||
ip = %ip,
|
||||
"Using route-based IP selection for target"
|
||||
);
|
||||
return Ok(ip);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!(
|
||||
target = target,
|
||||
error = %e,
|
||||
"Route-based IP selection failed — falling back to auto-detect"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Priority 4: Auto-detect (bridge subnets already filtered by get_ip_addresses)
|
||||
let addrs = get_ip_addresses()?;
|
||||
addrs
|
||||
.first()
|
||||
.cloned()
|
||||
.ok_or_else(|| anyhow!("No suitable IPv4 address found on any interface"))
|
||||
}
|
||||
|
||||
/// Extract OS distribution details from `/etc/os-release` and kernel version.
|
||||
/// Returns a JSON object with: distro, version, id_like, kernel.
|
||||
pub fn get_os_details() -> Result<serde_json::Value> {
|
||||
@ -170,6 +443,56 @@ mod tests {
|
||||
assert!(!fqdn.is_empty(), "FQDN should not be empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fqdn_prefers_full_domain() {
|
||||
// If hostname -f returns a value with a dot, get_fqdn should return it
|
||||
// (not the short hostname from /etc/hostname)
|
||||
let fqdn = get_fqdn().expect("Failed to get FQDN");
|
||||
// On properly configured systems, FQDN should contain at least one dot
|
||||
// If it doesn't, it's likely a short hostname from /etc/hostname
|
||||
if fqdn.contains('.') {
|
||||
// FQDN contains domain — good
|
||||
assert!(
|
||||
fqdn.split('.').count() >= 2,
|
||||
"FQDN should have at least host.domain format, got: {}",
|
||||
fqdn
|
||||
);
|
||||
}
|
||||
// If no dot, it's a short hostname — acceptable fallback but not ideal
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hostname_is_not_empty() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
assert!(!hostname.is_empty(), "Hostname should not be empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hostname_is_short_form() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
// Short hostname should NOT contain dots
|
||||
assert!(
|
||||
!hostname.contains('.'),
|
||||
"Short hostname should not contain dots, got: {}",
|
||||
hostname
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hostname_is_prefix_of_fqdn() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
let fqdn = get_fqdn().expect("Failed to get FQDN");
|
||||
// If FQDN contains a dot, hostname should be the first component
|
||||
if fqdn.contains('.') {
|
||||
let fqdn_prefix = fqdn.split('.').next().unwrap_or(&fqdn);
|
||||
assert_eq!(
|
||||
hostname, fqdn_prefix,
|
||||
"Short hostname '{}' should match FQDN prefix '{}'",
|
||||
hostname, fqdn_prefix
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn os_details_contains_kernel() {
|
||||
let details = get_os_details().expect("Failed to get OS details");
|
||||
@ -178,4 +501,191 @@ mod tests {
|
||||
"OS details must contain kernel version"
|
||||
);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Container Bridge & Link-Local Filtering Tests
|
||||
// =============================================================================
|
||||
|
||||
#[test]
|
||||
fn test_is_container_bridge_docker_default() {
|
||||
// Docker default bridge network: 172.17.0.0/16
|
||||
assert!(is_container_bridge(&"172.17.0.1".parse().unwrap()));
|
||||
assert!(is_container_bridge(&"172.17.255.255".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_container_bridge_full_range() {
|
||||
// 172.16.0.0/12 = 172.16.0.0 – 172.31.255.255
|
||||
assert!(is_container_bridge(&"172.16.0.1".parse().unwrap()));
|
||||
assert!(is_container_bridge(&"172.31.255.255".parse().unwrap()));
|
||||
assert!(is_container_bridge(&"172.20.0.1".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_not_container_bridge() {
|
||||
// Outside 172.16.0.0/12
|
||||
assert!(!is_container_bridge(&"192.168.3.36".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"10.0.0.1".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"172.32.0.1".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"172.15.0.1".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"8.8.8.8".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_link_local() {
|
||||
assert!(is_link_local(&"169.254.0.1".parse().unwrap()));
|
||||
assert!(is_link_local(&"169.254.255.255".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_not_link_local() {
|
||||
assert!(!is_link_local(&"192.168.1.1".parse().unwrap()));
|
||||
assert!(!is_link_local(&"169.253.0.1".parse().unwrap()));
|
||||
assert!(!is_link_local(&"169.255.0.1".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_ip_addresses_excludes_docker_bridge() {
|
||||
// On a system with Docker, the returned IPs should not include 172.16.0.0/12
|
||||
let addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
for addr in &addrs {
|
||||
let parsed: Ipv4Addr = addr.parse().expect("Should parse as IPv4");
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"IP '{}' is in Docker bridge range 172.16.0.0/12 — should be excluded",
|
||||
addr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_ip_addresses_excludes_link_local() {
|
||||
let addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
for addr in &addrs {
|
||||
let parsed: Ipv4Addr = addr.parse().expect("Should parse as IPv4");
|
||||
assert!(
|
||||
!is_link_local(&parsed),
|
||||
"IP '{}' is link-local 169.254.0.0/16 — should be excluded",
|
||||
addr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_auto_detect() {
|
||||
// Without overrides, should return a valid non-bridge IP
|
||||
// In Docker containers, auto-detect may find no routable IPs — that's valid
|
||||
match get_primary_ip(None, None, None) {
|
||||
Ok(ip) => {
|
||||
assert!(!ip.is_empty(), "Primary IP should not be empty");
|
||||
let parsed: Ipv4Addr = ip.parse().expect("Primary IP should be valid IPv4");
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"Auto-detected IP should not be Docker bridge"
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!("NOTE: No routable IPs found — likely running inside a Docker container");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_explicit_override() {
|
||||
// Explicit IP should be returned as-is
|
||||
let ip = get_primary_ip(None, Some("10.99.99.1"), None).expect("Failed with explicit IP");
|
||||
assert_eq!(ip, "10.99.99.1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_rejects_loopback_override() {
|
||||
// Loopback in report_ip should fall back to auto-detect
|
||||
// In Docker containers, auto-detect may also fail — that's valid
|
||||
match get_primary_ip(None, Some("127.0.0.1"), None) {
|
||||
Ok(ip) => assert_ne!(ip, "127.0.0.1"),
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"NOTE: Loopback rejected but no routable IPs for fallback — Docker container"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_invalid_override_falls_back() {
|
||||
// Invalid IP in report_ip should fall back to auto-detect
|
||||
// In Docker containers, auto-detect may also fail — that's valid
|
||||
match get_primary_ip(None, Some("not-an-ip"), None) {
|
||||
Ok(ip) => assert!(!ip.is_empty()),
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"NOTE: Invalid IP rejected but no routable IPs for fallback — Docker container"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_route_target_priority() {
|
||||
// Route-based selection should be tried before auto-detect
|
||||
// We test with a well-known IP; if iproute2 is available this may succeed,
|
||||
// otherwise it falls back gracefully
|
||||
match get_primary_ip(None, None, Some("8.8.8.8")) {
|
||||
Ok(ip) => {
|
||||
assert!(!ip.is_empty(), "Route-based IP should not be empty");
|
||||
let parsed: Ipv4Addr = ip.parse().expect("Route-based IP should be valid IPv4");
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"Route-based IP should not be Docker bridge"
|
||||
);
|
||||
assert!(
|
||||
!parsed.is_loopback(),
|
||||
"Route-based IP should not be loopback"
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"NOTE: Route-based selection failed — iproute2 may not be available in this environment"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_explicit_overrides_route_target() {
|
||||
// Explicit report_ip should take priority over route_target
|
||||
let ip = get_primary_ip(None, Some("10.99.99.1"), Some("8.8.8.8"))
|
||||
.expect("Explicit IP should override route_target");
|
||||
assert_eq!(ip, "10.99.99.1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_route_source_ip_known_target() {
|
||||
// Test route-based IP detection with a well-known target
|
||||
// This test requires iproute2 to be installed
|
||||
match get_route_source_ip("8.8.8.8") {
|
||||
Ok(ip) => {
|
||||
let parsed: Ipv4Addr = ip.parse().expect("Route source IP should be valid IPv4");
|
||||
assert!(
|
||||
!parsed.is_loopback(),
|
||||
"Route source IP should not be loopback"
|
||||
);
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"Route source IP should not be Docker bridge"
|
||||
);
|
||||
assert!(
|
||||
!is_link_local(&parsed),
|
||||
"Route source IP should not be link-local"
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
// Acceptable in containers without iproute2 or routing
|
||||
eprintln!(
|
||||
"NOTE: Route-based IP detection failed: {} — may be unavailable in this environment",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,10 @@ pub use client::{
|
||||
EnrollmentClient, EnrollmentRequest, EnrollmentResponse, EnrollmentStatusResponse, PkiBundle,
|
||||
};
|
||||
/// Re-export identity extraction functions.
|
||||
pub use identity::{get_fqdn, get_ip_addresses, get_machine_id, get_os_details};
|
||||
pub use identity::{
|
||||
get_fqdn, get_hostname, get_ip_addresses, get_ip_for_interface, get_machine_id, get_os_details,
|
||||
get_primary_ip, get_route_source_ip, is_container_bridge, is_link_local,
|
||||
};
|
||||
|
||||
/// Run the full enrollment flow against the manager at the given URL.
|
||||
///
|
||||
@ -28,7 +31,14 @@ pub use identity::{get_fqdn, get_ip_addresses, get_machine_id, get_os_details};
|
||||
/// Returns Err on registration failure, polling timeout, denial, user interruption,
|
||||
/// PKI provisioning failure, or whitelist update failure.
|
||||
pub async fn run_enrollment(manager_url: &str, config: &super::AppConfig) -> Result<()> {
|
||||
let client = EnrollmentClient::new(manager_url);
|
||||
// Extract IP reporting overrides from enrollment config
|
||||
let (report_interface, report_ip) = config
|
||||
.enrollment
|
||||
.as_ref()
|
||||
.map(|e| (e.report_interface.clone(), e.report_ip.clone()))
|
||||
.unwrap_or((None, None));
|
||||
|
||||
let client = EnrollmentClient::with_ip_overrides(manager_url, report_interface, report_ip);
|
||||
|
||||
// Phase 1: Registration
|
||||
tracing::info!(
|
||||
|
||||
@ -57,6 +57,11 @@ async fn main() -> Result<()> {
|
||||
// Initialize logging
|
||||
let _guard = init_logging(args.verbose)?;
|
||||
|
||||
// Install rustls crypto provider (required for mTLS and HTTPS clients)
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("Failed to install rustls crypto provider (aws-lc-rs)");
|
||||
|
||||
info!(
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
config_path = args.config,
|
||||
|
||||
34
tasks/fix-non-ubuntu-packages.md
Normal file
34
tasks/fix-non-ubuntu-packages.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Fix Non-Ubuntu Package Builds
|
||||
|
||||
## Goal
|
||||
All platform packages must produce identical install results as the Debian/Ubuntu package.
|
||||
|
||||
## Debian Baseline Behavior
|
||||
- No system user creation (service runs as root)
|
||||
- Directory ownership: root:root
|
||||
- Create dirs: /etc/linux_patch_api/certs, /var/lib/linux_patch_api, /var/log/linux_patch_api
|
||||
- Permissions: 750 on config dirs, 755 on data/log dirs
|
||||
- Copy .example configs to live configs if not present
|
||||
- Enable service (systemd or rc-update)
|
||||
- Print next-steps message
|
||||
|
||||
## Tasks
|
||||
- [x] 1. Fix Arch linux-patch-api.install - removed system user creation, root:root ownership, matches Debian
|
||||
- [x] 2. Fix Arch build-arch.sh - fixed $startdir path, added source=() array
|
||||
- [x] 3. Fix RPM linux-patch-api.spec - uncommented BuildRequires, added runtime deps, removed system user, root:root ownership
|
||||
- [x] 4. Fix Alpine linux-patch-api.apk-install - removed system user creation, root:root ownership, matches Debian
|
||||
- [x] 5. Fix Alpine build-alpine.sh - co-located install script with APKBUILD, used install -Dm commands
|
||||
- [ ] 6. Verify all platforms produce consistent results (needs CI run)
|
||||
|
||||
## Changes Summary
|
||||
|
||||
### Arch Linux
|
||||
- **configs/linux-patch-api.install**: Removed user/group creation, changed ownership to root:root, matches Debian preinst/postinst
|
||||
- **build-arch.sh**: Fixed PKGBUILD package() to use $startdir (not $srcdir), added source=() array
|
||||
|
||||
### RPM (Fedora/RHEL/CentOS)
|
||||
- **linux-patch-api.spec**: Uncommented BuildRequires (cargo, rust, gcc, openssl-devel, systemd-devel, pkgconfig(systemd)), added runtime Requires (openssl-libs, ca-certificates), removed system user creation from %pre, changed ownership to root:root in %pre, matches Debian behavior in %post
|
||||
|
||||
### Alpine Linux
|
||||
- **configs/linux-patch-api.apk-install**: Removed addgroup/adduser, changed ownership to root:root, matches Debian preinst/postinst
|
||||
- **build-alpine.sh**: Restructured to co-locate install script with APKBUILD in workspace directory, used install -Dm commands in package() function, fixed $startdir references
|
||||
@ -82,8 +82,10 @@ fn build_tls_config(cert_dir: &std::path::Path) -> TlsConfig {
|
||||
}
|
||||
|
||||
/// Build an EnrollmentClient pointing at the mock server.
|
||||
/// Uses a test report_ip so enrollment works inside Docker containers
|
||||
/// where the only IPs are in the 172.16.0.0/12 bridge range (filtered).
|
||||
fn build_client(base_url: &str) -> EnrollmentClient {
|
||||
EnrollmentClient::new(base_url)
|
||||
EnrollmentClient::with_ip_overrides(base_url, None, Some("192.168.1.10".to_string()))
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@ -33,8 +33,10 @@ async fn create_mock_manager() -> (MockServer, String) {
|
||||
}
|
||||
|
||||
/// Build an EnrollmentClient pointing at the mock server.
|
||||
/// Uses a test report_ip so enrollment works inside Docker containers
|
||||
/// where the only IPs are in the 172.16.0.0/12 bridge range (filtered).
|
||||
fn build_client(base_url: &str) -> EnrollmentClient {
|
||||
EnrollmentClient::new(base_url)
|
||||
EnrollmentClient::with_ip_overrides(base_url, None, Some("192.168.1.10".to_string()))
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@ -471,6 +473,21 @@ async fn test_registration_payload_structure() {
|
||||
os_obj.contains_key("distro") || os_obj.contains_key("kernel"),
|
||||
"os_details should contain distro or kernel information"
|
||||
);
|
||||
|
||||
// Verify hostname field (optional, may be present or absent)
|
||||
// When present, it should be a non-empty string without dots (short hostname)
|
||||
if let Some(hostname) = payload.get("hostname").and_then(|v| v.as_str()) {
|
||||
assert!(
|
||||
!hostname.is_empty(),
|
||||
"hostname should not be empty when present"
|
||||
);
|
||||
assert!(
|
||||
!hostname.contains('.'),
|
||||
"hostname should be short form (no dots), got: {}",
|
||||
hostname
|
||||
);
|
||||
}
|
||||
// hostname field is optional — its absence is valid (skip_serializing_if = None)
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
//! Verifies machine-id, FQDN, IP address collection, and OS detail parsing.
|
||||
|
||||
use linux_patch_api::enroll::identity::{
|
||||
get_fqdn, get_ip_addresses, get_machine_id, get_os_details,
|
||||
get_fqdn, get_hostname, get_ip_addresses, get_machine_id, get_os_details, get_primary_ip,
|
||||
get_route_source_ip, is_container_bridge, is_link_local,
|
||||
};
|
||||
use linux_patch_api::enroll::EnrollmentRequest;
|
||||
use serde_json::Value;
|
||||
@ -137,6 +138,97 @@ fn test_fqdn_reasonable_length() {
|
||||
);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Hostname Tests
|
||||
// =============================================================================
|
||||
|
||||
#[test]
|
||||
fn test_hostname_returns_non_empty() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
assert!(!hostname.is_empty(), "Hostname should not be empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hostname_is_short_form() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
// Short hostname should NOT contain dots (that would be an FQDN)
|
||||
assert!(
|
||||
!hostname.contains('.'),
|
||||
"Short hostname should not contain dots, got: {}",
|
||||
hostname
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hostname_is_consistent() {
|
||||
let h1 = get_hostname().expect("Failed to get hostname (call 1)");
|
||||
let h2 = get_hostname().expect("Failed to get hostname (call 2)");
|
||||
assert_eq!(h1, h2, "Hostname should be consistent across calls");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hostname_is_subset_of_fqdn() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
let fqdn = get_fqdn().expect("Failed to get FQDN");
|
||||
// If FQDN contains a dot, the short hostname should be the first component
|
||||
if fqdn.contains('.') {
|
||||
let fqdn_prefix = fqdn.split('.').next().unwrap_or(&fqdn);
|
||||
assert_eq!(
|
||||
hostname, fqdn_prefix,
|
||||
"Short hostname '{}' should match FQDN prefix '{}'",
|
||||
hostname, fqdn_prefix
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hostname_valid_characters() {
|
||||
let hostname = get_hostname().expect("Failed to get hostname");
|
||||
for c in hostname.chars() {
|
||||
assert!(
|
||||
c.is_alphanumeric() || c == '-',
|
||||
"Short hostname contains invalid character: {:?}",
|
||||
c
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enrollment_hostname_field_serializes() {
|
||||
// Verify that hostname field serializes correctly when Some and when None
|
||||
let request_with_hostname = EnrollmentRequest {
|
||||
machine_id: "test-id".to_string(),
|
||||
fqdn: "host.example.com".to_string(),
|
||||
ip_address: "10.0.0.1".to_string(),
|
||||
os_details: serde_json::json!({"name": "Test"}),
|
||||
hostname: Some("host".to_string()),
|
||||
};
|
||||
let json_with =
|
||||
serde_json::to_string(&request_with_hostname).expect("Should serialize with hostname");
|
||||
assert!(
|
||||
json_with.contains("\"hostname\""),
|
||||
"hostname field should be present in JSON when Some"
|
||||
);
|
||||
assert!(
|
||||
json_with.contains("\"host\""),
|
||||
"hostname value should be 'host' in JSON"
|
||||
);
|
||||
|
||||
let request_without_hostname = EnrollmentRequest {
|
||||
machine_id: "test-id".to_string(),
|
||||
fqdn: "host.example.com".to_string(),
|
||||
ip_address: "10.0.0.1".to_string(),
|
||||
os_details: serde_json::json!({"name": "Test"}),
|
||||
hostname: None,
|
||||
};
|
||||
let json_without = serde_json::to_string(&request_without_hostname)
|
||||
.expect("Should serialize without hostname");
|
||||
assert!(
|
||||
!json_without.contains("\"hostname\""),
|
||||
"hostname field should be omitted from JSON when None (skip_serializing_if)"
|
||||
);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// IP Address Tests
|
||||
// =============================================================================
|
||||
@ -144,10 +236,10 @@ fn test_fqdn_reasonable_length() {
|
||||
#[test]
|
||||
fn test_ip_addresses_returns_at_least_one() {
|
||||
let addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
assert!(
|
||||
!addrs.is_empty(),
|
||||
"Should return at least one IP address on this system"
|
||||
);
|
||||
// In Docker containers, all IPs may be in 172.16.0.0/12 (filtered), so empty is valid
|
||||
if addrs.is_empty() {
|
||||
eprintln!("NOTE: No routable IPs found — likely running inside a Docker container with only bridge IPs");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -364,17 +456,20 @@ fn test_enrollment_payload_construction() {
|
||||
let ip_addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
let os_details = get_os_details().expect("Failed to get OS details");
|
||||
|
||||
// Use first non-loopback IP as the primary address
|
||||
// In Docker containers, all IPs may be in 172.16.0.0/12 (filtered), so use fallback
|
||||
let primary_ip = ip_addrs
|
||||
.first()
|
||||
.expect("Should have at least one IP")
|
||||
.clone();
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "127.0.0.1".to_string());
|
||||
|
||||
let hostname = get_hostname().ok();
|
||||
|
||||
let request = EnrollmentRequest {
|
||||
machine_id,
|
||||
fqdn,
|
||||
ip_address: primary_ip,
|
||||
os_details,
|
||||
hostname,
|
||||
};
|
||||
|
||||
// Verify payload serializes to valid JSON
|
||||
@ -411,11 +506,14 @@ fn test_enrollment_payload_matches_manager_schema() {
|
||||
let ip_addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
let os_details = get_os_details().expect("Failed to get OS details");
|
||||
|
||||
let hostname = get_hostname().ok();
|
||||
|
||||
let request = EnrollmentRequest {
|
||||
machine_id: machine_id.clone(),
|
||||
fqdn: fqdn.clone(),
|
||||
ip_address: ip_addrs.first().cloned().unwrap_or_default(),
|
||||
os_details: os_details.clone(),
|
||||
hostname,
|
||||
};
|
||||
|
||||
// Validate against expected manager API schema
|
||||
@ -448,11 +546,14 @@ fn test_enrollment_payload_roundtrip() {
|
||||
let ip_addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
let os_details = get_os_details().expect("Failed to get OS details");
|
||||
|
||||
let hostname = get_hostname().ok();
|
||||
|
||||
let request = EnrollmentRequest {
|
||||
machine_id,
|
||||
fqdn,
|
||||
ip_address: ip_addrs.first().cloned().unwrap_or_default(),
|
||||
os_details,
|
||||
hostname,
|
||||
};
|
||||
|
||||
// Serialize to JSON then deserialize back
|
||||
@ -463,6 +564,7 @@ fn test_enrollment_payload_roundtrip() {
|
||||
assert_eq!(request.machine_id, deserialized.machine_id);
|
||||
assert_eq!(request.fqdn, deserialized.fqdn);
|
||||
assert_eq!(request.ip_address, deserialized.ip_address);
|
||||
assert_eq!(request.hostname, deserialized.hostname);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@ -506,6 +608,10 @@ fn test_identity_functions_do_not_panic() {
|
||||
let _ = get_fqdn();
|
||||
});
|
||||
|
||||
let _ = std::panic::catch_unwind(|| {
|
||||
let _ = get_hostname();
|
||||
});
|
||||
|
||||
let _ = std::panic::catch_unwind(|| {
|
||||
let _ = get_ip_addresses();
|
||||
});
|
||||
@ -514,3 +620,184 @@ fn test_identity_functions_do_not_panic() {
|
||||
let _ = get_os_details();
|
||||
});
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Container Bridge & Link-Local Filtering Tests
|
||||
// =============================================================================
|
||||
|
||||
#[test]
|
||||
fn test_is_container_bridge_docker_default_range() {
|
||||
// Docker default bridge: 172.17.0.0/16
|
||||
assert!(is_container_bridge(&"172.17.0.1".parse().unwrap()));
|
||||
assert!(is_container_bridge(&"172.17.255.255".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_container_bridge_full_172_16_range() {
|
||||
// 172.16.0.0/12 = 172.16.0.0 – 172.31.255.255
|
||||
assert!(is_container_bridge(&"172.16.0.1".parse().unwrap()));
|
||||
assert!(is_container_bridge(&"172.20.0.1".parse().unwrap()));
|
||||
assert!(is_container_bridge(&"172.31.255.255".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_not_container_bridge_outside_range() {
|
||||
assert!(!is_container_bridge(&"192.168.3.36".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"10.0.0.1".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"172.32.0.1".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"172.15.255.255".parse().unwrap()));
|
||||
assert!(!is_container_bridge(&"8.8.8.8".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_link_local_range() {
|
||||
assert!(is_link_local(&"169.254.0.1".parse().unwrap()));
|
||||
assert!(is_link_local(&"169.254.255.255".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_not_link_local() {
|
||||
assert!(!is_link_local(&"192.168.1.1".parse().unwrap()));
|
||||
assert!(!is_link_local(&"169.253.0.1".parse().unwrap()));
|
||||
assert!(!is_link_local(&"169.255.0.1".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_ip_addresses_excludes_docker_bridge() {
|
||||
let addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
for addr in &addrs {
|
||||
let parsed: std::net::Ipv4Addr = addr.parse().expect("Should parse as IPv4");
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"IP '{}' is in Docker bridge range 172.16.0.0/12 — should be excluded",
|
||||
addr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_ip_addresses_excludes_link_local() {
|
||||
let addrs = get_ip_addresses().expect("Failed to get IP addresses");
|
||||
for addr in &addrs {
|
||||
let parsed: std::net::Ipv4Addr = addr.parse().expect("Should parse as IPv4");
|
||||
assert!(
|
||||
!is_link_local(&parsed),
|
||||
"IP '{}' is link-local 169.254.0.0/16 — should be excluded",
|
||||
addr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_auto_detect_no_bridge() {
|
||||
// In Docker containers, auto-detect may find no routable IPs — that's valid
|
||||
match get_primary_ip(None, None, None) {
|
||||
Ok(ip) => {
|
||||
assert!(!ip.is_empty(), "Primary IP should not be empty");
|
||||
let parsed: std::net::Ipv4Addr = ip.parse().expect("Primary IP should be valid IPv4");
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"Auto-detected IP should not be Docker bridge"
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!("NOTE: No routable IPs found — likely running inside a Docker container");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_explicit_override() {
|
||||
let ip = get_primary_ip(None, Some("10.99.99.1"), None).expect("Failed with explicit IP");
|
||||
assert_eq!(ip, "10.99.99.1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_rejects_loopback_override() {
|
||||
// Loopback override should fall back to auto-detect; if auto-detect also fails, that's valid
|
||||
match get_primary_ip(None, Some("127.0.0.1"), None) {
|
||||
Ok(ip) => assert_ne!(ip, "127.0.0.1"),
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"NOTE: Loopback rejected but no routable IPs for fallback — Docker container"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_invalid_override_falls_back() {
|
||||
// Invalid IP override should fall back to auto-detect; if auto-detect also fails, that's valid
|
||||
match get_primary_ip(None, Some("not-an-ip"), None) {
|
||||
Ok(ip) => assert!(!ip.is_empty()),
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"NOTE: Invalid IP rejected but no routable IPs for fallback — Docker container"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_route_target_priority() {
|
||||
// Route-based selection should be tried before auto-detect
|
||||
// If iproute2 is available this may succeed, otherwise falls back gracefully
|
||||
match get_primary_ip(None, None, Some("8.8.8.8")) {
|
||||
Ok(ip) => {
|
||||
assert!(!ip.is_empty(), "Route-based IP should not be empty");
|
||||
let parsed: std::net::Ipv4Addr =
|
||||
ip.parse().expect("Route-based IP should be valid IPv4");
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"Route-based IP should not be Docker bridge"
|
||||
);
|
||||
assert!(
|
||||
!parsed.is_loopback(),
|
||||
"Route-based IP should not be loopback"
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"NOTE: Route-based selection failed — iproute2 may not be available in this environment"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_primary_ip_explicit_overrides_route_target() {
|
||||
// Explicit report_ip should take priority over route_target
|
||||
let ip = get_primary_ip(None, Some("10.99.99.1"), Some("8.8.8.8"))
|
||||
.expect("Explicit IP should override route_target");
|
||||
assert_eq!(ip, "10.99.99.1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_route_source_ip_known_target() {
|
||||
// Test route-based IP detection with a well-known target
|
||||
// Requires iproute2 to be installed
|
||||
match get_route_source_ip("8.8.8.8") {
|
||||
Ok(ip) => {
|
||||
let parsed: std::net::Ipv4Addr =
|
||||
ip.parse().expect("Route source IP should be valid IPv4");
|
||||
assert!(
|
||||
!parsed.is_loopback(),
|
||||
"Route source IP should not be loopback"
|
||||
);
|
||||
assert!(
|
||||
!is_container_bridge(&parsed),
|
||||
"Route source IP should not be Docker bridge"
|
||||
);
|
||||
assert!(
|
||||
!is_link_local(&parsed),
|
||||
"Route source IP should not be link-local"
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"NOTE: Route-based IP detection failed: {} — may be unavailable in this environment",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user