Skip to content

Conversation

@abtreece
Copy link
Owner

Summary

  • Add Linux package generation (RPM and DEB) using goreleaser's nFPM integration
  • Include systemd service with security hardening
  • Support environment file configuration pattern (/etc/default/confd or /etc/sysconfig/confd)
  • Packages automatically attached to GitHub Releases

Package Contents

Path Description
/usr/bin/confd Binary
/usr/lib/systemd/system/confd.service Systemd unit with security hardening
/etc/confd/confd.toml Default config (preserved on upgrade)
/etc/confd/conf.d/ Template resources directory
/etc/confd/templates/ Templates directory
/etc/default/confd Environment file (deb)
/etc/sysconfig/confd Environment file (rpm)
/var/lib/confd/ State directory

Systemd Security Hardening

The service runs as root but with significant restrictions:

  • CapabilityBoundingSet - Only essential capabilities
  • ProtectSystem=strict - Read-only filesystem except allowed paths
  • NoNewPrivileges=true - Prevent privilege escalation
  • PrivateTmp, PrivateDevices - Isolation
  • SystemCallFilter=@system-service - Restricted syscalls

Usage After Install

# Configure backend and options
sudo vi /etc/default/confd

# Create template resources and templates
sudo vi /etc/confd/conf.d/myapp.toml
sudo vi /etc/confd/templates/myapp.conf.tmpl

# Enable and start
sudo systemctl enable --now confd

Test plan

  • go test ./... passes
  • make snapshot builds packages successfully
  • Package contents verified (correct files in correct locations)
  • Test install on Debian/Ubuntu
  • Test install on RHEL/Fedora

Add Linux package generation to the release process using goreleaser's
nFPM integration. Packages include:

- Systemd service with security hardening (CapabilityBoundingSet,
  ProtectSystem, NoNewPrivileges, etc.)
- Environment file configuration (/etc/default/confd for Debian,
  /etc/sysconfig/confd for RHEL)
- Default confd.toml with documented options
- Post-install script with setup instructions
- Pre-remove script for clean service shutdown

Package architectures: amd64, arm64, armv7
Package formats: .deb (Debian/Ubuntu), .rpm (RHEL/Fedora/CentOS)

Packages will be automatically attached to GitHub Releases.
Copilot AI review requested due to automatic review settings January 26, 2026 04:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Linux package distribution support for confd by integrating goreleaser's nFPM tool to generate RPM and DEB packages. The packages include a systemd service with comprehensive security hardening features and follow standard Linux filesystem conventions for configuration and state management.

Changes:

  • Added nFPM configuration to .goreleaser.yml for automated RPM and DEB package generation
  • Created systemd service unit with security hardening (capability restrictions, filesystem protection, syscall filtering)
  • Added lifecycle scripts (postinstall/preremove) for proper service management and user guidance

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.goreleaser.yml Defines package structure, file locations, dependencies, and build configuration for RPM/DEB packages
packaging/confd.service Systemd unit file with security hardening directives and service lifecycle management
packaging/confd.default Environment file template for configuring backend and runtime options
packaging/confd.toml.default Default configuration file with commented examples of all available settings
packaging/scripts/postinstall.sh Post-installation script that creates directories and displays usage instructions
packaging/scripts/preremove.sh Pre-removal script that stops and disables the service before package removal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

MemoryDenyWriteExecute=true

# Allow writes to config directories and common application paths
ReadWritePaths=/etc /var/lib/confd /var/run
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Granting write access to the entire /etc directory is overly permissive and undermines the ProtectSystem=strict hardening. This allows confd to modify any system configuration file. Consider restricting this to only the specific paths confd needs to write to, such as /etc/confd or specific application configuration directories that confd manages.

Suggested change
ReadWritePaths=/etc /var/lib/confd /var/run
ReadWritePaths=/etc/confd /var/lib/confd /var/run

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,68 @@
# confd configuration file
# See https://github.com/abtreece/confd/blob/main/docs/configuration-guide.md
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation link references the 'main' branch which may not correspond to the installed version of confd. Consider using a version-specific documentation link or a stable URL that redirects to the appropriate version's documentation.

Suggested change
# See https://github.com/abtreece/confd/blob/main/docs/configuration-guide.md
# See the confd configuration guide in the project's documentation (docs/configuration-guide.md).

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.50%. Comparing base (d10a1dd) to head (f9897cc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #520      +/-   ##
==========================================
+ Coverage   62.45%   62.50%   +0.05%     
==========================================
  Files          48       48              
  Lines        5420     5420              
==========================================
+ Hits         3385     3388       +3     
+ Misses       1828     1825       -3     
  Partials      207      207              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45c42cf41d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 4 to 12
# Stop and disable the service before removal
if command -v systemctl >/dev/null 2>&1; then
if systemctl is-active --quiet confd 2>/dev/null; then
echo "Stopping confd service..."
systemctl stop confd
fi
if systemctl is-enabled --quiet confd 2>/dev/null; then
echo "Disabling confd service..."
systemctl disable confd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid disabling the service on package upgrades

The preremove script always stops and disables the service. nFPM runs this hook for upgrades as well as removals, so an in-place upgrade will leave confd disabled afterward, and the postinstall hook never re-enables it. This means users who upgrade the package will unexpectedly lose the service until they manually re-enable it. Gate the systemctl disable (and possibly the stop) on a true removal/purge, or check the maintainer-script arguments so upgrades don’t disable the service.

Useful? React with 👍 / 👎.

- Add Linux package installation section to installation.md
- Update service-deployment.md with package-based setup instructions
- Add comment in confd.service explaining why /etc write access is needed
- Improve documentation links in packaging files
- Simplify postinstall.sh output with single docs link
- preremove.sh: Only disable service on true removal, not upgrades
  - DEB receives "remove" or "upgrade" as $1
  - RPM receives 0 (uninstall) or 1 (upgrade) as $1
- postinstall.sh: Restart service on upgrade if it was enabled
  - Only show setup instructions on fresh install
  - Automatically restart service after upgrade completes

This prevents the service from being left disabled after package upgrades.
@abtreece abtreece merged commit 47e1e48 into main Jan 26, 2026
9 checks passed
@abtreece abtreece deleted the feat/linux-packaging branch January 26, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant