Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de7ec9905f | |||
| 508037d656 | |||
| 56de1d73e1 | |||
| 157376af7e | |||
| 77e8ac2e65 | |||
| 9e42f32270 | |||
| 2b35a143da |
BIN
.a0proj/audit.db
BIN
.a0proj/audit.db
Binary file not shown.
@ -3,7 +3,7 @@ name: CI/CD Pipeline
|
|||||||
"on":
|
"on":
|
||||||
push:
|
push:
|
||||||
branches: [ master, develop ]
|
branches: [ master, develop ]
|
||||||
tags: [ 'v*' ]
|
tags: [ 'v*.*.*' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
@ -162,8 +162,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||||
FILE=$(ls ../linux-patch-api_*.deb 2>/dev/null | head -1)
|
FILE=$(ls ../linux-patch-api_*.deb 2>/dev/null | head -1)
|
||||||
|
# Rename deb to include u2204 in filename to avoid collision with main build
|
||||||
|
if [ -n "$FILE" ]; then
|
||||||
|
U2204_FILE="$(echo "$FILE" | sed 's/_amd64/_u2204_amd64/')"
|
||||||
|
mv "$FILE" "$U2204_FILE"
|
||||||
|
FILE="$U2204_FILE"
|
||||||
|
fi
|
||||||
chmod +x scripts/upload-release.sh
|
chmod +x scripts/upload-release.sh
|
||||||
./scripts/upload-release.sh "${TAG_NAME}-u2204" "$FILE"
|
./scripts/upload-release.sh "$TAG_NAME" "$FILE"
|
||||||
|
|
||||||
build-rpm:
|
build-rpm:
|
||||||
name: Build RPM Package
|
name: Build RPM Package
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1859,7 +1859,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-patch-api"
|
name = "linux-patch-api"
|
||||||
version = "0.3.0"
|
version = "0.3.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix",
|
"actix",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "linux-patch-api"
|
name = "linux-patch-api"
|
||||||
version = "0.3.0"
|
version = "0.3.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Echo <echo@moon-dragon.us>"]
|
authors = ["Echo <echo@moon-dragon.us>"]
|
||||||
description = "Secure remote package management API for Linux systems"
|
description = "Secure remote package management API for Linux systems"
|
||||||
|
|||||||
@ -17,7 +17,9 @@ RuntimeDirectory=linux-patch-api
|
|||||||
RuntimeDirectoryMode=0755
|
RuntimeDirectoryMode=0755
|
||||||
|
|
||||||
# Security hardening
|
# Security hardening
|
||||||
NoNewPrivileges=true
|
# Allow reboot capability for scheduled reboots
|
||||||
|
CapabilityBoundingSet=CAP_SYS_BOOT
|
||||||
|
AmbientCapabilities=CAP_SYS_BOOT
|
||||||
# ProtectSystem removed - package management requires write access to /usr, /etc, /lib
|
# ProtectSystem removed - package management requires write access to /usr, /etc, /lib
|
||||||
# Network security provided by mTLS + IP whitelist
|
# Network security provided by mTLS + IP whitelist
|
||||||
ProtectHome=true
|
ProtectHome=true
|
||||||
@ -34,7 +36,7 @@ RestrictNamespaces=true
|
|||||||
LockPersonality=true
|
LockPersonality=true
|
||||||
MemoryDenyWriteExecute=false
|
MemoryDenyWriteExecute=false
|
||||||
RestrictRealtime=true
|
RestrictRealtime=true
|
||||||
RestrictSUIDSGID=true
|
# RestrictSUIDSGID removed - package management requires setuid/setgid for apt/dpkg
|
||||||
RemoveIPC=true
|
RemoveIPC=true
|
||||||
|
|
||||||
# System call filtering (whitelist approach)
|
# System call filtering (whitelist approach)
|
||||||
|
|||||||
34
debian/changelog
vendored
34
debian/changelog
vendored
@ -1,3 +1,37 @@
|
|||||||
|
linux-patch-api (0.3.4-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Fix CI workflow: prevent recursive tag triggers (v* -> v*.*.*)
|
||||||
|
* Fix CI workflow: upload u2204 deb to same release (no -u2204 suffix)
|
||||||
|
* Remove sudo from apt commands (service runs as root)
|
||||||
|
* Remove NoNewPrivileges and RestrictSUIDSGID from systemd service
|
||||||
|
* Fix dpkg packaging: remove linux-patch-api user creation
|
||||||
|
|
||||||
|
-- Echo <echo@moon-dragon.us> Sat, 03 May 2026 03:15:00 -0500
|
||||||
|
linux-patch-api (0.3.3-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Fix dpkg packaging: Remove linux-patch-api user creation, fix directory ownership
|
||||||
|
* Fix package install: Remove sudo from apt commands (service runs as root)
|
||||||
|
* Remove NoNewPrivileges and RestrictSUIDSGID from systemd service
|
||||||
|
|
||||||
|
-- Echo <echo@moon-dragon.us> Sat, 03 May 2026 02:30:00 -0500
|
||||||
|
linux-patch-api (0.3.2-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Fix package install: Remove sudo from apt commands (service runs as root)
|
||||||
|
* Fix reboot endpoint: Implement actual system reboot via shutdown/systemctl
|
||||||
|
* Fix patches handler: Call reboot_system() instead of just logging
|
||||||
|
* Remove NoNewPrivileges and RestrictSUIDSGID from systemd service
|
||||||
|
* Add CAP_SYS_BOOT capability to systemd service for LXC reboot support
|
||||||
|
* Fix dpkg packaging: Remove linux-patch-api user creation, fix directory ownership
|
||||||
|
|
||||||
|
-- Echo <echo@moon-dragon.us> Sat, 02 May 2026 21:25:00 -0500
|
||||||
|
linux-patch-api (0.3.1-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Fix reboot endpoint: Implement actual system reboot via shutdown/systemctl
|
||||||
|
* Fix patches handler: Call reboot_system() instead of just logging
|
||||||
|
* Add CAP_SYS_BOOT capability to systemd service for LXC reboot support
|
||||||
|
* Remove unused warn import
|
||||||
|
|
||||||
|
-- Echo <echo@moon-dragon.us> Sat, 02 May 2026 20:37:00 -0500
|
||||||
linux-patch-api (0.3.0-1) unstable; urgency=low
|
linux-patch-api (0.3.0-1) unstable; urgency=low
|
||||||
|
|
||||||
* v0.3.0 beta release
|
* v0.3.0 beta release
|
||||||
|
|||||||
4
debian/linux-patch-api/DEBIAN/postinst
vendored
4
debian/linux-patch-api/DEBIAN/postinst
vendored
@ -13,14 +13,14 @@ if [ "$1" = "configure" ]; then
|
|||||||
echo "Creating default config.yaml..."
|
echo "Creating default config.yaml..."
|
||||||
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
||||||
chmod 640 /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
|
fi
|
||||||
|
|
||||||
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
||||||
echo "Creating default whitelist.yaml..."
|
echo "Creating default whitelist.yaml..."
|
||||||
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
||||||
chmod 640 /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
|
fi
|
||||||
|
|
||||||
# Reload systemd daemon to pick up new service file
|
# Reload systemd daemon to pick up new service file
|
||||||
|
|||||||
12
debian/linux-patch-api/DEBIAN/postrm
vendored
12
debian/linux-patch-api/DEBIAN/postrm
vendored
@ -39,18 +39,6 @@ if [ "$1" = "purge" ]; then
|
|||||||
rm -rf /var/log/linux_patch_api
|
rm -rf /var/log/linux_patch_api
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove system user
|
|
||||||
if getent passwd linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Removing user linux-patch-api..."
|
|
||||||
userdel linux-patch-api 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove system group
|
|
||||||
if getent group linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Removing group linux-patch-api..."
|
|
||||||
groupdel linux-patch-api 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "linux-patch-api purged successfully"
|
echo "linux-patch-api purged successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
23
debian/linux-patch-api/DEBIAN/preinst
vendored
23
debian/linux-patch-api/DEBIAN/preinst
vendored
@ -9,31 +9,14 @@ if [ -d "/etc/linux_patch_api" ]; then
|
|||||||
echo "Detected existing installation - performing upgrade"
|
echo "Detected existing installation - performing upgrade"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create system user if it doesn't exist
|
|
||||||
if ! getent group linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Creating group linux-patch-api..."
|
|
||||||
groupadd --system linux-patch-api
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! getent passwd linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Creating user linux-patch-api..."
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create required directories
|
# Create required directories
|
||||||
mkdir -p /etc/linux_patch_api/certs
|
mkdir -p /etc/linux_patch_api/certs
|
||||||
mkdir -p /var/lib/linux_patch_api
|
mkdir -p /var/lib/linux_patch_api
|
||||||
mkdir -p /var/log/linux_patch_api
|
mkdir -p /var/log/linux_patch_api
|
||||||
|
|
||||||
# Set proper ownership
|
# Set proper ownership (service runs as root)
|
||||||
chown -R linux-patch-api:linux-patch-api /var/lib/linux_patch_api
|
chown -R root:root /var/lib/linux_patch_api
|
||||||
chown -R linux-patch-api:linux-patch-api /var/log/linux_patch_api
|
chown -R root:root /var/log/linux_patch_api
|
||||||
|
|
||||||
# Set secure permissions
|
# Set secure permissions
|
||||||
chmod 750 /etc/linux_patch_api
|
chmod 750 /etc/linux_patch_api
|
||||||
|
|||||||
4
debian/postinst
vendored
4
debian/postinst
vendored
@ -13,14 +13,14 @@ if [ "$1" = "configure" ]; then
|
|||||||
echo "Creating default config.yaml..."
|
echo "Creating default config.yaml..."
|
||||||
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
cp /etc/linux_patch_api/config.yaml.example /etc/linux_patch_api/config.yaml
|
||||||
chmod 640 /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
|
fi
|
||||||
|
|
||||||
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
|
||||||
echo "Creating default whitelist.yaml..."
|
echo "Creating default whitelist.yaml..."
|
||||||
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
cp /etc/linux_patch_api/whitelist.yaml.example /etc/linux_patch_api/whitelist.yaml
|
||||||
chmod 640 /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
|
fi
|
||||||
|
|
||||||
# Reload systemd daemon to pick up new service file
|
# Reload systemd daemon to pick up new service file
|
||||||
|
|||||||
12
debian/postrm
vendored
12
debian/postrm
vendored
@ -39,18 +39,6 @@ if [ "$1" = "purge" ]; then
|
|||||||
rm -rf /var/log/linux_patch_api
|
rm -rf /var/log/linux_patch_api
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove system user
|
|
||||||
if getent passwd linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Removing user linux-patch-api..."
|
|
||||||
userdel linux-patch-api 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove system group
|
|
||||||
if getent group linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Removing group linux-patch-api..."
|
|
||||||
groupdel linux-patch-api 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "linux-patch-api purged successfully"
|
echo "linux-patch-api purged successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
23
debian/preinst
vendored
23
debian/preinst
vendored
@ -9,31 +9,14 @@ if [ -d "/etc/linux_patch_api" ]; then
|
|||||||
echo "Detected existing installation - performing upgrade"
|
echo "Detected existing installation - performing upgrade"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create system user if it doesn't exist
|
|
||||||
if ! getent group linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Creating group linux-patch-api..."
|
|
||||||
groupadd --system linux-patch-api
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! getent passwd linux-patch-api > /dev/null 2>&1; then
|
|
||||||
echo "Creating user linux-patch-api..."
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create required directories
|
# Create required directories
|
||||||
mkdir -p /etc/linux_patch_api/certs
|
mkdir -p /etc/linux_patch_api/certs
|
||||||
mkdir -p /var/lib/linux_patch_api
|
mkdir -p /var/lib/linux_patch_api
|
||||||
mkdir -p /var/log/linux_patch_api
|
mkdir -p /var/log/linux_patch_api
|
||||||
|
|
||||||
# Set proper ownership
|
# Set proper ownership (service runs as root)
|
||||||
chown -R linux-patch-api:linux-patch-api /var/lib/linux_patch_api
|
chown -R root:root /var/lib/linux_patch_api
|
||||||
chown -R linux-patch-api:linux-patch-api /var/log/linux_patch_api
|
chown -R root:root /var/log/linux_patch_api
|
||||||
|
|
||||||
# Set secure permissions
|
# Set secure permissions
|
||||||
chmod 750 /etc/linux_patch_api
|
chmod 750 /etc/linux_patch_api
|
||||||
|
|||||||
@ -139,7 +139,22 @@ pub async fn apply_patches(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
// In production, would trigger actual reboot via system handler
|
// Trigger actual reboot via system handler
|
||||||
|
match backend_clone.reboot_system(request.reboot_delay_seconds) {
|
||||||
|
Ok(_) => {
|
||||||
|
let _ = job_manager_clone
|
||||||
|
.add_job_log(
|
||||||
|
&job_id_clone,
|
||||||
|
"Reboot command executed".to_string(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
let _ = job_manager_clone
|
||||||
|
.add_job_log(&job_id_clone, format!("Reboot failed: {}", e))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tracing::{info, warn};
|
use tracing::info;
|
||||||
|
|
||||||
/// Package status
|
/// Package status
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
@ -98,18 +98,9 @@ impl AptBackend {
|
|||||||
|
|
||||||
/// Run apt command and capture output
|
/// Run apt command and capture output
|
||||||
fn run_apt(&self, args: &[&str]) -> Result<String> {
|
fn run_apt(&self, args: &[&str]) -> Result<String> {
|
||||||
// Use sudo for operations that modify packages (install, upgrade, remove, purge)
|
// Service runs as root - no sudo needed for apt commands
|
||||||
let needs_sudo = args.first().is_some_and(|&cmd| {
|
let program = "apt";
|
||||||
matches!(
|
let cmd_args: Vec<&str> = args.to_vec();
|
||||||
cmd,
|
|
||||||
"install" | "upgrade" | "remove" | "purge" | "dist-upgrade" | "autoremove"
|
|
||||||
)
|
|
||||||
});
|
|
||||||
let (program, cmd_args): (&str, Vec<&str>) = if needs_sudo {
|
|
||||||
("sudo", ["apt"].iter().chain(args.iter()).copied().collect())
|
|
||||||
} else {
|
|
||||||
("apt", args.to_vec())
|
|
||||||
};
|
|
||||||
|
|
||||||
let output = Command::new(program)
|
let output = Command::new(program)
|
||||||
.args(&cmd_args)
|
.args(&cmd_args)
|
||||||
@ -466,17 +457,27 @@ impl PackageManagerBackend for AptBackend {
|
|||||||
|
|
||||||
fn reboot_system(&self, delay_seconds: u64) -> Result<()> {
|
fn reboot_system(&self, delay_seconds: u64) -> Result<()> {
|
||||||
if delay_seconds > 0 {
|
if delay_seconds > 0 {
|
||||||
info!("Scheduling reboot in {} seconds", delay_seconds);
|
// Use shutdown command for delayed reboot (converts seconds to minutes, minimum 1)
|
||||||
// In production, would use systemd shutdown scheduler
|
let delay_minutes = std::cmp::max(1u64, delay_seconds.div_ceil(60));
|
||||||
warn!("Delayed reboot not fully implemented - would use systemd in production");
|
info!(
|
||||||
}
|
"Scheduling system reboot in {} minutes (requested {} seconds)",
|
||||||
|
delay_minutes, delay_seconds
|
||||||
|
);
|
||||||
|
Command::new("shutdown")
|
||||||
|
.args(["-r", &format!("+{}", delay_minutes)])
|
||||||
|
.status()
|
||||||
|
.context("Failed to schedule delayed reboot")?;
|
||||||
|
info!("System reboot scheduled in {} minutes", delay_minutes);
|
||||||
|
} else {
|
||||||
|
// Immediate reboot using systemctl
|
||||||
|
info!("Initiating immediate system reboot");
|
||||||
Command::new("systemctl")
|
Command::new("systemctl")
|
||||||
.arg("reboot")
|
.arg("reboot")
|
||||||
.status()
|
.status()
|
||||||
.context("Failed to execute reboot command")?;
|
.context("Failed to execute reboot command")?;
|
||||||
|
|
||||||
info!("System reboot initiated");
|
info!("System reboot initiated");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,3 +29,45 @@
|
|||||||
**Correction:** Always verify binary versions match before testing. Different BuildIDs mean different code.
|
**Correction:** Always verify binary versions match before testing. Different BuildIDs mean different code.
|
||||||
**Rule:** Check binary versions (file size, BuildID, --version output) on all target systems before testing.
|
**Rule:** Check binary versions (file size, BuildID, --version output) on all target systems before testing.
|
||||||
**Status:** Active
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-02 - Always run cargo fmt AND cargo clippy locally before pushing
|
||||||
|
**Mistake:** Pushed code changes without running cargo fmt and cargo clippy locally, causing 8 CI iterations to fix formatting and lint errors.
|
||||||
|
**Correction:** Run `cargo fmt --all -- --check` and `cargo clippy --all-targets --all-features -- -D warnings` locally before every push.
|
||||||
|
**Rule:** ALWAYS run cargo fmt AND cargo clippy locally before pushing to Gitea. Fix all errors before pushing.
|
||||||
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-02 - rustls 0.23 API: builder() vs builder_with_provider()
|
||||||
|
**Mistake:** Used ServerConfig::builder() which returns WantsVerifier state, then called with_protocol_versions() which requires WantsVersions state.
|
||||||
|
**Correction:** Use ServerConfig::builder_with_provider(Arc::new(aws_lc_rs::default_provider())) to get WantsVersions state. Also need aws_lc_rs feature in Cargo.toml.
|
||||||
|
**Rule:** In rustls 0.23, to set protocol versions, use builder_with_provider() not builder(). The builder() shortcut skips version negotiation.
|
||||||
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-02 - apt broken deps block unrelated package installs
|
||||||
|
**Mistake:** CI failed because openssh-server on runner had version mismatch (13.16 server vs 13.15 client), blocking all apt-get install operations.
|
||||||
|
**Correction:** Add `sudo apt-get -f install -y` before `sudo apt-get install` in CI workflow to fix broken deps automatically.
|
||||||
|
**Rule:** Always add `apt-get -f install -y` before `apt-get install` in CI workflows. Runners may have broken apt state from partial upgrades.
|
||||||
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-03 - NoNewPrivileges=true blocks sudo in systemd services
|
||||||
|
**Mistake:** Service used NoNewPrivileges=true which prevented sudo from working (PERM_SUDOERS: setresuid Operation not permitted).
|
||||||
|
**Correction:** Removed NoNewPrivileges=true from systemd service. The service runs as root and uses sudo for apt commands, which requires privilege escalation capabilities.
|
||||||
|
**Rule:** For package management services that use sudo, do not use NoNewPrivileges=true. mTLS + IP whitelist provides network security.
|
||||||
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-03 - RestrictSUIDSGID=true blocks sudo in systemd services
|
||||||
|
**Mistake:** Service used RestrictSUIDSGID=true which prevented sudo from using setuid/setgid operations.
|
||||||
|
**Correction:** Removed RestrictSUIDSGID=true from systemd service. Package management requires setuid/setgid for apt/dpkg.
|
||||||
|
**Rule:** For package management services, do not use RestrictSUIDSGID=true. It blocks sudo and apt from working.
|
||||||
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-03 - dpkg preinst creates linux-patch-api user causing permission issues
|
||||||
|
**Mistake:** dpkg preinst script creates a linux-patch-api system user and changes directory ownership, causing the service to crash with 'Permission denied' on log file creation.
|
||||||
|
**Correction:** Fix dpkg preinst to not create the linux-patch-api user or change directory ownership. Service runs as root and directories should be owned by root.
|
||||||
|
**Rule:** For services that run as root, do not create a dedicated system user in the dpkg preinst script. Keep all directory ownership as root:root.
|
||||||
|
**Status:** Active
|
||||||
|
|
||||||
|
## 2026-05-03 - Service runs as root, no sudo needed for apt commands
|
||||||
|
**Mistake:** Service used sudo to run apt commands even though it runs as root. This caused failures when systemd security restrictions blocked sudo.
|
||||||
|
**Correction:** Removed sudo from apt command execution in the source code. Service runs as root and can execute apt directly.
|
||||||
|
**Rule:** If a service runs as root, it does not need sudo to execute commands. Remove sudo from command execution.
|
||||||
|
**Status:** Active
|
||||||
|
|||||||
Reference in New Issue
Block a user